Make DRY
#281
Replies: 1 comment
-
Hey @amustapha thanks!, could you provide some code outline how this would look. If I understand you correctly this would look along the line of: from investing_algorithm_framework import create_app, PortfolioConfiguration, \
TimeUnit, CCXTOHLCVMarketDataSource, Algorithm, \
CCXTTickerMarketDataSource, MarketCredential
# New data on every 2h interval
bitvavo_btc_eur_ohlcv_2h = CCXTOHLCVMarketDataSource(
identifier="BTC-ohlcv",
market="BITVAVO",
symbol="BTC/EUR",
time_frame="2h",
window_size=200
)
# New data on every 1h interval
bitvavo_btc_eur_ohlcv_1h = CCXTOHLCVMarketDataSource(
identifier="BTC-ohlcv",
market="BITVAVO",
symbol="BTC/EUR",
time_frame="1h",
window_size=200
)
# Ticker data for orders, trades and positions
bitvavo_btc_eur_ticker = CCXTTickerMarketDataSource(
identifier="BTC-ticker",
market="BITVAVO",
symbol="BTC/EUR",
)
... App creation here
# Without explicitly defining the interval when the strategy runs, it would run when there is new data
# available for bitvavo_btc_eur_ohlcv_2h and bitvavo_btc_eur_ohlcv_1h. Meaning that this function runs every 1h and 2h (basically every hour)
@algorithm.strategy()
def on_data(algorithm: Algorithm, market_data: dict):
# Access the data sources with the indentifier
polars_df = market_data["BTC-ohlcv"]
if __name__ == "__main__":
app.run() I see a couple of limitations here that we then should address:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I think it might be a good idea to use dependency injection or a centralized config handler to minimize code repition, e.g We have to define data sources with a timeframe, then when using the datasource in a Strategy, the strategy would also have a timeframe which is defined then our backtest also uses a timeframe.
I think it might be a nice idea for a strategy to be time frame agnostic... this might keep the Strategy class open enough to have an optimizer... e.g, I can create a strategy and try to find on what time frame it would perform best. I can have a strategy and try to tweak the input parameters...
just ideas in my head
Beta Was this translation helpful? Give feedback.
All reactions