investing-algorithm-framework 6.9.7__tar.gz → 7.0.0__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.
Files changed (285) hide show
  1. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/PKG-INFO +31 -41
  2. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/README.md +30 -40
  3. investing_algorithm_framework-7.0.0/investing_algorithm_framework/__init__.py +166 -0
  4. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/__init__.py +17 -3
  5. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/algorithm/algorithm.py +2 -40
  6. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/algorithm/algorithm_factory.py +17 -10
  7. investing_algorithm_framework-7.0.0/investing_algorithm_framework/app/analysis/__init__.py +8 -0
  8. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/analysis/backtest_data_ranges.py +27 -2
  9. investing_algorithm_framework-7.0.0/investing_algorithm_framework/app/analysis/ranking.py +58 -0
  10. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/app.py +742 -656
  11. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/context.py +43 -72
  12. investing_algorithm_framework-7.0.0/investing_algorithm_framework/app/eventloop.py +590 -0
  13. investing_algorithm_framework-7.0.0/investing_algorithm_framework/app/reporting/__init__.py +25 -0
  14. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/reporting/ascii.py +3 -2
  15. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/reporting/backtest_report.py +3 -4
  16. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/reporting/charts/__init__.py +5 -3
  17. investing_algorithm_framework-7.0.0/investing_algorithm_framework/app/reporting/charts/entry_exist_signals.py +66 -0
  18. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/reporting/charts/rolling_sharp_ratio.py +1 -1
  19. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/reporting/generate.py +2 -2
  20. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/strategy.py +59 -42
  21. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/task.py +5 -3
  22. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/initialize_app.py +0 -1
  23. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/create_app.py +3 -5
  24. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/dependency_container.py +14 -29
  25. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/__init__.py +23 -24
  26. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/backtesting/__init__.py +1 -1
  27. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/backtesting/backtest.py +8 -8
  28. investing_algorithm_framework-7.0.0/investing_algorithm_framework/domain/backtesting/backtest_date_range.py +96 -0
  29. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/backtesting/backtest_metrics.py +19 -5
  30. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/backtesting/backtest_results.py +17 -28
  31. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/constants.py +6 -3
  32. investing_algorithm_framework-7.0.0/investing_algorithm_framework/domain/data_provider.py +279 -0
  33. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/__init__.py +4 -7
  34. investing_algorithm_framework-7.0.0/investing_algorithm_framework/domain/models/data/__init__.py +7 -0
  35. investing_algorithm_framework-7.0.0/investing_algorithm_framework/domain/models/data/data_source.py +169 -0
  36. investing_algorithm_framework-6.9.7/investing_algorithm_framework/domain/models/market_data_type.py → investing_algorithm_framework-7.0.0/investing_algorithm_framework/domain/models/data/data_type.py +7 -7
  37. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/order/order.py +5 -0
  38. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/order/order_status.py +1 -1
  39. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/order/order_type.py +1 -1
  40. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/portfolio/portfolio.py +2 -1
  41. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/portfolio/portfolio_configuration.py +4 -0
  42. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/snapshot_interval.py +0 -1
  43. investing_algorithm_framework-7.0.0/investing_algorithm_framework/domain/models/strategy_profile.py +33 -0
  44. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/time_frame.py +7 -0
  45. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/time_unit.py +16 -0
  46. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/trade/trade_stop_loss.py +1 -1
  47. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/order_executor.py +19 -0
  48. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/portfolio_provider.py +20 -1
  49. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/services/__init__.py +0 -9
  50. investing_algorithm_framework-7.0.0/investing_algorithm_framework/domain/strategy.py +44 -0
  51. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/utils/__init__.py +5 -1
  52. investing_algorithm_framework-7.0.0/investing_algorithm_framework/domain/utils/custom_tqdm.py +22 -0
  53. investing_algorithm_framework-7.0.0/investing_algorithm_framework/domain/utils/jupyter_notebook_detection.py +19 -0
  54. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/download_data.py +33 -4
  55. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/__init__.py +13 -23
  56. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/data_providers/__init__.py +7 -4
  57. investing_algorithm_framework-7.0.0/investing_algorithm_framework/infrastructure/data_providers/ccxt.py +993 -0
  58. investing_algorithm_framework-7.0.0/investing_algorithm_framework/infrastructure/data_providers/csv.py +456 -0
  59. investing_algorithm_framework-7.0.0/investing_algorithm_framework/infrastructure/data_providers/pandas.py +440 -0
  60. investing_algorithm_framework-7.0.0/investing_algorithm_framework/infrastructure/database/__init__.py +10 -0
  61. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/database/sql_alchemy.py +39 -0
  62. investing_algorithm_framework-7.0.0/investing_algorithm_framework/infrastructure/models/__init__.py +16 -0
  63. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/order_executors/__init__.py +2 -0
  64. investing_algorithm_framework-7.0.0/investing_algorithm_framework/infrastructure/order_executors/backtest_oder_executor.py +28 -0
  65. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/repositories/trade_repository.py +2 -2
  66. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/services/__init__.py +0 -2
  67. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/__init__.py +6 -7
  68. investing_algorithm_framework-7.0.0/investing_algorithm_framework/services/backtesting/backtest_service.py +462 -0
  69. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/configuration_service.py +14 -3
  70. investing_algorithm_framework-7.0.0/investing_algorithm_framework/services/data_providers/__init__.py +5 -0
  71. investing_algorithm_framework-7.0.0/investing_algorithm_framework/services/data_providers/data_provider_service.py +718 -0
  72. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/metrics/__init__.py +5 -2
  73. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/metrics/generate.py +14 -3
  74. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/metrics/profit_factor.py +36 -0
  75. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/metrics/returns.py +76 -4
  76. investing_algorithm_framework-7.0.0/investing_algorithm_framework/services/metrics/ulcer.py +0 -0
  77. investing_algorithm_framework-7.0.0/investing_algorithm_framework/services/metrics/value_at_risk.py +0 -0
  78. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/order_service/order_backtest_service.py +9 -14
  79. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/order_service/order_service.py +9 -41
  80. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/portfolios/portfolio_provider_lookup.py +0 -2
  81. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/portfolios/portfolio_service.py +2 -9
  82. investing_algorithm_framework-7.0.0/investing_algorithm_framework/services/portfolios/portfolio_snapshot_service.py +136 -0
  83. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/portfolios/portfolio_sync_service.py +0 -3
  84. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/repository_service.py +5 -2
  85. investing_algorithm_framework-7.0.0/investing_algorithm_framework/services/trade_order_evaluator/__init__.py +9 -0
  86. investing_algorithm_framework-7.0.0/investing_algorithm_framework/services/trade_order_evaluator/backtest_trade_oder_evaluator.py +132 -0
  87. investing_algorithm_framework-7.0.0/investing_algorithm_framework/services/trade_order_evaluator/default_trade_order_evaluator.py +66 -0
  88. investing_algorithm_framework-7.0.0/investing_algorithm_framework/services/trade_order_evaluator/trade_order_evaluator.py +41 -0
  89. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/trade_service/trade_service.py +6 -10
  90. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/pyproject.toml +2 -2
  91. investing_algorithm_framework-6.9.7/investing_algorithm_framework/__init__.py +0 -95
  92. investing_algorithm_framework-6.9.7/investing_algorithm_framework/app/analysis/__init__.py +0 -5
  93. investing_algorithm_framework-6.9.7/investing_algorithm_framework/app/reporting/__init__.py +0 -13
  94. investing_algorithm_framework-6.9.7/investing_algorithm_framework/domain/backtesting/backtest_date_range.py +0 -47
  95. investing_algorithm_framework-6.9.7/investing_algorithm_framework/domain/data_provider.py +0 -190
  96. investing_algorithm_framework-6.9.7/investing_algorithm_framework/domain/models/data_source.py +0 -21
  97. investing_algorithm_framework-6.9.7/investing_algorithm_framework/domain/models/strategy_profile.py +0 -165
  98. investing_algorithm_framework-6.9.7/investing_algorithm_framework/domain/models/trading_data_types.py +0 -48
  99. investing_algorithm_framework-6.9.7/investing_algorithm_framework/domain/models/trading_time_frame.py +0 -223
  100. investing_algorithm_framework-6.9.7/investing_algorithm_framework/domain/services/market_data_sources.py +0 -549
  101. investing_algorithm_framework-6.9.7/investing_algorithm_framework/domain/services/market_service.py +0 -153
  102. investing_algorithm_framework-6.9.7/investing_algorithm_framework/domain/strategy.py +0 -72
  103. investing_algorithm_framework-6.9.7/investing_algorithm_framework/infrastructure/data_providers/ccxt.py +0 -884
  104. investing_algorithm_framework-6.9.7/investing_algorithm_framework/infrastructure/data_providers/csv.py +0 -257
  105. investing_algorithm_framework-6.9.7/investing_algorithm_framework/infrastructure/database/__init__.py +0 -6
  106. investing_algorithm_framework-6.9.7/investing_algorithm_framework/infrastructure/models/__init__.py +0 -29
  107. investing_algorithm_framework-6.9.7/investing_algorithm_framework/infrastructure/models/market_data_sources/__init__.py +0 -16
  108. investing_algorithm_framework-6.9.7/investing_algorithm_framework/infrastructure/models/market_data_sources/ccxt.py +0 -746
  109. investing_algorithm_framework-6.9.7/investing_algorithm_framework/infrastructure/models/market_data_sources/csv.py +0 -271
  110. investing_algorithm_framework-6.9.7/investing_algorithm_framework/infrastructure/models/market_data_sources/pandas.py +0 -317
  111. investing_algorithm_framework-6.9.7/investing_algorithm_framework/infrastructure/services/market_service/__init__.py +0 -5
  112. investing_algorithm_framework-6.9.7/investing_algorithm_framework/infrastructure/services/market_service/ccxt_market_service.py +0 -471
  113. investing_algorithm_framework-6.9.7/investing_algorithm_framework/services/backtesting/backtest_service.py +0 -435
  114. investing_algorithm_framework-6.9.7/investing_algorithm_framework/services/market_data_source_service/__init__.py +0 -10
  115. investing_algorithm_framework-6.9.7/investing_algorithm_framework/services/market_data_source_service/backtest_market_data_source_service.py +0 -269
  116. investing_algorithm_framework-6.9.7/investing_algorithm_framework/services/market_data_source_service/data_provider_service.py +0 -350
  117. investing_algorithm_framework-6.9.7/investing_algorithm_framework/services/market_data_source_service/market_data_source_service.py +0 -393
  118. investing_algorithm_framework-6.9.7/investing_algorithm_framework/services/portfolios/portfolio_snapshot_service.py +0 -174
  119. investing_algorithm_framework-6.9.7/investing_algorithm_framework/services/strategy_orchestrator_service.py +0 -293
  120. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/LICENSE +0 -0
  121. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/algorithm/__init__.py +0 -0
  122. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/app_hook.py +0 -0
  123. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/reporting/charts/equity_curve_drawdown.py +0 -0
  124. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/reporting/charts/monthly_returns_heatmap.py +0 -0
  125. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/reporting/charts/ohlcv_data_completeness.py +0 -0
  126. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/reporting/charts/yearly_returns_barchart.py +0 -0
  127. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/reporting/tables/__init__.py +0 -0
  128. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/reporting/tables/key_metrics_table.py +0 -0
  129. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/reporting/tables/stop_loss_table.py +0 -0
  130. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/reporting/tables/time_metrics_table.py +0 -0
  131. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/reporting/tables/trade_metrics_table.py +0 -0
  132. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/reporting/tables/trades_table.py +0 -0
  133. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/reporting/tables/utils.py +0 -0
  134. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/reporting/templates/report_template.html.j2 +0 -0
  135. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/stateless/__init__.py +0 -0
  136. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/stateless/action_handlers/__init__.py +0 -0
  137. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/stateless/action_handlers/action_handler_strategy.py +0 -0
  138. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/stateless/action_handlers/check_online_handler.py +0 -0
  139. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/stateless/action_handlers/run_strategy_handler.py +0 -0
  140. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/stateless/exception_handler.py +0 -0
  141. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/web/__init__.py +0 -0
  142. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/web/controllers/__init__.py +0 -0
  143. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/web/controllers/orders.py +0 -0
  144. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/web/controllers/portfolio.py +0 -0
  145. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/web/controllers/positions.py +0 -0
  146. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/web/create_app.py +0 -0
  147. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/web/error_handler.py +0 -0
  148. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/web/responses.py +0 -0
  149. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/web/run_strategies.py +0 -0
  150. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/web/schemas/__init__.py +0 -0
  151. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/web/schemas/order.py +0 -0
  152. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/web/schemas/portfolio.py +0 -0
  153. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/web/schemas/position.py +0 -0
  154. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/app/web/setup_cors.py +0 -0
  155. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/__init__.py +0 -0
  156. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/cli.py +0 -0
  157. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/deploy_to_aws_lambda.py +0 -0
  158. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/deploy_to_azure_function.py +0 -0
  159. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/templates/.gitignore.template +0 -0
  160. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/templates/app.py.template +0 -0
  161. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/templates/app_aws_lambda_function.py.template +0 -0
  162. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/templates/app_azure_function.py.template +0 -0
  163. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/templates/app_web.py.template +0 -0
  164. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/templates/aws_lambda_dockerfile.template +0 -0
  165. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/templates/aws_lambda_dockerignore.template +0 -0
  166. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/templates/aws_lambda_readme.md.template +0 -0
  167. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/templates/aws_lambda_requirements.txt.template +0 -0
  168. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/templates/azure_function_function_app.py.template +0 -0
  169. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/templates/azure_function_host.json.template +0 -0
  170. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/templates/azure_function_local.settings.json.template +0 -0
  171. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/templates/azure_function_requirements.txt.template +0 -0
  172. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/templates/data_providers.py.template +0 -0
  173. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/templates/env.example.template +0 -0
  174. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/templates/env_azure_function.example.template +0 -0
  175. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/templates/market_data_providers.py.template +0 -0
  176. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/templates/readme.md.template +0 -0
  177. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/templates/requirements.txt.template +0 -0
  178. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/templates/run_backtest.py.template +0 -0
  179. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/cli/templates/strategy.py.template +0 -0
  180. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/backtesting/backtest_position.py +0 -0
  181. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/config.py +0 -0
  182. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/data_structures.py +0 -0
  183. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/decimal_parsing.py +0 -0
  184. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/exceptions.py +0 -0
  185. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/app_mode.py +0 -0
  186. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/base_model.py +0 -0
  187. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/event.py +0 -0
  188. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/market/__init__.py +0 -0
  189. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/market/market_credential.py +0 -0
  190. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/order/__init__.py +0 -0
  191. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/order/order_side.py +0 -0
  192. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/portfolio/__init__.py +0 -0
  193. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/portfolio/portfolio_snapshot.py +0 -0
  194. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/position/__init__.py +0 -0
  195. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/position/position.py +0 -0
  196. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/position/position_snapshot.py +0 -0
  197. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/time_interval.py +0 -0
  198. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/tracing/__init__.py +0 -0
  199. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/tracing/trace.py +0 -0
  200. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/trade/__init__.py +0 -0
  201. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/trade/trade.py +0 -0
  202. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/trade/trade_risk_type.py +0 -0
  203. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/trade/trade_status.py +0 -0
  204. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/models/trade/trade_take_profit.py +0 -0
  205. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/services/market_credential_service.py +0 -0
  206. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/services/observable.py +0 -0
  207. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/services/observer.py +0 -0
  208. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/services/portfolios/__init__.py +0 -0
  209. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/services/portfolios/portfolio_sync_service.py +0 -0
  210. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/services/rounding_service.py +0 -0
  211. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/services/state_handler.py +0 -0
  212. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/stateless_actions.py +0 -0
  213. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/utils/csv.py +0 -0
  214. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/utils/dates.py +0 -0
  215. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/utils/polars.py +0 -0
  216. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/utils/random.py +0 -0
  217. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/utils/signatures.py +0 -0
  218. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/utils/stoppable_thread.py +0 -0
  219. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/domain/utils/synchronized.py +0 -0
  220. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/models/decimal_parser.py +0 -0
  221. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/models/model_extension.py +0 -0
  222. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/models/order/__init__.py +0 -0
  223. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/models/order/order.py +0 -0
  224. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/models/order/order_metadata.py +0 -0
  225. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/models/order_trade_association.py +0 -0
  226. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/models/portfolio/__init__.py +0 -0
  227. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/models/portfolio/portfolio_snapshot.py +0 -0
  228. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/models/portfolio/sql_portfolio.py +0 -0
  229. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/models/position/__init__.py +0 -0
  230. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/models/position/position.py +0 -0
  231. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/models/position/position_snapshot.py +0 -0
  232. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/models/trades/__init__.py +0 -0
  233. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/models/trades/trade.py +0 -0
  234. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/models/trades/trade_stop_loss.py +0 -0
  235. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/models/trades/trade_take_profit.py +0 -0
  236. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/order_executors/ccxt_order_executor.py +0 -0
  237. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/portfolio_providers/__init__.py +0 -0
  238. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/portfolio_providers/ccxt_portfolio_provider.py +0 -0
  239. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/repositories/__init__.py +0 -0
  240. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/repositories/order_metadata_repository.py +0 -0
  241. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/repositories/order_repository.py +0 -0
  242. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/repositories/portfolio_repository.py +0 -0
  243. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/repositories/portfolio_snapshot_repository.py +0 -0
  244. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/repositories/position_repository.py +0 -0
  245. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/repositories/position_snapshot_repository.py +0 -0
  246. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/repositories/repository.py +0 -0
  247. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/repositories/trade_stop_loss_repository.py +0 -0
  248. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/repositories/trade_take_profit_repository.py +0 -0
  249. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/services/aws/__init__.py +0 -0
  250. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/services/aws/state_handler.py +0 -0
  251. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/services/azure/__init__.py +0 -0
  252. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/services/azure/state_handler.py +0 -0
  253. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/services/performance_service/__init__.py +0 -0
  254. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/services/performance_service/backtest_performance_service.py +0 -0
  255. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/infrastructure/services/performance_service/performance_service.py +0 -0
  256. /investing_algorithm_framework-6.9.7/investing_algorithm_framework/services/metrics/alpha.py → /investing_algorithm_framework-7.0.0/investing_algorithm_framework/infrastructure/unit_of_work/in_memory.py +0 -0
  257. /investing_algorithm_framework-6.9.7/investing_algorithm_framework/services/metrics/beta.py → /investing_algorithm_framework-7.0.0/investing_algorithm_framework/infrastructure/unit_of_work/sqlalchemy.py +0 -0
  258. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/backtesting/__init__.py +0 -0
  259. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/market_credential_service.py +0 -0
  260. /investing_algorithm_framework-6.9.7/investing_algorithm_framework/services/metrics/treynor_ratio.py → /investing_algorithm_framework-7.0.0/investing_algorithm_framework/services/metrics/alpha.py +0 -0
  261. /investing_algorithm_framework-6.9.7/investing_algorithm_framework/services/metrics/ulcer.py → /investing_algorithm_framework-7.0.0/investing_algorithm_framework/services/metrics/beta.py +0 -0
  262. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/metrics/cagr.py +0 -0
  263. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/metrics/calmar_ratio.py +0 -0
  264. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/metrics/drawdown.py +0 -0
  265. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/metrics/equity_curve.py +0 -0
  266. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/metrics/exposure.py +0 -0
  267. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/metrics/mean_daily_return.py +0 -0
  268. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/metrics/price_efficiency.py +0 -0
  269. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/metrics/recovery.py +0 -0
  270. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/metrics/risk_free_rate.py +0 -0
  271. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/metrics/sharpe_ratio.py +0 -0
  272. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/metrics/sortino_ratio.py +0 -0
  273. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/metrics/standard_deviation.py +0 -0
  274. /investing_algorithm_framework-6.9.7/investing_algorithm_framework/services/metrics/value_at_risk.py → /investing_algorithm_framework-7.0.0/investing_algorithm_framework/services/metrics/treynor_ratio.py +0 -0
  275. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/metrics/volatility.py +0 -0
  276. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/metrics/win_rate.py +0 -0
  277. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/order_service/__init__.py +0 -0
  278. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/order_service/order_executor_lookup.py +0 -0
  279. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/portfolios/__init__.py +0 -0
  280. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/portfolios/backtest_portfolio_service.py +0 -0
  281. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/portfolios/portfolio_configuration_service.py +0 -0
  282. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/positions/__init__.py +0 -0
  283. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/positions/position_service.py +0 -0
  284. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/positions/position_snapshot_service.py +0 -0
  285. {investing_algorithm_framework-6.9.7 → investing_algorithm_framework-7.0.0}/investing_algorithm_framework/services/trade_service/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: investing-algorithm-framework
3
- Version: 6.9.7
3
+ Version: 7.0.0
4
4
  Summary: A framework for creating trading bots
5
5
  Author: MDUYN
6
6
  Requires-Python: >=3.10
@@ -49,8 +49,18 @@ Description-Content-Type: text/markdown
49
49
  <img src="static/showcase.svg" alt="Investing Algorithm Framework Logo" style="height: 50vh; max-height: 750px;">
50
50
  </div>
51
51
 
52
- The investing algorithm framework is a Python framework designed to help you build, backtest, and deploy quantitative trading strategies. It comes with a event-based backtesting engine, ensuring an accurate and realistic evaluation of your strategies. The framework supports live trading with multiple exchanges and has various deployment options including Azure Functions and AWS Lambda.
53
- The framework is designed to be extensible, allowing you to add custom strategies, data providers, and order executors. It also supports multiple data sources, including OHLCV, ticker, and custom data, with integration for both Polars and Pandas.
52
+ The Investing Algorithm Framework is a Python-based framework built to streamline the entire lifecycle of quantitative trading strategies from signal generation and backtesting to live deployment.
53
+ It offers a complete quantitative workflow, featuring two dedicated backtesting engines:
54
+
55
+ * A vectorized backtest engine for fast signal research and prototyping
56
+
57
+ * An event-based backtest engine for realistic and accurate strategy evaluation
58
+
59
+ The framework supports live trading across multiple exchanges and offers flexible deployment options, including Azure Functions and AWS Lambda.
60
+ Designed for extensibility, it allows you to integrate custom strategies, data providers, and order executors, enabling support for any exchange or broker.
61
+ It natively supports multiple data formats, including OHLCV, ticker, and custom datasets with seamless compatibility for both Pandas and Polars DataFrames.
62
+
63
+
54
64
 
55
65
  ## Sponsors
56
66
 
@@ -66,11 +76,14 @@ The framework is designed to be extensible, allowing you to add custom strategie
66
76
  ## 🌟 Features
67
77
 
68
78
  - [x] Python 3.10+: Cross-platform support for Windows, macOS, and Linux.
69
- - [x] Backtesting: Simulate strategies with detailed performance reports.
79
+ - [x] Event-Driven Backtest Engine: Accurate and realistic backtesting with event-driven architecture.
80
+ - [x] Vectorized Backtest Engine: Fast signal research and prototyping with vectorized operations.
81
+ - [x] Backtest Reporting: Generate detailed reports to analyse and compare backtests.
70
82
  - [x] Live Trading: Execute trades in real-time with support for multiple exchanges via ccxt.
71
83
  - [x] Portfolio Management: Manage portfolios, trades, and positions with persistence via SQLite.
72
84
  - [x] Market Data Sources: Fetch OHLCV, ticker, and custom data with support for Polars and Pandas.
73
- - [x] Azure Functions Support: Deploy stateless trading bots to Azure.
85
+ - [x] Azure Functions Support: Deploy trading bots to Azure.
86
+ - [x] AWS Lambda Support: Deploy trading bots to AWS Lambda.
74
87
  - [x] Web API: Interact with your bot via REST API.
75
88
  - [x] PyIndicators Integration: Perform technical analysis directly on your dataframes.
76
89
  - [x] Extensibility: Add custom strategies, data providers, order executors so you can connect your trading bot to your favorite exchange or broker.
@@ -122,31 +135,15 @@ the 20, 50 and 100 period exponential moving averages (EMA) and the
122
135
  import logging.config
123
136
  from dotenv import load_dotenv
124
137
 
125
- from pyindicators import ema, rsi
138
+ from pyindicators import ema, rsi, crossunder, crossover, is_above
126
139
 
127
140
  from investing_algorithm_framework import create_app, TimeUnit, Context, BacktestDateRange, \
128
- CCXTOHLCVMarketDataSource, CCXTTickerMarketDataSource, DEFAULT_LOGGING_CONFIG, \
129
- TradingStrategy, SnapshotInterval, convert_polars_to_pandas, BacktestReport
141
+ DEFAULT_LOGGING_CONFIG, TradingStrategy, SnapshotInterval, BacktestReport, DataSource
130
142
 
131
143
  load_dotenv()
132
144
  logging.config.dictConfig(DEFAULT_LOGGING_CONFIG)
133
145
  logger = logging.getLogger(__name__)
134
146
 
135
- # OHLCV data for candles
136
- bitvavo_btc_eur_ohlcv_2h = CCXTOHLCVMarketDataSource(
137
- identifier="BTC-ohlcv",
138
- market="BITVAVO",
139
- symbol="BTC/EUR",
140
- time_frame="2h",
141
- window_size=200
142
- )
143
- # Ticker data for orders, trades and positions
144
- bitvavo_btc_eur_ticker = CCXTTickerMarketDataSource(
145
- identifier="BTC-ticker",
146
- market="BITVAVO",
147
- symbol="BTC/EUR",
148
- )
149
-
150
147
  app = create_app()
151
148
  # Registered bitvavo market, credentials are read from .env file by default
152
149
  app.add_market(market="BITVAVO", trading_symbol="EUR", initial_balance=100)
@@ -154,20 +151,23 @@ app.add_market(market="BITVAVO", trading_symbol="EUR", initial_balance=100)
154
151
  class MyStrategy(TradingStrategy):
155
152
  interval = 2
156
153
  time_unit = TimeUnit.HOUR
157
- data_sources = [bitvavo_btc_eur_ohlcv_2h, bitvavo_btc_eur_ticker]
154
+ data_sources = [
155
+ DataSource(data_type="OHLCV", market="bitvavo", symbol="BTC/EUR", window_size=200, time_frame="2h", identifier="BTC-ohlcv", pandas=True),
156
+ ]
157
+ symbols = ["BTC/EUR"]
158
158
 
159
- def run_strategy(self, context: Context, market_data):
159
+ def run_strategy(self, context: Context, data):
160
160
 
161
161
  if context.has_open_orders(target_symbol="BTC"):
162
162
  logger.info("There are open orders, skipping strategy iteration.")
163
163
  return
164
164
 
165
- print(market_data)
166
-
167
- data = convert_polars_to_pandas(market_data["BTC-ohlcv"])
165
+ data = data["BTC-ohlcv"]
168
166
  data = ema(data, source_column="Close", period=20, result_column="ema_20")
169
167
  data = ema(data, source_column="Close", period=50, result_column="ema_50")
170
168
  data = ema(data, source_column="Close", period=100, result_column="ema_100")
169
+ data = crossunder(data, first_column="ema_50", second_column="ema_100", result_column="crossunder_50_20")
170
+ data = crossover(data, first_column="ema_50", second_column="ema_100", result_column="crossover_50_20")
171
171
  data = rsi(data, source_column="Close", period=14, result_column="rsi_14")
172
172
 
173
173
  if context.has_position("BTC") and self.sell_signal(data):
@@ -182,20 +182,10 @@ class MyStrategy(TradingStrategy):
182
182
  )
183
183
  return
184
184
 
185
- def buy_signal(self, data):
186
- if len(data) < 100:
187
- return False
188
- last_row = data.iloc[-1]
189
- if last_row["ema_20"] > last_row["ema_50"] and last_row["ema_50"] > last_row["ema_100"]:
190
- return True
185
+ def buy_signal(self, data) -> bool:
191
186
  return False
192
187
 
193
- def sell_signal(self, data):
194
-
195
- if data["ema_20"].iloc[-1] < data["ema_50"].iloc[-1] and \
196
- data["ema_20"].iloc[-2] >= data["ema_50"].iloc[-2]:
197
- return True
198
-
188
+ def sell_signal(self, data) -> bool:
199
189
  return False
200
190
 
201
191
  date_range = BacktestDateRange(
@@ -206,7 +196,7 @@ app.add_strategy(MyStrategy)
206
196
  if __name__ == "__main__":
207
197
  # Run the backtest with a daily snapshot interval for end-of-day granular reporting
208
198
  backtest = app.run_backtest(
209
- backtest_date_range=date_range, initial_amount=100, snapshot_interval=SnapshotInterval.STRATEGY_ITERATION
199
+ backtest_date_range=date_range, initial_amount=100, snapshot_interval=SnapshotInterval.DAILY
210
200
  )
211
201
  backtest_report = BacktestReport(backtests=[backtest])
212
202
  backtest_report.show()
@@ -13,8 +13,18 @@
13
13
  <img src="static/showcase.svg" alt="Investing Algorithm Framework Logo" style="height: 50vh; max-height: 750px;">
14
14
  </div>
15
15
 
16
- The investing algorithm framework is a Python framework designed to help you build, backtest, and deploy quantitative trading strategies. It comes with a event-based backtesting engine, ensuring an accurate and realistic evaluation of your strategies. The framework supports live trading with multiple exchanges and has various deployment options including Azure Functions and AWS Lambda.
17
- The framework is designed to be extensible, allowing you to add custom strategies, data providers, and order executors. It also supports multiple data sources, including OHLCV, ticker, and custom data, with integration for both Polars and Pandas.
16
+ The Investing Algorithm Framework is a Python-based framework built to streamline the entire lifecycle of quantitative trading strategies from signal generation and backtesting to live deployment.
17
+ It offers a complete quantitative workflow, featuring two dedicated backtesting engines:
18
+
19
+ * A vectorized backtest engine for fast signal research and prototyping
20
+
21
+ * An event-based backtest engine for realistic and accurate strategy evaluation
22
+
23
+ The framework supports live trading across multiple exchanges and offers flexible deployment options, including Azure Functions and AWS Lambda.
24
+ Designed for extensibility, it allows you to integrate custom strategies, data providers, and order executors, enabling support for any exchange or broker.
25
+ It natively supports multiple data formats, including OHLCV, ticker, and custom datasets with seamless compatibility for both Pandas and Polars DataFrames.
26
+
27
+
18
28
 
19
29
  ## Sponsors
20
30
 
@@ -30,11 +40,14 @@ The framework is designed to be extensible, allowing you to add custom strategie
30
40
  ## 🌟 Features
31
41
 
32
42
  - [x] Python 3.10+: Cross-platform support for Windows, macOS, and Linux.
33
- - [x] Backtesting: Simulate strategies with detailed performance reports.
43
+ - [x] Event-Driven Backtest Engine: Accurate and realistic backtesting with event-driven architecture.
44
+ - [x] Vectorized Backtest Engine: Fast signal research and prototyping with vectorized operations.
45
+ - [x] Backtest Reporting: Generate detailed reports to analyse and compare backtests.
34
46
  - [x] Live Trading: Execute trades in real-time with support for multiple exchanges via ccxt.
35
47
  - [x] Portfolio Management: Manage portfolios, trades, and positions with persistence via SQLite.
36
48
  - [x] Market Data Sources: Fetch OHLCV, ticker, and custom data with support for Polars and Pandas.
37
- - [x] Azure Functions Support: Deploy stateless trading bots to Azure.
49
+ - [x] Azure Functions Support: Deploy trading bots to Azure.
50
+ - [x] AWS Lambda Support: Deploy trading bots to AWS Lambda.
38
51
  - [x] Web API: Interact with your bot via REST API.
39
52
  - [x] PyIndicators Integration: Perform technical analysis directly on your dataframes.
40
53
  - [x] Extensibility: Add custom strategies, data providers, order executors so you can connect your trading bot to your favorite exchange or broker.
@@ -86,31 +99,15 @@ the 20, 50 and 100 period exponential moving averages (EMA) and the
86
99
  import logging.config
87
100
  from dotenv import load_dotenv
88
101
 
89
- from pyindicators import ema, rsi
102
+ from pyindicators import ema, rsi, crossunder, crossover, is_above
90
103
 
91
104
  from investing_algorithm_framework import create_app, TimeUnit, Context, BacktestDateRange, \
92
- CCXTOHLCVMarketDataSource, CCXTTickerMarketDataSource, DEFAULT_LOGGING_CONFIG, \
93
- TradingStrategy, SnapshotInterval, convert_polars_to_pandas, BacktestReport
105
+ DEFAULT_LOGGING_CONFIG, TradingStrategy, SnapshotInterval, BacktestReport, DataSource
94
106
 
95
107
  load_dotenv()
96
108
  logging.config.dictConfig(DEFAULT_LOGGING_CONFIG)
97
109
  logger = logging.getLogger(__name__)
98
110
 
99
- # OHLCV data for candles
100
- bitvavo_btc_eur_ohlcv_2h = CCXTOHLCVMarketDataSource(
101
- identifier="BTC-ohlcv",
102
- market="BITVAVO",
103
- symbol="BTC/EUR",
104
- time_frame="2h",
105
- window_size=200
106
- )
107
- # Ticker data for orders, trades and positions
108
- bitvavo_btc_eur_ticker = CCXTTickerMarketDataSource(
109
- identifier="BTC-ticker",
110
- market="BITVAVO",
111
- symbol="BTC/EUR",
112
- )
113
-
114
111
  app = create_app()
115
112
  # Registered bitvavo market, credentials are read from .env file by default
116
113
  app.add_market(market="BITVAVO", trading_symbol="EUR", initial_balance=100)
@@ -118,20 +115,23 @@ app.add_market(market="BITVAVO", trading_symbol="EUR", initial_balance=100)
118
115
  class MyStrategy(TradingStrategy):
119
116
  interval = 2
120
117
  time_unit = TimeUnit.HOUR
121
- data_sources = [bitvavo_btc_eur_ohlcv_2h, bitvavo_btc_eur_ticker]
118
+ data_sources = [
119
+ DataSource(data_type="OHLCV", market="bitvavo", symbol="BTC/EUR", window_size=200, time_frame="2h", identifier="BTC-ohlcv", pandas=True),
120
+ ]
121
+ symbols = ["BTC/EUR"]
122
122
 
123
- def run_strategy(self, context: Context, market_data):
123
+ def run_strategy(self, context: Context, data):
124
124
 
125
125
  if context.has_open_orders(target_symbol="BTC"):
126
126
  logger.info("There are open orders, skipping strategy iteration.")
127
127
  return
128
128
 
129
- print(market_data)
130
-
131
- data = convert_polars_to_pandas(market_data["BTC-ohlcv"])
129
+ data = data["BTC-ohlcv"]
132
130
  data = ema(data, source_column="Close", period=20, result_column="ema_20")
133
131
  data = ema(data, source_column="Close", period=50, result_column="ema_50")
134
132
  data = ema(data, source_column="Close", period=100, result_column="ema_100")
133
+ data = crossunder(data, first_column="ema_50", second_column="ema_100", result_column="crossunder_50_20")
134
+ data = crossover(data, first_column="ema_50", second_column="ema_100", result_column="crossover_50_20")
135
135
  data = rsi(data, source_column="Close", period=14, result_column="rsi_14")
136
136
 
137
137
  if context.has_position("BTC") and self.sell_signal(data):
@@ -146,20 +146,10 @@ class MyStrategy(TradingStrategy):
146
146
  )
147
147
  return
148
148
 
149
- def buy_signal(self, data):
150
- if len(data) < 100:
151
- return False
152
- last_row = data.iloc[-1]
153
- if last_row["ema_20"] > last_row["ema_50"] and last_row["ema_50"] > last_row["ema_100"]:
154
- return True
149
+ def buy_signal(self, data) -> bool:
155
150
  return False
156
151
 
157
- def sell_signal(self, data):
158
-
159
- if data["ema_20"].iloc[-1] < data["ema_50"].iloc[-1] and \
160
- data["ema_20"].iloc[-2] >= data["ema_50"].iloc[-2]:
161
- return True
162
-
152
+ def sell_signal(self, data) -> bool:
163
153
  return False
164
154
 
165
155
  date_range = BacktestDateRange(
@@ -170,7 +160,7 @@ app.add_strategy(MyStrategy)
170
160
  if __name__ == "__main__":
171
161
  # Run the backtest with a daily snapshot interval for end-of-day granular reporting
172
162
  backtest = app.run_backtest(
173
- backtest_date_range=date_range, initial_amount=100, snapshot_interval=SnapshotInterval.STRATEGY_ITERATION
163
+ backtest_date_range=date_range, initial_amount=100, snapshot_interval=SnapshotInterval.DAILY
174
164
  )
175
165
  backtest_report = BacktestReport(backtests=[backtest])
176
166
  backtest_report.show()
@@ -0,0 +1,166 @@
1
+ from .app import App, Algorithm, \
2
+ TradingStrategy, StatelessAction, Task, AppHook, Context, \
3
+ add_html_report, BacktestReport, \
4
+ pretty_print_trades, pretty_print_positions, \
5
+ pretty_print_orders, pretty_print_backtest, select_backtest_date_ranges, \
6
+ get_equity_curve_with_drawdown_chart, \
7
+ get_rolling_sharpe_ratio_chart, rank_results, \
8
+ get_monthly_returns_heatmap_chart, defaults_ranking_weights, \
9
+ get_yearly_returns_bar_chart, get_entry_and_exit_signals, \
10
+ get_ohlcv_data_completeness_chart
11
+ from .domain import ApiException, \
12
+ OrderType, OperationalException, OrderStatus, OrderSide, \
13
+ TimeUnit, TimeInterval, Order, Portfolio, Backtest, \
14
+ Position, TimeFrame, INDEX_DATETIME, MarketCredential, \
15
+ PortfolioConfiguration, RESOURCE_DIRECTORY, AWS_LAMBDA_LOGGING_CONFIG, \
16
+ Trade, SYMBOLS, RESERVED_BALANCES, APP_MODE, AppMode, DATETIME_FORMAT, \
17
+ BacktestDateRange, convert_polars_to_pandas, \
18
+ DEFAULT_LOGGING_CONFIG, DataType, DataProvider, \
19
+ BacktestResult, TradeStatus, TradeRiskType, \
20
+ APPLICATION_DIRECTORY, DataSource, OrderExecutor, PortfolioProvider, \
21
+ SnapshotInterval, AWS_S3_STATE_BUCKET_NAME
22
+ from .infrastructure import AzureBlobStorageStateHandler, \
23
+ CSVOHLCVDataProvider, CCXTOHLCVDataProvider, PandasOHLCVDataProvider, \
24
+ AWSS3StorageStateHandler
25
+ from .create_app import create_app
26
+ from .download_data import download
27
+ from .services.metrics import get_annual_volatility, get_sortino_ratio, \
28
+ get_drawdown_series, get_max_drawdown, get_equity_curve, \
29
+ get_price_efficiency_ratio, get_sharpe_ratio, \
30
+ get_profit_factor, get_cumulative_profit_factor_series, \
31
+ get_rolling_profit_factor_series, get_cagr, \
32
+ get_standard_deviation_returns, get_standard_deviation_downside_returns, \
33
+ get_max_drawdown_absolute, get_total_return, get_exposure, \
34
+ get_average_trade_duration, get_win_rate, get_win_loss_ratio, \
35
+ get_calmar_ratio, get_trade_frequency, get_yearly_returns, \
36
+ get_monthly_returns, get_best_year, get_best_month, get_worst_year, \
37
+ get_worst_month, get_best_trade, get_worst_trade, \
38
+ get_average_yearly_return, get_average_gain, get_average_loss, \
39
+ get_average_monthly_return, get_percentage_winning_months, \
40
+ get_max_drawdown_duration, get_max_daily_drawdown, get_trades_per_day, \
41
+ get_trades_per_year, get_average_monthly_return_losing_months, \
42
+ get_average_monthly_return_winning_months, get_percentage_winning_years, \
43
+ get_rolling_sharpe_ratio, create_backtest_metrics, get_growth, \
44
+ get_growth_percentage
45
+
46
+
47
+ __all__ = [
48
+ "Algorithm",
49
+ "RESOURCE_DIRECTORY",
50
+ "App",
51
+ "AppHook",
52
+ "create_app",
53
+ "ApiException",
54
+ "OrderType",
55
+ "OrderStatus",
56
+ "OrderSide",
57
+ "PortfolioConfiguration",
58
+ "TimeUnit",
59
+ "TimeInterval",
60
+ "TradingStrategy",
61
+ "Order",
62
+ "Portfolio",
63
+ "Position",
64
+ "StatelessAction",
65
+ "Task",
66
+ "pretty_print_backtest",
67
+ "INDEX_DATETIME",
68
+ "Trade",
69
+ "TimeFrame",
70
+ "MarketCredential",
71
+ "OperationalException",
72
+ "SYMBOLS",
73
+ "RESERVED_BALANCES",
74
+ "APP_MODE",
75
+ "AppMode",
76
+ "DATETIME_FORMAT",
77
+ "Backtest",
78
+ "BacktestResult",
79
+ "BacktestDateRange",
80
+ "convert_polars_to_pandas",
81
+ "AzureBlobStorageStateHandler",
82
+ "DEFAULT_LOGGING_CONFIG",
83
+ "BacktestReport",
84
+ "TradeStatus",
85
+ "TradeRiskType",
86
+ "Context",
87
+ "APPLICATION_DIRECTORY",
88
+ "download",
89
+ "pretty_print_orders",
90
+ "pretty_print_trades",
91
+ "pretty_print_positions",
92
+ "DataSource",
93
+ "OrderExecutor",
94
+ "PortfolioProvider",
95
+ "SnapshotInterval",
96
+ "add_html_report",
97
+ "AWSS3StorageStateHandler",
98
+ "AWS_S3_STATE_BUCKET_NAME",
99
+ "AWS_LAMBDA_LOGGING_CONFIG",
100
+ 'select_backtest_date_ranges',
101
+ 'DataType',
102
+ 'CSVOHLCVDataProvider',
103
+ "CCXTOHLCVDataProvider",
104
+ "DataProvider",
105
+ "get_annual_volatility",
106
+ "get_sortino_ratio",
107
+ "get_drawdown_series",
108
+ "get_max_drawdown",
109
+ "get_equity_curve",
110
+ "get_price_efficiency_ratio",
111
+ "get_sharpe_ratio",
112
+ "get_profit_factor",
113
+ "get_cumulative_profit_factor_series",
114
+ "get_rolling_profit_factor_series",
115
+ "get_sharpe_ratio",
116
+ "get_cagr",
117
+ "get_standard_deviation_returns",
118
+ "get_standard_deviation_downside_returns",
119
+ "get_max_drawdown_absolute",
120
+ "get_total_return",
121
+ "get_exposure",
122
+ "get_average_trade_duration",
123
+ "get_win_rate",
124
+ "get_win_loss_ratio",
125
+ "get_calmar_ratio",
126
+ "get_trade_frequency",
127
+ "get_yearly_returns",
128
+ "get_monthly_returns",
129
+ "get_best_year",
130
+ "get_best_month",
131
+ "get_worst_year",
132
+ "get_worst_month",
133
+ "get_best_trade",
134
+ "get_worst_trade",
135
+ "get_average_yearly_return",
136
+ "get_average_gain",
137
+ "get_average_loss",
138
+ "get_average_monthly_return",
139
+ "get_percentage_winning_months",
140
+ "get_average_trade_duration",
141
+ "get_trade_frequency",
142
+ "get_win_rate",
143
+ "get_win_loss_ratio",
144
+ "get_calmar_ratio",
145
+ "get_max_drawdown_absolute",
146
+ "get_max_drawdown_duration",
147
+ "get_max_daily_drawdown",
148
+ "get_trades_per_day",
149
+ "get_trades_per_year",
150
+ "get_average_monthly_return_losing_months",
151
+ "get_average_monthly_return_winning_months",
152
+ "get_percentage_winning_years",
153
+ "get_rolling_sharpe_ratio",
154
+ "create_backtest_metrics",
155
+ "PandasOHLCVDataProvider",
156
+ "get_equity_curve_with_drawdown_chart",
157
+ "get_rolling_sharpe_ratio_chart",
158
+ "get_monthly_returns_heatmap_chart",
159
+ "get_yearly_returns_bar_chart",
160
+ "get_ohlcv_data_completeness_chart",
161
+ "rank_results",
162
+ "defaults_ranking_weights",
163
+ "get_entry_and_exit_signals",
164
+ "get_growth",
165
+ "get_growth_percentage"
166
+ ]
@@ -7,8 +7,14 @@ from .algorithm import Algorithm
7
7
  from .context import Context
8
8
  from .reporting import add_html_report, \
9
9
  BacktestReport, pretty_print_backtest, pretty_print_trades, \
10
- pretty_print_positions, pretty_print_orders
11
- from .analysis import select_backtest_date_ranges
10
+ pretty_print_positions, pretty_print_orders, \
11
+ get_equity_curve_with_drawdown_chart, \
12
+ get_rolling_sharpe_ratio_chart, \
13
+ get_monthly_returns_heatmap_chart, \
14
+ get_yearly_returns_bar_chart, \
15
+ get_ohlcv_data_completeness_chart, get_entry_and_exit_signals
16
+ from .analysis import select_backtest_date_ranges, rank_results, \
17
+ defaults_ranking_weights
12
18
 
13
19
 
14
20
  __all__ = [
@@ -26,5 +32,13 @@ __all__ = [
26
32
  "pretty_print_trades",
27
33
  "pretty_print_positions",
28
34
  "pretty_print_orders",
29
- "select_backtest_date_ranges"
35
+ "select_backtest_date_ranges",
36
+ "get_equity_curve_with_drawdown_chart",
37
+ "get_rolling_sharpe_ratio_chart",
38
+ "get_monthly_returns_heatmap_chart",
39
+ "get_yearly_returns_bar_chart",
40
+ "get_ohlcv_data_completeness_chart",
41
+ "rank_results",
42
+ "defaults_ranking_weights",
43
+ "get_entry_and_exit_signals"
30
44
  ]
@@ -6,7 +6,7 @@ from typing import List
6
6
  from investing_algorithm_framework.app.app_hook import AppHook
7
7
  from investing_algorithm_framework.app.strategy import TradingStrategy
8
8
  from investing_algorithm_framework.domain import OperationalException, \
9
- MarketDataSource
9
+ DataSource
10
10
 
11
11
  logger = logging.getLogger("investing_algorithm_framework")
12
12
 
@@ -32,7 +32,7 @@ class Algorithm:
32
32
  strategy=None,
33
33
  strategies=None,
34
34
  tasks: List = None,
35
- data_sources: List[MarketDataSource] = None,
35
+ data_sources: List[DataSource] = None,
36
36
  on_strategy_run_hooks=None
37
37
  ):
38
38
  self._name = name
@@ -210,9 +210,6 @@ class Algorithm:
210
210
  "with the same id in the algorithm"
211
211
  )
212
212
 
213
- if strategy.market_data_sources is not None:
214
- self.add_data_sources(strategy.market_data_sources)
215
-
216
213
  self._strategies.append(strategy)
217
214
 
218
215
  def add_task(self, task):
@@ -221,41 +218,6 @@ class Algorithm:
221
218
 
222
219
  self._tasks.append(task)
223
220
 
224
- def add_data_source(self, data_source) -> None:
225
- """
226
- Function to add a data source to the app. The data source should
227
- be an instance of DataSource.
228
-
229
- Args:
230
- data_source: Instance of DataSource
231
-
232
- Returns:
233
- None
234
- """
235
- if inspect.isclass(data_source):
236
- if not issubclass(data_source, MarketDataSource):
237
- raise OperationalException(
238
- "Data source should be an instance of MarketDataSource"
239
- )
240
-
241
- data_source = data_source()
242
-
243
- self.data_sources.append(data_source)
244
-
245
- def add_data_sources(self, data_sources) -> None:
246
- """
247
- Function to add a list of data sources to the app. The data sources
248
- should be instances of DataSource.
249
-
250
- Args:
251
- data_sources: List of DataSource
252
-
253
- Returns:
254
- None
255
- """
256
- for data_source in data_sources:
257
- self.add_data_source(data_source)
258
-
259
221
  def add_on_strategy_run_hook(self, app_hook):
260
222
  """
261
223
  Function to add a hook that will be called when a strategy is run.
@@ -56,7 +56,6 @@ class AlgorithmFactory:
56
56
  strategies=None,
57
57
  tasks=None,
58
58
  on_strategy_run_hooks=None,
59
- data_sources=None
60
59
  ) -> Algorithm:
61
60
  """
62
61
  Create an instance of the specified algorithm type.
@@ -69,7 +68,6 @@ class AlgorithmFactory:
69
68
  tasks (list): List of Task instances.
70
69
  on_strategy_run_hooks (list): List of hooks to be called
71
70
  when a strategy is run.
72
- data_sources (list): List of MarketDataSource instances.
73
71
 
74
72
  Returns:
75
73
  Algorithm: Instance of Algorithm.
@@ -78,21 +76,30 @@ class AlgorithmFactory:
78
76
  strategies = strategies or []
79
77
  tasks = tasks or []
80
78
  on_strategy_run_hooks = on_strategy_run_hooks or []
81
- data_sources = data_sources or []
79
+ data_sources = []
82
80
 
83
- if algorithm is not None:
81
+ if algorithm is not None and isinstance(algorithm, Algorithm):
82
+ if name is None:
83
+ name = algorithm.name
84
84
 
85
- for task in tasks:
86
- algorithm.add_task(task)
85
+ strategies.extend(algorithm.strategies)
86
+ tasks.extend(algorithm.tasks)
87
+ on_strategy_run_hooks.extend(algorithm.on_strategy_run_hooks)
87
88
 
88
- for app_hook in on_strategy_run_hooks:
89
- algorithm.add_on_strategy_run_hook(app_hook)
89
+ if hasattr(algorithm, 'data_sources'):
90
+ data_sources.extend(algorithm.data_sources)
90
91
 
91
- return algorithm
92
+ if strategy is not None:
93
+ strategies.append(strategy)
94
+ data_sources.extend(strategy.data_sources)
95
+
96
+ for strategy_entry in strategies:
97
+ if strategy_entry.data_sources is not None \
98
+ and len(strategy_entry.data_sources):
99
+ data_sources.extend(strategy_entry.data_sources)
92
100
 
93
101
  algorithm = Algorithm(
94
102
  name=name,
95
- strategy=strategy,
96
103
  strategies=strategies,
97
104
  tasks=tasks,
98
105
  on_strategy_run_hooks=on_strategy_run_hooks,
@@ -0,0 +1,8 @@
1
+ from .backtest_data_ranges import select_backtest_date_ranges
2
+ from .ranking import rank_results, defaults_ranking_weights
3
+
4
+ __all__ = [
5
+ "select_backtest_date_ranges",
6
+ "rank_results",
7
+ "defaults_ranking_weights"
8
+ ]
@@ -1,7 +1,9 @@
1
1
  import pandas as pd
2
+ from typing import List, Union
3
+
4
+ from datetime import timezone
2
5
  from investing_algorithm_framework.domain import BacktestDateRange, \
3
6
  OperationalException
4
- from typing import List, Union
5
7
 
6
8
 
7
9
  def select_backtest_date_ranges(
@@ -11,6 +13,18 @@ def select_backtest_date_ranges(
11
13
  Identifies the best upturn, worst downturn, and sideways periods
12
14
  for the given window duration. This allows you to quickly select
13
15
  interesting periods for backtesting.
16
+
17
+ Args:
18
+ df (pd.DataFrame): DataFrame with a DateTime index
19
+ and 'Close' column.
20
+ window (Union[str, int]): Duration of the window
21
+ to analyze. Can be a string like '365D' or an
22
+ integer representing days.
23
+
24
+ Returns:
25
+ List[BacktestDateRange]: List of BacktestDateRange
26
+ objects representing the best upturn, worst
27
+ downturn, and most sideways periods.
14
28
  """
15
29
  df = df.copy()
16
30
  df = df.sort_index()
@@ -22,6 +36,15 @@ def select_backtest_date_ranges(
22
36
  else:
23
37
  raise OperationalException("window must be a string or integer")
24
38
 
39
+ # Check if the window is larger than the DataFrame
40
+ if len(df) == 0:
41
+ raise OperationalException("DataFrame is empty")
42
+
43
+ if df.index[-1] - df.index[0] < window:
44
+ raise OperationalException(
45
+ "Window duration is larger than the data duration"
46
+ )
47
+
25
48
  if len(df) < 2 or df.index[-1] - df.index[0] < window:
26
49
  raise OperationalException(
27
50
  "DataFrame must contain at least two rows and span "
@@ -55,9 +78,11 @@ def select_backtest_date_ranges(
55
78
  ret = (end_price / start_price) - 1 # relative return
56
79
  volatility = window_df['Close'].std()
57
80
 
58
- # Ensure datetime for BacktestDateRange
81
+ # Ensure datetime for BacktestDateRange and with timezone utc
59
82
  start_time = pd.Timestamp(start_time).to_pydatetime()
83
+ start_time = start_time.replace(tzinfo=timezone.utc)
60
84
  end_time = pd.Timestamp(window_df.index[-1]).to_pydatetime()
85
+ end_time = end_time.replace(tzinfo=timezone.utc)
61
86
 
62
87
  if ret > best_upturn["return"]:
63
88
  best_upturn.update(