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 9c9ce69 commit 936aa9b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

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 @@ -49,10 +52,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_dot_eur_ohlcv_2h,
bitvavo_btc_eur_ticker,
bitvavo_btc_eur_ohlcv_2h
]
symbols = ["BTC/EUR", "DOT/EUR"]

Expand Down
9 changes: 6 additions & 3 deletions examples/crossover_moving_average_trading_bot/backtesting.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,10 +26,13 @@
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,
pending_order_check_interval="2h",
)
pretty_print_backtest(backtest_report)

0 comments on commit 936aa9b

Please sign in to comment.