turtle_quant_1.data_processing.processor¶
turtle_quant_1.data_processing.processor
¶
Data processor for orchestrating data fetching and storage.
DataProcessor
¶
DataProcessor(
symbols: Optional[List[str]] = None,
freq: CandleUnit = CANDLE_UNIT,
storage: Optional[BaseDataStorageAdapter] = None,
fetcher: Optional[BaseDataFetcher] = None,
maintainer: Optional[BaseDataMaintainer] = None,
)
Bases: BaseDataProcessor
Data processor for orchestrating data fetching and storage.
Initialize the data processor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbols
|
Optional[List[str]]
|
List of symbols to process. If None, uses SYMBOLS from config. |
None
|
freq
|
CandleUnit
|
Candle frequency to use for fetching and processing data. |
CANDLE_UNIT
|
storage
|
Optional[BaseDataStorageAdapter]
|
Data storage to use. If None, uses GCSDataStorage. |
None
|
fetcher
|
Optional[BaseDataFetcher]
|
Data fetcher to use. If None, uses YFinanceDataFetcher. |
None
|
maintainer
|
Optional[BaseDataMaintainer]
|
Data maintainer to use. If None, uses DataMaintainer. |
None
|
Source code in src/turtle_quant_1/data_processing/processor.py
load_data
¶
load_data(
symbol: str,
start_date: datetime,
end_date: datetime,
impute_data: bool = True,
) -> DataFrame
Load data for a symbol.
Auto-corrects start and end dates to be at the bounds of market hours for those days.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
Symbol to load data for. |
required |
start_date
|
datetime
|
Timezone-aware start date to fetch data from. |
required |
end_date
|
datetime
|
Timezone-aware end date to fetch data up to. |
required |
impute_data
|
bool
|
Whether to impute data. |
True
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with OHLCV data. |
Source code in src/turtle_quant_1/data_processing/processor.py
save_data
¶
Save data to storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
str
|
Symbol to save data for. |
required |
data
|
DataFrame
|
DataFrame with data. |
required |