Skip to content

Commit 9064138

Browse files
committed
Refactor data sources
1 parent 936aa9b commit 9064138

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

examples/backtest_example/algorithm/strategy.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from investing_algorithm_framework import TimeUnit, TradingStrategy, \
44
Algorithm, OrderSide
5+
from .data_sources import bitvavo_btc_eur_ohlcv_2h, bitvavo_btc_eur_ticker, \
6+
bitvavo_dot_eur_ticker, bitvavo_dot_eur_ohlcv_2h
57

68
"""
79
This strategy is based on the golden cross strategy. It will buy when the
@@ -47,10 +49,10 @@ class CrossOverStrategy(TradingStrategy):
4749
time_unit = TimeUnit.HOUR
4850
interval = 2
4951
market_data_sources = [
50-
"BTC/EUR-ohlcv",
51-
"DOT/EUR-ohlcv",
52-
"BTC/EUR-ticker",
53-
"DOT/EUR-ticker"
52+
bitvavo_dot_eur_ticker,
53+
bitvavo_btc_eur_ticker,
54+
bitvavo_dot_eur_ohlcv_2h,
55+
bitvavo_btc_eur_ohlcv_2h
5456
]
5557
symbols = ["BTC/EUR", "DOT/EUR"]
5658
fast = 21

examples/backtest_example/run_backtest.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
bitvavo_dot_eur_ohlcv_2h, bitvavo_dot_eur_ticker, bitvavo_btc_eur_ticker
66
from app import app
77
from investing_algorithm_framework import PortfolioConfiguration, \
8-
pretty_print_backtest
8+
pretty_print_backtest, BacktestDateRange
99

1010
app.add_algorithm(algorithm)
1111
app.add_market_data_source(bitvavo_btc_eur_ohlcv_2h)
@@ -26,9 +26,12 @@
2626
if __name__ == "__main__":
2727
end_date = datetime(2023, 12, 2)
2828
start_date = end_date - timedelta(days=100)
29+
date_range = BacktestDateRange(
30+
start_date=start_date,
31+
end_date=end_date
32+
)
2933
backtest_report = app.run_backtest(
3034
algorithm=algorithm,
31-
start_date=start_date,
32-
end_date=end_date,
35+
backtest_date_range=date_range,
3336
)
3437
pretty_print_backtest(backtest_report)

0 commit comments

Comments
 (0)