turtle_quant_1.data_processing.base¶
turtle_quant_1.data_processing.base
¶
Base classes for data processing components.
BaseDataFetcher
¶
Bases: ABC
Base class for data fetchers.
Initialize the data fetcher.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbols
|
List[str]
|
List of symbols to fetch data for. |
required |
Source code in src/turtle_quant_1/data_processing/base.py
fetch_ohlcv
abstractmethod
¶
fetch_ohlcv(
symbol: str,
start_date: datetime,
end_date: datetime,
freq: CandleUnit = "5M",
) -> DataFrame
Fetch OHLCV data for a symbol at the requested candle frequency.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
Symbol to fetch data for. |
required |
start_date
|
datetime
|
Start date for the data. |
required |
end_date
|
datetime
|
End date for the data. |
required |
freq
|
CandleUnit
|
Candle frequency for the returned data. |
'5M'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with OHLCV data. |
Source code in src/turtle_quant_1/data_processing/base.py
BaseDataMaintainer
¶
BaseDataMaintainer(
symbols: Optional[List[str]] = None,
freq: CandleUnit = "5M",
fetcher: Optional[BaseDataFetcher] = None,
)
Bases: ABC
Base class for data maintainers.
Initialize the data maintainer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbols
|
Optional[List[str]]
|
List of symbols to maintain. |
None
|
freq
|
CandleUnit
|
Candle frequency for the data being maintained. |
'5M'
|
fetcher
|
Optional[BaseDataFetcher]
|
Data fetcher to use. If None, uses YFinanceDataFetcher. |
None
|
Source code in src/turtle_quant_1/data_processing/base.py
impute_data
abstractmethod
¶
Ensure continuous data for a symbol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
Symbol to impute data for. |
required |
data
|
DataFrame
|
DataFrame with data. |
required |
end_date
|
Optional[datetime]
|
End date to ensure data up to. If None, uses current time. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with updated data. |
Source code in src/turtle_quant_1/data_processing/base.py
BaseDataProcessor
¶
Bases: ABC
Base class for data processors.
load_data
abstractmethod
¶
Load data for a symbol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
Symbol to load data for. |
required |
start_date
|
datetime
|
Start date for the data. |
required |
end_date
|
datetime
|
End date for the data. |
required |
Source code in src/turtle_quant_1/data_processing/base.py
save_data
abstractmethod
¶
Save data for a symbol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
Symbol to save data for. |
required |
data
|
DataFrame
|
DataFrame with data. |
required |
BaseDataStorageAdapter
¶
Bases: ABC
Base class for data storage.
delete_ohlcv_data
abstractmethod
¶
Delete data for a symbol from storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
Symbol to delete data for. |
required |
freq
|
CandleUnit
|
Candle frequency of the data to delete. |
'5M'
|
Source code in src/turtle_quant_1/data_processing/base.py
load_ohlcv_data
abstractmethod
¶
load_ohlcv_data(
symbol: str,
start_date: Optional[datetime] = None,
end_date: Optional[datetime] = None,
freq: CandleUnit = "5M",
) -> DataFrame
Load OHLCV data for a symbol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
Symbol to load data for. |
required |
start_date
|
Optional[datetime]
|
Start date for the data. |
None
|
end_date
|
Optional[datetime]
|
End date for the data. |
None
|
freq
|
CandleUnit
|
Candle frequency of the data to load. |
'5M'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with OHLCV data. |
Source code in src/turtle_quant_1/data_processing/base.py
save_ohlcv_data
abstractmethod
¶
Save OHLCV data for a symbol.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
Symbol to save data for. |
required |
data
|
DataFrame
|
DataFrame with OHLCV data. |
required |
freq
|
CandleUnit
|
Candle frequency of the data being saved. |
'5M'
|