investing-algorithm-framework 3.8.1__tar.gz → 4.0.1__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.1 → investing_algorithm_framework-4.0.1}/PKG-INFO +71 -60
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/README.md +64 -59
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/__init__.py +11 -7
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/app/algorithm.py +40 -26
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/app/app.py +255 -197
- investing_algorithm_framework-4.0.1/investing_algorithm_framework/app/web/__init__.py +5 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/app/web/create_app.py +4 -2
- investing_algorithm_framework-4.0.1/investing_algorithm_framework/cli/create_azure_function_app_skeleton.py +149 -0
- investing_algorithm_framework-4.0.1/investing_algorithm_framework/cli/deploy_to_azure_function.py +701 -0
- investing_algorithm_framework-4.0.1/investing_algorithm_framework/cli/templates/azure_function_framework_app.py.template +48 -0
- investing_algorithm_framework-4.0.1/investing_algorithm_framework/cli/templates/azure_function_function_app.py.template +32 -0
- investing_algorithm_framework-4.0.1/investing_algorithm_framework/cli/templates/azure_function_host.json.template +15 -0
- investing_algorithm_framework-4.0.1/investing_algorithm_framework/cli/templates/azure_function_local.settings.json.template +8 -0
- investing_algorithm_framework-4.0.1/investing_algorithm_framework/cli/templates/azure_function_requirements.txt.template +2 -0
- investing_algorithm_framework-4.0.1/investing_algorithm_framework/create_app.py +46 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/__init__.py +6 -4
- investing_algorithm_framework-4.0.1/investing_algorithm_framework/domain/config.py +84 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/backtesting/backtest_report.py +23 -1
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/base_model.py +6 -0
- investing_algorithm_framework-4.0.1/investing_algorithm_framework/domain/models/market/market_credential.py +87 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/order/order.py +4 -1
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/portfolio/portfolio.py +37 -3
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/position/position.py +3 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/time_unit.py +3 -1
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/trade/trade.py +23 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/utils/__init__.py +4 -2
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/utils/backtesting.py +170 -21
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/indicators/__init__.py +5 -2
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/indicators/trend.py +12 -1
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/indicators/utils.py +129 -16
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/__init__.py +3 -1
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/database/sql_alchemy.py +5 -12
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/models/market_data_sources/ccxt.py +43 -28
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/models/portfolio/__init__.py +1 -1
- investing_algorithm_framework-3.8.1/investing_algorithm_framework/infrastructure/models/portfolio/portfolio.py → investing_algorithm_framework-4.0.1/investing_algorithm_framework/infrastructure/models/portfolio/sql_portfolio.py +10 -1
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/repositories/order_repository.py +1 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/repositories/repository.py +12 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/services/__init__.py +3 -1
- investing_algorithm_framework-4.0.1/investing_algorithm_framework/infrastructure/services/azure/__init__.py +5 -0
- investing_algorithm_framework-4.0.1/investing_algorithm_framework/infrastructure/services/azure/state_handler.py +148 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/services/market_service/ccxt_market_service.py +5 -1
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/services/backtesting/backtest_service.py +1 -0
- investing_algorithm_framework-4.0.1/investing_algorithm_framework/services/configuration_service.py +80 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/services/market_credential_service.py +8 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/services/market_data_source_service/backtest_market_data_source_service.py +0 -1
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/services/market_data_source_service/market_data_source_service.py +14 -1
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/services/order_service/order_backtest_service.py +5 -5
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/services/order_service/order_service.py +11 -5
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/services/portfolios/backtest_portfolio_service.py +1 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/services/portfolios/portfolio_configuration_service.py +5 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/services/portfolios/portfolio_service.py +52 -1
- investing_algorithm_framework-4.0.1/investing_algorithm_framework/services/portfolios/portfolio_sync_service.py +307 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/services/repository_service.py +3 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/services/strategy_orchestrator_service.py +1 -3
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/pyproject.toml +14 -3
- investing_algorithm_framework-3.8.1/investing_algorithm_framework/app/web/__init__.py +0 -4
- investing_algorithm_framework-3.8.1/investing_algorithm_framework/create_app.py +0 -20
- investing_algorithm_framework-3.8.1/investing_algorithm_framework/deployment/azure/__init__.py +0 -3
- investing_algorithm_framework-3.8.1/investing_algorithm_framework/deployment/azure/azure_functions.py +0 -102
- investing_algorithm_framework-3.8.1/investing_algorithm_framework/domain/config.py +0 -143
- investing_algorithm_framework-3.8.1/investing_algorithm_framework/domain/models/market/market_credential.py +0 -34
- investing_algorithm_framework-3.8.1/investing_algorithm_framework/services/configuration_service.py +0 -29
- investing_algorithm_framework-3.8.1/investing_algorithm_framework/services/portfolios/portfolio_sync_service.py +0 -379
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/LICENSE +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/app/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/app/stateless/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/app/stateless/action_handlers/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/app/stateless/action_handlers/action_handler_strategy.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/app/stateless/action_handlers/check_online_handler.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/app/stateless/action_handlers/run_strategy_handler.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/app/stateless/exception_handler.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/app/strategy.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/app/task.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/app/web/controllers/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/app/web/controllers/orders.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/app/web/controllers/portfolio.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/app/web/controllers/positions.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/app/web/error_handler.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/app/web/responses.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/app/web/run_strategies.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/app/web/schemas/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/app/web/schemas/order.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/app/web/schemas/portfolio.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/app/web/schemas/position.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/app/web/setup_cors.py +0 -0
- {investing_algorithm_framework-3.8.1/investing_algorithm_framework/deployment → investing_algorithm_framework-4.0.1/investing_algorithm_framework/cli}/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/dependency_container.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/constants.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/data_structures.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/decimal_parsing.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/exceptions.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/metrics/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/metrics/price_efficiency.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/app_mode.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/backtesting/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/backtesting/backtest_date_range.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/backtesting/backtest_position.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/backtesting/backtest_reports_evaluation.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/date_range.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/market/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/order/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/order/order_side.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/order/order_status.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/order/order_type.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/portfolio/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/portfolio/portfolio_configuration.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/portfolio/portfolio_snapshot.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/position/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/position/position_snapshot.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/strategy_profile.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/time_frame.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/time_interval.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/tracing/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/tracing/trace.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/trade/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/trade/trade_status.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/trading_data_types.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/models/trading_time_frame.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/services/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/services/market_credential_service.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/services/market_data_sources.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/services/market_service.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/services/portfolios/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/services/portfolios/portfolio_sync_service.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/services/rounding_service.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/singleton.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/stateless_actions.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/strategy.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/utils/csv.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/utils/polars.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/utils/random.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/utils/signatures.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/utils/stoppable_thread.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/domain/utils/synchronized.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/indicators/advanced.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/indicators/momentum.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/database/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/models/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/models/decimal_parser.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/models/market_data_sources/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/models/market_data_sources/csv.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/models/market_data_sources/pandas.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/models/market_data_sources/us_treasury_yield.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/models/model_extension.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/models/order/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/models/order/order.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/models/portfolio/portfolio_snapshot.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/models/position/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/models/position/position.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/models/position/position_snapshot.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/repositories/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/repositories/portfolio_repository.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/repositories/portfolio_snapshot_repository.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/repositories/position_repository.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/repositories/position_snapshot_repository.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/services/market_service/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/services/performance_service/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/services/performance_service/backtest_performance_service.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/infrastructure/services/performance_service/performance_service.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/services/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/services/backtesting/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/services/backtesting/backtest_report_writer_service.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/services/backtesting/graphs.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/services/market_data_source_service/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/services/order_service/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/services/portfolios/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/services/portfolios/portfolio_snapshot_service.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/services/position_service.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/services/position_snapshot_service.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/investing_algorithm_framework/services/trade_service/__init__.py +0 -0
- {investing_algorithm_framework-3.8.1 → investing_algorithm_framework-4.0.1}/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.1
|
|
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" />
|
|
@@ -50,7 +57,7 @@ The Investing Algorithm Framework is a Python framework that enables swift and e
|
|
|
50
57
|
|
|
51
58
|
Features:
|
|
52
59
|
|
|
53
|
-
* Indicators module: A collection of indicators and utility functions that can be used in your trading strategies.
|
|
60
|
+
* Indicators module: A collection of indicators and utility functions that can be used in your trading strategies.
|
|
54
61
|
* Order execution and tracking
|
|
55
62
|
* Broker and exchange connections through [ccxt](https://github.com/ccxt/ccxt)
|
|
56
63
|
* Backtesting and performance analysis reports [example](./examples/backtest_example)
|
|
@@ -67,23 +74,13 @@ Features:
|
|
|
67
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.
|
|
68
75
|
|
|
69
76
|
```python
|
|
70
|
-
import
|
|
77
|
+
import logging
|
|
71
78
|
from investing_algorithm_framework import create_app, PortfolioConfiguration, \
|
|
72
|
-
|
|
73
|
-
CCXTTickerMarketDataSource, MarketCredential,
|
|
74
|
-
|
|
75
|
-
# Define the symbols you want to trade for optimization, otherwise the
|
|
76
|
-
# algorithm will check if you have orders and balances on all available
|
|
77
|
-
# symbols on the market
|
|
78
|
-
symbols = ["BTC/EUR"]
|
|
79
|
+
TimeUnit, CCXTOHLCVMarketDataSource, Algorithm, \
|
|
80
|
+
CCXTTickerMarketDataSource, MarketCredential, DEFAULT_LOGGING_CONFIG
|
|
79
81
|
|
|
80
|
-
|
|
81
|
-
config = {
|
|
82
|
-
RESOURCE_DIRECTORY: pathlib.Path(__file__).parent.resolve(),
|
|
83
|
-
SYMBOLS: symbols
|
|
84
|
-
}
|
|
82
|
+
logging.config.dictConfig(DEFAULT_LOGGING_CONFIG)
|
|
85
83
|
|
|
86
|
-
# Define market data sources
|
|
87
84
|
# OHLCV data for candles
|
|
88
85
|
bitvavo_btc_eur_ohlcv_2h = CCXTOHLCVMarketDataSource(
|
|
89
86
|
identifier="BTC-ohlcv",
|
|
@@ -98,13 +95,10 @@ bitvavo_btc_eur_ticker = CCXTTickerMarketDataSource(
|
|
|
98
95
|
market="BITVAVO",
|
|
99
96
|
symbol="BTC/EUR",
|
|
100
97
|
)
|
|
101
|
-
app = create_app(
|
|
98
|
+
app = create_app()
|
|
102
99
|
algorithm = Algorithm()
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
api_key="<your api key>",
|
|
106
|
-
secret_key="<your secret key>",
|
|
107
|
-
))
|
|
100
|
+
# Bitvavo market credentials are read from .env file
|
|
101
|
+
app.add_market_credential(MarketCredential(market="bitvavo"))
|
|
108
102
|
app.add_portfolio_configuration(
|
|
109
103
|
PortfolioConfiguration(
|
|
110
104
|
market="bitvavo",
|
|
@@ -114,42 +108,39 @@ app.add_portfolio_configuration(
|
|
|
114
108
|
)
|
|
115
109
|
app.add_algorithm(algorithm)
|
|
116
110
|
|
|
111
|
+
# Run every two hours and register the data sources
|
|
117
112
|
@algorithm.strategy(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
interval=2,
|
|
121
|
-
# Specify market data sources that need to be passed to the strategy
|
|
113
|
+
time_unit=TimeUnit.HOUR,
|
|
114
|
+
interval=2,
|
|
122
115
|
market_data_sources=[bitvavo_btc_eur_ticker, bitvavo_btc_eur_ohlcv_2h]
|
|
123
116
|
)
|
|
124
117
|
def perform_strategy(algorithm: Algorithm, market_data: dict):
|
|
125
|
-
#
|
|
126
|
-
|
|
127
|
-
# call to_pandas() to convert to pandas
|
|
128
|
-
polars_df = market_data["BTC-ohlcv"]
|
|
129
|
-
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"]
|
|
130
120
|
|
|
131
|
-
#
|
|
121
|
+
# Convert the polars dataframe to a pandas dataframe
|
|
122
|
+
pandas_df = polars_df.to_pandas()
|
|
132
123
|
ticker_data = market_data["BTC-ticker"]
|
|
133
124
|
unallocated_balance = algorithm.get_unallocated()
|
|
134
125
|
positions = algorithm.get_positions()
|
|
135
126
|
trades = algorithm.get_trades()
|
|
136
127
|
open_trades = algorithm.get_open_trades()
|
|
137
128
|
closed_trades = algorithm.get_closed_trades()
|
|
138
|
-
|
|
139
|
-
# Create a buy oder
|
|
129
|
+
|
|
130
|
+
# Create a buy oder
|
|
140
131
|
algorithm.create_limit_order(
|
|
141
132
|
target_symbol="BTC/EUR",
|
|
142
133
|
order_side="buy",
|
|
143
134
|
amount=0.01,
|
|
144
135
|
price=ticker_data["ask"],
|
|
145
136
|
)
|
|
146
|
-
|
|
137
|
+
|
|
147
138
|
# Close a trade
|
|
148
139
|
algorithm.close_trade(trades[0].id)
|
|
149
|
-
|
|
140
|
+
|
|
150
141
|
# Close a position
|
|
151
142
|
algorithm.close_position(positions[0].get_symbol())
|
|
152
|
-
|
|
143
|
+
|
|
153
144
|
if __name__ == "__main__":
|
|
154
145
|
app.run()
|
|
155
146
|
```
|
|
@@ -167,14 +158,14 @@ To run a single backtest you can use the example code that can be found [here](.
|
|
|
167
158
|
You can use the ```pretty_print_backtest``` function to print a backtest report.
|
|
168
159
|
For example if you run the [moving average example trading bot](./examples/crossover_moving_average_trading_bot)
|
|
169
160
|
you will get the following backtesting report:
|
|
170
|
-
|
|
161
|
+
|
|
171
162
|
```bash
|
|
172
163
|
|
|
173
164
|
:%%%#+- .=*#%%% Backtest report
|
|
174
165
|
*%%%%%%%+------=*%%%%%%%- ---------------------------
|
|
175
166
|
*%%%%%%%%%%%%%%%%%%%%%%%- Start date: 2023-08-24 00:00:00
|
|
176
167
|
.%%%%%%%%%%%%%%%%%%%%%%# End date: 2023-12-02 00:00:00
|
|
177
|
-
#%%%####%%%%%%%%**#%%%+ Number of days: 100
|
|
168
|
+
#%%%####%%%%%%%%**#%%%+ Number of days: 100
|
|
178
169
|
.:-+*%%%%- -+..#%%%+.+- +%%%#*=-: Number of runs: 1201
|
|
179
170
|
.:-=*%%%%. += .%%# -+.-%%%%=-:.. Number of orders: 40
|
|
180
171
|
.:=+#%%%%%*###%%%%#*+#%%%%%%*+-: Initial balance: 400.0
|
|
@@ -187,10 +178,10 @@ you will get the following backtesting report:
|
|
|
187
178
|
.++- -%%%%%%%%%%%+= Percentage negative trades: 70.0%
|
|
188
179
|
.++- .%%%%%%%%%%%%%+= Average trade size: 100.9692 EUR
|
|
189
180
|
.++- *%%%%%%%%%%%%%*+: Average trade duration: 83.6 hours
|
|
190
|
-
.++- %%%%%%%%%%%%%%#+=
|
|
191
|
-
=++........:::%%%%%%%%%%%%%%*+-
|
|
192
|
-
.=++++++++++**#%%%%%%%%%%%%%++.
|
|
193
|
-
|
|
181
|
+
.++- %%%%%%%%%%%%%%#+=
|
|
182
|
+
=++........:::%%%%%%%%%%%%%%*+-
|
|
183
|
+
.=++++++++++**#%%%%%%%%%%%%%++.
|
|
184
|
+
|
|
194
185
|
Price noise
|
|
195
186
|
|
|
196
187
|
Positions overview
|
|
@@ -251,8 +242,8 @@ Trades overview
|
|
|
251
242
|
|
|
252
243
|
### Backtest experiments
|
|
253
244
|
|
|
254
|
-
The framework also supports backtest experiments. Backtest experiments allows you to
|
|
255
|
-
compare multiple algorithms and evaluate their performance. Ideally,
|
|
245
|
+
The framework also supports backtest experiments. Backtest experiments allows you to
|
|
246
|
+
compare multiple algorithms and evaluate their performance. Ideally,
|
|
256
247
|
you would do this by parameterizing your strategy and creating a factory function that
|
|
257
248
|
creates the algorithm with the different parameters. You can find an example of this
|
|
258
249
|
in the [backtest experiments example](./examples/backtest_experiment).
|
|
@@ -268,16 +259,15 @@ 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
|
)
|
|
@@ -288,7 +278,7 @@ app.add_portfolio_configuration(
|
|
|
288
278
|
We are continuously working on improving the performance of the framework. If
|
|
289
279
|
you have any suggestions, please let us know.
|
|
290
280
|
|
|
291
|
-
##
|
|
281
|
+
## How to install
|
|
292
282
|
|
|
293
283
|
You can download the framework with pypi.
|
|
294
284
|
|
|
@@ -296,29 +286,50 @@ You can download the framework with pypi.
|
|
|
296
286
|
pip install investing-algorithm-framework
|
|
297
287
|
```
|
|
298
288
|
|
|
289
|
+
## Installation for local development
|
|
290
|
+
|
|
291
|
+
The framework is built with poetry. To install the framework for local development, you can run the following commands:
|
|
292
|
+
|
|
293
|
+
> Make sure you have poetry installed. If you don't have poetry installed, you can find installation instructions [here](https://python-poetry.org/docs/#installation)
|
|
294
|
+
|
|
295
|
+
```bash
|
|
296
|
+
git clone http
|
|
297
|
+
cd investing-algorithm-framework
|
|
298
|
+
poetry install
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Running tests
|
|
302
|
+
|
|
303
|
+
To run the tests, you can run the following command:
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
# In the root of the project
|
|
307
|
+
python -m unittest discover -s tests
|
|
308
|
+
```
|
|
309
|
+
|
|
299
310
|
## Disclaimer
|
|
300
311
|
|
|
301
|
-
If you use this framework for your investments, do not risk money
|
|
302
|
-
which you are afraid to lose, until you have clear understanding how
|
|
312
|
+
If you use this framework for your investments, do not risk money
|
|
313
|
+
which you are afraid to lose, until you have clear understanding how
|
|
303
314
|
the framework works. We can't stress this enough:
|
|
304
315
|
|
|
305
|
-
BEFORE YOU START USING MONEY WITH THE FRAMEWORK, MAKE SURE THAT YOU TESTED
|
|
306
|
-
YOUR COMPONENTS THOROUGHLY. USE THE SOFTWARE AT YOUR OWN RISK.
|
|
316
|
+
BEFORE YOU START USING MONEY WITH THE FRAMEWORK, MAKE SURE THAT YOU TESTED
|
|
317
|
+
YOUR COMPONENTS THOROUGHLY. USE THE SOFTWARE AT YOUR OWN RISK.
|
|
307
318
|
THE AUTHORS AND ALL AFFILIATES ASSUME NO RESPONSIBILITY FOR YOUR INVESTMENT RESULTS.
|
|
308
319
|
|
|
309
|
-
Also, make sure that you read the source code of any plugin you use or
|
|
320
|
+
Also, make sure that you read the source code of any plugin you use or
|
|
310
321
|
implementation of an algorithm made with this framework.
|
|
311
322
|
|
|
312
323
|
## Documentation
|
|
313
324
|
|
|
314
|
-
All the documentation can be found online
|
|
325
|
+
All the documentation can be found online
|
|
315
326
|
at the [documentation webstie](https://investing-algorithm-framework.com)
|
|
316
327
|
|
|
317
|
-
In most cases, you'll probably never have to change code on this repo directly
|
|
318
|
-
if you are building your algorithm/bot. But if you do, check out the
|
|
328
|
+
In most cases, you'll probably never have to change code on this repo directly
|
|
329
|
+
if you are building your algorithm/bot. But if you do, check out the
|
|
319
330
|
contributing page at the website.
|
|
320
331
|
|
|
321
|
-
If you'd like to chat with investing-algorithm-framework users
|
|
332
|
+
If you'd like to chat with investing-algorithm-framework users
|
|
322
333
|
and developers, [join us on Slack](https://inv-algo-framework.slack.com) or [join us on reddit](https://www.reddit.com/r/InvestingBots/)
|
|
323
334
|
|
|
324
335
|
## Acknowledgements
|
|
@@ -333,12 +344,12 @@ first. If it hasn't been reported, please [create a new issue](https://github.co
|
|
|
333
344
|
|
|
334
345
|
### Contributing
|
|
335
346
|
|
|
336
|
-
The investing algorithm framework is a community driven project.
|
|
347
|
+
The investing algorithm framework is a community driven project.
|
|
337
348
|
We welcome you to participate, contribute and together help build the future trading bots developed in python.
|
|
338
349
|
|
|
339
350
|
Feel like the framework is missing a feature? We welcome your pull requests!
|
|
340
351
|
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).
|
|
341
|
-
You can pick up a task by assigning yourself to it.
|
|
352
|
+
You can pick up a task by assigning yourself to it.
|
|
342
353
|
|
|
343
354
|
**Note** before starting any major new feature work, *please open an issue describing what you are planning to do*.
|
|
344
355
|
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" />
|
|
@@ -19,7 +20,7 @@ The Investing Algorithm Framework is a Python framework that enables swift and e
|
|
|
19
20
|
|
|
20
21
|
Features:
|
|
21
22
|
|
|
22
|
-
* Indicators module: A collection of indicators and utility functions that can be used in your trading strategies.
|
|
23
|
+
* Indicators module: A collection of indicators and utility functions that can be used in your trading strategies.
|
|
23
24
|
* Order execution and tracking
|
|
24
25
|
* Broker and exchange connections through [ccxt](https://github.com/ccxt/ccxt)
|
|
25
26
|
* Backtesting and performance analysis reports [example](./examples/backtest_example)
|
|
@@ -36,23 +37,13 @@ Features:
|
|
|
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.
|
|
37
38
|
|
|
38
39
|
```python
|
|
39
|
-
import
|
|
40
|
+
import logging
|
|
40
41
|
from investing_algorithm_framework import create_app, PortfolioConfiguration, \
|
|
41
|
-
|
|
42
|
-
CCXTTickerMarketDataSource, MarketCredential,
|
|
43
|
-
|
|
44
|
-
# Define the symbols you want to trade for optimization, otherwise the
|
|
45
|
-
# algorithm will check if you have orders and balances on all available
|
|
46
|
-
# symbols on the market
|
|
47
|
-
symbols = ["BTC/EUR"]
|
|
42
|
+
TimeUnit, CCXTOHLCVMarketDataSource, Algorithm, \
|
|
43
|
+
CCXTTickerMarketDataSource, MarketCredential, DEFAULT_LOGGING_CONFIG
|
|
48
44
|
|
|
49
|
-
|
|
50
|
-
config = {
|
|
51
|
-
RESOURCE_DIRECTORY: pathlib.Path(__file__).parent.resolve(),
|
|
52
|
-
SYMBOLS: symbols
|
|
53
|
-
}
|
|
45
|
+
logging.config.dictConfig(DEFAULT_LOGGING_CONFIG)
|
|
54
46
|
|
|
55
|
-
# Define market data sources
|
|
56
47
|
# OHLCV data for candles
|
|
57
48
|
bitvavo_btc_eur_ohlcv_2h = CCXTOHLCVMarketDataSource(
|
|
58
49
|
identifier="BTC-ohlcv",
|
|
@@ -67,13 +58,10 @@ bitvavo_btc_eur_ticker = CCXTTickerMarketDataSource(
|
|
|
67
58
|
market="BITVAVO",
|
|
68
59
|
symbol="BTC/EUR",
|
|
69
60
|
)
|
|
70
|
-
app = create_app(
|
|
61
|
+
app = create_app()
|
|
71
62
|
algorithm = Algorithm()
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
api_key="<your api key>",
|
|
75
|
-
secret_key="<your secret key>",
|
|
76
|
-
))
|
|
63
|
+
# Bitvavo market credentials are read from .env file
|
|
64
|
+
app.add_market_credential(MarketCredential(market="bitvavo"))
|
|
77
65
|
app.add_portfolio_configuration(
|
|
78
66
|
PortfolioConfiguration(
|
|
79
67
|
market="bitvavo",
|
|
@@ -83,42 +71,39 @@ app.add_portfolio_configuration(
|
|
|
83
71
|
)
|
|
84
72
|
app.add_algorithm(algorithm)
|
|
85
73
|
|
|
74
|
+
# Run every two hours and register the data sources
|
|
86
75
|
@algorithm.strategy(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
interval=2,
|
|
90
|
-
# Specify market data sources that need to be passed to the strategy
|
|
76
|
+
time_unit=TimeUnit.HOUR,
|
|
77
|
+
interval=2,
|
|
91
78
|
market_data_sources=[bitvavo_btc_eur_ticker, bitvavo_btc_eur_ohlcv_2h]
|
|
92
79
|
)
|
|
93
80
|
def perform_strategy(algorithm: Algorithm, market_data: dict):
|
|
94
|
-
#
|
|
95
|
-
|
|
96
|
-
# call to_pandas() to convert to pandas
|
|
97
|
-
polars_df = market_data["BTC-ohlcv"]
|
|
98
|
-
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"]
|
|
99
83
|
|
|
100
|
-
#
|
|
84
|
+
# Convert the polars dataframe to a pandas dataframe
|
|
85
|
+
pandas_df = polars_df.to_pandas()
|
|
101
86
|
ticker_data = market_data["BTC-ticker"]
|
|
102
87
|
unallocated_balance = algorithm.get_unallocated()
|
|
103
88
|
positions = algorithm.get_positions()
|
|
104
89
|
trades = algorithm.get_trades()
|
|
105
90
|
open_trades = algorithm.get_open_trades()
|
|
106
91
|
closed_trades = algorithm.get_closed_trades()
|
|
107
|
-
|
|
108
|
-
# Create a buy oder
|
|
92
|
+
|
|
93
|
+
# Create a buy oder
|
|
109
94
|
algorithm.create_limit_order(
|
|
110
95
|
target_symbol="BTC/EUR",
|
|
111
96
|
order_side="buy",
|
|
112
97
|
amount=0.01,
|
|
113
98
|
price=ticker_data["ask"],
|
|
114
99
|
)
|
|
115
|
-
|
|
100
|
+
|
|
116
101
|
# Close a trade
|
|
117
102
|
algorithm.close_trade(trades[0].id)
|
|
118
|
-
|
|
103
|
+
|
|
119
104
|
# Close a position
|
|
120
105
|
algorithm.close_position(positions[0].get_symbol())
|
|
121
|
-
|
|
106
|
+
|
|
122
107
|
if __name__ == "__main__":
|
|
123
108
|
app.run()
|
|
124
109
|
```
|
|
@@ -136,14 +121,14 @@ To run a single backtest you can use the example code that can be found [here](.
|
|
|
136
121
|
You can use the ```pretty_print_backtest``` function to print a backtest report.
|
|
137
122
|
For example if you run the [moving average example trading bot](./examples/crossover_moving_average_trading_bot)
|
|
138
123
|
you will get the following backtesting report:
|
|
139
|
-
|
|
124
|
+
|
|
140
125
|
```bash
|
|
141
126
|
|
|
142
127
|
:%%%#+- .=*#%%% Backtest report
|
|
143
128
|
*%%%%%%%+------=*%%%%%%%- ---------------------------
|
|
144
129
|
*%%%%%%%%%%%%%%%%%%%%%%%- Start date: 2023-08-24 00:00:00
|
|
145
130
|
.%%%%%%%%%%%%%%%%%%%%%%# End date: 2023-12-02 00:00:00
|
|
146
|
-
#%%%####%%%%%%%%**#%%%+ Number of days: 100
|
|
131
|
+
#%%%####%%%%%%%%**#%%%+ Number of days: 100
|
|
147
132
|
.:-+*%%%%- -+..#%%%+.+- +%%%#*=-: Number of runs: 1201
|
|
148
133
|
.:-=*%%%%. += .%%# -+.-%%%%=-:.. Number of orders: 40
|
|
149
134
|
.:=+#%%%%%*###%%%%#*+#%%%%%%*+-: Initial balance: 400.0
|
|
@@ -156,10 +141,10 @@ you will get the following backtesting report:
|
|
|
156
141
|
.++- -%%%%%%%%%%%+= Percentage negative trades: 70.0%
|
|
157
142
|
.++- .%%%%%%%%%%%%%+= Average trade size: 100.9692 EUR
|
|
158
143
|
.++- *%%%%%%%%%%%%%*+: Average trade duration: 83.6 hours
|
|
159
|
-
.++- %%%%%%%%%%%%%%#+=
|
|
160
|
-
=++........:::%%%%%%%%%%%%%%*+-
|
|
161
|
-
.=++++++++++**#%%%%%%%%%%%%%++.
|
|
162
|
-
|
|
144
|
+
.++- %%%%%%%%%%%%%%#+=
|
|
145
|
+
=++........:::%%%%%%%%%%%%%%*+-
|
|
146
|
+
.=++++++++++**#%%%%%%%%%%%%%++.
|
|
147
|
+
|
|
163
148
|
Price noise
|
|
164
149
|
|
|
165
150
|
Positions overview
|
|
@@ -220,8 +205,8 @@ Trades overview
|
|
|
220
205
|
|
|
221
206
|
### Backtest experiments
|
|
222
207
|
|
|
223
|
-
The framework also supports backtest experiments. Backtest experiments allows you to
|
|
224
|
-
compare multiple algorithms and evaluate their performance. Ideally,
|
|
208
|
+
The framework also supports backtest experiments. Backtest experiments allows you to
|
|
209
|
+
compare multiple algorithms and evaluate their performance. Ideally,
|
|
225
210
|
you would do this by parameterizing your strategy and creating a factory function that
|
|
226
211
|
creates the algorithm with the different parameters. You can find an example of this
|
|
227
212
|
in the [backtest experiments example](./examples/backtest_experiment).
|
|
@@ -237,16 +222,15 @@ 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
|
)
|
|
@@ -257,7 +241,7 @@ app.add_portfolio_configuration(
|
|
|
257
241
|
We are continuously working on improving the performance of the framework. If
|
|
258
242
|
you have any suggestions, please let us know.
|
|
259
243
|
|
|
260
|
-
##
|
|
244
|
+
## How to install
|
|
261
245
|
|
|
262
246
|
You can download the framework with pypi.
|
|
263
247
|
|
|
@@ -265,29 +249,50 @@ You can download the framework with pypi.
|
|
|
265
249
|
pip install investing-algorithm-framework
|
|
266
250
|
```
|
|
267
251
|
|
|
252
|
+
## Installation for local development
|
|
253
|
+
|
|
254
|
+
The framework is built with poetry. To install the framework for local development, you can run the following commands:
|
|
255
|
+
|
|
256
|
+
> Make sure you have poetry installed. If you don't have poetry installed, you can find installation instructions [here](https://python-poetry.org/docs/#installation)
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
git clone http
|
|
260
|
+
cd investing-algorithm-framework
|
|
261
|
+
poetry install
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### Running tests
|
|
265
|
+
|
|
266
|
+
To run the tests, you can run the following command:
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
# In the root of the project
|
|
270
|
+
python -m unittest discover -s tests
|
|
271
|
+
```
|
|
272
|
+
|
|
268
273
|
## Disclaimer
|
|
269
274
|
|
|
270
|
-
If you use this framework for your investments, do not risk money
|
|
271
|
-
which you are afraid to lose, until you have clear understanding how
|
|
275
|
+
If you use this framework for your investments, do not risk money
|
|
276
|
+
which you are afraid to lose, until you have clear understanding how
|
|
272
277
|
the framework works. We can't stress this enough:
|
|
273
278
|
|
|
274
|
-
BEFORE YOU START USING MONEY WITH THE FRAMEWORK, MAKE SURE THAT YOU TESTED
|
|
275
|
-
YOUR COMPONENTS THOROUGHLY. USE THE SOFTWARE AT YOUR OWN RISK.
|
|
279
|
+
BEFORE YOU START USING MONEY WITH THE FRAMEWORK, MAKE SURE THAT YOU TESTED
|
|
280
|
+
YOUR COMPONENTS THOROUGHLY. USE THE SOFTWARE AT YOUR OWN RISK.
|
|
276
281
|
THE AUTHORS AND ALL AFFILIATES ASSUME NO RESPONSIBILITY FOR YOUR INVESTMENT RESULTS.
|
|
277
282
|
|
|
278
|
-
Also, make sure that you read the source code of any plugin you use or
|
|
283
|
+
Also, make sure that you read the source code of any plugin you use or
|
|
279
284
|
implementation of an algorithm made with this framework.
|
|
280
285
|
|
|
281
286
|
## Documentation
|
|
282
287
|
|
|
283
|
-
All the documentation can be found online
|
|
288
|
+
All the documentation can be found online
|
|
284
289
|
at the [documentation webstie](https://investing-algorithm-framework.com)
|
|
285
290
|
|
|
286
|
-
In most cases, you'll probably never have to change code on this repo directly
|
|
287
|
-
if you are building your algorithm/bot. But if you do, check out the
|
|
291
|
+
In most cases, you'll probably never have to change code on this repo directly
|
|
292
|
+
if you are building your algorithm/bot. But if you do, check out the
|
|
288
293
|
contributing page at the website.
|
|
289
294
|
|
|
290
|
-
If you'd like to chat with investing-algorithm-framework users
|
|
295
|
+
If you'd like to chat with investing-algorithm-framework users
|
|
291
296
|
and developers, [join us on Slack](https://inv-algo-framework.slack.com) or [join us on reddit](https://www.reddit.com/r/InvestingBots/)
|
|
292
297
|
|
|
293
298
|
## Acknowledgements
|
|
@@ -302,12 +307,12 @@ first. If it hasn't been reported, please [create a new issue](https://github.co
|
|
|
302
307
|
|
|
303
308
|
### Contributing
|
|
304
309
|
|
|
305
|
-
The investing algorithm framework is a community driven project.
|
|
310
|
+
The investing algorithm framework is a community driven project.
|
|
306
311
|
We welcome you to participate, contribute and together help build the future trading bots developed in python.
|
|
307
312
|
|
|
308
313
|
Feel like the framework is missing a feature? We welcome your pull requests!
|
|
309
314
|
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).
|
|
310
|
-
You can pick up a task by assigning yourself to it.
|
|
315
|
+
You can pick up a task by assigning yourself to it.
|
|
311
316
|
|
|
312
317
|
**Note** before starting any major new feature work, *please open an issue describing what you are planning to do*.
|
|
313
318
|
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",
|
|
@@ -67,7 +70,6 @@ __all__ = [
|
|
|
67
70
|
"BacktestDateRange",
|
|
68
71
|
"convert_polars_to_pandas",
|
|
69
72
|
"DateRange",
|
|
70
|
-
"get_rsi",
|
|
71
73
|
"get_peaks",
|
|
72
74
|
"is_uptrend",
|
|
73
75
|
"is_downtrend",
|
|
@@ -83,6 +85,8 @@ __all__ = [
|
|
|
83
85
|
"get_adx",
|
|
84
86
|
"has_crossed_downward",
|
|
85
87
|
"get_willr",
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
+
"is_divergence",
|
|
89
|
+
"get_backtest_report",
|
|
90
|
+
"AzureBlobStorageStateHandler",
|
|
91
|
+
"DEFAULT_LOGGING_CONFIG"
|
|
88
92
|
]
|