investing-algorithm-framework 6.9.6__tar.gz → 6.9.7__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-6.9.6 → investing_algorithm_framework-6.9.7}/PKG-INFO +4 -3
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/README.md +3 -2
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/__init__.py +6 -8
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/__init__.py +6 -6
- investing_algorithm_framework-6.9.7/investing_algorithm_framework/app/analysis/__init__.py +5 -0
- investing_algorithm_framework-6.9.7/investing_algorithm_framework/app/analysis/backtest_data_ranges.py +96 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/app.py +42 -42
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/context.py +17 -6
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/reporting/__init__.py +1 -4
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/reporting/ascii.py +22 -175
- investing_algorithm_framework-6.9.7/investing_algorithm_framework/app/reporting/backtest_report.py +347 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/reporting/charts/__init__.py +2 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/reporting/charts/equity_curve_drawdown.py +11 -26
- investing_algorithm_framework-6.9.7/investing_algorithm_framework/app/reporting/charts/ohlcv_data_completeness.py +51 -0
- investing_algorithm_framework-6.9.7/investing_algorithm_framework/app/reporting/generate.py +185 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/reporting/tables/key_metrics_table.py +36 -31
- investing_algorithm_framework-6.9.7/investing_algorithm_framework/app/reporting/tables/time_metrics_table.py +80 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/reporting/tables/trade_metrics_table.py +17 -16
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/reporting/tables/trades_table.py +1 -1
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/reporting/tables/utils.py +1 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/reporting/templates/report_template.html.j2 +10 -16
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/__init__.py +9 -5
- {investing_algorithm_framework-6.9.6/investing_algorithm_framework/domain/models → investing_algorithm_framework-6.9.7/investing_algorithm_framework/domain}/backtesting/__init__.py +5 -1
- investing_algorithm_framework-6.9.7/investing_algorithm_framework/domain/backtesting/backtest.py +251 -0
- investing_algorithm_framework-6.9.7/investing_algorithm_framework/domain/backtesting/backtest_metrics.py +334 -0
- {investing_algorithm_framework-6.9.6/investing_algorithm_framework/domain/models → investing_algorithm_framework-6.9.7/investing_algorithm_framework/domain}/backtesting/backtest_results.py +66 -4
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/exceptions.py +8 -1
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/__init__.py +0 -8
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/order/order.py +8 -1
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/portfolio/portfolio_snapshot.py +5 -1
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/time_interval.py +33 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/time_unit.py +30 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/trade/trade.py +19 -10
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/services/market_data_sources.py +7 -1
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/utils/polars.py +13 -15
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/data_providers/ccxt.py +7 -1
- investing_algorithm_framework-6.9.7/investing_algorithm_framework/infrastructure/database/sql_alchemy.py +81 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/models/market_data_sources/ccxt.py +26 -26
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/models/market_data_sources/csv.py +4 -3
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/models/market_data_sources/pandas.py +37 -32
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/models/order/order.py +9 -3
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/repositories/repository.py +0 -1
- investing_algorithm_framework-6.9.7/investing_algorithm_framework/services/backtesting/backtest_service.py +435 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/market_data_source_service/market_data_source_service.py +16 -0
- {investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting → investing_algorithm_framework-6.9.7/investing_algorithm_framework/services}/metrics/__init__.py +5 -7
- {investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting → investing_algorithm_framework-6.9.7/investing_algorithm_framework/services}/metrics/drawdown.py +9 -9
- {investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting → investing_algorithm_framework-6.9.7/investing_algorithm_framework/services}/metrics/equity_curve.py +2 -2
- investing_algorithm_framework-6.9.7/investing_algorithm_framework/services/metrics/generate.py +142 -0
- {investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting → investing_algorithm_framework-6.9.7/investing_algorithm_framework/services}/metrics/returns.py +20 -52
- investing_algorithm_framework-6.9.7/investing_algorithm_framework/services/metrics/risk_free_rate.py +28 -0
- investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting/metrics/sharp_ratio.py → investing_algorithm_framework-6.9.7/investing_algorithm_framework/services/metrics/sharpe_ratio.py +4 -1
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/order_service/order_backtest_service.py +12 -17
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/portfolios/portfolio_snapshot_service.py +5 -1
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/strategy_orchestrator_service.py +1 -4
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/trade_service/trade_service.py +11 -1
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/pyproject.toml +1 -1
- investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting/backtest_report.py +0 -235
- investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting/evaluation.py +0 -243
- investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting/generate.py +0 -199
- investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting/metrics/risk_free_rate.py +0 -8
- investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting/tables/time_metrics_table.py +0 -73
- investing_algorithm_framework-6.9.6/investing_algorithm_framework/domain/models/backtesting/backtest_reports_evaluation.py +0 -0
- investing_algorithm_framework-6.9.6/investing_algorithm_framework/domain/models/date_range.py +0 -64
- investing_algorithm_framework-6.9.6/investing_algorithm_framework/infrastructure/database/sql_alchemy.py +0 -46
- investing_algorithm_framework-6.9.6/investing_algorithm_framework/services/backtesting/backtest_service.py +0 -591
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/LICENSE +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/algorithm/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/algorithm/algorithm.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/algorithm/algorithm_factory.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/app_hook.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/reporting/charts/monthly_returns_heatmap.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/reporting/charts/rolling_sharp_ratio.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/reporting/charts/yearly_returns_barchart.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/reporting/tables/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/reporting/tables/stop_loss_table.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/stateless/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/stateless/action_handlers/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/stateless/action_handlers/action_handler_strategy.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/stateless/action_handlers/check_online_handler.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/stateless/action_handlers/run_strategy_handler.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/stateless/exception_handler.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/strategy.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/task.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/web/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/web/controllers/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/web/controllers/orders.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/web/controllers/portfolio.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/web/controllers/positions.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/web/create_app.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/web/error_handler.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/web/responses.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/web/run_strategies.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/web/schemas/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/web/schemas/order.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/web/schemas/portfolio.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/web/schemas/position.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/app/web/setup_cors.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/cli.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/deploy_to_aws_lambda.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/deploy_to_azure_function.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/initialize_app.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/templates/.gitignore.template +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/templates/app.py.template +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/templates/app_aws_lambda_function.py.template +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/templates/app_azure_function.py.template +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/templates/app_web.py.template +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/templates/aws_lambda_dockerfile.template +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/templates/aws_lambda_dockerignore.template +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/templates/aws_lambda_readme.md.template +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/templates/aws_lambda_requirements.txt.template +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/templates/azure_function_function_app.py.template +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/templates/azure_function_host.json.template +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/templates/azure_function_local.settings.json.template +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/templates/azure_function_requirements.txt.template +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/templates/data_providers.py.template +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/templates/env.example.template +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/templates/env_azure_function.example.template +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/templates/market_data_providers.py.template +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/templates/readme.md.template +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/templates/requirements.txt.template +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/templates/run_backtest.py.template +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/cli/templates/strategy.py.template +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/create_app.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/dependency_container.py +0 -0
- {investing_algorithm_framework-6.9.6/investing_algorithm_framework/domain/models → investing_algorithm_framework-6.9.7/investing_algorithm_framework/domain}/backtesting/backtest_date_range.py +0 -0
- {investing_algorithm_framework-6.9.6/investing_algorithm_framework/domain/models → investing_algorithm_framework-6.9.7/investing_algorithm_framework/domain}/backtesting/backtest_position.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/config.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/constants.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/data_provider.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/data_structures.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/decimal_parsing.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/app_mode.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/base_model.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/data_source.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/event.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/market/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/market/market_credential.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/market_data_type.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/order/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/order/order_side.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/order/order_status.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/order/order_type.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/portfolio/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/portfolio/portfolio.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/portfolio/portfolio_configuration.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/position/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/position/position.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/position/position_snapshot.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/snapshot_interval.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/strategy_profile.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/time_frame.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/tracing/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/tracing/trace.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/trade/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/trade/trade_risk_type.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/trade/trade_status.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/trade/trade_stop_loss.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/trade/trade_take_profit.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/trading_data_types.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/models/trading_time_frame.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/order_executor.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/portfolio_provider.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/services/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/services/market_credential_service.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/services/market_service.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/services/observable.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/services/observer.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/services/portfolios/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/services/portfolios/portfolio_sync_service.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/services/rounding_service.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/services/state_handler.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/stateless_actions.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/strategy.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/utils/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/utils/csv.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/utils/dates.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/utils/random.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/utils/signatures.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/utils/stoppable_thread.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/domain/utils/synchronized.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/download_data.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/data_providers/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/data_providers/csv.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/database/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/models/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/models/decimal_parser.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/models/market_data_sources/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/models/model_extension.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/models/order/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/models/order/order_metadata.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/models/order_trade_association.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/models/portfolio/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/models/portfolio/portfolio_snapshot.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/models/portfolio/sql_portfolio.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/models/position/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/models/position/position.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/models/position/position_snapshot.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/models/trades/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/models/trades/trade.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/models/trades/trade_stop_loss.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/models/trades/trade_take_profit.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/order_executors/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/order_executors/ccxt_order_executor.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/portfolio_providers/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/portfolio_providers/ccxt_portfolio_provider.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/repositories/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/repositories/order_metadata_repository.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/repositories/order_repository.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/repositories/portfolio_repository.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/repositories/portfolio_snapshot_repository.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/repositories/position_repository.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/repositories/position_snapshot_repository.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/repositories/trade_repository.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/repositories/trade_stop_loss_repository.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/repositories/trade_take_profit_repository.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/services/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/services/aws/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/services/aws/state_handler.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/services/azure/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/services/azure/state_handler.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/services/market_service/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/services/market_service/ccxt_market_service.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/services/performance_service/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/services/performance_service/backtest_performance_service.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/infrastructure/services/performance_service/performance_service.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/backtesting/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/configuration_service.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/market_credential_service.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/market_data_source_service/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/market_data_source_service/backtest_market_data_source_service.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/market_data_source_service/data_provider_service.py +0 -0
- {investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting → investing_algorithm_framework-6.9.7/investing_algorithm_framework/services}/metrics/alpha.py +0 -0
- {investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting → investing_algorithm_framework-6.9.7/investing_algorithm_framework/services}/metrics/beta.py +0 -0
- {investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting → investing_algorithm_framework-6.9.7/investing_algorithm_framework/services}/metrics/cagr.py +0 -0
- {investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting → investing_algorithm_framework-6.9.7/investing_algorithm_framework/services}/metrics/calmar_ratio.py +0 -0
- {investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting → investing_algorithm_framework-6.9.7/investing_algorithm_framework/services}/metrics/exposure.py +0 -0
- {investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting → investing_algorithm_framework-6.9.7/investing_algorithm_framework/services}/metrics/mean_daily_return.py +0 -0
- {investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting → investing_algorithm_framework-6.9.7/investing_algorithm_framework/services}/metrics/price_efficiency.py +0 -0
- {investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting → investing_algorithm_framework-6.9.7/investing_algorithm_framework/services}/metrics/profit_factor.py +0 -0
- {investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting → investing_algorithm_framework-6.9.7/investing_algorithm_framework/services}/metrics/recovery.py +0 -0
- {investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting → investing_algorithm_framework-6.9.7/investing_algorithm_framework/services}/metrics/sortino_ratio.py +0 -0
- {investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting → investing_algorithm_framework-6.9.7/investing_algorithm_framework/services}/metrics/standard_deviation.py +0 -0
- {investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting → investing_algorithm_framework-6.9.7/investing_algorithm_framework/services}/metrics/treynor_ratio.py +0 -0
- {investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting → investing_algorithm_framework-6.9.7/investing_algorithm_framework/services}/metrics/ulcer.py +0 -0
- {investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting → investing_algorithm_framework-6.9.7/investing_algorithm_framework/services}/metrics/value_at_risk.py +0 -0
- {investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting → investing_algorithm_framework-6.9.7/investing_algorithm_framework/services}/metrics/volatility.py +0 -0
- {investing_algorithm_framework-6.9.6/investing_algorithm_framework/app/reporting → investing_algorithm_framework-6.9.7/investing_algorithm_framework/services}/metrics/win_rate.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/order_service/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/order_service/order_executor_lookup.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/order_service/order_service.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/portfolios/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/portfolios/backtest_portfolio_service.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/portfolios/portfolio_configuration_service.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/portfolios/portfolio_provider_lookup.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/portfolios/portfolio_service.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/portfolios/portfolio_sync_service.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/positions/__init__.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/positions/position_service.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/positions/position_snapshot_service.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/repository_service.py +0 -0
- {investing_algorithm_framework-6.9.6 → investing_algorithm_framework-6.9.7}/investing_algorithm_framework/services/trade_service/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: investing-algorithm-framework
|
|
3
|
-
Version: 6.9.
|
|
3
|
+
Version: 6.9.7
|
|
4
4
|
Summary: A framework for creating trading bots
|
|
5
5
|
Author: MDUYN
|
|
6
6
|
Requires-Python: >=3.10
|
|
@@ -126,7 +126,7 @@ from pyindicators import ema, rsi
|
|
|
126
126
|
|
|
127
127
|
from investing_algorithm_framework import create_app, TimeUnit, Context, BacktestDateRange, \
|
|
128
128
|
CCXTOHLCVMarketDataSource, CCXTTickerMarketDataSource, DEFAULT_LOGGING_CONFIG, \
|
|
129
|
-
TradingStrategy, SnapshotInterval, convert_polars_to_pandas
|
|
129
|
+
TradingStrategy, SnapshotInterval, convert_polars_to_pandas, BacktestReport
|
|
130
130
|
|
|
131
131
|
load_dotenv()
|
|
132
132
|
logging.config.dictConfig(DEFAULT_LOGGING_CONFIG)
|
|
@@ -205,9 +205,10 @@ app.add_strategy(MyStrategy)
|
|
|
205
205
|
|
|
206
206
|
if __name__ == "__main__":
|
|
207
207
|
# Run the backtest with a daily snapshot interval for end-of-day granular reporting
|
|
208
|
-
|
|
208
|
+
backtest = app.run_backtest(
|
|
209
209
|
backtest_date_range=date_range, initial_amount=100, snapshot_interval=SnapshotInterval.STRATEGY_ITERATION
|
|
210
210
|
)
|
|
211
|
+
backtest_report = BacktestReport(backtests=[backtest])
|
|
211
212
|
backtest_report.show()
|
|
212
213
|
```
|
|
213
214
|
|
|
@@ -90,7 +90,7 @@ from pyindicators import ema, rsi
|
|
|
90
90
|
|
|
91
91
|
from investing_algorithm_framework import create_app, TimeUnit, Context, BacktestDateRange, \
|
|
92
92
|
CCXTOHLCVMarketDataSource, CCXTTickerMarketDataSource, DEFAULT_LOGGING_CONFIG, \
|
|
93
|
-
TradingStrategy, SnapshotInterval, convert_polars_to_pandas
|
|
93
|
+
TradingStrategy, SnapshotInterval, convert_polars_to_pandas, BacktestReport
|
|
94
94
|
|
|
95
95
|
load_dotenv()
|
|
96
96
|
logging.config.dictConfig(DEFAULT_LOGGING_CONFIG)
|
|
@@ -169,9 +169,10 @@ app.add_strategy(MyStrategy)
|
|
|
169
169
|
|
|
170
170
|
if __name__ == "__main__":
|
|
171
171
|
# Run the backtest with a daily snapshot interval for end-of-day granular reporting
|
|
172
|
-
|
|
172
|
+
backtest = app.run_backtest(
|
|
173
173
|
backtest_date_range=date_range, initial_amount=100, snapshot_interval=SnapshotInterval.STRATEGY_ITERATION
|
|
174
174
|
)
|
|
175
|
+
backtest_report = BacktestReport(backtests=[backtest])
|
|
175
176
|
backtest_report.show()
|
|
176
177
|
```
|
|
177
178
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
from investing_algorithm_framework.app import App, Algorithm, \
|
|
2
2
|
TradingStrategy, StatelessAction, Task, AppHook, Context, \
|
|
3
|
-
add_html_report,
|
|
4
|
-
|
|
5
|
-
pretty_print_orders, pretty_print_backtest
|
|
3
|
+
add_html_report, BacktestReport, \
|
|
4
|
+
pretty_print_trades, pretty_print_positions, \
|
|
5
|
+
pretty_print_orders, pretty_print_backtest, select_backtest_date_ranges
|
|
6
6
|
from investing_algorithm_framework.domain import ApiException, \
|
|
7
7
|
TradingDataType, TradingTimeFrame, OrderType, OperationalException, \
|
|
8
8
|
OrderStatus, OrderSide, TimeUnit, TimeInterval, Order, Portfolio, \
|
|
@@ -12,7 +12,7 @@ from investing_algorithm_framework.domain import ApiException, \
|
|
|
12
12
|
TickerMarketDataSource, MarketService, \
|
|
13
13
|
RESERVED_BALANCES, APP_MODE, AppMode, DATETIME_FORMAT, \
|
|
14
14
|
BacktestDateRange, convert_polars_to_pandas, \
|
|
15
|
-
|
|
15
|
+
DEFAULT_LOGGING_CONFIG, \
|
|
16
16
|
BacktestResult, TradeStatus, MarketDataType, TradeRiskType, \
|
|
17
17
|
APPLICATION_DIRECTORY, DataSource, OrderExecutor, PortfolioProvider, \
|
|
18
18
|
SnapshotInterval, AWS_S3_STATE_BUCKET_NAME
|
|
@@ -61,7 +61,6 @@ __all__ = [
|
|
|
61
61
|
"MarketCredential",
|
|
62
62
|
"MarketService",
|
|
63
63
|
"OperationalException",
|
|
64
|
-
"BacktestReportsEvaluation",
|
|
65
64
|
"SYMBOLS",
|
|
66
65
|
"RESERVED_BALANCES",
|
|
67
66
|
"APP_MODE",
|
|
@@ -70,7 +69,6 @@ __all__ = [
|
|
|
70
69
|
"BacktestResult",
|
|
71
70
|
"BacktestDateRange",
|
|
72
71
|
"convert_polars_to_pandas",
|
|
73
|
-
"DateRange",
|
|
74
72
|
"AzureBlobStorageStateHandler",
|
|
75
73
|
"DEFAULT_LOGGING_CONFIG",
|
|
76
74
|
"BacktestReport",
|
|
@@ -89,9 +87,9 @@ __all__ = [
|
|
|
89
87
|
"PandasOHLCVBacktestMarketDataSource",
|
|
90
88
|
"PandasOHLCVMarketDataSource",
|
|
91
89
|
"SnapshotInterval",
|
|
92
|
-
"add_metrics",
|
|
93
90
|
"add_html_report",
|
|
94
91
|
"AWSS3StorageStateHandler",
|
|
95
92
|
"AWS_S3_STATE_BUCKET_NAME",
|
|
96
|
-
"AWS_LAMBDA_LOGGING_CONFIG"
|
|
93
|
+
"AWS_LAMBDA_LOGGING_CONFIG",
|
|
94
|
+
'select_backtest_date_ranges'
|
|
97
95
|
]
|
|
@@ -5,9 +5,10 @@ from investing_algorithm_framework.app.task import Task
|
|
|
5
5
|
from investing_algorithm_framework.app.web import create_flask_app
|
|
6
6
|
from .algorithm import Algorithm
|
|
7
7
|
from .context import Context
|
|
8
|
-
from .reporting import add_html_report,
|
|
9
|
-
BacktestReport, pretty_print_backtest,
|
|
10
|
-
|
|
8
|
+
from .reporting import add_html_report, \
|
|
9
|
+
BacktestReport, pretty_print_backtest, pretty_print_trades, \
|
|
10
|
+
pretty_print_positions, pretty_print_orders
|
|
11
|
+
from .analysis import select_backtest_date_ranges
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
__all__ = [
|
|
@@ -20,11 +21,10 @@ __all__ = [
|
|
|
20
21
|
"AppHook",
|
|
21
22
|
"Context",
|
|
22
23
|
"add_html_report",
|
|
23
|
-
"add_metrics",
|
|
24
24
|
"BacktestReport",
|
|
25
25
|
"pretty_print_backtest",
|
|
26
|
-
"BacktestReportsEvaluation",
|
|
27
26
|
"pretty_print_trades",
|
|
28
27
|
"pretty_print_positions",
|
|
29
|
-
"pretty_print_orders"
|
|
28
|
+
"pretty_print_orders",
|
|
29
|
+
"select_backtest_date_ranges"
|
|
30
30
|
]
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
from investing_algorithm_framework.domain import BacktestDateRange, \
|
|
3
|
+
OperationalException
|
|
4
|
+
from typing import List, Union
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def select_backtest_date_ranges(
|
|
8
|
+
df: pd.DataFrame, window: Union[str, int] = '365D'
|
|
9
|
+
) -> List[BacktestDateRange]:
|
|
10
|
+
"""
|
|
11
|
+
Identifies the best upturn, worst downturn, and sideways periods
|
|
12
|
+
for the given window duration. This allows you to quickly select
|
|
13
|
+
interesting periods for backtesting.
|
|
14
|
+
"""
|
|
15
|
+
df = df.copy()
|
|
16
|
+
df = df.sort_index()
|
|
17
|
+
|
|
18
|
+
if isinstance(window, int):
|
|
19
|
+
window = pd.Timedelta(days=window)
|
|
20
|
+
elif isinstance(window, str):
|
|
21
|
+
window = pd.to_timedelta(window)
|
|
22
|
+
else:
|
|
23
|
+
raise OperationalException("window must be a string or integer")
|
|
24
|
+
|
|
25
|
+
if len(df) < 2 or df.index[-1] - df.index[0] < window:
|
|
26
|
+
raise OperationalException(
|
|
27
|
+
"DataFrame must contain at least two rows and span "
|
|
28
|
+
"the full window duration"
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
best_upturn = {
|
|
32
|
+
"name": "UpTurn", "return": float('-inf'), "start": None, "end": None
|
|
33
|
+
}
|
|
34
|
+
worst_downturn = {
|
|
35
|
+
"name": "DownTurn", "return": float('inf'), "start": None, "end": None
|
|
36
|
+
}
|
|
37
|
+
most_sideways = {
|
|
38
|
+
"name": "SideWays",
|
|
39
|
+
"volatility": float('inf'),
|
|
40
|
+
"return": None,
|
|
41
|
+
"start": None,
|
|
42
|
+
"end": None
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
for i in range(len(df)):
|
|
46
|
+
start_time = df.index[i]
|
|
47
|
+
end_time = start_time + window
|
|
48
|
+
window_df = df[(df.index >= start_time) & (df.index <= end_time)]
|
|
49
|
+
|
|
50
|
+
if len(window_df) < 2 or (window_df.index[-1] - start_time) < window:
|
|
51
|
+
continue
|
|
52
|
+
|
|
53
|
+
start_price = window_df['Close'].iloc[0]
|
|
54
|
+
end_price = window_df['Close'].iloc[-1]
|
|
55
|
+
ret = (end_price / start_price) - 1 # relative return
|
|
56
|
+
volatility = window_df['Close'].std()
|
|
57
|
+
|
|
58
|
+
# Ensure datetime for BacktestDateRange
|
|
59
|
+
start_time = pd.Timestamp(start_time).to_pydatetime()
|
|
60
|
+
end_time = pd.Timestamp(window_df.index[-1]).to_pydatetime()
|
|
61
|
+
|
|
62
|
+
if ret > best_upturn["return"]:
|
|
63
|
+
best_upturn.update(
|
|
64
|
+
{"return": ret, "start": start_time, "end": end_time}
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
if ret < worst_downturn["return"]:
|
|
68
|
+
worst_downturn.update(
|
|
69
|
+
{"return": ret, "start": start_time, "end": end_time}
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
if volatility < most_sideways["volatility"]:
|
|
73
|
+
most_sideways.update({
|
|
74
|
+
"return": ret,
|
|
75
|
+
"volatility": volatility,
|
|
76
|
+
"start": start_time,
|
|
77
|
+
"end": end_time
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
return [
|
|
81
|
+
BacktestDateRange(
|
|
82
|
+
start_date=best_upturn['start'],
|
|
83
|
+
end_date=best_upturn['end'],
|
|
84
|
+
name=best_upturn['name']
|
|
85
|
+
),
|
|
86
|
+
BacktestDateRange(
|
|
87
|
+
start_date=worst_downturn['start'],
|
|
88
|
+
end_date=worst_downturn['end'],
|
|
89
|
+
name=worst_downturn['name']
|
|
90
|
+
),
|
|
91
|
+
BacktestDateRange(
|
|
92
|
+
start_date=most_sideways['start'],
|
|
93
|
+
end_date=most_sideways['end'],
|
|
94
|
+
name=most_sideways['name']
|
|
95
|
+
)
|
|
96
|
+
]
|
|
@@ -18,7 +18,7 @@ from investing_algorithm_framework.domain import DATABASE_NAME, TimeUnit, \
|
|
|
18
18
|
SQLALCHEMY_DATABASE_URI, OperationalException, StateHandler, \
|
|
19
19
|
BACKTESTING_START_DATE, BACKTESTING_END_DATE, APP_MODE, MarketCredential, \
|
|
20
20
|
AppMode, BacktestDateRange, DATABASE_DIRECTORY_NAME, \
|
|
21
|
-
BACKTESTING_INITIAL_AMOUNT, SNAPSHOT_INTERVAL, \
|
|
21
|
+
BACKTESTING_INITIAL_AMOUNT, SNAPSHOT_INTERVAL, Backtest, \
|
|
22
22
|
MarketDataSource, PortfolioConfiguration, SnapshotInterval, \
|
|
23
23
|
PortfolioProvider, OrderExecutor, ImproperlyConfigured
|
|
24
24
|
from investing_algorithm_framework.infrastructure import setup_sqlalchemy, \
|
|
@@ -42,7 +42,9 @@ class App:
|
|
|
42
42
|
|
|
43
43
|
Attributes:
|
|
44
44
|
container: The dependency container for the app. This is used
|
|
45
|
-
to store all the services and repositories for the app
|
|
45
|
+
to store all the services and repositories for the app.
|
|
46
|
+
algorithm: The algorithm to run. This is used to run the
|
|
47
|
+
trading bot.
|
|
46
48
|
_flask_app: The flask app instance. This is used to run the
|
|
47
49
|
web app.
|
|
48
50
|
_state_handler: The state handler for the app. This is used
|
|
@@ -503,6 +505,7 @@ class App:
|
|
|
503
505
|
try:
|
|
504
506
|
while strategy_orchestrator_service.running:
|
|
505
507
|
if number_of_iterations_since_last_orders_check == 30:
|
|
508
|
+
logger.info("Checking pending orders")
|
|
506
509
|
number_of_iterations_since_last_orders_check = 1
|
|
507
510
|
|
|
508
511
|
strategy_orchestrator_service.run_pending_jobs()
|
|
@@ -514,8 +517,7 @@ class App:
|
|
|
514
517
|
logger.error(e)
|
|
515
518
|
raise e
|
|
516
519
|
finally:
|
|
517
|
-
|
|
518
|
-
self._run_history = strategy_orchestrator_service.history
|
|
520
|
+
self._run_history = strategy_orchestrator_service.history
|
|
519
521
|
|
|
520
522
|
try:
|
|
521
523
|
strategy_orchestrator_service.stop()
|
|
@@ -628,9 +630,11 @@ class App:
|
|
|
628
630
|
def _create_resources_if_not_exists(self):
|
|
629
631
|
"""
|
|
630
632
|
Function to create the resources required by the app if they
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
633
|
+
do not exist. This function will check if the resource directory
|
|
634
|
+
exists and check if the database directory exists. If they do
|
|
635
|
+
not exist, it will create them. Also it will make sure that
|
|
636
|
+
the resource directory is read and write accessible by the
|
|
637
|
+
application.
|
|
634
638
|
|
|
635
639
|
Returns:
|
|
636
640
|
None
|
|
@@ -650,6 +654,9 @@ class App:
|
|
|
650
654
|
if not os.path.isdir(resource_dir):
|
|
651
655
|
try:
|
|
652
656
|
os.makedirs(resource_dir)
|
|
657
|
+
|
|
658
|
+
# Make sure the resource directory is readable and writable
|
|
659
|
+
os.chmod(resource_dir, 0o755)
|
|
653
660
|
except OSError as e:
|
|
654
661
|
logger.error(e)
|
|
655
662
|
raise OperationalException(
|
|
@@ -712,11 +719,12 @@ class App:
|
|
|
712
719
|
algorithm=None,
|
|
713
720
|
strategy=None,
|
|
714
721
|
strategies: List = None,
|
|
715
|
-
|
|
722
|
+
save=True,
|
|
716
723
|
snapshot_interval: SnapshotInterval = SnapshotInterval.TRADE_CLOSE,
|
|
717
724
|
strategy_directory_path: Optional[str] = None,
|
|
718
|
-
|
|
719
|
-
|
|
725
|
+
backtest_directory_name: Optional[str] = None,
|
|
726
|
+
risk_free_rate: Optional[float] = None
|
|
727
|
+
) -> Backtest:
|
|
720
728
|
"""
|
|
721
729
|
Run a backtest for an algorithm.
|
|
722
730
|
|
|
@@ -730,14 +738,13 @@ class App:
|
|
|
730
738
|
portfolio will start with.
|
|
731
739
|
strategy (TradingStrategy) (Optional): The strategy object
|
|
732
740
|
that needs to be backtested.
|
|
733
|
-
strategies (List[TradingStrategy) (Optional): List of strategy
|
|
741
|
+
strategies (List[TradingStrategy]) (Optional): List of strategy
|
|
734
742
|
objects that need to be backtested
|
|
735
|
-
algorithm:
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
strategies when running multiple backtests. This is because
|
|
743
|
+
algorithm (Algorithm) (Optional): The algorithm object that needs
|
|
744
|
+
to be backtested. If this is provided, then the strategies
|
|
745
|
+
and tasks of the algorithm will be used for the backtest.
|
|
746
|
+
output_directory (str) (Optional): The directory to write
|
|
747
|
+
the backtest report to
|
|
741
748
|
snapshot_interval (SnapshotInterval): The snapshot
|
|
742
749
|
interval to use for the backtest. This is used to determine
|
|
743
750
|
how often the portfolio snapshot should be taken during the
|
|
@@ -748,7 +755,7 @@ class App:
|
|
|
748
755
|
strategy if save_strategy is True. If not provided,
|
|
749
756
|
the framework tries to determine the path via the
|
|
750
757
|
algorithm or strategy object.
|
|
751
|
-
|
|
758
|
+
backtest_directory_name (Optional[str]): If not
|
|
752
759
|
provided, the framework will generate a name based on the
|
|
753
760
|
algorithm name and the backtest date range and the current
|
|
754
761
|
date and time.
|
|
@@ -765,7 +772,9 @@ class App:
|
|
|
765
772
|
DATABASE_NAME: "backtest-database.sqlite3",
|
|
766
773
|
DATABASE_DIRECTORY_NAME: "backtest_databases",
|
|
767
774
|
BACKTESTING_INITIAL_AMOUNT: initial_amount,
|
|
768
|
-
SNAPSHOT_INTERVAL:
|
|
775
|
+
SNAPSHOT_INTERVAL: SnapshotInterval.from_value(
|
|
776
|
+
snapshot_interval
|
|
777
|
+
).value,
|
|
769
778
|
})
|
|
770
779
|
|
|
771
780
|
self.initialize_config()
|
|
@@ -811,41 +820,33 @@ class App:
|
|
|
811
820
|
portfolio_service = self.container.portfolio_service()
|
|
812
821
|
portfolio_service.clear_observers()
|
|
813
822
|
portfolio_service.add_observer(portfolio_snapshot_service)
|
|
814
|
-
|
|
815
|
-
# Run the backtest with the backtest_service and collect and
|
|
816
|
-
# save the report
|
|
817
|
-
results = backtest_service.run_backtest(
|
|
823
|
+
backtest = backtest_service.run_backtest(
|
|
818
824
|
algorithm=algorithm,
|
|
819
825
|
context=context,
|
|
820
826
|
strategy_orchestrator_service=strategy_orchestrator_service,
|
|
821
827
|
initial_amount=initial_amount,
|
|
822
|
-
backtest_date_range=backtest_date_range
|
|
828
|
+
backtest_date_range=backtest_date_range,
|
|
829
|
+
risk_free_rate=risk_free_rate,
|
|
830
|
+
strategy_directory_path=strategy_directory_path
|
|
823
831
|
)
|
|
824
|
-
report = BacktestReport(results=results)
|
|
825
832
|
|
|
826
833
|
if output_directory is None:
|
|
827
834
|
output_directory = os.path.join(
|
|
828
835
|
config[RESOURCE_DIRECTORY], "backtest_reports"
|
|
829
836
|
)
|
|
830
837
|
|
|
831
|
-
if
|
|
832
|
-
|
|
838
|
+
if backtest_directory_name is None:
|
|
839
|
+
backtest_directory_name = BacktestService\
|
|
840
|
+
.create_report_directory_name(backtest)
|
|
833
841
|
|
|
834
|
-
output_directory = os.path.join(
|
|
835
|
-
|
|
836
|
-
path=output_directory,
|
|
837
|
-
algorithm=algorithm,
|
|
838
|
-
strategy_directory_path=strategy_directory_path,
|
|
839
|
-
save_strategy=save_strategy
|
|
842
|
+
output_directory = os.path.join(
|
|
843
|
+
output_directory, backtest_directory_name
|
|
840
844
|
)
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
# save_strategy=save_strategy,
|
|
847
|
-
# )
|
|
848
|
-
return report
|
|
845
|
+
|
|
846
|
+
if save:
|
|
847
|
+
backtest.save(directory_path=output_directory)
|
|
848
|
+
|
|
849
|
+
return backtest
|
|
849
850
|
|
|
850
851
|
def run_backtests(
|
|
851
852
|
self,
|
|
@@ -956,7 +957,6 @@ class App:
|
|
|
956
957
|
initial_amount=initial_amount,
|
|
957
958
|
output_directory=output_directory,
|
|
958
959
|
algorithm=algorithm,
|
|
959
|
-
save_strategy=save_strategy
|
|
960
960
|
)
|
|
961
961
|
reports.append(report)
|
|
962
962
|
|
|
@@ -828,7 +828,12 @@ class Context:
|
|
|
828
828
|
return (position.cost / net_size) * 100
|
|
829
829
|
|
|
830
830
|
def close_position(
|
|
831
|
-
self,
|
|
831
|
+
self,
|
|
832
|
+
position=None,
|
|
833
|
+
symbol=None,
|
|
834
|
+
portfolio=None,
|
|
835
|
+
precision=None,
|
|
836
|
+
price=None
|
|
832
837
|
) -> Order:
|
|
833
838
|
"""
|
|
834
839
|
Function to close a position. This function will close a position
|
|
@@ -841,6 +846,8 @@ class Context:
|
|
|
841
846
|
symbol (Optional): The symbol of the asset
|
|
842
847
|
portfolio (Optional): The portfolio where the position is located
|
|
843
848
|
precision (Optional): The precision of the amount
|
|
849
|
+
price (Optional[Float]): The price with which the position needs
|
|
850
|
+
to be closed.
|
|
844
851
|
|
|
845
852
|
Returns:
|
|
846
853
|
Order: The order created to close the position
|
|
@@ -887,19 +894,23 @@ class Context:
|
|
|
887
894
|
|
|
888
895
|
target_symbol = position.get_symbol()
|
|
889
896
|
symbol = f"{target_symbol.upper()}/{portfolio.trading_symbol.upper()}"
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
897
|
+
|
|
898
|
+
if price is None:
|
|
899
|
+
ticker = self.market_data_source_service.get_ticker(
|
|
900
|
+
symbol=symbol, market=portfolio.market
|
|
901
|
+
)
|
|
902
|
+
price = ticker["bid"]
|
|
903
|
+
|
|
893
904
|
logger.info(
|
|
894
905
|
f"Closing position {position.symbol} "
|
|
895
906
|
f"with amount {position.get_amount()} "
|
|
896
|
-
f"at price {
|
|
907
|
+
f"at price {price}"
|
|
897
908
|
)
|
|
898
909
|
return self.create_limit_order(
|
|
899
910
|
target_symbol=position.symbol,
|
|
900
911
|
amount=position.get_amount(),
|
|
901
912
|
order_side=OrderSide.SELL.value,
|
|
902
|
-
price=
|
|
913
|
+
price=price,
|
|
903
914
|
precision=precision,
|
|
904
915
|
)
|
|
905
916
|
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
from .generate import add_html_report
|
|
1
|
+
from .generate import add_html_report
|
|
2
2
|
from .backtest_report import BacktestReport
|
|
3
3
|
from .ascii import pretty_print_backtest, pretty_print_positions, \
|
|
4
4
|
pretty_print_trades, pretty_print_orders
|
|
5
|
-
from .evaluation import BacktestReportsEvaluation
|
|
6
5
|
|
|
7
6
|
__all__ = [
|
|
8
7
|
"add_html_report",
|
|
9
|
-
"add_metrics",
|
|
10
8
|
"BacktestReport",
|
|
11
9
|
"pretty_print_backtest",
|
|
12
|
-
"BacktestReportsEvaluation",
|
|
13
10
|
"pretty_print_positions",
|
|
14
11
|
"pretty_print_trades",
|
|
15
12
|
"pretty_print_orders"
|