investing-algorithm-framework 4.1.0__tar.gz → 4.1.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-4.1.0 → investing_algorithm_framework-4.1.1}/PKG-INFO +1 -1
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/algorithm.py +14 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/app.py +4 -9
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/dependency_container.py +1 -5
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/services/market_data_sources.py +15 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/services/market_service.py +1 -1
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/market_data_sources/ccxt.py +14 -6
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/__init__.py +1 -5
- investing_algorithm_framework-4.1.1/investing_algorithm_framework/services/backtesting/__init__.py +5 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/backtesting/backtest_service.py +110 -6
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/pyproject.toml +1 -1
- investing_algorithm_framework-4.1.0/investing_algorithm_framework/services/backtesting/__init__.py +0 -12
- investing_algorithm_framework-4.1.0/investing_algorithm_framework/services/backtesting/backtest_report_writer_service.py +0 -91
- investing_algorithm_framework-4.1.0/investing_algorithm_framework/services/backtesting/graphs.py +0 -61
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/LICENSE +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/README.md +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/stateless/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/stateless/action_handlers/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/stateless/action_handlers/action_handler_strategy.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/stateless/action_handlers/check_online_handler.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/stateless/action_handlers/run_strategy_handler.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/stateless/exception_handler.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/strategy.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/task.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/controllers/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/controllers/orders.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/controllers/portfolio.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/controllers/positions.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/create_app.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/error_handler.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/responses.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/run_strategies.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/schemas/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/schemas/order.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/schemas/portfolio.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/schemas/position.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/setup_cors.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/cli/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/cli/create_azure_function_app_skeleton.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/cli/deploy_to_azure_function.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/cli/templates/azure_function_framework_app.py.template +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/cli/templates/azure_function_function_app.py.template +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/cli/templates/azure_function_host.json.template +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/cli/templates/azure_function_local.settings.json.template +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/cli/templates/azure_function_requirements.txt.template +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/create_app.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/config.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/constants.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/data_structures.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/decimal_parsing.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/exceptions.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/metrics/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/metrics/price_efficiency.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/app_mode.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/backtesting/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/backtesting/backtest_date_range.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/backtesting/backtest_position.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/backtesting/backtest_report.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/backtesting/backtest_reports_evaluation.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/base_model.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/date_range.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/market/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/market/market_credential.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/order/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/order/order.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/order/order_side.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/order/order_status.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/order/order_type.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/portfolio/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/portfolio/portfolio.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/portfolio/portfolio_configuration.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/portfolio/portfolio_snapshot.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/position/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/position/position.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/position/position_snapshot.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/strategy_profile.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/time_frame.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/time_interval.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/time_unit.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/tracing/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/tracing/trace.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/trade/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/trade/trade.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/trade/trade_status.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/trading_data_types.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/trading_time_frame.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/services/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/services/market_credential_service.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/services/portfolios/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/services/portfolios/portfolio_sync_service.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/services/rounding_service.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/singleton.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/stateless_actions.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/strategy.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/utils/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/utils/backtesting.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/utils/csv.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/utils/polars.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/utils/random.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/utils/signatures.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/utils/stoppable_thread.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/utils/synchronized.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/indicators/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/indicators/advanced.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/indicators/momentum.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/indicators/trend.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/indicators/utils.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/database/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/database/sql_alchemy.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/decimal_parser.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/market_data_sources/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/market_data_sources/csv.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/market_data_sources/pandas.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/market_data_sources/us_treasury_yield.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/model_extension.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/order/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/order/order.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/portfolio/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/portfolio/portfolio_snapshot.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/portfolio/sql_portfolio.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/position/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/position/position.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/position/position_snapshot.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/repositories/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/repositories/order_repository.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/repositories/portfolio_repository.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/repositories/portfolio_snapshot_repository.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/repositories/position_repository.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/repositories/position_snapshot_repository.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/repositories/repository.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/services/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/services/azure/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/services/azure/state_handler.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/services/market_service/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/services/market_service/ccxt_market_service.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/services/performance_service/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/services/performance_service/backtest_performance_service.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/services/performance_service/performance_service.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/configuration_service.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/market_credential_service.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/market_data_source_service/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/market_data_source_service/backtest_market_data_source_service.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/market_data_source_service/market_data_source_service.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/order_service/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/order_service/order_backtest_service.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/order_service/order_service.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/portfolios/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/portfolios/backtest_portfolio_service.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/portfolios/portfolio_configuration_service.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/portfolios/portfolio_service.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/portfolios/portfolio_snapshot_service.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/portfolios/portfolio_sync_service.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/position_service.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/position_snapshot_service.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/repository_service.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/strategy_orchestrator_service.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/trade_service/__init__.py +0 -0
- {investing_algorithm_framework-4.1.0 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/trade_service/trade_service.py +0 -0
|
@@ -94,12 +94,21 @@ class Algorithm:
|
|
|
94
94
|
)
|
|
95
95
|
|
|
96
96
|
pattern = re.compile(r"^[a-zA-Z0-9]*$")
|
|
97
|
+
|
|
97
98
|
if not pattern.match(name):
|
|
98
99
|
raise OperationalException(
|
|
99
100
|
"The name of the algorithm can only contain" +
|
|
100
101
|
" letters and numbers"
|
|
101
102
|
)
|
|
102
103
|
|
|
104
|
+
illegal_chars = r"[\/:*?\"<>|]"
|
|
105
|
+
|
|
106
|
+
if re.search(illegal_chars, name):
|
|
107
|
+
raise OperationalException(
|
|
108
|
+
f"Illegal characters detected in algorithm: {name}. "
|
|
109
|
+
f"Illegal characters: / \\ : * ? \" < > |"
|
|
110
|
+
)
|
|
111
|
+
|
|
103
112
|
def initialize_services(
|
|
104
113
|
self,
|
|
105
114
|
configuration_service,
|
|
@@ -159,6 +168,11 @@ class Algorithm:
|
|
|
159
168
|
def name(self):
|
|
160
169
|
return self._name
|
|
161
170
|
|
|
171
|
+
@name.setter
|
|
172
|
+
def name(self, name):
|
|
173
|
+
self._validate_name(name)
|
|
174
|
+
self._name = name
|
|
175
|
+
|
|
162
176
|
@property
|
|
163
177
|
def data_sources(self):
|
|
164
178
|
return self._data_sources
|
|
@@ -773,7 +773,7 @@ class App:
|
|
|
773
773
|
Run a backtest for an algorithm. This method should be called when
|
|
774
774
|
running a backtest.
|
|
775
775
|
|
|
776
|
-
|
|
776
|
+
Args:
|
|
777
777
|
backtest_date_range: The date range to run the backtest for
|
|
778
778
|
(instance of BacktestDateRange)
|
|
779
779
|
initial_amount: The initial amount to start the backtest with.
|
|
@@ -812,8 +812,6 @@ class App:
|
|
|
812
812
|
initial_amount=initial_amount,
|
|
813
813
|
backtest_date_range=backtest_date_range
|
|
814
814
|
)
|
|
815
|
-
backtest_report_writer_service = self.container \
|
|
816
|
-
.backtest_report_writer_service()
|
|
817
815
|
|
|
818
816
|
config = self.container.configuration_service().get_config()
|
|
819
817
|
|
|
@@ -822,7 +820,7 @@ class App:
|
|
|
822
820
|
config[RESOURCE_DIRECTORY], "backtest_reports"
|
|
823
821
|
)
|
|
824
822
|
|
|
825
|
-
|
|
823
|
+
backtest_service.write_report_to_json(
|
|
826
824
|
report=report, output_directory=output_directory
|
|
827
825
|
)
|
|
828
826
|
|
|
@@ -840,7 +838,7 @@ class App:
|
|
|
840
838
|
Run a backtest for a set algorithm. This method should be called when
|
|
841
839
|
running a backtest.
|
|
842
840
|
|
|
843
|
-
|
|
841
|
+
Args:
|
|
844
842
|
Algorithms: List[Algorithm] - The algorithms to run backtests for
|
|
845
843
|
date_ranges: List[BacktestDateRange] - The date ranges to run the
|
|
846
844
|
backtests for
|
|
@@ -916,15 +914,12 @@ class App:
|
|
|
916
914
|
if date_range.name is not None:
|
|
917
915
|
report.date_range_name = date_range.name
|
|
918
916
|
|
|
919
|
-
backtest_report_writer_service = self.container \
|
|
920
|
-
.backtest_report_writer_service()
|
|
921
|
-
|
|
922
917
|
if output_directory is None:
|
|
923
918
|
output_directory = os.path.join(
|
|
924
919
|
self.config[RESOURCE_DIRECTORY], "backtest_reports"
|
|
925
920
|
)
|
|
926
921
|
|
|
927
|
-
|
|
922
|
+
backtest_service.write_report_to_json(
|
|
928
923
|
report=report, output_directory=output_directory
|
|
929
924
|
)
|
|
930
925
|
reports.append(report)
|
|
@@ -9,8 +9,7 @@ from investing_algorithm_framework.services import OrderService, \
|
|
|
9
9
|
PositionService, PortfolioService, StrategyOrchestratorService, \
|
|
10
10
|
PortfolioConfigurationService, MarketDataSourceService, BacktestService, \
|
|
11
11
|
ConfigurationService, PortfolioSnapshotService, PositionSnapshotService, \
|
|
12
|
-
MarketCredentialService, TradeService,
|
|
13
|
-
PortfolioSyncService
|
|
12
|
+
MarketCredentialService, TradeService, PortfolioSyncService
|
|
14
13
|
|
|
15
14
|
|
|
16
15
|
def setup_dependency_container(app, modules=None, packages=None):
|
|
@@ -132,9 +131,6 @@ class DependencyContainer(containers.DeclarativeContainer):
|
|
|
132
131
|
market_data_source_service=market_data_source_service,
|
|
133
132
|
portfolio_configuration_service=portfolio_configuration_service,
|
|
134
133
|
)
|
|
135
|
-
backtest_report_writer_service = providers.Factory(
|
|
136
|
-
BacktestReportWriterService,
|
|
137
|
-
)
|
|
138
134
|
algorithm = providers.Factory(
|
|
139
135
|
Algorithm,
|
|
140
136
|
configuration_service=configuration_service,
|
|
@@ -49,6 +49,12 @@ class BacktestMarketDataSource(ABC):
|
|
|
49
49
|
|
|
50
50
|
This function prevents the backtest datasource to download the data
|
|
51
51
|
every time the backtest is run.
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
file_path: str - the file path of the data storage file
|
|
55
|
+
|
|
56
|
+
Returns:
|
|
57
|
+
bool - True if the file exists and the column names are correct,
|
|
52
58
|
"""
|
|
53
59
|
try:
|
|
54
60
|
if os.path.isfile(file_path):
|
|
@@ -444,6 +450,15 @@ class OHLCVMarketDataSource(MarketDataSource, ABC):
|
|
|
444
450
|
Function to get the date ranges of the market data source based
|
|
445
451
|
on the window size and the time_frame. The date ranges
|
|
446
452
|
will be calculated based on the start date and the end date.
|
|
453
|
+
|
|
454
|
+
Args:
|
|
455
|
+
start_date: datetime - The start date
|
|
456
|
+
end_date: datetime - The end date
|
|
457
|
+
window_size: int - The window size
|
|
458
|
+
time_frame: str - The time frame
|
|
459
|
+
|
|
460
|
+
Returns:
|
|
461
|
+
list - A list of tuples with the date ranges
|
|
447
462
|
"""
|
|
448
463
|
|
|
449
464
|
if start_date > end_date:
|
|
@@ -140,7 +140,7 @@ class MarketService(ABC):
|
|
|
140
140
|
|
|
141
141
|
for market_data_credentials in self.market_credentials:
|
|
142
142
|
|
|
143
|
-
if market_data_credentials.market.
|
|
143
|
+
if market_data_credentials.market.upper() == market.upper():
|
|
144
144
|
return market_data_credentials
|
|
145
145
|
|
|
146
146
|
return None
|
|
@@ -74,12 +74,12 @@ class CCXTOHLCVBacktestMarketDataSource(
|
|
|
74
74
|
|
|
75
75
|
When downloading the data it will use the ccxt library.
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
config
|
|
79
|
-
backtest_start_date
|
|
80
|
-
backtest_end_date
|
|
81
|
-
time_frame
|
|
82
|
-
window_size
|
|
77
|
+
Args:
|
|
78
|
+
config (dict): the configuration of the data source
|
|
79
|
+
backtest_start_date (datetime): the start date of the backtest
|
|
80
|
+
backtest_end_date (datetime): the end date of the backtest
|
|
81
|
+
time_frame (string): the time frame of the data
|
|
82
|
+
window_size (int): the total amount of candle sticks that need to
|
|
83
83
|
be returned
|
|
84
84
|
|
|
85
85
|
Returns:
|
|
@@ -137,6 +137,14 @@ class CCXTOHLCVBacktestMarketDataSource(
|
|
|
137
137
|
to_timestamp=backtest_end_date,
|
|
138
138
|
market=self.market
|
|
139
139
|
)
|
|
140
|
+
|
|
141
|
+
if len(ohlcv) == 0:
|
|
142
|
+
raise OperationalException(
|
|
143
|
+
f"No data found for {self.symbol} " +
|
|
144
|
+
f"for date range: {backtest_data_start_date} " +
|
|
145
|
+
f"to {backtest_end_date}. Please make sure that " +
|
|
146
|
+
"the market has data for this date range."
|
|
147
|
+
)
|
|
140
148
|
self.write_data_to_file_path(file_path, ohlcv)
|
|
141
149
|
|
|
142
150
|
self.load_data()
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
from .backtesting import BacktestService
|
|
2
|
-
create_trade_exit_markers_chart, create_trade_entry_markers_chart
|
|
1
|
+
from .backtesting import BacktestService
|
|
3
2
|
from .configuration_service import ConfigurationService
|
|
4
3
|
from .market_credential_service import MarketCredentialService
|
|
5
4
|
from .market_data_source_service import MarketDataSourceService, \
|
|
@@ -23,7 +22,6 @@ __all__ = [
|
|
|
23
22
|
"PortfolioConfigurationService",
|
|
24
23
|
"MarketDataSourceService",
|
|
25
24
|
"BacktestService",
|
|
26
|
-
"BacktestReportWriterService",
|
|
27
25
|
"OrderBacktestService",
|
|
28
26
|
"ConfigurationService",
|
|
29
27
|
"PortfolioSyncService",
|
|
@@ -33,6 +31,4 @@ __all__ = [
|
|
|
33
31
|
"BacktestMarketDataSourceService",
|
|
34
32
|
"BacktestPortfolioService",
|
|
35
33
|
"TradeService",
|
|
36
|
-
"create_trade_entry_markers_chart",
|
|
37
|
-
"create_trade_exit_markers_chart"
|
|
38
34
|
]
|
|
@@ -23,6 +23,27 @@ BACKTEST_REPORT_FILE_NAME_PATTERN = (
|
|
|
23
23
|
)
|
|
24
24
|
|
|
25
25
|
|
|
26
|
+
def validate_algorithm_name(name, illegal_chars=r"[\/:*?\"<>|]"):
|
|
27
|
+
"""
|
|
28
|
+
Validate a algorithm name for illegal characters and throw an
|
|
29
|
+
exception if any are found.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
name (str): The name to validate.
|
|
33
|
+
illegal_chars (str): A regex pattern for characters considered
|
|
34
|
+
illegal (default: r"[/:*?\"<>|]").
|
|
35
|
+
|
|
36
|
+
Raises:
|
|
37
|
+
ValueError: If illegal characters are found in the filename.
|
|
38
|
+
"""
|
|
39
|
+
# Check for illegal characters
|
|
40
|
+
if re.search(illegal_chars, name):
|
|
41
|
+
raise OperationalException(
|
|
42
|
+
f"Illegal characters detected in filename: {name}. "
|
|
43
|
+
f"Illegal characters: / \\ : * ? \" < > |"
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
26
47
|
class BacktestService:
|
|
27
48
|
"""
|
|
28
49
|
Service that facilitates backtests for algorithm objects.
|
|
@@ -87,6 +108,8 @@ class BacktestService:
|
|
|
87
108
|
Returns:
|
|
88
109
|
BacktestReport - The backtest report
|
|
89
110
|
"""
|
|
111
|
+
validate_algorithm_name(algorithm.name)
|
|
112
|
+
|
|
90
113
|
logging.info(
|
|
91
114
|
f"Running backtest for algorithm with name {algorithm.name}"
|
|
92
115
|
)
|
|
@@ -179,6 +202,10 @@ class BacktestService:
|
|
|
179
202
|
"""
|
|
180
203
|
backtest_reports = []
|
|
181
204
|
|
|
205
|
+
# Check algorithm names for illegal characters
|
|
206
|
+
for algorithm in algorithms:
|
|
207
|
+
validate_algorithm_name(algorithm.name)
|
|
208
|
+
|
|
182
209
|
for algorithm in algorithms:
|
|
183
210
|
backtest_reports.append(
|
|
184
211
|
self.run_backtest(
|
|
@@ -291,7 +318,7 @@ class BacktestService:
|
|
|
291
318
|
Also, it will add all traces to the backtest report. The traces
|
|
292
319
|
are collected from each strategy that was run during the backtest.
|
|
293
320
|
|
|
294
|
-
|
|
321
|
+
Args:
|
|
295
322
|
algorithm: The algorithm to create the backtest report for
|
|
296
323
|
number_of_runs: The number of runs
|
|
297
324
|
backtest_date_range: The backtest date range of the backtest
|
|
@@ -514,7 +541,7 @@ class BacktestService:
|
|
|
514
541
|
Function to get a report based on the algorithm name and
|
|
515
542
|
backtest date range if it exists.
|
|
516
543
|
|
|
517
|
-
|
|
544
|
+
Args:
|
|
518
545
|
algorithm_name: str - The name of the algorithm
|
|
519
546
|
backtest_date_range: BacktestDateRange - The backtest date range
|
|
520
547
|
directory: str - The output directory
|
|
@@ -563,7 +590,7 @@ class BacktestService:
|
|
|
563
590
|
"""
|
|
564
591
|
Function to get the backtest start date from a backtest report file.
|
|
565
592
|
|
|
566
|
-
|
|
593
|
+
Args:
|
|
567
594
|
path: str - The path to the backtest report file
|
|
568
595
|
|
|
569
596
|
Returns:
|
|
@@ -581,7 +608,7 @@ class BacktestService:
|
|
|
581
608
|
"""
|
|
582
609
|
Function to get the backtest end date from a backtest report file.
|
|
583
610
|
|
|
584
|
-
|
|
611
|
+
Args:
|
|
585
612
|
path: str - The path to the backtest report file
|
|
586
613
|
|
|
587
614
|
Returns:
|
|
@@ -599,7 +626,7 @@ class BacktestService:
|
|
|
599
626
|
"""
|
|
600
627
|
Function to get the algorithm name from a backtest report file.
|
|
601
628
|
|
|
602
|
-
|
|
629
|
+
Args:
|
|
603
630
|
path: str - The path to the backtest report file
|
|
604
631
|
|
|
605
632
|
Returns:
|
|
@@ -615,7 +642,7 @@ class BacktestService:
|
|
|
615
642
|
"""
|
|
616
643
|
Function to check if a file is a backtest report file.
|
|
617
644
|
|
|
618
|
-
|
|
645
|
+
Args:
|
|
619
646
|
path: str - The path to the file
|
|
620
647
|
|
|
621
648
|
Returns:
|
|
@@ -633,3 +660,80 @@ class BacktestService:
|
|
|
633
660
|
return True
|
|
634
661
|
|
|
635
662
|
return False
|
|
663
|
+
|
|
664
|
+
def write_report_to_json(
|
|
665
|
+
self, report: BacktestReport, output_directory: str
|
|
666
|
+
) -> None:
|
|
667
|
+
"""
|
|
668
|
+
Function to write a backtest report to a JSON file.
|
|
669
|
+
|
|
670
|
+
Args:
|
|
671
|
+
- report: BacktestReport
|
|
672
|
+
The backtest report to write to a file.
|
|
673
|
+
- output_directory: str
|
|
674
|
+
The directory to store the backtest report file.
|
|
675
|
+
|
|
676
|
+
Returns:
|
|
677
|
+
- None
|
|
678
|
+
"""
|
|
679
|
+
|
|
680
|
+
if not os.path.exists(output_directory):
|
|
681
|
+
os.makedirs(output_directory)
|
|
682
|
+
|
|
683
|
+
json_file_path = self.create_report_file_path(
|
|
684
|
+
report, output_directory, extension=".json"
|
|
685
|
+
)
|
|
686
|
+
|
|
687
|
+
report_dict = report.to_dict()
|
|
688
|
+
# Convert dictionary to JSON
|
|
689
|
+
json_data = json.dumps(report_dict, indent=4)
|
|
690
|
+
|
|
691
|
+
# Write JSON data to a .json file
|
|
692
|
+
with open(json_file_path, "w") as json_file:
|
|
693
|
+
json_file.write(json_data)
|
|
694
|
+
|
|
695
|
+
@staticmethod
|
|
696
|
+
def create_report_name(report, output_directory, extension=".json"):
|
|
697
|
+
backtest_start_date = report.backtest_start_date \
|
|
698
|
+
.strftime(DATETIME_FORMAT_BACKTESTING)
|
|
699
|
+
backtest_end_date = report.backtest_end_date \
|
|
700
|
+
.strftime(DATETIME_FORMAT_BACKTESTING)
|
|
701
|
+
created_at = report.created_at.strftime(DATETIME_FORMAT_BACKTESTING)
|
|
702
|
+
file_path = os.path.join(
|
|
703
|
+
output_directory,
|
|
704
|
+
f"report_{report.name}_backtest-start-date_"
|
|
705
|
+
f"{backtest_start_date}_backtest-end-date_"
|
|
706
|
+
f"{backtest_end_date}_created-at_{created_at}{extension}"
|
|
707
|
+
)
|
|
708
|
+
return file_path
|
|
709
|
+
|
|
710
|
+
@staticmethod
|
|
711
|
+
def create_report_file_path(
|
|
712
|
+
report, output_directory, extension=".json"
|
|
713
|
+
) -> str:
|
|
714
|
+
"""
|
|
715
|
+
Function to create a file path for a backtest report.
|
|
716
|
+
|
|
717
|
+
Args:
|
|
718
|
+
- report: BacktestReport
|
|
719
|
+
The backtest report to create a file path for.
|
|
720
|
+
- output_directory: str
|
|
721
|
+
The directory to store the backtest report file.
|
|
722
|
+
- extension: str (default=".json") - optional
|
|
723
|
+
The file extension to use for the backtest report file.
|
|
724
|
+
Returns:
|
|
725
|
+
- file_path: str
|
|
726
|
+
The file path for the backtest report file.
|
|
727
|
+
"""
|
|
728
|
+
backtest_start_date = report.backtest_start_date \
|
|
729
|
+
.strftime(DATETIME_FORMAT_BACKTESTING)
|
|
730
|
+
backtest_end_date = report.backtest_end_date \
|
|
731
|
+
.strftime(DATETIME_FORMAT_BACKTESTING)
|
|
732
|
+
created_at = report.created_at.strftime(DATETIME_FORMAT_BACKTESTING)
|
|
733
|
+
file_path = os.path.join(
|
|
734
|
+
output_directory,
|
|
735
|
+
f"report_{report.name}_backtest-start-date_"
|
|
736
|
+
f"{backtest_start_date}_backtest-end-date_"
|
|
737
|
+
f"{backtest_end_date}_created-at_{created_at}{extension}"
|
|
738
|
+
)
|
|
739
|
+
return file_path
|
investing_algorithm_framework-4.1.0/investing_algorithm_framework/services/backtesting/__init__.py
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
from .backtest_report_writer_service import BacktestReportWriterService
|
|
2
|
-
from .backtest_service import BacktestService
|
|
3
|
-
from .graphs import create_trade_entry_markers_chart, \
|
|
4
|
-
create_trade_exit_markers_chart
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
__all__ = [
|
|
8
|
-
"BacktestReportWriterService",
|
|
9
|
-
"BacktestService",
|
|
10
|
-
"create_trade_entry_markers_chart",
|
|
11
|
-
"create_trade_exit_markers_chart"
|
|
12
|
-
]
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
import os
|
|
3
|
-
|
|
4
|
-
from investing_algorithm_framework.domain import BacktestReport, \
|
|
5
|
-
DATETIME_FORMAT_BACKTESTING
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class BacktestReportWriterService:
|
|
9
|
-
"""
|
|
10
|
-
Service to write backtest reports to a file.
|
|
11
|
-
|
|
12
|
-
Service supports writing backtest reports to the following formats:
|
|
13
|
-
- JSON
|
|
14
|
-
"""
|
|
15
|
-
|
|
16
|
-
def write_report_to_json(
|
|
17
|
-
self, report: BacktestReport, output_directory: str
|
|
18
|
-
) -> None:
|
|
19
|
-
"""
|
|
20
|
-
Function to write a backtest report to a JSON file.
|
|
21
|
-
|
|
22
|
-
Parameters:
|
|
23
|
-
- report: BacktestReport
|
|
24
|
-
The backtest report to write to a file.
|
|
25
|
-
- output_directory: str
|
|
26
|
-
The directory to store the backtest report file.
|
|
27
|
-
|
|
28
|
-
Returns:
|
|
29
|
-
- None
|
|
30
|
-
"""
|
|
31
|
-
|
|
32
|
-
if not os.path.exists(output_directory):
|
|
33
|
-
os.makedirs(output_directory)
|
|
34
|
-
|
|
35
|
-
json_file_path = self.create_report_file_path(
|
|
36
|
-
report, output_directory, extension=".json"
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
report_dict = report.to_dict()
|
|
40
|
-
# Convert dictionary to JSON
|
|
41
|
-
json_data = json.dumps(report_dict, indent=4)
|
|
42
|
-
|
|
43
|
-
# Write JSON data to a .json file
|
|
44
|
-
with open(json_file_path, "w") as json_file:
|
|
45
|
-
json_file.write(json_data)
|
|
46
|
-
|
|
47
|
-
@staticmethod
|
|
48
|
-
def create_report_name(report, output_directory, extension=".json"):
|
|
49
|
-
backtest_start_date = report.backtest_start_date \
|
|
50
|
-
.strftime(DATETIME_FORMAT_BACKTESTING)
|
|
51
|
-
backtest_end_date = report.backtest_end_date \
|
|
52
|
-
.strftime(DATETIME_FORMAT_BACKTESTING)
|
|
53
|
-
created_at = report.created_at.strftime(DATETIME_FORMAT_BACKTESTING)
|
|
54
|
-
file_path = os.path.join(
|
|
55
|
-
output_directory,
|
|
56
|
-
f"report_{report.name}_backtest-start-date_"
|
|
57
|
-
f"{backtest_start_date}_backtest-end-date_"
|
|
58
|
-
f"{backtest_end_date}_created-at_{created_at}{extension}"
|
|
59
|
-
)
|
|
60
|
-
return file_path
|
|
61
|
-
|
|
62
|
-
@staticmethod
|
|
63
|
-
def create_report_file_path(
|
|
64
|
-
report, output_directory, extension=".json"
|
|
65
|
-
) -> str:
|
|
66
|
-
"""
|
|
67
|
-
Function to create a file path for a backtest report.
|
|
68
|
-
|
|
69
|
-
Parameters:
|
|
70
|
-
- report: BacktestReport
|
|
71
|
-
The backtest report to create a file path for.
|
|
72
|
-
- output_directory: str
|
|
73
|
-
The directory to store the backtest report file.
|
|
74
|
-
- extension: str (default=".json") - optional
|
|
75
|
-
The file extension to use for the backtest report file.
|
|
76
|
-
Returns:
|
|
77
|
-
- file_path: str
|
|
78
|
-
The file path for the backtest report file.
|
|
79
|
-
"""
|
|
80
|
-
backtest_start_date = report.backtest_start_date \
|
|
81
|
-
.strftime(DATETIME_FORMAT_BACKTESTING)
|
|
82
|
-
backtest_end_date = report.backtest_end_date \
|
|
83
|
-
.strftime(DATETIME_FORMAT_BACKTESTING)
|
|
84
|
-
created_at = report.created_at.strftime(DATETIME_FORMAT_BACKTESTING)
|
|
85
|
-
file_path = os.path.join(
|
|
86
|
-
output_directory,
|
|
87
|
-
f"report_{report.name}_backtest-start-date_"
|
|
88
|
-
f"{backtest_start_date}_backtest-end-date_"
|
|
89
|
-
f"{backtest_end_date}_created-at_{created_at}{extension}"
|
|
90
|
-
)
|
|
91
|
-
return file_path
|
investing_algorithm_framework-4.1.0/investing_algorithm_framework/services/backtesting/graphs.py
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
from typing import List
|
|
2
|
-
|
|
3
|
-
import pandas as pd
|
|
4
|
-
from plotly import graph_objects as go
|
|
5
|
-
|
|
6
|
-
from investing_algorithm_framework.domain import Trade
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def create_prices_chart(df, column="Close"):
|
|
10
|
-
"""
|
|
11
|
-
Function to create a prices chart.
|
|
12
|
-
"""
|
|
13
|
-
return go.Scatter(
|
|
14
|
-
x=df.index,
|
|
15
|
-
y=df[column],
|
|
16
|
-
mode='lines',
|
|
17
|
-
line=dict(color="blue", width=1),
|
|
18
|
-
name="Close"
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
def create_trade_entry_markers_chart(df, trades: List[Trade]):
|
|
23
|
-
df['entry_prices'] = None
|
|
24
|
-
|
|
25
|
-
for trade in trades:
|
|
26
|
-
opened_index = df.index.get_indexer(
|
|
27
|
-
[pd.to_datetime(trade.opened_at)], method='nearest'
|
|
28
|
-
)
|
|
29
|
-
df.at[df.index[opened_index[0]], 'entry_prices'] = df.at[
|
|
30
|
-
df.index[opened_index[0]], 'Close']
|
|
31
|
-
|
|
32
|
-
return go.Scatter(
|
|
33
|
-
x=df.index,
|
|
34
|
-
y=df["entry_prices"],
|
|
35
|
-
marker_symbol="arrow-up",
|
|
36
|
-
marker=dict(color='green'),
|
|
37
|
-
mode='markers',
|
|
38
|
-
name='Buy'
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def create_trade_exit_markers_chart(df, trades: List[Trade]):
|
|
43
|
-
df['exit_prices'] = None
|
|
44
|
-
|
|
45
|
-
for trade in trades:
|
|
46
|
-
|
|
47
|
-
if trade.closed_at is not None:
|
|
48
|
-
closed_index = df.index.get_indexer(
|
|
49
|
-
[pd.to_datetime(trade.closed_at)], method='nearest'
|
|
50
|
-
)
|
|
51
|
-
df.at[df.index[closed_index[0]], 'exit_prices'] = df.at[
|
|
52
|
-
df.index[closed_index[0]], 'Close']
|
|
53
|
-
|
|
54
|
-
return go.Scatter(
|
|
55
|
-
x=df.index,
|
|
56
|
-
y=df["exit_prices"],
|
|
57
|
-
marker_symbol="arrow-down",
|
|
58
|
-
marker=dict(color='red'),
|
|
59
|
-
mode='markers',
|
|
60
|
-
name='Sell'
|
|
61
|
-
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|