investing-algorithm-framework 5.0.0__tar.gz → 5.0.2__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-5.0.0 → investing_algorithm_framework-5.0.2}/PKG-INFO +1 -1
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/trade/trade.py +24 -6
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/utils/backtesting.py +35 -35
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/services/backtesting/backtest_service.py +19 -8
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/pyproject.toml +1 -1
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/LICENSE +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/README.md +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/app/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/app/algorithm.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/app/app.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/app/stateless/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/app/stateless/action_handlers/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/app/stateless/action_handlers/action_handler_strategy.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/app/stateless/action_handlers/check_online_handler.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/app/stateless/action_handlers/run_strategy_handler.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/app/stateless/exception_handler.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/app/strategy.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/app/task.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/app/web/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/app/web/controllers/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/app/web/controllers/orders.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/app/web/controllers/portfolio.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/app/web/controllers/positions.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/app/web/create_app.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/app/web/error_handler.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/app/web/responses.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/app/web/run_strategies.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/app/web/schemas/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/app/web/schemas/order.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/app/web/schemas/portfolio.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/app/web/schemas/position.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/app/web/setup_cors.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/cli/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/cli/create_azure_function_app_skeleton.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/cli/deploy_to_azure_function.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/cli/templates/azure_function_framework_app.py.template +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/cli/templates/azure_function_function_app.py.template +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/cli/templates/azure_function_host.json.template +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/cli/templates/azure_function_local.settings.json.template +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/cli/templates/azure_function_requirements.txt.template +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/create_app.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/dependency_container.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/config.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/constants.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/data_structures.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/decimal_parsing.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/exceptions.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/metrics/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/metrics/price_efficiency.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/app_mode.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/backtesting/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/backtesting/backtest_date_range.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/backtesting/backtest_position.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/backtesting/backtest_report.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/backtesting/backtest_reports_evaluation.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/base_model.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/date_range.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/market/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/market/market_credential.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/market_data_type.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/order/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/order/order.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/order/order_side.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/order/order_status.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/order/order_type.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/portfolio/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/portfolio/portfolio.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/portfolio/portfolio_configuration.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/portfolio/portfolio_snapshot.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/position/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/position/position.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/position/position_snapshot.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/strategy_profile.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/time_frame.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/time_interval.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/time_unit.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/tracing/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/tracing/trace.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/trade/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/trade/trade_status.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/trading_data_types.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/models/trading_time_frame.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/services/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/services/market_credential_service.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/services/market_data_sources.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/services/market_service.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/services/portfolios/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/services/portfolios/portfolio_sync_service.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/services/rounding_service.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/singleton.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/stateless_actions.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/strategy.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/utils/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/utils/csv.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/utils/polars.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/utils/random.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/utils/signatures.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/utils/stoppable_thread.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/domain/utils/synchronized.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/indicators/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/indicators/advanced.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/indicators/momentum.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/indicators/trend.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/indicators/utils.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/database/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/database/sql_alchemy.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/models/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/models/decimal_parser.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/models/market_data_sources/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/models/market_data_sources/ccxt.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/models/market_data_sources/csv.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/models/market_data_sources/pandas.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/models/market_data_sources/us_treasury_yield.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/models/model_extension.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/models/order/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/models/order/order.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/models/order_trade_association.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/models/portfolio/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/models/portfolio/portfolio_snapshot.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/models/portfolio/sql_portfolio.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/models/position/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/models/position/position.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/models/position/position_snapshot.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/models/trade.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/repositories/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/repositories/order_repository.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/repositories/portfolio_repository.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/repositories/portfolio_snapshot_repository.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/repositories/position_repository.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/repositories/position_snapshot_repository.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/repositories/repository.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/repositories/trade_repository.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/services/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/services/azure/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/services/azure/state_handler.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/services/market_service/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/services/market_service/ccxt_market_service.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/services/performance_service/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/services/performance_service/backtest_performance_service.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/infrastructure/services/performance_service/performance_service.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/services/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/services/backtesting/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/services/configuration_service.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/services/market_credential_service.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/services/market_data_source_service/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/services/market_data_source_service/backtest_market_data_source_service.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/services/market_data_source_service/market_data_source_service.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/services/order_service/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/services/order_service/order_backtest_service.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/services/order_service/order_service.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/services/portfolios/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/services/portfolios/backtest_portfolio_service.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/services/portfolios/portfolio_configuration_service.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/services/portfolios/portfolio_service.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/services/portfolios/portfolio_snapshot_service.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/services/portfolios/portfolio_sync_service.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/services/position_service.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/services/position_snapshot_service.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/services/repository_service.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/services/strategy_orchestrator_service.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/services/trade_service/__init__.py +0 -0
- {investing_algorithm_framework-5.0.0 → investing_algorithm_framework-5.0.2}/investing_algorithm_framework/services/trade_service/trade_service.py +0 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from dateutil.parser import parse
|
|
2
|
+
|
|
1
3
|
from investing_algorithm_framework.domain.models.base_model import BaseModel
|
|
2
4
|
from investing_algorithm_framework.domain.models.order import OrderSide
|
|
3
5
|
from investing_algorithm_framework.domain.models.trade.trade_status import \
|
|
@@ -154,7 +156,9 @@ class Trade(BaseModel):
|
|
|
154
156
|
def net_gain_percentage(self):
|
|
155
157
|
|
|
156
158
|
if TradeStatus.CLOSED.equals(self.status):
|
|
157
|
-
|
|
159
|
+
|
|
160
|
+
if self.cost != 0:
|
|
161
|
+
return (self.net_gain / self.cost) * 100
|
|
158
162
|
|
|
159
163
|
else:
|
|
160
164
|
gain = 0
|
|
@@ -170,7 +174,7 @@ class Trade(BaseModel):
|
|
|
170
174
|
if self.cost != 0:
|
|
171
175
|
return (gain / self.cost) * 100
|
|
172
176
|
|
|
173
|
-
|
|
177
|
+
return 0
|
|
174
178
|
|
|
175
179
|
@property
|
|
176
180
|
def percentage_change(self):
|
|
@@ -254,11 +258,25 @@ class Trade(BaseModel):
|
|
|
254
258
|
"opened_at": opened_at,
|
|
255
259
|
"closed_at": closed_at,
|
|
256
260
|
"updated_at": updated_at,
|
|
257
|
-
"net_gain": self.net_gain
|
|
261
|
+
"net_gain": self.net_gain,
|
|
262
|
+
"cost": self.cost,
|
|
258
263
|
}
|
|
259
264
|
|
|
260
265
|
@staticmethod
|
|
261
266
|
def from_dict(data):
|
|
267
|
+
opened_at = None
|
|
268
|
+
closed_at = None
|
|
269
|
+
updated_at = None
|
|
270
|
+
|
|
271
|
+
if "opened_at" in data and data["opened_at"] is not None:
|
|
272
|
+
opened_at = parse(data["opened_at"])
|
|
273
|
+
|
|
274
|
+
if "closed_at" in data and data["closed_at"] is not None:
|
|
275
|
+
closed_at = parse(data["closed_at"])
|
|
276
|
+
|
|
277
|
+
if "updated_at" in data and data["updated_at"] is not None:
|
|
278
|
+
updated_at = parse(data["updated_at"])
|
|
279
|
+
|
|
262
280
|
return Trade(
|
|
263
281
|
id=data.get("id", None),
|
|
264
282
|
orders=data.get("orders", None),
|
|
@@ -266,14 +284,14 @@ class Trade(BaseModel):
|
|
|
266
284
|
trading_symbol=data["trading_symbol"],
|
|
267
285
|
amount=data["amount"],
|
|
268
286
|
open_price=data["open_price"],
|
|
269
|
-
opened_at=
|
|
270
|
-
closed_at=
|
|
287
|
+
opened_at=opened_at,
|
|
288
|
+
closed_at=closed_at,
|
|
271
289
|
remaining=data.get("remaining", 0),
|
|
272
290
|
net_gain=data.get("net_gain", 0),
|
|
273
291
|
last_reported_price=data.get("last_reported_price"),
|
|
274
292
|
status=data["status"],
|
|
275
293
|
cost=data.get("cost", 0),
|
|
276
|
-
updated_at=
|
|
294
|
+
updated_at=updated_at,
|
|
277
295
|
)
|
|
278
296
|
|
|
279
297
|
def __repr__(self):
|
|
@@ -43,14 +43,14 @@ def pretty_print_profit_evaluation(reports, precision=4):
|
|
|
43
43
|
report.name for report in reports
|
|
44
44
|
]
|
|
45
45
|
profit_table["Profit"] = [
|
|
46
|
-
f"{report.total_net_gain:.{precision}f} {report.trading_symbol}"
|
|
46
|
+
f"{float(report.total_net_gain):.{precision}f} {report.trading_symbol}"
|
|
47
47
|
for report in reports
|
|
48
48
|
]
|
|
49
49
|
profit_table["Profit percentage"] = [
|
|
50
|
-
f"{report.total_net_gain_percentage:.{precision}f}%" for report in reports
|
|
50
|
+
f"{float(report.total_net_gain_percentage):.{precision}f}%" for report in reports
|
|
51
51
|
]
|
|
52
52
|
profit_table["Percentage positive trades"] = [
|
|
53
|
-
f"{report.percentage_positive_trades:.{0}f}%"
|
|
53
|
+
f"{float(report.percentage_positive_trades):.{0}f}%"
|
|
54
54
|
for report in reports
|
|
55
55
|
]
|
|
56
56
|
profit_table["Date range"] = [
|
|
@@ -58,7 +58,7 @@ def pretty_print_profit_evaluation(reports, precision=4):
|
|
|
58
58
|
for report in reports
|
|
59
59
|
]
|
|
60
60
|
profit_table["Total value"] = [
|
|
61
|
-
f"{report.total_value:.{precision}f}" for report in reports
|
|
61
|
+
f"{float(report.total_value):.{precision}f}" for report in reports
|
|
62
62
|
]
|
|
63
63
|
print(tabulate(profit_table, headers="keys", tablefmt="rounded_grid"))
|
|
64
64
|
|
|
@@ -69,13 +69,13 @@ def pretty_print_growth_evaluation(reports, precision=4):
|
|
|
69
69
|
report.name for report in reports
|
|
70
70
|
]
|
|
71
71
|
growth_table["Growth"] = [
|
|
72
|
-
f"{report.growth:.{precision}f} {report.trading_symbol}" for report in reports
|
|
72
|
+
f"{float(report.growth):.{precision}f} {report.trading_symbol}" for report in reports
|
|
73
73
|
]
|
|
74
74
|
growth_table["Growth percentage"] = [
|
|
75
|
-
f"{report.growth_rate:.{precision}f}%" for report in reports
|
|
75
|
+
f"{float(report.growth_rate):.{precision}f}%" for report in reports
|
|
76
76
|
]
|
|
77
77
|
growth_table["Percentage positive trades"] = [
|
|
78
|
-
f"{report.percentage_positive_trades:.{0}f}%"
|
|
78
|
+
f"{float(report.percentage_positive_trades):.{0}f}%"
|
|
79
79
|
for report in reports
|
|
80
80
|
]
|
|
81
81
|
growth_table["Date range"] = [
|
|
@@ -83,7 +83,7 @@ def pretty_print_growth_evaluation(reports, precision=4):
|
|
|
83
83
|
for report in reports
|
|
84
84
|
]
|
|
85
85
|
growth_table["Total value"] = [
|
|
86
|
-
f"{report.total_value:.{precision}f}" for report in reports
|
|
86
|
+
f"{float(report.total_value):.{precision}f}" for report in reports
|
|
87
87
|
]
|
|
88
88
|
print(
|
|
89
89
|
tabulate(growth_table, headers="keys", tablefmt="rounded_grid")
|
|
@@ -102,7 +102,7 @@ def pretty_print_percentage_positive_trades_evaluation(
|
|
|
102
102
|
report.name for report in order[:number_of_reports]
|
|
103
103
|
]
|
|
104
104
|
profit_table["Percentage positive trades"] = [
|
|
105
|
-
f"{report.percentage_positive_trades:.{precision}f}%"
|
|
105
|
+
f"{float(report.percentage_positive_trades):.{precision}f}%"
|
|
106
106
|
for report in order[:number_of_reports]
|
|
107
107
|
]
|
|
108
108
|
profit_table["Total amount of trades"] = [
|
|
@@ -118,7 +118,7 @@ def pretty_print_percentage_positive_trades_evaluation(
|
|
|
118
118
|
report.name for report in least
|
|
119
119
|
]
|
|
120
120
|
table["Percentage positive trades"] = [
|
|
121
|
-
f"{report.percentage_positive_trades:.{precision}f}%"
|
|
121
|
+
f"{float(report.percentage_positive_trades):.{precision}f}%"
|
|
122
122
|
for report in least
|
|
123
123
|
]
|
|
124
124
|
table["Total amount of trades"] = [
|
|
@@ -177,7 +177,7 @@ def pretty_print_price_efficiency(reports, precision=4):
|
|
|
177
177
|
for symbol in price_efficiency:
|
|
178
178
|
row = {}
|
|
179
179
|
row["Symbol"] = symbol
|
|
180
|
-
row["Efficiency ratio / Noise"] = f"{price_efficiency[symbol]:.{precision}f}"
|
|
180
|
+
row["Efficiency ratio / Noise"] = f"{float(price_efficiency[symbol]):.{precision}f}"
|
|
181
181
|
row["Date"] = f"{report.backtest_start_date} - {report.backtest_end_date}"
|
|
182
182
|
|
|
183
183
|
|
|
@@ -228,7 +228,7 @@ def pretty_print_most_profitable(
|
|
|
228
228
|
):
|
|
229
229
|
profits = evaluation.get_profit_order(backtest_date_range=backtest_date_range)
|
|
230
230
|
profit = profits[0]
|
|
231
|
-
print(f"{COLOR_YELLOW}Most profitable:{COLOR_RESET} {COLOR_GREEN}Algorithm {profit.name} {profit.total_net_gain:.{precision}f} {profit.trading_symbol} {profit.total_net_gain_percentage:.{precision}f}%{COLOR_RESET}")
|
|
231
|
+
print(f"{COLOR_YELLOW}Most profitable:{COLOR_RESET} {COLOR_GREEN}Algorithm {profit.name} {float(profit.total_net_gain):.{precision}f} {profit.trading_symbol} {float(profit.total_net_gain_percentage):.{precision}f}%{COLOR_RESET}")
|
|
232
232
|
|
|
233
233
|
|
|
234
234
|
def pretty_print_most_growth(
|
|
@@ -238,7 +238,7 @@ def pretty_print_most_growth(
|
|
|
238
238
|
):
|
|
239
239
|
profits = evaluation.get_growth_order(backtest_date_range=backtest_date_range)
|
|
240
240
|
profit = profits[0]
|
|
241
|
-
print(f"{COLOR_YELLOW}Most growth:{COLOR_RESET} {COLOR_GREEN}Algorithm {profit.name} {profit.growth:.{precision}f} {profit.trading_symbol} {profit.growth_rate:.{precision}f}%{COLOR_RESET}")
|
|
241
|
+
print(f"{COLOR_YELLOW}Most growth:{COLOR_RESET} {COLOR_GREEN}Algorithm {profit.name} {float(profit.growth):.{precision}f} {profit.trading_symbol} {float(profit.growth_rate):.{precision}f}%{COLOR_RESET}")
|
|
242
242
|
|
|
243
243
|
|
|
244
244
|
def pretty_print_percentage_positive_trades(
|
|
@@ -248,7 +248,7 @@ def pretty_print_percentage_positive_trades(
|
|
|
248
248
|
):
|
|
249
249
|
percentages = evaluation.get_percentage_positive_trades_order(backtest_date_range=backtest_date_range)
|
|
250
250
|
percentages = percentages[0]
|
|
251
|
-
print(f"{COLOR_YELLOW}Most positive trades:{COLOR_RESET} {COLOR_GREEN}Algorithm {percentages.name} {percentages.percentage_positive_trades:.{precision}f}%{COLOR_RESET}")
|
|
251
|
+
print(f"{COLOR_YELLOW}Most positive trades:{COLOR_RESET} {COLOR_GREEN}Algorithm {percentages.name} {float(percentages.percentage_positive_trades):.{precision}f}%{COLOR_RESET}")
|
|
252
252
|
|
|
253
253
|
|
|
254
254
|
def pretty_print_trades(backtest_report, precision=4):
|
|
@@ -268,14 +268,14 @@ def pretty_print_trades(backtest_report, precision=4):
|
|
|
268
268
|
trade.duration for trade in backtest_report.trades
|
|
269
269
|
]
|
|
270
270
|
trades_table[f"Size ({backtest_report.trading_symbol})"] = [
|
|
271
|
-
f"{trade.size:.{precision}f}" for trade in backtest_report.trades
|
|
271
|
+
f"{float(trade.size):.{precision}f}" for trade in backtest_report.trades
|
|
272
272
|
]
|
|
273
273
|
trades_table[f"Net gain ({backtest_report.trading_symbol})"] = [
|
|
274
|
-
f"{trade.net_gain:.{precision}f}" + (" (unrealized)" if trade.closed_price is None else "")
|
|
274
|
+
f"{float(trade.net_gain):.{precision}f}" + (" (unrealized)" if trade.closed_price is None else "")
|
|
275
275
|
for trade in backtest_report.trades
|
|
276
276
|
]
|
|
277
277
|
trades_table["Net gain percentage"] = [
|
|
278
|
-
f"{trade.net_gain_percentage:.{precision}f}%" + (" (unrealized)" if trade.closed_price is None else "")
|
|
278
|
+
f"{float(trade.net_gain_percentage):.{precision}f}%" + (" (unrealized)" if trade.closed_price is None else "")
|
|
279
279
|
for trade in backtest_report.trades
|
|
280
280
|
]
|
|
281
281
|
trades_table[f"Open price ({backtest_report.trading_symbol})"] = [
|
|
@@ -312,8 +312,8 @@ def pretty_print_backtest_reports_evaluation(
|
|
|
312
312
|
:%%%#+- .=*#%%% {COLOR_GREEN}Backtest reports evaluation{COLOR_RESET}
|
|
313
313
|
*%%%%%%%+------=*%%%%%%%- {COLOR_GREEN}---------------------------{COLOR_RESET}
|
|
314
314
|
*%%%%%%%%%%%%%%%%%%%%%%%- {COLOR_YELLOW}Number of reports:{COLOR_RESET} {COLOR_GREEN}{number_of_backtest_reports} backtest reports{COLOR_RESET}
|
|
315
|
-
.%%%%%%%%%%%%%%%%%%%%%%# {COLOR_YELLOW}Largest overall profit:{COLOR_RESET}{COLOR_GREEN}{COLOR_RESET}{COLOR_GREEN} (Algorithm {most_profitable.name}) {most_profitable.total_net_gain:.{precision}f} {most_profitable.trading_symbol} {most_profitable.total_net_gain_percentage:.{precision}f}% ({most_profitable.backtest_date_range.name} {most_profitable.backtest_date_range.start_date} - {most_profitable.backtest_date_range.end_date}){COLOR_RESET}
|
|
316
|
-
#%%%####%%%%%%%%**#%%%+ {COLOR_YELLOW}Largest overall growth:{COLOR_RESET}{COLOR_GREEN} (Algorithm {most_profitable.name}) {most_growth.growth:.{precision}f} {most_growth.trading_symbol} {most_growth.growth_rate:.{precision}f}% ({most_growth.backtest_date_range.name} {most_growth.backtest_date_range.start_date} - {most_growth.backtest_date_range.end_date}){COLOR_RESET}
|
|
315
|
+
.%%%%%%%%%%%%%%%%%%%%%%# {COLOR_YELLOW}Largest overall profit:{COLOR_RESET}{COLOR_GREEN}{COLOR_RESET}{COLOR_GREEN} (Algorithm {most_profitable.name}) {float(most_profitable.total_net_gain):.{precision}f} {most_profitable.trading_symbol} {float(most_profitable.total_net_gain_percentage):.{precision}f}% ({most_profitable.backtest_date_range.name} {most_profitable.backtest_date_range.start_date} - {most_profitable.backtest_date_range.end_date}){COLOR_RESET}
|
|
316
|
+
#%%%####%%%%%%%%**#%%%+ {COLOR_YELLOW}Largest overall growth:{COLOR_RESET}{COLOR_GREEN} (Algorithm {most_profitable.name}) {float(most_growth.growth):.{precision}f} {most_growth.trading_symbol} {float(most_growth.growth_rate):.{precision}f}% ({most_growth.backtest_date_range.name} {most_growth.backtest_date_range.start_date} - {most_growth.backtest_date_range.end_date}){COLOR_RESET}
|
|
317
317
|
.:-+*%%%%- {COLOR_PURPLE}-+..#{COLOR_RESET}%%%+.{COLOR_PURPLE}+- +{COLOR_RESET}%%%#*=-:
|
|
318
318
|
.:-=*%%%%. {COLOR_PURPLE}+={COLOR_RESET} .%%# {COLOR_PURPLE}-+.-{COLOR_RESET}%%%%=-:..
|
|
319
319
|
.:=+#%%%%%*###%%%%#*+#%%%%%%*+-:
|
|
@@ -381,14 +381,14 @@ def pretty_print_backtest(
|
|
|
381
381
|
.:-+*%%%%- {COLOR_PURPLE}-+..#{COLOR_RESET}%%%+.{COLOR_PURPLE}+- +{COLOR_RESET}%%%#*=-: {COLOR_YELLOW}Number of runs:{COLOR_RESET}{COLOR_GREEN} {backtest_report.number_of_runs}{COLOR_RESET}
|
|
382
382
|
.:-=*%%%%. {COLOR_PURPLE}+={COLOR_RESET} .%%# {COLOR_PURPLE}-+.-{COLOR_RESET}%%%%=-:.. {COLOR_YELLOW}Number of orders:{COLOR_RESET}{COLOR_GREEN} {backtest_report.number_of_orders}{COLOR_RESET}
|
|
383
383
|
.:=+#%%%%%*###%%%%#*+#%%%%%%*+-: {COLOR_YELLOW}Initial balance:{COLOR_RESET}{COLOR_GREEN} {backtest_report.initial_unallocated}{COLOR_RESET}
|
|
384
|
-
+%%%%%%%%%%%%%%%%%%%= {COLOR_YELLOW}Final balance:{COLOR_RESET}{COLOR_GREEN} {backtest_report.total_value:.{precision}f}{COLOR_RESET}
|
|
385
|
-
:++ .=#%%%%%%%%%%%%%*- {COLOR_YELLOW}Total net gain:{COLOR_RESET}{COLOR_GREEN} {backtest_report.total_net_gain:.{precision}f} {backtest_report.total_net_gain_percentage:.{precision}}%{COLOR_RESET}
|
|
386
|
-
:++: :+%%%%%%#-. {COLOR_YELLOW}Growth:{COLOR_RESET}{COLOR_GREEN} {backtest_report.growth:.{precision}f} {backtest_report.growth_rate:.{precision}}%{COLOR_RESET}
|
|
384
|
+
+%%%%%%%%%%%%%%%%%%%= {COLOR_YELLOW}Final balance:{COLOR_RESET}{COLOR_GREEN} {float(backtest_report.total_value):.{precision}f}{COLOR_RESET}
|
|
385
|
+
:++ .=#%%%%%%%%%%%%%*- {COLOR_YELLOW}Total net gain:{COLOR_RESET}{COLOR_GREEN} {float(backtest_report.total_net_gain):.{precision}f} {float(backtest_report.total_net_gain_percentage):.{precision}}%{COLOR_RESET}
|
|
386
|
+
:++: :+%%%%%%#-. {COLOR_YELLOW}Growth:{COLOR_RESET}{COLOR_GREEN} {float(backtest_report.growth):.{precision}f} {float(backtest_report.growth_rate):.{precision}}%{COLOR_RESET}
|
|
387
387
|
:++: .%%%%%#= {COLOR_YELLOW}Number of trades closed:{COLOR_RESET}{COLOR_GREEN} {backtest_report.number_of_trades_closed}{COLOR_RESET}
|
|
388
388
|
:++: .#%%%%%#*= {COLOR_YELLOW}Number of trades open(end of backtest):{COLOR_RESET}{COLOR_GREEN} {backtest_report.number_of_trades_open}{COLOR_RESET}
|
|
389
389
|
:++- :%%%%%%%%%+= {COLOR_YELLOW}Percentage positive trades:{COLOR_RESET}{COLOR_GREEN} {backtest_report.percentage_positive_trades}%{COLOR_RESET}
|
|
390
390
|
.++- -%%%%%%%%%%%+= {COLOR_YELLOW}Percentage negative trades:{COLOR_RESET}{COLOR_GREEN} {backtest_report.percentage_negative_trades}%{COLOR_RESET}
|
|
391
|
-
.++- .%%%%%%%%%%%%%+= {COLOR_YELLOW}Average trade size:{COLOR_RESET}{COLOR_GREEN} {backtest_report.average_trade_size:.{precision}f} {backtest_report.trading_symbol}{COLOR_RESET}
|
|
391
|
+
.++- .%%%%%%%%%%%%%+= {COLOR_YELLOW}Average trade size:{COLOR_RESET}{COLOR_GREEN} {float(backtest_report.average_trade_size):.{precision}f} {backtest_report.trading_symbol}{COLOR_RESET}
|
|
392
392
|
.++- *%%%%%%%%%%%%%*+: {COLOR_YELLOW}Average trade duration:{COLOR_RESET}{COLOR_GREEN} {backtest_report.average_trade_duration} hours{COLOR_RESET}
|
|
393
393
|
.++- %%%%%%%%%%%%%%#+=
|
|
394
394
|
=++........:::%%%%%%%%%%%%%%*+-
|
|
@@ -405,35 +405,35 @@ def pretty_print_backtest(
|
|
|
405
405
|
position.symbol for position in backtest_report.positions
|
|
406
406
|
]
|
|
407
407
|
position_table["Amount"] = [
|
|
408
|
-
f"{position.amount:.{precision}f}" for position in
|
|
408
|
+
f"{float(position.amount):.{precision}f}" for position in
|
|
409
409
|
backtest_report.positions
|
|
410
410
|
]
|
|
411
411
|
position_table["Pending buy amount"] = [
|
|
412
|
-
f"{position.amount_pending_buy:.{precision}f}"
|
|
412
|
+
f"{float(position.amount_pending_buy):.{precision}f}"
|
|
413
413
|
for position in backtest_report.positions
|
|
414
414
|
]
|
|
415
415
|
position_table["Pending sell amount"] = [
|
|
416
|
-
f"{position.amount_pending_sell:.{precision}f}"
|
|
416
|
+
f"{float(position.amount_pending_sell):.{precision}f}"
|
|
417
417
|
for position in backtest_report.positions
|
|
418
418
|
]
|
|
419
419
|
position_table[f"Cost ({backtest_report.trading_symbol})"] = [
|
|
420
|
-
f"{position.cost:.{precision}f}"
|
|
420
|
+
f"{float(position.cost):.{precision}f}"
|
|
421
421
|
for position in backtest_report.positions
|
|
422
422
|
]
|
|
423
423
|
position_table[f"Value ({backtest_report.trading_symbol})"] = [
|
|
424
|
-
f"{position.value:.{precision}f}"
|
|
424
|
+
f"{float(position.value):.{precision}f}"
|
|
425
425
|
for position in backtest_report.positions
|
|
426
426
|
]
|
|
427
427
|
position_table["Percentage of portfolio"] = [
|
|
428
|
-
f"{position.percentage_of_portfolio:.{precision}f}%"
|
|
428
|
+
f"{float(position.percentage_of_portfolio):.{precision}f}%"
|
|
429
429
|
for position in backtest_report.positions
|
|
430
430
|
]
|
|
431
431
|
position_table[f"Growth ({backtest_report.trading_symbol})"] = [
|
|
432
|
-
f"{position.growth:.{precision}f}"
|
|
432
|
+
f"{float(position.growth):.{precision}f}"
|
|
433
433
|
for position in backtest_report.positions
|
|
434
434
|
]
|
|
435
435
|
position_table["Growth_rate"] = [
|
|
436
|
-
f"{position.growth_rate:.{precision}f}%"
|
|
436
|
+
f"{float(position.growth_rate):.{precision}f}%"
|
|
437
437
|
for position in backtest_report.positions
|
|
438
438
|
]
|
|
439
439
|
print(
|
|
@@ -457,20 +457,20 @@ def pretty_print_backtest(
|
|
|
457
457
|
trade.duration for trade in backtest_report.trades
|
|
458
458
|
]
|
|
459
459
|
trades_table[f"Cost ({backtest_report.trading_symbol})"] = [
|
|
460
|
-
f"{trade.cost:.{precision}f}" for trade in backtest_report.trades
|
|
460
|
+
f"{float(trade.cost):.{precision}f}" for trade in backtest_report.trades
|
|
461
461
|
]
|
|
462
462
|
trades_table[f"Net gain ({backtest_report.trading_symbol})"] = [
|
|
463
|
-
f"{trade.net_gain:.{precision}f}"
|
|
463
|
+
f"{float(trade.net_gain):.{precision}f}"
|
|
464
464
|
for trade in backtest_report.trades
|
|
465
465
|
]
|
|
466
466
|
|
|
467
467
|
# Add (unrealized) to the net gain if the trade is still open
|
|
468
468
|
trades_table[f"Net gain ({backtest_report.trading_symbol})"] = [
|
|
469
|
-
f"{trade.net_gain_absolute:.{precision}f}" + (" (unrealized)" if not TradeStatus.CLOSED.equals(trade.status) else "")
|
|
469
|
+
f"{float(trade.net_gain_absolute):.{precision}f}" + (" (unrealized)" if not TradeStatus.CLOSED.equals(trade.status) else "")
|
|
470
470
|
for trade in backtest_report.trades
|
|
471
471
|
]
|
|
472
472
|
trades_table["Net gain percentage"] = [
|
|
473
|
-
f"{trade.net_gain_percentage:.{precision}f}%" + (" (unrealized)" if not TradeStatus.CLOSED.equals(trade.status) else "")
|
|
473
|
+
f"{float(trade.net_gain_percentage):.{precision}f}%" + (" (unrealized)" if not TradeStatus.CLOSED.equals(trade.status) else "")
|
|
474
474
|
for trade in backtest_report.trades
|
|
475
475
|
]
|
|
476
476
|
trades_table[f"Open price ({backtest_report.trading_symbol})"] = [
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from datetime import datetime, timedelta
|
|
2
|
+
from dateutil import parser
|
|
2
3
|
import re
|
|
3
4
|
import os
|
|
4
5
|
import json
|
|
@@ -612,10 +613,15 @@ class BacktestService:
|
|
|
612
613
|
|
|
613
614
|
# Get the backtest start date from the file name
|
|
614
615
|
backtest_start_date = os.path.basename(path).split("_")[3]
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
616
|
+
|
|
617
|
+
try:
|
|
618
|
+
# Parse the backtest start date
|
|
619
|
+
return datetime.strptime(
|
|
620
|
+
backtest_start_date, DATETIME_FORMAT_BACKTESTING
|
|
621
|
+
)
|
|
622
|
+
except ValueError:
|
|
623
|
+
# Try to parse the backtest start date with a different format
|
|
624
|
+
return parser.parse(backtest_start_date)
|
|
619
625
|
|
|
620
626
|
def _get_end_date_from_backtest_report_file(self, path: str) -> datetime:
|
|
621
627
|
"""
|
|
@@ -630,10 +636,15 @@ class BacktestService:
|
|
|
630
636
|
|
|
631
637
|
# Get the backtest end date from the file name
|
|
632
638
|
backtest_end_date = os.path.basename(path).split("_")[5]
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
639
|
+
|
|
640
|
+
try:
|
|
641
|
+
# Parse the backtest end date
|
|
642
|
+
return datetime.strptime(
|
|
643
|
+
backtest_end_date, DATETIME_FORMAT_BACKTESTING
|
|
644
|
+
)
|
|
645
|
+
except ValueError:
|
|
646
|
+
# Try to parse the backtest end date with a different format
|
|
647
|
+
return parser.parse(backtest_end_date)
|
|
637
648
|
|
|
638
649
|
def _get_algorithm_name_from_backtest_report_file(self, path: str) -> str:
|
|
639
650
|
"""
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|