diff --git a/examples/backtest_example/algorithm/strategy.py b/examples/backtest_example/algorithm/strategy.py index 6b15b33c..844535bd 100644 --- a/examples/backtest_example/algorithm/strategy.py +++ b/examples/backtest_example/algorithm/strategy.py @@ -2,6 +2,8 @@ from investing_algorithm_framework import TimeUnit, TradingStrategy, \ Algorithm, OrderSide +from .data_sources import bitvavo_btc_eur_ohlcv_2h, bitvavo_btc_eur_ticker, \ + bitvavo_dot_eur_ticker, bitvavo_dot_eur_ohlcv_2h """ This strategy is based on the golden cross strategy. It will buy when the @@ -47,10 +49,10 @@ class CrossOverStrategy(TradingStrategy): time_unit = TimeUnit.HOUR interval = 2 market_data_sources = [ - "BTC/EUR-ohlcv", - "DOT/EUR-ohlcv", - "BTC/EUR-ticker", - "DOT/EUR-ticker" + bitvavo_dot_eur_ticker, + bitvavo_btc_eur_ticker, + bitvavo_dot_eur_ohlcv_2h, + bitvavo_btc_eur_ohlcv_2h ] symbols = ["BTC/EUR", "DOT/EUR"] fast = 21 diff --git a/examples/backtest_example/run_backtest.py b/examples/backtest_example/run_backtest.py index dec528ef..1d1f5cb8 100644 --- a/examples/backtest_example/run_backtest.py +++ b/examples/backtest_example/run_backtest.py @@ -5,7 +5,7 @@ bitvavo_dot_eur_ohlcv_2h, bitvavo_dot_eur_ticker, bitvavo_btc_eur_ticker from app import app from investing_algorithm_framework import PortfolioConfiguration, \ - pretty_print_backtest + pretty_print_backtest, BacktestDateRange app.add_algorithm(algorithm) app.add_market_data_source(bitvavo_btc_eur_ohlcv_2h) @@ -26,9 +26,12 @@ if __name__ == "__main__": end_date = datetime(2023, 12, 2) start_date = end_date - timedelta(days=100) + date_range = BacktestDateRange( + start_date=start_date, + end_date=end_date + ) backtest_report = app.run_backtest( algorithm=algorithm, - start_date=start_date, - end_date=end_date, + backtest_date_range=date_range, ) pretty_print_backtest(backtest_report)