Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/pip/aiohttp-3.9.4
Browse files Browse the repository at this point in the history
  • Loading branch information
MDUYN committed Jul 2, 2024
2 parents 8cd6cab + 4b6b5fa commit 35e3c9a
Show file tree
Hide file tree
Showing 143 changed files with 45,448 additions and 1,842 deletions.
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
exclude =
investing_algorithm_framework/domain/utils/backtesting.py
examples
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
#----------------------------------------------
- run: python -m pip install black flake8 isort
- run: |
flake8 ./investing_algorithm_framework --exclude="investing_algorithm_framework/domain/utils/backtesting.py"
flake8 ./investing_algorithm_framework
test:
needs: linting
strategy:
Expand Down
114 changes: 65 additions & 49 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__='v3.5.2'
__version__ = 'v3.6.0'
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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)
128 changes: 0 additions & 128 deletions examples/backtest_experiment/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,133 +14,5 @@
"slow":50,
"trend":100,
"stop_loss_percentage":7
},
{
"name":"11-50-100",
"description":"11-50-100",
"fast":11,
"slow":50,
"trend":100,
"stop_loss_percentage":7
},
{
"name":"9-75-150",
"description":"9-75-150",
"fast":9,
"slow":75,
"trend":150,
"stop_loss_percentage":7
},
{
"name":"10-75-150",
"description":"10-75-150",
"fast":10,
"slow":75,
"trend":150,
"stop_loss_percentage":7
},
{
"name":"11-75-150",
"description":"11-75-150",
"fast":11,
"slow":75,
"trend":150,
"stop_loss_percentage":7
},
{
"name":"20-75-150",
"description":"20-75-150",
"fast":20,
"slow":75,
"trend":150,
"stop_loss_percentage":7
},
{
"name":"21-75-150",
"description":"21-75-150",
"fast":21,
"slow":75,
"trend":150,
"stop_loss_percentage":7
},
{
"name":"22-75-150",
"description":"22-75-150",
"fast":22,
"slow":75,
"trend":150,
"stop_loss_percentage":7
},
{
"name":"23-75-150",
"description":"23-75-150",
"fast":23,
"slow":75,
"trend":150,
"stop_loss_percentage":7
},
{
"name":"24-75-150",
"description":"24-75-150",
"fast":24,
"slow":75,
"trend":150,
"stop_loss_percentage":7
},
{
"name":"25-75-150",
"description":"25-75-150",
"fast":25,
"slow":75,
"trend":150,
"stop_loss_percentage":7
},
{
"name":"20-75-200",
"description":"20-75-200",
"fast":20,
"slow":75,
"trend":200,
"stop_loss_percentage":7
},
{
"name":"21-75-200",
"description":"24-75-200",
"fast":24,
"slow":75,
"trend":200,
"stop_loss_percentage":7
},
{
"name":"22-75-200",
"description":"24-75-200",
"fast":24,
"slow":75,
"trend":200,
"stop_loss_percentage":7
},
{
"name":"23-75-200",
"description":"24-75-200",
"fast":24,
"slow":75,
"trend":200,
"stop_loss_percentage":7
},
{
"name":"24-75-200",
"description":"24-75-200",
"fast":24,
"slow":75,
"trend":200,
"stop_loss_percentage":7
},
{
"name":"25-75-150",
"description":"25-75-200",
"fast":25,
"slow":75,
"trend":200,
"stop_loss_percentage":7
}
]
32 changes: 22 additions & 10 deletions examples/backtest_experiment/run_backtest.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
import json
from datetime import datetime, timedelta
from datetime import datetime

from algorithms import create_algorithm
from app import app
from investing_algorithm_framework import PortfolioConfiguration, \
pretty_print_backtest_reports_evaluation, BacktestReportsEvaluation
pretty_print_backtest_reports_evaluation, BacktestReportsEvaluation, \
BacktestDateRange

if __name__ == "__main__":
end_date = datetime(2023, 12, 2)
start_date = end_date - timedelta(days=100)
down_turn_date_range = BacktestDateRange(
start_date=datetime(2021, 12, 21),
end_date=datetime(2022, 6, 20),
name="down_turn"
)
up_turn_date_range = BacktestDateRange(
start_date=datetime(2022, 12, 20),
end_date=datetime(2023, 6, 1),
name="up_turn"
)
sideways_date_range = BacktestDateRange(
start_date=datetime(2022, 6, 10),
end_date=datetime(2023, 1, 10),
name="sideways"
)

json = json.load(open("configuration.json"))
algorithms = []

Expand All @@ -27,12 +42,9 @@
reports = app.run_backtests(
algorithms=algorithms,
date_ranges=[
(datetime(2023, 7, 2),
datetime(2023, 7, 2) + timedelta(days=200)),
(datetime(2022, 7, 2),
datetime(2022, 7, 2) + timedelta(days=200)),
(datetime(2024, 1, 1),
datetime(2024, 1, 1) + timedelta(days=100)),
down_turn_date_range,
up_turn_date_range,
sideways_date_range
],
pending_order_check_interval="2h",
)
Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions examples/backtests_example/algorithms/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .challenger import create_algorithm as create_challenger_algorithm
from .primary import create_algorithm as create_primary_algorithm


__all__ = ["create_challenger_algorithm", "create_primary_algorithm"]
Loading

0 comments on commit 35e3c9a

Please sign in to comment.