-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add experiment multiple algorithms support
- Loading branch information
Showing
84 changed files
with
2,436 additions
and
633 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
File renamed without changes.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from .algorithm_one import algorithm as algorithm_one | ||
from .algorithm_two import algorithm as algorithm_two | ||
from .algorithm_three import algorithm as algorithm_three | ||
|
||
|
||
__all__ = [ | ||
"algorithm_one", | ||
"algorithm_two", | ||
"algorithm_three", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from investing_algorithm_framework import TradingStrategy, Algorithm, TimeUnit | ||
|
||
algorithm = Algorithm() | ||
|
||
|
||
class Strategy(TradingStrategy): | ||
strategy_id = "strategy_one" | ||
time_unit = TimeUnit.MINUTE | ||
interval = 30 | ||
|
||
def run_strategy(self, algorithm: Algorithm, market_data): | ||
pass | ||
|
||
|
||
algorithm.add_strategy(Strategy()) |
16 changes: 16 additions & 0 deletions
16
examples/backtest_expirement/algorithms/algorithm_three.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from investing_algorithm_framework import TradingStrategy, Algorithm, TimeUnit | ||
|
||
|
||
algorithm = Algorithm() | ||
|
||
|
||
class Strategy(TradingStrategy): | ||
strategy_id = "strategy_three" | ||
time_unit = TimeUnit.MINUTE | ||
interval = 30 | ||
|
||
def run_strategy(self, algorithm: Algorithm, market_data): | ||
pass | ||
|
||
|
||
algorithm.add_strategy(Strategy()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from investing_algorithm_framework import TradingStrategy, Algorithm, TimeUnit | ||
|
||
algorithm = Algorithm() | ||
|
||
|
||
class Strategy(TradingStrategy): | ||
strategy_id = "strategy_two" | ||
time_unit = TimeUnit.MINUTE | ||
interval = 30 | ||
|
||
def run_strategy(self, algorithm: Algorithm, market_data): | ||
pass | ||
|
||
|
||
algorithm.add_strategy(Strategy()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import pathlib | ||
|
||
from data_sources import bitvavo_btc_eur_ohlcv_2h, bitvavo_dot_eur_ohlcv_2h, \ | ||
bitvavo_dot_eur_ticker, bitvavo_btc_eur_ticker | ||
from investing_algorithm_framework import create_app, RESOURCE_DIRECTORY | ||
|
||
app = create_app( | ||
config={RESOURCE_DIRECTORY: pathlib.Path(__file__).parent.resolve()} | ||
) | ||
app.add_market_data_source(bitvavo_btc_eur_ohlcv_2h) | ||
app.add_market_data_source(bitvavo_dot_eur_ohlcv_2h) | ||
app.add_market_data_source(bitvavo_btc_eur_ticker) | ||
app.add_market_data_source(bitvavo_dot_eur_ticker) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from datetime import datetime, timedelta | ||
|
||
from algorithms import algorithm_one, algorithm_two, algorithm_three | ||
from app import app | ||
from investing_algorithm_framework import PortfolioConfiguration | ||
|
||
if __name__ == "__main__": | ||
end_date = datetime(2023, 12, 2) | ||
start_date = end_date - timedelta(days=100) | ||
|
||
# Add a portfolio configuration of 400 euro initial balance | ||
app.add_portfolio_configuration( | ||
PortfolioConfiguration( | ||
market="BINANCE", | ||
trading_symbol="EUR", | ||
initial_balance=400, | ||
) | ||
) | ||
|
||
# Run the backtest for each algorithm | ||
reports = app.run_backtests( | ||
algorithms=[ | ||
algorithm_one, | ||
algorithm_two, | ||
algorithm_three, | ||
], | ||
start_date=start_date, | ||
end_date=end_date, | ||
pending_order_check_interval="2h", | ||
) | ||
|
||
|
||
# pretty_print_expirement(reports) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from investing_algorithm_framework import CCXTOHLCVMarketDataSource, \ | ||
CCXTTickerMarketDataSource | ||
|
||
|
||
bitvavo_btc_eur_ohlcv_2h = CCXTOHLCVMarketDataSource( | ||
identifier="BTC/EUR-ohlcv", | ||
market="BINANCE", | ||
symbol="BTC/EUR", | ||
timeframe="2h", | ||
window_size=200 | ||
) | ||
bitvavo_dot_eur_ohlcv_2h = CCXTOHLCVMarketDataSource( | ||
identifier="DOT/EUR-ohlcv", | ||
market="BINANCE", | ||
symbol="DOT/EUR", | ||
timeframe="2h", | ||
window_size=200 | ||
) | ||
bitvavo_dot_eur_ticker = CCXTTickerMarketDataSource( | ||
identifier="DOT/EUR-ticker", | ||
market="BINANCE", | ||
symbol="DOT/EUR", | ||
backtest_timeframe="2h", | ||
) | ||
bitvavo_btc_eur_ticker = CCXTTickerMarketDataSource( | ||
identifier="BTC/EUR-ticker", | ||
market="BINANCE", | ||
symbol="BTC/EUR", | ||
backtest_timeframe="2h", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.