investing-algorithm-framework 3.8__tar.gz → 4.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/PKG-INFO +67 -74
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/README.md +60 -73
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/__init__.py +28 -5
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/app/algorithm.py +326 -44
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/app/app.py +307 -213
- investing_algorithm_framework-4.0.0/investing_algorithm_framework/app/strategy.py +559 -0
- investing_algorithm_framework-4.0.0/investing_algorithm_framework/app/web/__init__.py +5 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/app/web/create_app.py +4 -2
- investing_algorithm_framework-4.0.0/investing_algorithm_framework/cli/create_azure_function_app_skeleton.py +149 -0
- investing_algorithm_framework-4.0.0/investing_algorithm_framework/cli/deploy_to_azure_function.py +701 -0
- investing_algorithm_framework-4.0.0/investing_algorithm_framework/cli/templates/azure_function_framework_app.py.template +48 -0
- investing_algorithm_framework-4.0.0/investing_algorithm_framework/cli/templates/azure_function_function_app.py.template +32 -0
- investing_algorithm_framework-4.0.0/investing_algorithm_framework/cli/templates/azure_function_host.json.template +15 -0
- investing_algorithm_framework-4.0.0/investing_algorithm_framework/cli/templates/azure_function_local.settings.json.template +8 -0
- investing_algorithm_framework-4.0.0/investing_algorithm_framework/cli/templates/azure_function_requirements.txt.template +2 -0
- investing_algorithm_framework-4.0.0/investing_algorithm_framework/create_app.py +46 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/__init__.py +6 -4
- investing_algorithm_framework-4.0.0/investing_algorithm_framework/domain/config.py +84 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/backtesting/backtest_date_range.py +6 -2
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/backtesting/backtest_report.py +23 -1
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/base_model.py +6 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/date_range.py +8 -0
- investing_algorithm_framework-4.0.0/investing_algorithm_framework/domain/models/market/market_credential.py +87 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/order/order.py +4 -1
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/portfolio/portfolio.py +37 -3
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/position/position.py +3 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/time_unit.py +3 -1
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/trade/trade.py +23 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/services/market_data_sources.py +9 -2
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/utils/__init__.py +4 -2
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/utils/backtesting.py +170 -21
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/utils/polars.py +6 -1
- investing_algorithm_framework-4.0.0/investing_algorithm_framework/indicators/__init__.py +40 -0
- investing_algorithm_framework-4.0.0/investing_algorithm_framework/indicators/advanced.py +404 -0
- investing_algorithm_framework-4.0.0/investing_algorithm_framework/indicators/momentum.py +41 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/indicators/trend.py +166 -97
- investing_algorithm_framework-4.0.0/investing_algorithm_framework/indicators/utils.py +580 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/__init__.py +3 -1
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/database/sql_alchemy.py +5 -12
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/models/market_data_sources/ccxt.py +87 -36
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/models/portfolio/__init__.py +1 -1
- investing_algorithm_framework-3.8/investing_algorithm_framework/infrastructure/models/portfolio/portfolio.py → investing_algorithm_framework-4.0.0/investing_algorithm_framework/infrastructure/models/portfolio/sql_portfolio.py +10 -1
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/repositories/order_repository.py +1 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/repositories/repository.py +12 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/services/__init__.py +3 -1
- investing_algorithm_framework-4.0.0/investing_algorithm_framework/infrastructure/services/azure/__init__.py +5 -0
- investing_algorithm_framework-4.0.0/investing_algorithm_framework/infrastructure/services/azure/state_handler.py +148 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/services/market_service/ccxt_market_service.py +6 -2
- investing_algorithm_framework-4.0.0/investing_algorithm_framework/services/backtesting/backtest_report_writer_service.py +91 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/services/backtesting/backtest_service.py +153 -9
- investing_algorithm_framework-4.0.0/investing_algorithm_framework/services/configuration_service.py +80 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/services/market_credential_service.py +8 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/services/market_data_source_service/market_data_source_service.py +33 -5
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/services/order_service/order_backtest_service.py +22 -6
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/services/order_service/order_service.py +11 -5
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/services/portfolios/backtest_portfolio_service.py +1 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/services/portfolios/portfolio_configuration_service.py +5 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/services/portfolios/portfolio_service.py +52 -1
- investing_algorithm_framework-4.0.0/investing_algorithm_framework/services/portfolios/portfolio_sync_service.py +307 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/services/repository_service.py +3 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/services/strategy_orchestrator_service.py +1 -3
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/pyproject.toml +16 -2
- investing_algorithm_framework-3.8/investing_algorithm_framework/app/strategy.py +0 -213
- investing_algorithm_framework-3.8/investing_algorithm_framework/app/web/__init__.py +0 -4
- investing_algorithm_framework-3.8/investing_algorithm_framework/create_app.py +0 -20
- investing_algorithm_framework-3.8/investing_algorithm_framework/deployment/azure/__init__.py +0 -3
- investing_algorithm_framework-3.8/investing_algorithm_framework/deployment/azure/azure_functions.py +0 -102
- investing_algorithm_framework-3.8/investing_algorithm_framework/domain/config.py +0 -143
- investing_algorithm_framework-3.8/investing_algorithm_framework/domain/models/market/market_credential.py +0 -34
- investing_algorithm_framework-3.8/investing_algorithm_framework/indicators/__init__.py +0 -13
- investing_algorithm_framework-3.8/investing_algorithm_framework/indicators/advanced.py +0 -224
- investing_algorithm_framework-3.8/investing_algorithm_framework/services/backtesting/backtest_report_writer_service.py +0 -53
- investing_algorithm_framework-3.8/investing_algorithm_framework/services/configuration_service.py +0 -29
- investing_algorithm_framework-3.8/investing_algorithm_framework/services/portfolios/portfolio_sync_service.py +0 -379
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/LICENSE +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/app/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/app/stateless/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/app/stateless/action_handlers/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/app/stateless/action_handlers/action_handler_strategy.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/app/stateless/action_handlers/check_online_handler.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/app/stateless/action_handlers/run_strategy_handler.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/app/stateless/exception_handler.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/app/task.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/app/web/controllers/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/app/web/controllers/orders.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/app/web/controllers/portfolio.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/app/web/controllers/positions.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/app/web/error_handler.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/app/web/responses.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/app/web/run_strategies.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/app/web/schemas/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/app/web/schemas/order.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/app/web/schemas/portfolio.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/app/web/schemas/position.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/app/web/setup_cors.py +0 -0
- {investing_algorithm_framework-3.8/investing_algorithm_framework/deployment → investing_algorithm_framework-4.0.0/investing_algorithm_framework/cli}/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/dependency_container.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/constants.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/data_structures.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/decimal_parsing.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/exceptions.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/metrics/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/metrics/price_efficiency.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/app_mode.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/backtesting/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/backtesting/backtest_position.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/backtesting/backtest_reports_evaluation.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/market/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/order/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/order/order_side.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/order/order_status.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/order/order_type.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/portfolio/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/portfolio/portfolio_configuration.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/portfolio/portfolio_snapshot.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/position/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/position/position_snapshot.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/strategy_profile.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/time_frame.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/time_interval.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/tracing/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/tracing/trace.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/trade/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/trade/trade_status.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/trading_data_types.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/models/trading_time_frame.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/services/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/services/market_credential_service.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/services/market_service.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/services/portfolios/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/services/portfolios/portfolio_sync_service.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/services/rounding_service.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/singleton.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/stateless_actions.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/strategy.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/utils/csv.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/utils/random.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/utils/signatures.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/utils/stoppable_thread.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/domain/utils/synchronized.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/database/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/models/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/models/decimal_parser.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/models/market_data_sources/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/models/market_data_sources/csv.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/models/market_data_sources/pandas.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/models/market_data_sources/us_treasury_yield.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/models/model_extension.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/models/order/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/models/order/order.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/models/portfolio/portfolio_snapshot.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/models/position/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/models/position/position.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/models/position/position_snapshot.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/repositories/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/repositories/portfolio_repository.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/repositories/portfolio_snapshot_repository.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/repositories/position_repository.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/repositories/position_snapshot_repository.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/services/market_service/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/services/performance_service/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/services/performance_service/backtest_performance_service.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/infrastructure/services/performance_service/performance_service.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/services/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/services/backtesting/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/services/backtesting/graphs.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/services/market_data_source_service/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/services/market_data_source_service/backtest_market_data_source_service.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/services/order_service/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/services/portfolios/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/services/portfolios/portfolio_snapshot_service.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/services/position_service.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/services/position_snapshot_service.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/services/trade_service/__init__.py +0 -0
- {investing_algorithm_framework-3.8 → investing_algorithm_framework-4.0.0}/investing_algorithm_framework/services/trade_service/trade_service.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: investing-algorithm-framework
|
|
3
|
-
Version:
|
|
3
|
+
Version: 4.0.0
|
|
4
4
|
Summary: A framework for creating trading bots
|
|
5
5
|
Author: MDUYN
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -13,6 +13,11 @@ Requires-Dist: Flask-Cors (>=3.0.9,<5.0.0)
|
|
|
13
13
|
Requires-Dist: Flask-Migrate (>=2.6.0,<3.0.0)
|
|
14
14
|
Requires-Dist: MarkupSafe (>=2.1.2,<3.0.0)
|
|
15
15
|
Requires-Dist: SQLAlchemy (>=2.0.18,<3.0.0)
|
|
16
|
+
Requires-Dist: azure-identity (>=1.19.0,<2.0.0)
|
|
17
|
+
Requires-Dist: azure-mgmt-resource (>=23.2.0,<24.0.0)
|
|
18
|
+
Requires-Dist: azure-mgmt-storage (>=21.2.1,<22.0.0)
|
|
19
|
+
Requires-Dist: azure-mgmt-web (>=7.3.1,<8.0.0)
|
|
20
|
+
Requires-Dist: azure-storage-blob (>=12.24.0,<13.0.0)
|
|
16
21
|
Requires-Dist: ccxt (>=4.2.48,<5.0.0)
|
|
17
22
|
Requires-Dist: dependency-injector (>=4.40.0,<5.0.0)
|
|
18
23
|
Requires-Dist: jupyter (>=1.0.0,<2.0.0)
|
|
@@ -21,6 +26,7 @@ Requires-Dist: numpy (>=2.1.3,<3.0.0)
|
|
|
21
26
|
Requires-Dist: plotly (>=5.22.0,<6.0.0)
|
|
22
27
|
Requires-Dist: polars[numpy,pandas] (>=0.20.10,<0.21.0)
|
|
23
28
|
Requires-Dist: python-dateutil (>=2.8.2,<3.0.0)
|
|
29
|
+
Requires-Dist: python-dotenv (>=1.0.1,<2.0.0)
|
|
24
30
|
Requires-Dist: schedule (>=1.1.0,<2.0.0)
|
|
25
31
|
Requires-Dist: scipy (>=1.14.1,<2.0.0)
|
|
26
32
|
Requires-Dist: tabulate (>=0.9.0,<0.10.0)
|
|
@@ -38,6 +44,7 @@ Description-Content-Type: text/markdown
|
|
|
38
44
|
[](https://github.com/SeaQL/sea-orm/stargazers/) If you like what we do, consider starring, sharing and contributing!
|
|
39
45
|
|
|
40
46
|
###### Sponsors
|
|
47
|
+
|
|
41
48
|
<p align="left">
|
|
42
49
|
<a href="https://finterion.com">
|
|
43
50
|
<img alt="Finterion" src="static/sponsors/finterion.png" width="200px" />
|
|
@@ -46,12 +53,11 @@ Description-Content-Type: text/markdown
|
|
|
46
53
|
|
|
47
54
|
# [Investing Algorithm Framework](https://github.com/coding-kitties/investing-algorithm-framework)
|
|
48
55
|
|
|
49
|
-
The Investing Algorithm Framework is a Python
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
portfolio management, and order execution.
|
|
56
|
+
The Investing Algorithm Framework is a Python framework that enables swift and elegant development of trading bots. It comes with all the necessary components for creating trading strategies, including data management, portfolio, order, position and trades management.
|
|
57
|
+
|
|
58
|
+
Features:
|
|
53
59
|
|
|
54
|
-
|
|
60
|
+
* Indicators module: A collection of indicators and utility functions that can be used in your trading strategies.
|
|
55
61
|
* Order execution and tracking
|
|
56
62
|
* Broker and exchange connections through [ccxt](https://github.com/ccxt/ccxt)
|
|
57
63
|
* Backtesting and performance analysis reports [example](./examples/backtest_example)
|
|
@@ -63,30 +69,18 @@ Features:
|
|
|
63
69
|
* Stateless running for cloud function deployments
|
|
64
70
|
* Polars dataframes support out of the box for fast data processing [pola.rs](https://pola.rs/)
|
|
65
71
|
|
|
66
|
-
Additional features:
|
|
67
|
-
* Indicators (python >= 3.10 required): Set of indicators that can be used in your trading bot. You can donwload the package with `pip install investing-algorithm-framework[indicators]` or `poetry add investing-algorithm-framework[indicators]]`
|
|
68
|
-
|
|
69
72
|
## Example implementation
|
|
70
|
-
|
|
71
|
-
It also exposes an REST API that allows you to interact with the algorithm.
|
|
73
|
+
|
|
74
|
+
The following algorithm connects to binance and buys BTC every 5 seconds. It also exposes an REST API that allows you to interact with the algorithm.
|
|
75
|
+
|
|
72
76
|
```python
|
|
73
|
-
import
|
|
77
|
+
import logging
|
|
74
78
|
from investing_algorithm_framework import create_app, PortfolioConfiguration, \
|
|
75
|
-
|
|
76
|
-
CCXTTickerMarketDataSource, MarketCredential,
|
|
77
|
-
|
|
78
|
-
# Define the symbols you want to trade for optimization, otherwise the
|
|
79
|
-
# algorithm will check if you have orders and balances on all available
|
|
80
|
-
# symbols on the market
|
|
81
|
-
symbols = ["BTC/EUR"]
|
|
79
|
+
TimeUnit, CCXTOHLCVMarketDataSource, Algorithm, \
|
|
80
|
+
CCXTTickerMarketDataSource, MarketCredential, DEFAULT_LOGGING_CONFIG
|
|
82
81
|
|
|
83
|
-
|
|
84
|
-
config = {
|
|
85
|
-
RESOURCE_DIRECTORY: pathlib.Path(__file__).parent.resolve(),
|
|
86
|
-
SYMBOLS: symbols
|
|
87
|
-
}
|
|
82
|
+
logging.config.dictConfig(DEFAULT_LOGGING_CONFIG)
|
|
88
83
|
|
|
89
|
-
# Define market data sources
|
|
90
84
|
# OHLCV data for candles
|
|
91
85
|
bitvavo_btc_eur_ohlcv_2h = CCXTOHLCVMarketDataSource(
|
|
92
86
|
identifier="BTC-ohlcv",
|
|
@@ -101,13 +95,10 @@ bitvavo_btc_eur_ticker = CCXTTickerMarketDataSource(
|
|
|
101
95
|
market="BITVAVO",
|
|
102
96
|
symbol="BTC/EUR",
|
|
103
97
|
)
|
|
104
|
-
app = create_app(
|
|
98
|
+
app = create_app()
|
|
105
99
|
algorithm = Algorithm()
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
api_key="<your api key>",
|
|
109
|
-
secret_key="<your secret key>",
|
|
110
|
-
))
|
|
100
|
+
# Bitvavo market credentials are read from .env file
|
|
101
|
+
app.add_market_credential(MarketCredential(market="bitvavo"))
|
|
111
102
|
app.add_portfolio_configuration(
|
|
112
103
|
PortfolioConfiguration(
|
|
113
104
|
market="bitvavo",
|
|
@@ -117,42 +108,39 @@ app.add_portfolio_configuration(
|
|
|
117
108
|
)
|
|
118
109
|
app.add_algorithm(algorithm)
|
|
119
110
|
|
|
111
|
+
# Run every two hours and register the data sources
|
|
120
112
|
@algorithm.strategy(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
interval=2,
|
|
124
|
-
# Specify market data sources that need to be passed to the strategy
|
|
113
|
+
time_unit=TimeUnit.HOUR,
|
|
114
|
+
interval=2,
|
|
125
115
|
market_data_sources=[bitvavo_btc_eur_ticker, bitvavo_btc_eur_ohlcv_2h]
|
|
126
116
|
)
|
|
127
117
|
def perform_strategy(algorithm: Algorithm, market_data: dict):
|
|
128
|
-
#
|
|
129
|
-
|
|
130
|
-
# call to_pandas() to convert to pandas
|
|
131
|
-
polars_df = market_data["BTC-ohlcv"]
|
|
132
|
-
print(f"I have access to {len(polars_df)} candles of ohlcv data")
|
|
118
|
+
# Access the data sources with the indentifier
|
|
119
|
+
polars_df = market_data["BTC-ohlcv"]
|
|
133
120
|
|
|
134
|
-
#
|
|
121
|
+
# Convert the polars dataframe to a pandas dataframe
|
|
122
|
+
pandas_df = polars_df.to_pandas()
|
|
135
123
|
ticker_data = market_data["BTC-ticker"]
|
|
136
124
|
unallocated_balance = algorithm.get_unallocated()
|
|
137
125
|
positions = algorithm.get_positions()
|
|
138
126
|
trades = algorithm.get_trades()
|
|
139
127
|
open_trades = algorithm.get_open_trades()
|
|
140
128
|
closed_trades = algorithm.get_closed_trades()
|
|
141
|
-
|
|
142
|
-
# Create a buy oder
|
|
129
|
+
|
|
130
|
+
# Create a buy oder
|
|
143
131
|
algorithm.create_limit_order(
|
|
144
132
|
target_symbol="BTC/EUR",
|
|
145
133
|
order_side="buy",
|
|
146
134
|
amount=0.01,
|
|
147
135
|
price=ticker_data["ask"],
|
|
148
136
|
)
|
|
149
|
-
|
|
137
|
+
|
|
150
138
|
# Close a trade
|
|
151
139
|
algorithm.close_trade(trades[0].id)
|
|
152
|
-
|
|
140
|
+
|
|
153
141
|
# Close a position
|
|
154
142
|
algorithm.close_position(positions[0].get_symbol())
|
|
155
|
-
|
|
143
|
+
|
|
156
144
|
if __name__ == "__main__":
|
|
157
145
|
app.run()
|
|
158
146
|
```
|
|
@@ -160,23 +148,24 @@ if __name__ == "__main__":
|
|
|
160
148
|
> You can find more examples [here](./examples) folder.
|
|
161
149
|
|
|
162
150
|
## Backtesting and experiments
|
|
163
|
-
|
|
164
|
-
a backtest, you can print a report that shows the performance of your trading bot.
|
|
151
|
+
|
|
152
|
+
The framework also supports backtesting and performing backtest experiments. After a backtest, you can print a report that shows the performance of your trading bot.
|
|
165
153
|
|
|
166
154
|
To run a single backtest you can use the example code that can be found [here](./examples/backtest).
|
|
167
155
|
|
|
168
156
|
### Backtesting report
|
|
157
|
+
|
|
169
158
|
You can use the ```pretty_print_backtest``` function to print a backtest report.
|
|
170
159
|
For example if you run the [moving average example trading bot](./examples/crossover_moving_average_trading_bot)
|
|
171
160
|
you will get the following backtesting report:
|
|
172
|
-
|
|
161
|
+
|
|
173
162
|
```bash
|
|
174
163
|
|
|
175
164
|
:%%%#+- .=*#%%% Backtest report
|
|
176
165
|
*%%%%%%%+------=*%%%%%%%- ---------------------------
|
|
177
166
|
*%%%%%%%%%%%%%%%%%%%%%%%- Start date: 2023-08-24 00:00:00
|
|
178
167
|
.%%%%%%%%%%%%%%%%%%%%%%# End date: 2023-12-02 00:00:00
|
|
179
|
-
#%%%####%%%%%%%%**#%%%+ Number of days: 100
|
|
168
|
+
#%%%####%%%%%%%%**#%%%+ Number of days: 100
|
|
180
169
|
.:-+*%%%%- -+..#%%%+.+- +%%%#*=-: Number of runs: 1201
|
|
181
170
|
.:-=*%%%%. += .%%# -+.-%%%%=-:.. Number of orders: 40
|
|
182
171
|
.:=+#%%%%%*###%%%%#*+#%%%%%%*+-: Initial balance: 400.0
|
|
@@ -189,10 +178,10 @@ you will get the following backtesting report:
|
|
|
189
178
|
.++- -%%%%%%%%%%%+= Percentage negative trades: 70.0%
|
|
190
179
|
.++- .%%%%%%%%%%%%%+= Average trade size: 100.9692 EUR
|
|
191
180
|
.++- *%%%%%%%%%%%%%*+: Average trade duration: 83.6 hours
|
|
192
|
-
.++- %%%%%%%%%%%%%%#+=
|
|
193
|
-
=++........:::%%%%%%%%%%%%%%*+-
|
|
194
|
-
.=++++++++++**#%%%%%%%%%%%%%++.
|
|
195
|
-
|
|
181
|
+
.++- %%%%%%%%%%%%%%#+=
|
|
182
|
+
=++........:::%%%%%%%%%%%%%%*+-
|
|
183
|
+
.=++++++++++**#%%%%%%%%%%%%%++.
|
|
184
|
+
|
|
196
185
|
Price noise
|
|
197
186
|
|
|
198
187
|
Positions overview
|
|
@@ -252,13 +241,15 @@ Trades overview
|
|
|
252
241
|
```
|
|
253
242
|
|
|
254
243
|
### Backtest experiments
|
|
255
|
-
|
|
256
|
-
|
|
244
|
+
|
|
245
|
+
The framework also supports backtest experiments. Backtest experiments allows you to
|
|
246
|
+
compare multiple algorithms and evaluate their performance. Ideally,
|
|
257
247
|
you would do this by parameterizing your strategy and creating a factory function that
|
|
258
248
|
creates the algorithm with the different parameters. You can find an example of this
|
|
259
249
|
in the [backtest experiments example](./examples/backtest_experiment).
|
|
260
250
|
|
|
261
251
|
## Broker/Exchange configuration
|
|
252
|
+
|
|
262
253
|
The framework has by default support for [ccxt](https://github.com/ccxt/ccxt).
|
|
263
254
|
This should allow you to connect to a lot of brokers/exchanges.
|
|
264
255
|
|
|
@@ -268,26 +259,27 @@ from investing_algorithm_framework import PortfolioConfiguration, \
|
|
|
268
259
|
app = create_app()
|
|
269
260
|
app.add_market_credential(
|
|
270
261
|
MarketCredential(
|
|
271
|
-
market="<your market>",
|
|
262
|
+
market="<your market>",
|
|
272
263
|
api_key="<your api key>",
|
|
273
264
|
secret_key="<your secret key>",
|
|
274
265
|
)
|
|
275
266
|
)
|
|
276
267
|
app.add_portfolio_configuration(
|
|
277
268
|
PortfolioConfiguration(
|
|
278
|
-
market="<your market>",
|
|
269
|
+
market="<your market>",
|
|
279
270
|
initial_balance=400,
|
|
280
|
-
track_from="01/01/2022",
|
|
281
271
|
trading_symbol="EUR"
|
|
282
272
|
)
|
|
283
273
|
)
|
|
284
274
|
```
|
|
285
275
|
|
|
286
276
|
## Performance
|
|
277
|
+
|
|
287
278
|
We are continuously working on improving the performance of the framework. If
|
|
288
279
|
you have any suggestions, please let us know.
|
|
289
280
|
|
|
290
281
|
## Download
|
|
282
|
+
|
|
291
283
|
You can download the framework with pypi.
|
|
292
284
|
|
|
293
285
|
```bash
|
|
@@ -295,32 +287,33 @@ pip install investing-algorithm-framework
|
|
|
295
287
|
```
|
|
296
288
|
|
|
297
289
|
## Disclaimer
|
|
298
|
-
|
|
299
|
-
|
|
290
|
+
|
|
291
|
+
If you use this framework for your investments, do not risk money
|
|
292
|
+
which you are afraid to lose, until you have clear understanding how
|
|
300
293
|
the framework works. We can't stress this enough:
|
|
301
294
|
|
|
302
|
-
BEFORE YOU START USING MONEY WITH THE FRAMEWORK, MAKE SURE THAT YOU TESTED
|
|
303
|
-
YOUR COMPONENTS THOROUGHLY. USE THE SOFTWARE AT YOUR OWN RISK.
|
|
295
|
+
BEFORE YOU START USING MONEY WITH THE FRAMEWORK, MAKE SURE THAT YOU TESTED
|
|
296
|
+
YOUR COMPONENTS THOROUGHLY. USE THE SOFTWARE AT YOUR OWN RISK.
|
|
304
297
|
THE AUTHORS AND ALL AFFILIATES ASSUME NO RESPONSIBILITY FOR YOUR INVESTMENT RESULTS.
|
|
305
298
|
|
|
306
|
-
Also, make sure that you read the source code of any plugin you use or
|
|
299
|
+
Also, make sure that you read the source code of any plugin you use or
|
|
307
300
|
implementation of an algorithm made with this framework.
|
|
308
301
|
|
|
309
302
|
## Documentation
|
|
310
303
|
|
|
311
|
-
All the documentation can be found online
|
|
304
|
+
All the documentation can be found online
|
|
312
305
|
at the [documentation webstie](https://investing-algorithm-framework.com)
|
|
313
306
|
|
|
314
|
-
In most cases, you'll probably never have to change code on this repo directly
|
|
315
|
-
if you are building your algorithm/bot. But if you do, check out the
|
|
307
|
+
In most cases, you'll probably never have to change code on this repo directly
|
|
308
|
+
if you are building your algorithm/bot. But if you do, check out the
|
|
316
309
|
contributing page at the website.
|
|
317
310
|
|
|
318
|
-
If you'd like to chat with investing-algorithm-framework users
|
|
311
|
+
If you'd like to chat with investing-algorithm-framework users
|
|
319
312
|
and developers, [join us on Slack](https://inv-algo-framework.slack.com) or [join us on reddit](https://www.reddit.com/r/InvestingBots/)
|
|
320
313
|
|
|
321
314
|
## Acknowledgements
|
|
322
|
-
|
|
323
|
-
the people that contributed to the project can be
|
|
315
|
+
|
|
316
|
+
We want to thank all contributors to this project. A full list of all the people that contributed to the project can be
|
|
324
317
|
found [here](https://github.com/investing-algorithms/investing-algorithm-framework/blob/master/AUTHORS.md)
|
|
325
318
|
|
|
326
319
|
### [Bugs / Issues](https://github.com/investing-algorithms/investing-algorithm-framework/issues?q=is%3Aissue)
|
|
@@ -329,13 +322,13 @@ If you discover a bug in the framework, please [search our issue tracker](https:
|
|
|
329
322
|
first. If it hasn't been reported, please [create a new issue](https://github.com/investing-algorithms/investing-algorithm-framework/issues/new).
|
|
330
323
|
|
|
331
324
|
### Contributing
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
the future trading bots developed in python.
|
|
325
|
+
|
|
326
|
+
The investing algorithm framework is a community driven project.
|
|
327
|
+
We welcome you to participate, contribute and together help build the future trading bots developed in python.
|
|
335
328
|
|
|
336
329
|
Feel like the framework is missing a feature? We welcome your pull requests!
|
|
337
330
|
If you want to contribute to the project roadmap, please take a look at the [project board](https://github.com/coding-kitties/investing-algorithm-framework/projects?query=is%3Aopen).
|
|
338
|
-
You can pick up a task by assigning yourself to it.
|
|
331
|
+
You can pick up a task by assigning yourself to it.
|
|
339
332
|
|
|
340
333
|
**Note** before starting any major new feature work, *please open an issue describing what you are planning to do*.
|
|
341
334
|
This will ensure that interested parties can give valuable feedback on the feature, and let others know that you are working on it.
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
[](https://github.com/SeaQL/sea-orm/stargazers/) If you like what we do, consider starring, sharing and contributing!
|
|
8
8
|
|
|
9
9
|
###### Sponsors
|
|
10
|
+
|
|
10
11
|
<p align="left">
|
|
11
12
|
<a href="https://finterion.com">
|
|
12
13
|
<img alt="Finterion" src="static/sponsors/finterion.png" width="200px" />
|
|
@@ -15,12 +16,11 @@
|
|
|
15
16
|
|
|
16
17
|
# [Investing Algorithm Framework](https://github.com/coding-kitties/investing-algorithm-framework)
|
|
17
18
|
|
|
18
|
-
The Investing Algorithm Framework is a Python
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
portfolio management, and order execution.
|
|
19
|
+
The Investing Algorithm Framework is a Python framework that enables swift and elegant development of trading bots. It comes with all the necessary components for creating trading strategies, including data management, portfolio, order, position and trades management.
|
|
20
|
+
|
|
21
|
+
Features:
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
* Indicators module: A collection of indicators and utility functions that can be used in your trading strategies.
|
|
24
24
|
* Order execution and tracking
|
|
25
25
|
* Broker and exchange connections through [ccxt](https://github.com/ccxt/ccxt)
|
|
26
26
|
* Backtesting and performance analysis reports [example](./examples/backtest_example)
|
|
@@ -32,30 +32,18 @@ Features:
|
|
|
32
32
|
* Stateless running for cloud function deployments
|
|
33
33
|
* Polars dataframes support out of the box for fast data processing [pola.rs](https://pola.rs/)
|
|
34
34
|
|
|
35
|
-
Additional features:
|
|
36
|
-
* Indicators (python >= 3.10 required): Set of indicators that can be used in your trading bot. You can donwload the package with `pip install investing-algorithm-framework[indicators]` or `poetry add investing-algorithm-framework[indicators]]`
|
|
37
|
-
|
|
38
35
|
## Example implementation
|
|
39
|
-
|
|
40
|
-
It also exposes an REST API that allows you to interact with the algorithm.
|
|
36
|
+
|
|
37
|
+
The following algorithm connects to binance and buys BTC every 5 seconds. It also exposes an REST API that allows you to interact with the algorithm.
|
|
38
|
+
|
|
41
39
|
```python
|
|
42
|
-
import
|
|
40
|
+
import logging
|
|
43
41
|
from investing_algorithm_framework import create_app, PortfolioConfiguration, \
|
|
44
|
-
|
|
45
|
-
CCXTTickerMarketDataSource, MarketCredential,
|
|
46
|
-
|
|
47
|
-
# Define the symbols you want to trade for optimization, otherwise the
|
|
48
|
-
# algorithm will check if you have orders and balances on all available
|
|
49
|
-
# symbols on the market
|
|
50
|
-
symbols = ["BTC/EUR"]
|
|
42
|
+
TimeUnit, CCXTOHLCVMarketDataSource, Algorithm, \
|
|
43
|
+
CCXTTickerMarketDataSource, MarketCredential, DEFAULT_LOGGING_CONFIG
|
|
51
44
|
|
|
52
|
-
|
|
53
|
-
config = {
|
|
54
|
-
RESOURCE_DIRECTORY: pathlib.Path(__file__).parent.resolve(),
|
|
55
|
-
SYMBOLS: symbols
|
|
56
|
-
}
|
|
45
|
+
logging.config.dictConfig(DEFAULT_LOGGING_CONFIG)
|
|
57
46
|
|
|
58
|
-
# Define market data sources
|
|
59
47
|
# OHLCV data for candles
|
|
60
48
|
bitvavo_btc_eur_ohlcv_2h = CCXTOHLCVMarketDataSource(
|
|
61
49
|
identifier="BTC-ohlcv",
|
|
@@ -70,13 +58,10 @@ bitvavo_btc_eur_ticker = CCXTTickerMarketDataSource(
|
|
|
70
58
|
market="BITVAVO",
|
|
71
59
|
symbol="BTC/EUR",
|
|
72
60
|
)
|
|
73
|
-
app = create_app(
|
|
61
|
+
app = create_app()
|
|
74
62
|
algorithm = Algorithm()
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
api_key="<your api key>",
|
|
78
|
-
secret_key="<your secret key>",
|
|
79
|
-
))
|
|
63
|
+
# Bitvavo market credentials are read from .env file
|
|
64
|
+
app.add_market_credential(MarketCredential(market="bitvavo"))
|
|
80
65
|
app.add_portfolio_configuration(
|
|
81
66
|
PortfolioConfiguration(
|
|
82
67
|
market="bitvavo",
|
|
@@ -86,42 +71,39 @@ app.add_portfolio_configuration(
|
|
|
86
71
|
)
|
|
87
72
|
app.add_algorithm(algorithm)
|
|
88
73
|
|
|
74
|
+
# Run every two hours and register the data sources
|
|
89
75
|
@algorithm.strategy(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
interval=2,
|
|
93
|
-
# Specify market data sources that need to be passed to the strategy
|
|
76
|
+
time_unit=TimeUnit.HOUR,
|
|
77
|
+
interval=2,
|
|
94
78
|
market_data_sources=[bitvavo_btc_eur_ticker, bitvavo_btc_eur_ohlcv_2h]
|
|
95
79
|
)
|
|
96
80
|
def perform_strategy(algorithm: Algorithm, market_data: dict):
|
|
97
|
-
#
|
|
98
|
-
|
|
99
|
-
# call to_pandas() to convert to pandas
|
|
100
|
-
polars_df = market_data["BTC-ohlcv"]
|
|
101
|
-
print(f"I have access to {len(polars_df)} candles of ohlcv data")
|
|
81
|
+
# Access the data sources with the indentifier
|
|
82
|
+
polars_df = market_data["BTC-ohlcv"]
|
|
102
83
|
|
|
103
|
-
#
|
|
84
|
+
# Convert the polars dataframe to a pandas dataframe
|
|
85
|
+
pandas_df = polars_df.to_pandas()
|
|
104
86
|
ticker_data = market_data["BTC-ticker"]
|
|
105
87
|
unallocated_balance = algorithm.get_unallocated()
|
|
106
88
|
positions = algorithm.get_positions()
|
|
107
89
|
trades = algorithm.get_trades()
|
|
108
90
|
open_trades = algorithm.get_open_trades()
|
|
109
91
|
closed_trades = algorithm.get_closed_trades()
|
|
110
|
-
|
|
111
|
-
# Create a buy oder
|
|
92
|
+
|
|
93
|
+
# Create a buy oder
|
|
112
94
|
algorithm.create_limit_order(
|
|
113
95
|
target_symbol="BTC/EUR",
|
|
114
96
|
order_side="buy",
|
|
115
97
|
amount=0.01,
|
|
116
98
|
price=ticker_data["ask"],
|
|
117
99
|
)
|
|
118
|
-
|
|
100
|
+
|
|
119
101
|
# Close a trade
|
|
120
102
|
algorithm.close_trade(trades[0].id)
|
|
121
|
-
|
|
103
|
+
|
|
122
104
|
# Close a position
|
|
123
105
|
algorithm.close_position(positions[0].get_symbol())
|
|
124
|
-
|
|
106
|
+
|
|
125
107
|
if __name__ == "__main__":
|
|
126
108
|
app.run()
|
|
127
109
|
```
|
|
@@ -129,23 +111,24 @@ if __name__ == "__main__":
|
|
|
129
111
|
> You can find more examples [here](./examples) folder.
|
|
130
112
|
|
|
131
113
|
## Backtesting and experiments
|
|
132
|
-
|
|
133
|
-
a backtest, you can print a report that shows the performance of your trading bot.
|
|
114
|
+
|
|
115
|
+
The framework also supports backtesting and performing backtest experiments. After a backtest, you can print a report that shows the performance of your trading bot.
|
|
134
116
|
|
|
135
117
|
To run a single backtest you can use the example code that can be found [here](./examples/backtest).
|
|
136
118
|
|
|
137
119
|
### Backtesting report
|
|
120
|
+
|
|
138
121
|
You can use the ```pretty_print_backtest``` function to print a backtest report.
|
|
139
122
|
For example if you run the [moving average example trading bot](./examples/crossover_moving_average_trading_bot)
|
|
140
123
|
you will get the following backtesting report:
|
|
141
|
-
|
|
124
|
+
|
|
142
125
|
```bash
|
|
143
126
|
|
|
144
127
|
:%%%#+- .=*#%%% Backtest report
|
|
145
128
|
*%%%%%%%+------=*%%%%%%%- ---------------------------
|
|
146
129
|
*%%%%%%%%%%%%%%%%%%%%%%%- Start date: 2023-08-24 00:00:00
|
|
147
130
|
.%%%%%%%%%%%%%%%%%%%%%%# End date: 2023-12-02 00:00:00
|
|
148
|
-
#%%%####%%%%%%%%**#%%%+ Number of days: 100
|
|
131
|
+
#%%%####%%%%%%%%**#%%%+ Number of days: 100
|
|
149
132
|
.:-+*%%%%- -+..#%%%+.+- +%%%#*=-: Number of runs: 1201
|
|
150
133
|
.:-=*%%%%. += .%%# -+.-%%%%=-:.. Number of orders: 40
|
|
151
134
|
.:=+#%%%%%*###%%%%#*+#%%%%%%*+-: Initial balance: 400.0
|
|
@@ -158,10 +141,10 @@ you will get the following backtesting report:
|
|
|
158
141
|
.++- -%%%%%%%%%%%+= Percentage negative trades: 70.0%
|
|
159
142
|
.++- .%%%%%%%%%%%%%+= Average trade size: 100.9692 EUR
|
|
160
143
|
.++- *%%%%%%%%%%%%%*+: Average trade duration: 83.6 hours
|
|
161
|
-
.++- %%%%%%%%%%%%%%#+=
|
|
162
|
-
=++........:::%%%%%%%%%%%%%%*+-
|
|
163
|
-
.=++++++++++**#%%%%%%%%%%%%%++.
|
|
164
|
-
|
|
144
|
+
.++- %%%%%%%%%%%%%%#+=
|
|
145
|
+
=++........:::%%%%%%%%%%%%%%*+-
|
|
146
|
+
.=++++++++++**#%%%%%%%%%%%%%++.
|
|
147
|
+
|
|
165
148
|
Price noise
|
|
166
149
|
|
|
167
150
|
Positions overview
|
|
@@ -221,13 +204,15 @@ Trades overview
|
|
|
221
204
|
```
|
|
222
205
|
|
|
223
206
|
### Backtest experiments
|
|
224
|
-
|
|
225
|
-
|
|
207
|
+
|
|
208
|
+
The framework also supports backtest experiments. Backtest experiments allows you to
|
|
209
|
+
compare multiple algorithms and evaluate their performance. Ideally,
|
|
226
210
|
you would do this by parameterizing your strategy and creating a factory function that
|
|
227
211
|
creates the algorithm with the different parameters. You can find an example of this
|
|
228
212
|
in the [backtest experiments example](./examples/backtest_experiment).
|
|
229
213
|
|
|
230
214
|
## Broker/Exchange configuration
|
|
215
|
+
|
|
231
216
|
The framework has by default support for [ccxt](https://github.com/ccxt/ccxt).
|
|
232
217
|
This should allow you to connect to a lot of brokers/exchanges.
|
|
233
218
|
|
|
@@ -237,26 +222,27 @@ from investing_algorithm_framework import PortfolioConfiguration, \
|
|
|
237
222
|
app = create_app()
|
|
238
223
|
app.add_market_credential(
|
|
239
224
|
MarketCredential(
|
|
240
|
-
market="<your market>",
|
|
225
|
+
market="<your market>",
|
|
241
226
|
api_key="<your api key>",
|
|
242
227
|
secret_key="<your secret key>",
|
|
243
228
|
)
|
|
244
229
|
)
|
|
245
230
|
app.add_portfolio_configuration(
|
|
246
231
|
PortfolioConfiguration(
|
|
247
|
-
market="<your market>",
|
|
232
|
+
market="<your market>",
|
|
248
233
|
initial_balance=400,
|
|
249
|
-
track_from="01/01/2022",
|
|
250
234
|
trading_symbol="EUR"
|
|
251
235
|
)
|
|
252
236
|
)
|
|
253
237
|
```
|
|
254
238
|
|
|
255
239
|
## Performance
|
|
240
|
+
|
|
256
241
|
We are continuously working on improving the performance of the framework. If
|
|
257
242
|
you have any suggestions, please let us know.
|
|
258
243
|
|
|
259
244
|
## Download
|
|
245
|
+
|
|
260
246
|
You can download the framework with pypi.
|
|
261
247
|
|
|
262
248
|
```bash
|
|
@@ -264,32 +250,33 @@ pip install investing-algorithm-framework
|
|
|
264
250
|
```
|
|
265
251
|
|
|
266
252
|
## Disclaimer
|
|
267
|
-
|
|
268
|
-
|
|
253
|
+
|
|
254
|
+
If you use this framework for your investments, do not risk money
|
|
255
|
+
which you are afraid to lose, until you have clear understanding how
|
|
269
256
|
the framework works. We can't stress this enough:
|
|
270
257
|
|
|
271
|
-
BEFORE YOU START USING MONEY WITH THE FRAMEWORK, MAKE SURE THAT YOU TESTED
|
|
272
|
-
YOUR COMPONENTS THOROUGHLY. USE THE SOFTWARE AT YOUR OWN RISK.
|
|
258
|
+
BEFORE YOU START USING MONEY WITH THE FRAMEWORK, MAKE SURE THAT YOU TESTED
|
|
259
|
+
YOUR COMPONENTS THOROUGHLY. USE THE SOFTWARE AT YOUR OWN RISK.
|
|
273
260
|
THE AUTHORS AND ALL AFFILIATES ASSUME NO RESPONSIBILITY FOR YOUR INVESTMENT RESULTS.
|
|
274
261
|
|
|
275
|
-
Also, make sure that you read the source code of any plugin you use or
|
|
262
|
+
Also, make sure that you read the source code of any plugin you use or
|
|
276
263
|
implementation of an algorithm made with this framework.
|
|
277
264
|
|
|
278
265
|
## Documentation
|
|
279
266
|
|
|
280
|
-
All the documentation can be found online
|
|
267
|
+
All the documentation can be found online
|
|
281
268
|
at the [documentation webstie](https://investing-algorithm-framework.com)
|
|
282
269
|
|
|
283
|
-
In most cases, you'll probably never have to change code on this repo directly
|
|
284
|
-
if you are building your algorithm/bot. But if you do, check out the
|
|
270
|
+
In most cases, you'll probably never have to change code on this repo directly
|
|
271
|
+
if you are building your algorithm/bot. But if you do, check out the
|
|
285
272
|
contributing page at the website.
|
|
286
273
|
|
|
287
|
-
If you'd like to chat with investing-algorithm-framework users
|
|
274
|
+
If you'd like to chat with investing-algorithm-framework users
|
|
288
275
|
and developers, [join us on Slack](https://inv-algo-framework.slack.com) or [join us on reddit](https://www.reddit.com/r/InvestingBots/)
|
|
289
276
|
|
|
290
277
|
## Acknowledgements
|
|
291
|
-
|
|
292
|
-
the people that contributed to the project can be
|
|
278
|
+
|
|
279
|
+
We want to thank all contributors to this project. A full list of all the people that contributed to the project can be
|
|
293
280
|
found [here](https://github.com/investing-algorithms/investing-algorithm-framework/blob/master/AUTHORS.md)
|
|
294
281
|
|
|
295
282
|
### [Bugs / Issues](https://github.com/investing-algorithms/investing-algorithm-framework/issues?q=is%3Aissue)
|
|
@@ -298,13 +285,13 @@ If you discover a bug in the framework, please [search our issue tracker](https:
|
|
|
298
285
|
first. If it hasn't been reported, please [create a new issue](https://github.com/investing-algorithms/investing-algorithm-framework/issues/new).
|
|
299
286
|
|
|
300
287
|
### Contributing
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
the future trading bots developed in python.
|
|
288
|
+
|
|
289
|
+
The investing algorithm framework is a community driven project.
|
|
290
|
+
We welcome you to participate, contribute and together help build the future trading bots developed in python.
|
|
304
291
|
|
|
305
292
|
Feel like the framework is missing a feature? We welcome your pull requests!
|
|
306
293
|
If you want to contribute to the project roadmap, please take a look at the [project board](https://github.com/coding-kitties/investing-algorithm-framework/projects?query=is%3Aopen).
|
|
307
|
-
You can pick up a task by assigning yourself to it.
|
|
294
|
+
You can pick up a task by assigning yourself to it.
|
|
308
295
|
|
|
309
296
|
**Note** before starting any major new feature work, *please open an issue describing what you are planning to do*.
|
|
310
297
|
This will ensure that interested parties can give valuable feedback on the feature, and let others know that you are working on it.
|
|
@@ -3,7 +3,7 @@ from investing_algorithm_framework.app import TradingStrategy, \
|
|
|
3
3
|
StatelessAction, Task
|
|
4
4
|
from investing_algorithm_framework.domain import ApiException, \
|
|
5
5
|
TradingDataType, TradingTimeFrame, OrderType, OperationalException, \
|
|
6
|
-
OrderStatus, OrderSide,
|
|
6
|
+
OrderStatus, OrderSide, TimeUnit, TimeInterval, Order, Portfolio, \
|
|
7
7
|
Position, TimeFrame, BACKTESTING_INDEX_DATETIME, MarketCredential, \
|
|
8
8
|
PortfolioConfiguration, RESOURCE_DIRECTORY, pretty_print_backtest, \
|
|
9
9
|
Trade, OHLCVMarketDataSource, OrderBookMarketDataSource, SYMBOLS, \
|
|
@@ -11,12 +11,16 @@ from investing_algorithm_framework.domain import ApiException, \
|
|
|
11
11
|
pretty_print_backtest_reports_evaluation, load_backtest_reports, \
|
|
12
12
|
RESERVED_BALANCES, APP_MODE, AppMode, DATETIME_FORMAT, \
|
|
13
13
|
load_backtest_report, BacktestDateRange, convert_polars_to_pandas, \
|
|
14
|
-
DateRange
|
|
14
|
+
DateRange, get_backtest_report, DEFAULT_LOGGING_CONFIG
|
|
15
15
|
from investing_algorithm_framework.infrastructure import \
|
|
16
16
|
CCXTOrderBookMarketDataSource, CCXTOHLCVMarketDataSource, \
|
|
17
17
|
CCXTTickerMarketDataSource, CSVOHLCVMarketDataSource, \
|
|
18
|
-
CSVTickerMarketDataSource
|
|
18
|
+
CSVTickerMarketDataSource, AzureBlobStorageStateHandler
|
|
19
19
|
from .create_app import create_app
|
|
20
|
+
from investing_algorithm_framework.indicators import get_rsi, get_peaks, \
|
|
21
|
+
is_uptrend, is_downtrend, is_crossover, is_crossunder, is_above, \
|
|
22
|
+
is_below, has_crossed_upward, get_sma, get_up_and_downtrends, \
|
|
23
|
+
get_ema, get_adx, has_crossed_downward, get_willr, is_divergence
|
|
20
24
|
|
|
21
25
|
__all__ = [
|
|
22
26
|
"Algorithm",
|
|
@@ -30,7 +34,6 @@ __all__ = [
|
|
|
30
34
|
"OrderType",
|
|
31
35
|
"OrderStatus",
|
|
32
36
|
"OrderSide",
|
|
33
|
-
"Config",
|
|
34
37
|
"PortfolioConfiguration",
|
|
35
38
|
"TimeUnit",
|
|
36
39
|
"TimeInterval",
|
|
@@ -66,5 +69,25 @@ __all__ = [
|
|
|
66
69
|
"load_backtest_report",
|
|
67
70
|
"BacktestDateRange",
|
|
68
71
|
"convert_polars_to_pandas",
|
|
69
|
-
"DateRange"
|
|
72
|
+
"DateRange",
|
|
73
|
+
"get_rsi",
|
|
74
|
+
"get_peaks",
|
|
75
|
+
"is_uptrend",
|
|
76
|
+
"is_downtrend",
|
|
77
|
+
"is_crossover",
|
|
78
|
+
"is_crossunder",
|
|
79
|
+
"is_above",
|
|
80
|
+
"is_below",
|
|
81
|
+
"has_crossed_upward",
|
|
82
|
+
"get_sma",
|
|
83
|
+
"get_up_and_downtrends",
|
|
84
|
+
"get_rsi",
|
|
85
|
+
"get_ema",
|
|
86
|
+
"get_adx",
|
|
87
|
+
"has_crossed_downward",
|
|
88
|
+
"get_willr",
|
|
89
|
+
"is_divergence",
|
|
90
|
+
"get_backtest_report",
|
|
91
|
+
"AzureBlobStorageStateHandler",
|
|
92
|
+
"DEFAULT_LOGGING_CONFIG"
|
|
70
93
|
]
|