investing-algorithm-framework 6.5.0__tar.gz → 6.5.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-6.5.0 → investing_algorithm_framework-6.5.2}/PKG-INFO +1 -1
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/app.py +103 -6
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/context.py +24 -3
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/dependency_container.py +1 -1
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/market/market_credential.py +0 -8
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/order_executors/ccxt_order_executor.py +45 -1
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/portfolio_providers/ccxt_portfolio_provider.py +56 -1
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/strategy_orchestrator_service.py +18 -1
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/pyproject.toml +1 -1
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/LICENSE +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/README.md +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/algorithm.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/stateless/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/stateless/action_handlers/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/stateless/action_handlers/action_handler_strategy.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/stateless/action_handlers/check_online_handler.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/stateless/action_handlers/run_strategy_handler.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/stateless/exception_handler.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/strategy.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/task.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/web/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/web/controllers/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/web/controllers/orders.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/web/controllers/portfolio.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/web/controllers/positions.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/web/create_app.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/web/error_handler.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/web/responses.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/web/run_strategies.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/web/schemas/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/web/schemas/order.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/web/schemas/portfolio.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/web/schemas/position.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/app/web/setup_cors.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/cli/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/cli/cli.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/cli/deploy_to_azure_function.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/cli/initialize_app.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/cli/templates/.gitignore.template +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/cli/templates/app-web.py.template +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/cli/templates/app.py.template +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/cli/templates/app_azure_function.py.template +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/cli/templates/app_web.py.template +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/cli/templates/azure_function_function_app.py.template +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/cli/templates/azure_function_host.json.template +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/cli/templates/azure_function_local.settings.json.template +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/cli/templates/data_providers.py.template +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/cli/templates/env.example.template +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/cli/templates/env_azure_function.example.template +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/cli/templates/market_data_providers.py.template +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/cli/templates/readme.md.template +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/cli/templates/requirements.txt.template +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/cli/templates/requirements_azure_function.txt.template +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/cli/templates/run_backtest.py.template +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/cli/templates/strategy.py.template +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/create_app.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/config.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/constants.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/data_provider.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/data_structures.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/decimal_parsing.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/exceptions.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/metrics/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/metrics/price_efficiency.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/app_mode.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/backtesting/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/backtesting/backtest_date_range.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/backtesting/backtest_position.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/backtesting/backtest_report.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/backtesting/backtest_reports_evaluation.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/base_model.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/data_source.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/date_range.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/market/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/market_data_type.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/order/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/order/order.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/order/order_side.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/order/order_status.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/order/order_type.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/portfolio/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/portfolio/portfolio.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/portfolio/portfolio_configuration.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/portfolio/portfolio_snapshot.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/position/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/position/position.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/position/position_snapshot.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/strategy_profile.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/time_frame.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/time_interval.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/time_unit.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/tracing/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/tracing/trace.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/trade/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/trade/trade.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/trade/trade_risk_type.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/trade/trade_status.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/trade/trade_stop_loss.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/trade/trade_take_profit.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/trading_data_types.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/models/trading_time_frame.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/order_executor.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/portfolio_provider.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/services/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/services/market_credential_service.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/services/market_data_sources.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/services/market_service.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/services/portfolios/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/services/portfolios/portfolio_sync_service.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/services/rounding_service.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/services/state_handler.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/stateless_actions.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/strategy.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/utils/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/utils/backtesting.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/utils/csv.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/utils/polars.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/utils/random.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/utils/signatures.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/utils/stoppable_thread.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/domain/utils/synchronized.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/download_data.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/data_providers/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/data_providers/ccxt.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/data_providers/csv.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/database/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/database/sql_alchemy.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/models/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/models/decimal_parser.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/models/market_data_sources/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/models/market_data_sources/ccxt.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/models/market_data_sources/csv.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/models/market_data_sources/pandas.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/models/market_data_sources/us_treasury_yield.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/models/model_extension.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/models/order/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/models/order/order.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/models/order/order_metadata.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/models/order_trade_association.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/models/portfolio/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/models/portfolio/portfolio_snapshot.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/models/portfolio/sql_portfolio.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/models/position/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/models/position/position.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/models/position/position_snapshot.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/models/trades/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/models/trades/trade.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/models/trades/trade_stop_loss.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/models/trades/trade_take_profit.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/order_executors/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/portfolio_providers/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/repositories/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/repositories/order_metadata_repository.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/repositories/order_repository.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/repositories/portfolio_repository.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/repositories/portfolio_snapshot_repository.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/repositories/position_repository.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/repositories/position_snapshot_repository.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/repositories/repository.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/repositories/trade_repository.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/repositories/trade_stop_loss_repository.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/repositories/trade_take_profit_repository.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/services/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/services/azure/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/services/azure/state_handler.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/services/market_service/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/services/market_service/ccxt_market_service.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/services/performance_service/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/services/performance_service/backtest_performance_service.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/infrastructure/services/performance_service/performance_service.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/backtesting/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/backtesting/backtest_service.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/configuration_service.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/market_credential_service.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/market_data_source_service/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/market_data_source_service/backtest_market_data_source_service.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/market_data_source_service/data_provider_service.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/market_data_source_service/market_data_source_service.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/order_service/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/order_service/order_backtest_service.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/order_service/order_executor_lookup.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/order_service/order_service.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/portfolios/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/portfolios/backtest_portfolio_service.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/portfolios/portfolio_configuration_service.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/portfolios/portfolio_provider_lookup.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/portfolios/portfolio_service.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/portfolios/portfolio_snapshot_service.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/portfolios/portfolio_sync_service.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/positions/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/positions/position_service.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/positions/position_snapshot_service.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/repository_service.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/trade_service/__init__.py +0 -0
- {investing_algorithm_framework-6.5.0 → investing_algorithm_framework-6.5.2}/investing_algorithm_framework/services/trade_service/trade_service.py +0 -0
|
@@ -34,13 +34,51 @@ COLOR_YELLOW = '\033[93m'
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
class AppHook:
|
|
37
|
+
"""
|
|
38
|
+
Abstract class for app hooks. App hooks are used to run code before
|
|
39
|
+
actions of the framework are executed. This is useful for running code
|
|
40
|
+
that needs to be run before the following events:
|
|
41
|
+
- App initialization
|
|
42
|
+
- Strategy run
|
|
43
|
+
"""
|
|
37
44
|
|
|
38
45
|
@abstractmethod
|
|
39
|
-
def on_run(self,
|
|
46
|
+
def on_run(self, context) -> None:
|
|
47
|
+
"""
|
|
48
|
+
Method to run the app hook. This method should be implemented
|
|
49
|
+
by the user. This method will be called when the app is performing
|
|
50
|
+
a specific action.
|
|
51
|
+
|
|
52
|
+
Args:
|
|
53
|
+
context: The context of the app. This can be used to get the
|
|
54
|
+
current state of the trading bot, such as portfolios,
|
|
55
|
+
orders, positions, etc.
|
|
56
|
+
|
|
57
|
+
Returns:
|
|
58
|
+
None
|
|
59
|
+
"""
|
|
40
60
|
raise NotImplementedError()
|
|
41
61
|
|
|
42
62
|
|
|
43
63
|
class App:
|
|
64
|
+
"""
|
|
65
|
+
Class to represent the app. This class is used to initialize the
|
|
66
|
+
application and run your trading bot.
|
|
67
|
+
|
|
68
|
+
Attributes:
|
|
69
|
+
- container: The dependency container for the app. This is used
|
|
70
|
+
to store all the services and repositories for the app.
|
|
71
|
+
- algorithm: The algorithm to run. This is used to run the
|
|
72
|
+
trading bot.
|
|
73
|
+
- flask_app: The flask app instance. This is used to run the
|
|
74
|
+
web app.
|
|
75
|
+
- state_handler: The state handler for the app. This is used
|
|
76
|
+
to save and load the state of the app.
|
|
77
|
+
- name: The name of the app. This is used to identify the app
|
|
78
|
+
in logs and other places.
|
|
79
|
+
- started: A boolean value that indicates if the app has been
|
|
80
|
+
started or not.
|
|
81
|
+
"""
|
|
44
82
|
|
|
45
83
|
def __init__(self, state_handler=None, name=None):
|
|
46
84
|
self._flask_app: Optional[Flask] = None
|
|
@@ -54,6 +92,7 @@ class App:
|
|
|
54
92
|
self._market_credential_service: \
|
|
55
93
|
Optional[MarketCredentialService] = None
|
|
56
94
|
self._on_initialize_hooks = []
|
|
95
|
+
self._on_strategy_run_hooks = []
|
|
57
96
|
self._on_after_initialize_hooks = []
|
|
58
97
|
self._state_handler = state_handler
|
|
59
98
|
self._name = name
|
|
@@ -114,12 +153,25 @@ class App:
|
|
|
114
153
|
configuration_service.add_dict(dictionary)
|
|
115
154
|
|
|
116
155
|
def initialize_services(self) -> None:
|
|
117
|
-
|
|
118
|
-
|
|
156
|
+
"""
|
|
157
|
+
Method to initialize the services for the app. This method should
|
|
158
|
+
be called before running the application. This method initializes
|
|
159
|
+
all services so that they are ready to be used.
|
|
160
|
+
|
|
161
|
+
Returns:
|
|
162
|
+
None
|
|
163
|
+
"""
|
|
119
164
|
self._market_data_source_service = \
|
|
120
165
|
self.container.market_data_source_service()
|
|
121
166
|
self._market_credential_service = \
|
|
122
167
|
self.container.market_credential_service()
|
|
168
|
+
self._configuration_service = self.container.configuration_service()
|
|
169
|
+
|
|
170
|
+
strategy_orchestrator_service = \
|
|
171
|
+
self.container.strategy_orchestrator_service()
|
|
172
|
+
|
|
173
|
+
for app_hook in self._on_strategy_run_hooks:
|
|
174
|
+
strategy_orchestrator_service.add_app_hook(app_hook)
|
|
123
175
|
|
|
124
176
|
@algorithm.setter
|
|
125
177
|
def algorithm(self, algorithm: Algorithm) -> None:
|
|
@@ -212,6 +264,7 @@ class App:
|
|
|
212
264
|
None
|
|
213
265
|
"""
|
|
214
266
|
logger.info("Initializing app")
|
|
267
|
+
self.initialize_services()
|
|
215
268
|
self._initialize_default_order_executors()
|
|
216
269
|
self._initialize_default_portfolio_providers()
|
|
217
270
|
|
|
@@ -418,7 +471,7 @@ class App:
|
|
|
418
471
|
|
|
419
472
|
# Run all on_initialize hooks
|
|
420
473
|
for hook in self._on_initialize_hooks:
|
|
421
|
-
hook.on_run(self
|
|
474
|
+
hook.on_run(self.context)
|
|
422
475
|
|
|
423
476
|
configuration_service = self.container.configuration_service()
|
|
424
477
|
config = configuration_service.get_config()
|
|
@@ -580,7 +633,28 @@ class App:
|
|
|
580
633
|
.portfolio_configuration_service()
|
|
581
634
|
return portfolio_configuration_service.get_all()
|
|
582
635
|
|
|
583
|
-
def
|
|
636
|
+
def get_market_credential(self, market: str) -> MarketCredential:
|
|
637
|
+
"""
|
|
638
|
+
Function to get a market credential from the app. This method
|
|
639
|
+
should be called when you want to get a market credential.
|
|
640
|
+
|
|
641
|
+
Args:
|
|
642
|
+
market (str): The market to get the credential for
|
|
643
|
+
|
|
644
|
+
Returns:
|
|
645
|
+
MarketCredential: Instance of MarketCredential
|
|
646
|
+
"""
|
|
647
|
+
|
|
648
|
+
market_credential_service = self.container \
|
|
649
|
+
.market_credential_service()
|
|
650
|
+
market_credential = market_credential_service.get(market)
|
|
651
|
+
if market_credential is None:
|
|
652
|
+
raise OperationalException(
|
|
653
|
+
f"Market credential for {market} not found"
|
|
654
|
+
)
|
|
655
|
+
return market_credential
|
|
656
|
+
|
|
657
|
+
def get_market_credentials(self) -> List[MarketCredential]:
|
|
584
658
|
"""
|
|
585
659
|
Function to get all market credentials from the app. This method
|
|
586
660
|
should be called when you want to get all market credentials.
|
|
@@ -852,17 +926,40 @@ class App:
|
|
|
852
926
|
market_credential.market = market_credential.market.upper()
|
|
853
927
|
self._market_credential_service.add(market_credential)
|
|
854
928
|
|
|
855
|
-
def on_initialize(self, app_hook
|
|
929
|
+
def on_initialize(self, app_hook):
|
|
856
930
|
"""
|
|
857
931
|
Function to add a hook that runs when the app is initialized. The hook
|
|
858
932
|
should be an instance of AppHook.
|
|
859
933
|
"""
|
|
860
934
|
|
|
935
|
+
# Check if the app_hook inherits from AppHook
|
|
936
|
+
if not issubclass(app_hook, AppHook):
|
|
937
|
+
raise OperationalException(
|
|
938
|
+
"App hook should be an instance of AppHook"
|
|
939
|
+
)
|
|
940
|
+
|
|
861
941
|
if inspect.isclass(app_hook):
|
|
862
942
|
app_hook = app_hook()
|
|
863
943
|
|
|
864
944
|
self._on_initialize_hooks.append(app_hook)
|
|
865
945
|
|
|
946
|
+
def on_strategy_run(self, app_hook):
|
|
947
|
+
"""
|
|
948
|
+
Function to add a hook that runs when a strategy is run. The hook
|
|
949
|
+
should be an instance of AppHook.
|
|
950
|
+
"""
|
|
951
|
+
|
|
952
|
+
# Check if the app_hook inherits from AppHook
|
|
953
|
+
if not issubclass(app_hook, AppHook):
|
|
954
|
+
raise OperationalException(
|
|
955
|
+
"App hook should be an instance of AppHook"
|
|
956
|
+
)
|
|
957
|
+
|
|
958
|
+
if inspect.isclass(app_hook):
|
|
959
|
+
app_hook = app_hook()
|
|
960
|
+
|
|
961
|
+
self._on_strategy_run_hooks.append(app_hook)
|
|
962
|
+
|
|
866
963
|
def after_initialize(self, app_hook: AppHook):
|
|
867
964
|
"""
|
|
868
965
|
Function to add a hook that runs after the app is initialized.
|
|
@@ -8,7 +8,7 @@ from investing_algorithm_framework.services import ConfigurationService, \
|
|
|
8
8
|
from investing_algorithm_framework.domain import OrderStatus, OrderType, \
|
|
9
9
|
OrderSide, OperationalException, Portfolio, RoundingService, \
|
|
10
10
|
BACKTESTING_FLAG, BACKTESTING_INDEX_DATETIME, TradeRiskType, Order, \
|
|
11
|
-
Position, Trade, TradeStatus, MarketService
|
|
11
|
+
Position, Trade, TradeStatus, MarketService, MarketCredential
|
|
12
12
|
|
|
13
13
|
logger = logging.getLogger("investing_algorithm_framework")
|
|
14
14
|
|
|
@@ -1431,7 +1431,7 @@ class Context:
|
|
|
1431
1431
|
)
|
|
1432
1432
|
|
|
1433
1433
|
return sum(
|
|
1434
|
-
[order.
|
|
1434
|
+
[order.get_remaining() * order.get_price()
|
|
1435
1435
|
for order in pending_orders]
|
|
1436
1436
|
)
|
|
1437
1437
|
|
|
@@ -1444,6 +1444,27 @@ class Context:
|
|
|
1444
1444
|
)
|
|
1445
1445
|
|
|
1446
1446
|
return sum(
|
|
1447
|
-
[order.
|
|
1447
|
+
[order.get_remaining() * order.get_price()
|
|
1448
1448
|
for order in pending_orders]
|
|
1449
1449
|
)
|
|
1450
|
+
|
|
1451
|
+
def get_market_credential(self, market) -> MarketCredential:
|
|
1452
|
+
"""
|
|
1453
|
+
Function to get the market credential for a given market.
|
|
1454
|
+
|
|
1455
|
+
Args:
|
|
1456
|
+
market: The market to get the credential for
|
|
1457
|
+
|
|
1458
|
+
Returns:
|
|
1459
|
+
MarketCredential: The market credential for the given market
|
|
1460
|
+
"""
|
|
1461
|
+
return self.market_credential_service.get(market)
|
|
1462
|
+
|
|
1463
|
+
def get_market_credentials(self) -> List[MarketCredential]:
|
|
1464
|
+
"""
|
|
1465
|
+
Function to get all market credentials.
|
|
1466
|
+
|
|
1467
|
+
Returns:
|
|
1468
|
+
List[MarketCredential]: A list of all market credentials
|
|
1469
|
+
"""
|
|
1470
|
+
return self.market_credential_service.get_all()
|
|
@@ -132,7 +132,7 @@ class DependencyContainer(containers.DeclarativeContainer):
|
|
|
132
132
|
market_service=market_service,
|
|
133
133
|
portfolio_provider_lookup=portfolio_provider_lookup,
|
|
134
134
|
)
|
|
135
|
-
strategy_orchestrator_service = providers.
|
|
135
|
+
strategy_orchestrator_service = providers.ThreadSafeSingleton(
|
|
136
136
|
StrategyOrchestratorService,
|
|
137
137
|
market_data_source_service=market_data_source_service,
|
|
138
138
|
configuration_service=configuration_service,
|
|
@@ -51,14 +51,6 @@ class MarketCredential:
|
|
|
51
51
|
environment_variable = f"{self.market.upper()}_SECRET_KEY"
|
|
52
52
|
self._secret_key = os.getenv(environment_variable)
|
|
53
53
|
|
|
54
|
-
if self.secret_key is None:
|
|
55
|
-
raise OperationalException(
|
|
56
|
-
f"Market credential for market {self.market}"
|
|
57
|
-
" requires a secret key, either"
|
|
58
|
-
" as an argument or as an environment variable"
|
|
59
|
-
f" named as {self._market.upper()}_SECRET_KEY"
|
|
60
|
-
)
|
|
61
|
-
|
|
62
54
|
def get_api_key(self):
|
|
63
55
|
return self.api_key
|
|
64
56
|
|
|
@@ -3,7 +3,8 @@ from logging import getLogger
|
|
|
3
3
|
import ccxt
|
|
4
4
|
|
|
5
5
|
from investing_algorithm_framework.domain import OrderExecutor, \
|
|
6
|
-
OperationalException, Order, OrderStatus, OrderSide, OrderType
|
|
6
|
+
OperationalException, Order, OrderStatus, OrderSide, OrderType, \
|
|
7
|
+
MarketCredential
|
|
7
8
|
|
|
8
9
|
logger = getLogger("investing_algorithm_framework")
|
|
9
10
|
|
|
@@ -136,12 +137,55 @@ class CCXTOrderExecutor(OrderExecutor):
|
|
|
136
137
|
f"No market service found for market id {market}"
|
|
137
138
|
)
|
|
138
139
|
|
|
140
|
+
# Check the credentials for the exchange
|
|
141
|
+
CCXTOrderExecutor.check_credentials(exchange_class, market_credential)
|
|
139
142
|
exchange = exchange_class({
|
|
140
143
|
'apiKey': market_credential.api_key,
|
|
141
144
|
'secret': market_credential.secret_key,
|
|
142
145
|
})
|
|
143
146
|
return exchange
|
|
144
147
|
|
|
148
|
+
@staticmethod
|
|
149
|
+
def check_credentials(
|
|
150
|
+
exchange_class, market_credential: MarketCredential
|
|
151
|
+
):
|
|
152
|
+
"""
|
|
153
|
+
Function to check if the credentials are valid for the exchange.
|
|
154
|
+
|
|
155
|
+
Args:
|
|
156
|
+
exchange_class: The exchange class to check the credentials for
|
|
157
|
+
market_credential: The market credential to use for the exchange
|
|
158
|
+
|
|
159
|
+
Raises:
|
|
160
|
+
OperationalException: If the credentials are not valid
|
|
161
|
+
|
|
162
|
+
Returns:
|
|
163
|
+
None
|
|
164
|
+
"""
|
|
165
|
+
exchange = exchange_class()
|
|
166
|
+
credentials_info = exchange.requiredCredentials
|
|
167
|
+
market = market_credential.get_market()
|
|
168
|
+
|
|
169
|
+
if ('apiKey' in credentials_info
|
|
170
|
+
and credentials_info["apiKey"]
|
|
171
|
+
and market_credential.get_api_key() is None):
|
|
172
|
+
raise OperationalException(
|
|
173
|
+
f"Market credential for market {market}"
|
|
174
|
+
" requires an api key, either"
|
|
175
|
+
" as an argument or as an environment variable"
|
|
176
|
+
f" named as {market.upper()}_API_KEY"
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
if ('secret' in credentials_info
|
|
180
|
+
and credentials_info["secret"]
|
|
181
|
+
and market_credential.get_secret_key() is None):
|
|
182
|
+
raise OperationalException(
|
|
183
|
+
f"Market credential for market {market}"
|
|
184
|
+
" requires a secret key, either"
|
|
185
|
+
" as an argument or as an environment variable"
|
|
186
|
+
f" named as {market.upper()}_SECRET_KEY"
|
|
187
|
+
)
|
|
188
|
+
|
|
145
189
|
def supports_market(self, market):
|
|
146
190
|
"""
|
|
147
191
|
Function to check if the market is supported by the portfolio
|
|
@@ -3,7 +3,7 @@ from logging import getLogger
|
|
|
3
3
|
from typing import Union
|
|
4
4
|
|
|
5
5
|
from investing_algorithm_framework.domain import PortfolioProvider, \
|
|
6
|
-
OperationalException, Order, Position
|
|
6
|
+
OperationalException, Order, Position, MarketCredential
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
logger = getLogger("investing_algorithm_framework")
|
|
@@ -110,6 +110,17 @@ class CCXTPortfolioProvider(PortfolioProvider):
|
|
|
110
110
|
|
|
111
111
|
@staticmethod
|
|
112
112
|
def initialize_exchange(market, market_credential):
|
|
113
|
+
"""
|
|
114
|
+
Function to initialize the exchange for the market.
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
market (str): The market to initialize the exchange for
|
|
118
|
+
market_credential (MarketCredential): The market credential to use
|
|
119
|
+
for the exchange
|
|
120
|
+
|
|
121
|
+
Returns:
|
|
122
|
+
|
|
123
|
+
"""
|
|
113
124
|
market = market.lower()
|
|
114
125
|
|
|
115
126
|
if not hasattr(ccxt, market):
|
|
@@ -124,12 +135,56 @@ class CCXTPortfolioProvider(PortfolioProvider):
|
|
|
124
135
|
f"No market service found for market id {market}"
|
|
125
136
|
)
|
|
126
137
|
|
|
138
|
+
# Check the credentials for the exchange
|
|
139
|
+
(CCXTPortfolioProvider
|
|
140
|
+
.check_credentials(exchange_class, market_credential))
|
|
127
141
|
exchange = exchange_class({
|
|
128
142
|
'apiKey': market_credential.api_key,
|
|
129
143
|
'secret': market_credential.secret_key,
|
|
130
144
|
})
|
|
131
145
|
return exchange
|
|
132
146
|
|
|
147
|
+
@staticmethod
|
|
148
|
+
def check_credentials(
|
|
149
|
+
exchange_class, market_credential: MarketCredential
|
|
150
|
+
):
|
|
151
|
+
"""
|
|
152
|
+
Function to check if the credentials are valid for the exchange.
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
exchange_class: The exchange class to check the credentials for
|
|
156
|
+
market_credential: The market credential to use for the exchange
|
|
157
|
+
|
|
158
|
+
Raises:
|
|
159
|
+
OperationalException: If the credentials are not valid
|
|
160
|
+
|
|
161
|
+
Returns:
|
|
162
|
+
None
|
|
163
|
+
"""
|
|
164
|
+
exchange = exchange_class()
|
|
165
|
+
credentials_info = exchange.requiredCredentials
|
|
166
|
+
market = market_credential.get_market()
|
|
167
|
+
|
|
168
|
+
if ('apiKey' in credentials_info
|
|
169
|
+
and credentials_info["apiKey"]
|
|
170
|
+
and market_credential.get_api_key() is None):
|
|
171
|
+
raise OperationalException(
|
|
172
|
+
f"Market credential for market {market}"
|
|
173
|
+
" requires an api key, either"
|
|
174
|
+
" as an argument or as an environment variable"
|
|
175
|
+
f" named as {market.upper()}_API_KEY"
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
if ('secret' in credentials_info
|
|
179
|
+
and credentials_info["secret"]
|
|
180
|
+
and market_credential.get_secret_key() is None):
|
|
181
|
+
raise OperationalException(
|
|
182
|
+
f"Market credential for market {market}"
|
|
183
|
+
" requires a secret key, either"
|
|
184
|
+
" as an argument or as an environment variable"
|
|
185
|
+
f" named as {market.upper()}_SECRET_KEY"
|
|
186
|
+
)
|
|
187
|
+
|
|
133
188
|
def supports_market(self, market):
|
|
134
189
|
"""
|
|
135
190
|
Function to check if the market is supported by the portfolio
|
|
@@ -36,8 +36,9 @@ class StrategyOrchestratorService:
|
|
|
36
36
|
def __init__(
|
|
37
37
|
self,
|
|
38
38
|
market_data_source_service: MarketDataSourceService,
|
|
39
|
-
configuration_service
|
|
39
|
+
configuration_service,
|
|
40
40
|
):
|
|
41
|
+
self._app_hooks = []
|
|
41
42
|
self.history = {}
|
|
42
43
|
self._strategies = []
|
|
43
44
|
self._tasks = []
|
|
@@ -49,6 +50,18 @@ class StrategyOrchestratorService:
|
|
|
49
50
|
= market_data_source_service
|
|
50
51
|
self.configuration_service = configuration_service
|
|
51
52
|
|
|
53
|
+
def add_app_hook(self, app_hook):
|
|
54
|
+
"""
|
|
55
|
+
Add an app hook to the list of app hooks
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
app_hook (AppHook): The app hook to add
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
None
|
|
62
|
+
"""
|
|
63
|
+
self._app_hooks.append(app_hook)
|
|
64
|
+
|
|
52
65
|
def cleanup_threads(self):
|
|
53
66
|
|
|
54
67
|
for stoppable in self.threads:
|
|
@@ -73,6 +86,10 @@ class StrategyOrchestratorService:
|
|
|
73
86
|
|
|
74
87
|
logger.info(f"Running strategy {strategy.worker_id}")
|
|
75
88
|
|
|
89
|
+
# Run the app hooks
|
|
90
|
+
for app_hook in self._app_hooks:
|
|
91
|
+
app_hook.on_run(context=context)
|
|
92
|
+
|
|
76
93
|
if sync:
|
|
77
94
|
strategy.run_strategy(
|
|
78
95
|
market_data=market_data,
|
|
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
|