Skip to content

Commit 0521db7

Browse files
committed
refactor: extract OHLCVDataProviderBase to eliminate duplication
Introduce an intermediate base class OHLCVDataProviderBase that handles all shared OHLCV data provider logic: - Constructor, copy(), get_data(), prepare_backtest_data(), get_backtest_data() - CSV storage helpers, date range resolution, number of data points - Fixes bug: create_start_date was missing from Yahoo/AV/Polygon providers Concrete providers now only implement: - market_name, timeframe_map (class attributes) - _download_ohlcv() (API-specific download) - _validate_symbol() (optional, Yahoo only) Reduces Yahoo/AlphaVantage/Polygon from ~1,851 lines to ~1,033 total (44% reduction). CCXT intentionally excluded (different pattern: exchange-based detection, pagination, ticker support).
1 parent 45656c4 commit 0521db7

10 files changed

Lines changed: 630 additions & 1442 deletions

File tree

investing_algorithm_framework/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
from .infrastructure import AzureBlobStorageStateHandler, \
2929
CSVOHLCVDataProvider, CSVTickerDataProvider, \
3030
CCXTOHLCVDataProvider, CCXTTickerDataProvider, \
31-
PandasOHLCVDataProvider, YahooOHLCVDataProvider, \
31+
PandasOHLCVDataProvider, OHLCVDataProviderBase, \
32+
YahooOHLCVDataProvider, \
3233
AlphaVantageOHLCVDataProvider, PolygonOHLCVDataProvider, \
3334
AWSS3StorageStateHandler
3435
from .create_app import create_app
@@ -117,6 +118,7 @@
117118
'CSVTickerDataProvider',
118119
"CCXTOHLCVDataProvider",
119120
"CCXTTickerDataProvider",
121+
"OHLCVDataProviderBase",
120122
"YahooOHLCVDataProvider",
121123
"AlphaVantageOHLCVDataProvider",
122124
"PolygonOHLCVDataProvider",

investing_algorithm_framework/infrastructure/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
CSVTickerDataProvider, get_default_data_providers, \
1515
get_default_ohlcv_data_providers, CCXTOHLCVDataProvider, \
1616
CCXTTickerDataProvider, PandasOHLCVDataProvider, \
17+
OHLCVDataProviderBase, \
1718
YahooOHLCVDataProvider, AlphaVantageOHLCVDataProvider, \
1819
PolygonOHLCVDataProvider
1920
from .order_executors import CCXTOrderExecutor, BacktestOrderExecutor
@@ -53,6 +54,7 @@
5354
"CCXTTickerDataProvider",
5455
"BacktestOrderExecutor",
5556
"PandasOHLCVDataProvider",
57+
"OHLCVDataProviderBase",
5658
"YahooOHLCVDataProvider",
5759
"AlphaVantageOHLCVDataProvider",
5860
"PolygonOHLCVDataProvider",

investing_algorithm_framework/infrastructure/data_providers/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from .ccxt import CCXTOHLCVDataProvider, CCXTTickerDataProvider
22
from .csv import CSVOHLCVDataProvider, CSVTickerDataProvider
33
from .pandas import PandasOHLCVDataProvider
4+
from .ohlcv_base import OHLCVDataProviderBase
45
from .yahoo import YahooOHLCVDataProvider
56
from .alpha_vantage import AlphaVantageOHLCVDataProvider
67
from .polygon import PolygonOHLCVDataProvider
@@ -44,6 +45,7 @@ def get_default_ohlcv_data_providers():
4445
'CCXTTickerDataProvider',
4546
'get_default_data_providers',
4647
'get_default_ohlcv_data_providers',
48+
'OHLCVDataProviderBase',
4749
'PandasOHLCVDataProvider',
4850
'YahooOHLCVDataProvider',
4951
'AlphaVantageOHLCVDataProvider',

0 commit comments

Comments
 (0)