Skip to content

Commit

Permalink
Refactor data sources
Browse files Browse the repository at this point in the history
  • Loading branch information
MDUYN committed Jul 1, 2024
1 parent 936aa9b commit 9064138
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 6 additions & 4 deletions examples/backtest_example/algorithm/strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions examples/backtest_example/run_backtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

0 comments on commit 9064138

Please sign in to comment.