investing-algorithm-framework 6.8.2__tar.gz → 6.9.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 (265) hide show
  1. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/PKG-INFO +82 -20
  2. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/README.md +79 -19
  3. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/__init__.py +18 -50
  4. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/__init__.py +11 -0
  5. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/app.py +42 -12
  6. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/context.py +148 -0
  7. investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/__init__.py +16 -0
  8. investing_algorithm_framework-6.8.2/investing_algorithm_framework/domain/utils/backtesting.py → investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/ascii.py +61 -297
  9. investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/backtest_report.py +235 -0
  10. investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/charts/__init__.py +11 -0
  11. investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/charts/equity_curve_drawdown.py +89 -0
  12. investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/charts/monthly_returns_heatmap.py +70 -0
  13. investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/charts/rolling_sharp_ratio.py +79 -0
  14. investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/charts/yearly_returns_barchart.py +55 -0
  15. investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/generate.py +199 -0
  16. investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/metrics/__init__.py +83 -0
  17. {investing_algorithm_framework-6.8.2/investing_algorithm_framework → investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting}/metrics/cagr.py +4 -8
  18. {investing_algorithm_framework-6.8.2/investing_algorithm_framework → investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting}/metrics/calmar_ratio.py +7 -6
  19. {investing_algorithm_framework-6.8.2/investing_algorithm_framework → investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting}/metrics/drawdown.py +84 -16
  20. {investing_algorithm_framework-6.8.2/investing_algorithm_framework → investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting}/metrics/equity_curve.py +5 -6
  21. investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/metrics/exposure.py +152 -0
  22. {investing_algorithm_framework-6.8.2/investing_algorithm_framework → investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting}/metrics/mean_daily_return.py +3 -4
  23. {investing_algorithm_framework-6.8.2/investing_algorithm_framework → investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting}/metrics/profit_factor.py +23 -15
  24. {investing_algorithm_framework-6.8.2/investing_algorithm_framework → investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting}/metrics/recovery.py +12 -14
  25. investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/metrics/returns.py +453 -0
  26. {investing_algorithm_framework-6.8.2/investing_algorithm_framework → investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting}/metrics/sharp_ratio.py +61 -7
  27. {investing_algorithm_framework-6.8.2/investing_algorithm_framework → investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting}/metrics/sortino_ratio.py +14 -10
  28. {investing_algorithm_framework-6.8.2/investing_algorithm_framework → investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting}/metrics/standard_deviation.py +3 -5
  29. investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/metrics/treynor_ratio.py +0 -0
  30. investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/metrics/ulcer.py +0 -0
  31. investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/metrics/value_at_risk.py +0 -0
  32. investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/metrics/volatility.py +69 -0
  33. {investing_algorithm_framework-6.8.2/investing_algorithm_framework → investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting}/metrics/win_rate.py +25 -12
  34. investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/tables/__init__.py +11 -0
  35. investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/tables/key_metrics_table.py +209 -0
  36. investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/tables/stop_loss_table.py +0 -0
  37. investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/tables/time_metrics_table.py +73 -0
  38. investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/tables/trade_metrics_table.py +143 -0
  39. investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/tables/trades_table.py +75 -0
  40. investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/tables/utils.py +28 -0
  41. investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/templates/report_template.html.j2 +160 -0
  42. investing_algorithm_framework-6.9.0/investing_algorithm_framework/cli/__init__.py +0 -0
  43. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/cli/cli.py +60 -4
  44. investing_algorithm_framework-6.9.0/investing_algorithm_framework/cli/deploy_to_aws_lambda.py +404 -0
  45. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/cli/deploy_to_azure_function.py +0 -1
  46. investing_algorithm_framework-6.9.0/investing_algorithm_framework/cli/initialize_app.py +584 -0
  47. investing_algorithm_framework-6.9.0/investing_algorithm_framework/cli/templates/app_aws_lambda_function.py.template +36 -0
  48. investing_algorithm_framework-6.9.0/investing_algorithm_framework/cli/templates/aws_lambda_readme.md.template +110 -0
  49. investing_algorithm_framework-6.9.0/investing_algorithm_framework/cli/templates/aws_lambda_requirements.txt.template +2 -0
  50. investing_algorithm_framework-6.9.0/investing_algorithm_framework/cli/templates/azure_function_requirements.txt.template +3 -0
  51. investing_algorithm_framework-6.9.0/investing_algorithm_framework/cli/templates/env.example.template +2 -0
  52. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/cli/templates/readme.md.template +1 -1
  53. investing_algorithm_framework-6.9.0/investing_algorithm_framework/cli/templates/requirements.txt.template +2 -0
  54. investing_algorithm_framework-6.9.0/investing_algorithm_framework/cli/templates/requirements_azure_function.txt.template +3 -0
  55. investing_algorithm_framework-6.9.0/investing_algorithm_framework/cli/templates/run_backtest.py.template +20 -0
  56. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/dependency_container.py +1 -0
  57. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/__init__.py +11 -21
  58. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/constants.py +3 -0
  59. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/data_provider.py +3 -1
  60. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/__init__.py +3 -3
  61. investing_algorithm_framework-6.9.0/investing_algorithm_framework/domain/models/backtesting/__init__.py +9 -0
  62. investing_algorithm_framework-6.9.0/investing_algorithm_framework/domain/models/backtesting/backtest_reports_evaluation.py +0 -0
  63. investing_algorithm_framework-6.9.0/investing_algorithm_framework/domain/models/backtesting/backtest_results.py +440 -0
  64. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/market/market_credential.py +2 -1
  65. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/portfolio/portfolio_snapshot.py +4 -1
  66. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/snapshot_interval.py +1 -0
  67. investing_algorithm_framework-6.9.0/investing_algorithm_framework/domain/models/tracing/__init__.py +0 -0
  68. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/trade/trade.py +0 -78
  69. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/trade/trade_stop_loss.py +29 -3
  70. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/trade/trade_take_profit.py +27 -3
  71. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/utils/__init__.py +0 -12
  72. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/__init__.py +3 -2
  73. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/repositories/order_repository.py +0 -1
  74. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/services/__init__.py +3 -1
  75. investing_algorithm_framework-6.9.0/investing_algorithm_framework/infrastructure/services/aws/__init__.py +6 -0
  76. investing_algorithm_framework-6.9.0/investing_algorithm_framework/infrastructure/services/aws/state_handler.py +113 -0
  77. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/backtesting/backtest_service.py +57 -346
  78. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/pyproject.toml +3 -1
  79. investing_algorithm_framework-6.8.2/investing_algorithm_framework/cli/initialize_app.py +0 -311
  80. investing_algorithm_framework-6.8.2/investing_algorithm_framework/cli/templates/app_web.py.template +0 -18
  81. investing_algorithm_framework-6.8.2/investing_algorithm_framework/cli/templates/env.example.template +0 -2
  82. investing_algorithm_framework-6.8.2/investing_algorithm_framework/cli/templates/requirements.txt.template +0 -2
  83. investing_algorithm_framework-6.8.2/investing_algorithm_framework/cli/templates/requirements_azure_function.txt.template +0 -3
  84. investing_algorithm_framework-6.8.2/investing_algorithm_framework/cli/templates/run_backtest.py.template +0 -13
  85. investing_algorithm_framework-6.8.2/investing_algorithm_framework/domain/models/backtesting/__init__.py +0 -11
  86. investing_algorithm_framework-6.8.2/investing_algorithm_framework/domain/models/backtesting/backtest_report.py +0 -735
  87. investing_algorithm_framework-6.8.2/investing_algorithm_framework/metrics/__init__.py +0 -46
  88. investing_algorithm_framework-6.8.2/investing_algorithm_framework/metrics/exposure.py +0 -85
  89. investing_algorithm_framework-6.8.2/investing_algorithm_framework/metrics/net_profit.py +0 -17
  90. investing_algorithm_framework-6.8.2/investing_algorithm_framework/metrics/volatility.py +0 -56
  91. investing_algorithm_framework-6.8.2/investing_algorithm_framework/overfitting/__init__.py +0 -9
  92. investing_algorithm_framework-6.8.2/investing_algorithm_framework/overfitting/permutations.py +0 -101
  93. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/LICENSE +0 -0
  94. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/algorithm/__init__.py +0 -0
  95. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/algorithm/algorithm.py +0 -0
  96. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/algorithm/algorithm_factory.py +0 -0
  97. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/app_hook.py +0 -0
  98. /investing_algorithm_framework-6.8.2/investing_algorithm_framework/domain/models/backtesting/backtest_reports_evaluation.py → /investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/evaluation.py +0 -0
  99. /investing_algorithm_framework-6.8.2/investing_algorithm_framework/cli/__init__.py → /investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/metrics/alpha.py +0 -0
  100. /investing_algorithm_framework-6.8.2/investing_algorithm_framework/domain/models/tracing/__init__.py → /investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting/metrics/beta.py +0 -0
  101. {investing_algorithm_framework-6.8.2/investing_algorithm_framework → investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting}/metrics/price_efficiency.py +0 -0
  102. {investing_algorithm_framework-6.8.2/investing_algorithm_framework → investing_algorithm_framework-6.9.0/investing_algorithm_framework/app/reporting}/metrics/risk_free_rate.py +0 -0
  103. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/stateless/__init__.py +0 -0
  104. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/stateless/action_handlers/__init__.py +0 -0
  105. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/stateless/action_handlers/action_handler_strategy.py +0 -0
  106. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/stateless/action_handlers/check_online_handler.py +0 -0
  107. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/stateless/action_handlers/run_strategy_handler.py +0 -0
  108. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/stateless/exception_handler.py +0 -0
  109. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/strategy.py +0 -0
  110. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/task.py +0 -0
  111. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/web/__init__.py +0 -0
  112. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/web/controllers/__init__.py +0 -0
  113. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/web/controllers/orders.py +0 -0
  114. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/web/controllers/portfolio.py +0 -0
  115. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/web/controllers/positions.py +0 -0
  116. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/web/create_app.py +0 -0
  117. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/web/error_handler.py +0 -0
  118. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/web/responses.py +0 -0
  119. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/web/run_strategies.py +0 -0
  120. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/web/schemas/__init__.py +0 -0
  121. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/web/schemas/order.py +0 -0
  122. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/web/schemas/portfolio.py +0 -0
  123. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/web/schemas/position.py +0 -0
  124. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/app/web/setup_cors.py +0 -0
  125. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/cli/templates/.gitignore.template +0 -0
  126. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/cli/templates/app.py.template +0 -0
  127. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/cli/templates/app_azure_function.py.template +0 -0
  128. /investing_algorithm_framework-6.8.2/investing_algorithm_framework/cli/templates/app-web.py.template → /investing_algorithm_framework-6.9.0/investing_algorithm_framework/cli/templates/app_web.py.template +0 -0
  129. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/cli/templates/azure_function_function_app.py.template +0 -0
  130. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/cli/templates/azure_function_host.json.template +0 -0
  131. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/cli/templates/azure_function_local.settings.json.template +0 -0
  132. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/cli/templates/data_providers.py.template +0 -0
  133. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/cli/templates/env_azure_function.example.template +0 -0
  134. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/cli/templates/market_data_providers.py.template +0 -0
  135. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/cli/templates/strategy.py.template +0 -0
  136. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/create_app.py +0 -0
  137. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/config.py +0 -0
  138. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/data_structures.py +0 -0
  139. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/decimal_parsing.py +0 -0
  140. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/exceptions.py +0 -0
  141. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/app_mode.py +0 -0
  142. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/backtesting/backtest_date_range.py +0 -0
  143. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/backtesting/backtest_position.py +0 -0
  144. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/base_model.py +0 -0
  145. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/data_source.py +0 -0
  146. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/date_range.py +0 -0
  147. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/event.py +0 -0
  148. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/market/__init__.py +0 -0
  149. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/market_data_type.py +0 -0
  150. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/order/__init__.py +0 -0
  151. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/order/order.py +0 -0
  152. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/order/order_side.py +0 -0
  153. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/order/order_status.py +0 -0
  154. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/order/order_type.py +0 -0
  155. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/portfolio/__init__.py +0 -0
  156. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/portfolio/portfolio.py +0 -0
  157. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/portfolio/portfolio_configuration.py +0 -0
  158. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/position/__init__.py +0 -0
  159. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/position/position.py +0 -0
  160. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/position/position_snapshot.py +0 -0
  161. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/strategy_profile.py +0 -0
  162. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/time_frame.py +0 -0
  163. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/time_interval.py +0 -0
  164. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/time_unit.py +0 -0
  165. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/tracing/trace.py +0 -0
  166. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/trade/__init__.py +0 -0
  167. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/trade/trade_risk_type.py +0 -0
  168. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/trade/trade_status.py +0 -0
  169. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/trading_data_types.py +0 -0
  170. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/models/trading_time_frame.py +0 -0
  171. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/order_executor.py +0 -0
  172. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/portfolio_provider.py +0 -0
  173. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/services/__init__.py +0 -0
  174. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/services/market_credential_service.py +0 -0
  175. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/services/market_data_sources.py +0 -0
  176. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/services/market_service.py +0 -0
  177. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/services/observable.py +0 -0
  178. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/services/observer.py +0 -0
  179. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/services/portfolios/__init__.py +0 -0
  180. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/services/portfolios/portfolio_sync_service.py +0 -0
  181. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/services/rounding_service.py +0 -0
  182. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/services/state_handler.py +0 -0
  183. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/stateless_actions.py +0 -0
  184. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/strategy.py +0 -0
  185. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/utils/csv.py +0 -0
  186. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/utils/dates.py +0 -0
  187. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/utils/polars.py +0 -0
  188. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/utils/random.py +0 -0
  189. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/utils/signatures.py +0 -0
  190. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/utils/stoppable_thread.py +0 -0
  191. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/domain/utils/synchronized.py +0 -0
  192. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/download_data.py +0 -0
  193. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/data_providers/__init__.py +0 -0
  194. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/data_providers/ccxt.py +0 -0
  195. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/data_providers/csv.py +0 -0
  196. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/database/__init__.py +0 -0
  197. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/database/sql_alchemy.py +0 -0
  198. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/models/__init__.py +0 -0
  199. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/models/decimal_parser.py +0 -0
  200. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/models/market_data_sources/__init__.py +0 -0
  201. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/models/market_data_sources/ccxt.py +0 -0
  202. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/models/market_data_sources/csv.py +0 -0
  203. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/models/market_data_sources/pandas.py +0 -0
  204. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/models/model_extension.py +0 -0
  205. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/models/order/__init__.py +0 -0
  206. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/models/order/order.py +0 -0
  207. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/models/order/order_metadata.py +0 -0
  208. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/models/order_trade_association.py +0 -0
  209. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/models/portfolio/__init__.py +0 -0
  210. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/models/portfolio/portfolio_snapshot.py +0 -0
  211. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/models/portfolio/sql_portfolio.py +0 -0
  212. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/models/position/__init__.py +0 -0
  213. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/models/position/position.py +0 -0
  214. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/models/position/position_snapshot.py +0 -0
  215. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/models/trades/__init__.py +0 -0
  216. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/models/trades/trade.py +0 -0
  217. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/models/trades/trade_stop_loss.py +0 -0
  218. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/models/trades/trade_take_profit.py +0 -0
  219. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/order_executors/__init__.py +0 -0
  220. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/order_executors/ccxt_order_executor.py +0 -0
  221. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/portfolio_providers/__init__.py +0 -0
  222. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/portfolio_providers/ccxt_portfolio_provider.py +0 -0
  223. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/repositories/__init__.py +0 -0
  224. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/repositories/order_metadata_repository.py +0 -0
  225. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/repositories/portfolio_repository.py +0 -0
  226. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/repositories/portfolio_snapshot_repository.py +0 -0
  227. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/repositories/position_repository.py +0 -0
  228. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/repositories/position_snapshot_repository.py +0 -0
  229. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/repositories/repository.py +0 -0
  230. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/repositories/trade_repository.py +0 -0
  231. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/repositories/trade_stop_loss_repository.py +0 -0
  232. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/repositories/trade_take_profit_repository.py +0 -0
  233. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/services/azure/__init__.py +0 -0
  234. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/services/azure/state_handler.py +0 -0
  235. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/services/market_service/__init__.py +0 -0
  236. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/services/market_service/ccxt_market_service.py +0 -0
  237. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/services/performance_service/__init__.py +0 -0
  238. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/services/performance_service/backtest_performance_service.py +0 -0
  239. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/infrastructure/services/performance_service/performance_service.py +0 -0
  240. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/__init__.py +0 -0
  241. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/backtesting/__init__.py +0 -0
  242. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/configuration_service.py +0 -0
  243. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/market_credential_service.py +0 -0
  244. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/market_data_source_service/__init__.py +0 -0
  245. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/market_data_source_service/backtest_market_data_source_service.py +0 -0
  246. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/market_data_source_service/data_provider_service.py +0 -0
  247. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/market_data_source_service/market_data_source_service.py +0 -0
  248. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/order_service/__init__.py +0 -0
  249. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/order_service/order_backtest_service.py +0 -0
  250. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/order_service/order_executor_lookup.py +0 -0
  251. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/order_service/order_service.py +0 -0
  252. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/portfolios/__init__.py +0 -0
  253. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/portfolios/backtest_portfolio_service.py +0 -0
  254. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/portfolios/portfolio_configuration_service.py +0 -0
  255. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/portfolios/portfolio_provider_lookup.py +0 -0
  256. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/portfolios/portfolio_service.py +0 -0
  257. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/portfolios/portfolio_snapshot_service.py +0 -0
  258. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/portfolios/portfolio_sync_service.py +0 -0
  259. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/positions/__init__.py +0 -0
  260. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/positions/position_service.py +0 -0
  261. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/positions/position_snapshot_service.py +0 -0
  262. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/repository_service.py +0 -0
  263. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/strategy_orchestrator_service.py +0 -0
  264. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/trade_service/__init__.py +0 -0
  265. {investing_algorithm_framework-6.8.2 → investing_algorithm_framework-6.9.0}/investing_algorithm_framework/services/trade_service/trade_service.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: investing-algorithm-framework
3
- Version: 6.8.2
3
+ Version: 6.9.0
4
4
  Summary: A framework for creating trading bots
5
5
  Author: MDUYN
6
6
  Requires-Python: >=3.10
@@ -17,10 +17,12 @@ Requires-Dist: azure-mgmt-resource (>=23.2.0,<24.0.0)
17
17
  Requires-Dist: azure-mgmt-storage (>=21.2.1,<22.0.0)
18
18
  Requires-Dist: azure-mgmt-web (>=7.3.1,<8.0.0)
19
19
  Requires-Dist: azure-storage-blob (>=12.24.0,<13.0.0)
20
+ Requires-Dist: boto3 (>=1.38.41,<2.0.0)
20
21
  Requires-Dist: ccxt (>=4.2.48)
21
22
  Requires-Dist: dependency-injector (>=4.40.0)
22
23
  Requires-Dist: jupyter (>=1.0.0)
23
24
  Requires-Dist: marshmallow (>=3.5.0)
25
+ Requires-Dist: plotly (>=6.1.2,<7.0.0)
24
26
  Requires-Dist: polars[numpy,pandas] (>=0.20.10)
25
27
  Requires-Dist: pyarrow (>=19.0.1)
26
28
  Requires-Dist: python-dateutil (>=2.8.2)
@@ -43,13 +45,20 @@ Description-Content-Type: text/markdown
43
45
 
44
46
  > If you like what we do, consider starring, sharing and contributing!
45
47
 
48
+ <div align="center">
49
+ <img src="static/showcase.svg" alt="Investing Algorithm Framework Logo" style="height: 50vh; max-height: 750px;">
50
+ </div>
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.
54
+
46
55
  ## Sponsors
47
56
 
48
57
  <a href="https://www.finterion.com/" target="_blank">
49
58
  <picture style="height: 30px;">
50
59
  <source media="(prefers-color-scheme: dark)" srcset="static/sponsors/finterion-dark.png">
51
60
  <source media="(prefers-color-scheme: light)" srcset="static/sponsors/finterion-light.png">
52
- <img src="static/sponsors/finterion-light.svg" alt="Finterion Logo" width="200px" height="50px">
61
+ <img src="static/sponsors/finterion-light.png" alt="Finterion Logo" width="200px" height="50px">
53
62
  </picture>
54
63
  </a>
55
64
 
@@ -100,17 +109,30 @@ This will create:
100
109
  ---
101
110
 
102
111
  ## 📈 Example: A Simple Trading Bot
103
- The following example connects to Binance and buys BTC every 2 hours.
112
+ The following example trading bot implements a simple moving average strategy.
113
+ The strategy will use data from bitvavo exchange and will calculate
114
+ the 20, 50 and 100 period exponential moving averages (EMA) and the
115
+ 14 period relative strength index (RSI).
116
+
117
+ > This example uses [PyIndicators](https://github.com/coding-kitties/pyindicators) for technical analysis.
118
+ > This dependency is not part of the framework, but is used to perform technical analysis on the dataframes.
119
+ > You can install it using pip: pip install pyindicators.
120
+
121
+ ```bash
104
122
 
105
123
  ```python
106
124
  import logging.config
107
125
  from dotenv import load_dotenv
108
126
 
109
- from investing_algorithm_framework import create_app, TimeUnit, Context, \
110
- CCXTOHLCVMarketDataSource, CCXTTickerMarketDataSource, DEFAULT_LOGGING_CONFIG
127
+ from pyindicators import ema, rsi
128
+
129
+ from investing_algorithm_framework import create_app, TimeUnit, Context, BacktestDateRange, \
130
+ CCXTOHLCVMarketDataSource, CCXTTickerMarketDataSource, DEFAULT_LOGGING_CONFIG, \
131
+ TradingStrategy, SnapshotInterval, convert_polars_to_pandas
111
132
 
112
133
  load_dotenv()
113
134
  logging.config.dictConfig(DEFAULT_LOGGING_CONFIG)
135
+ logger = logging.getLogger(__name__)
114
136
 
115
137
  # OHLCV data for candles
116
138
  bitvavo_btc_eur_ohlcv_2h = CCXTOHLCVMarketDataSource(
@@ -131,24 +153,64 @@ app = create_app()
131
153
  # Registered bitvavo market, credentials are read from .env file by default
132
154
  app.add_market(market="BITVAVO", trading_symbol="EUR", initial_balance=100)
133
155
 
134
- # Define a strategy for the algorithm that will run every 10 seconds
135
- @app.strategy(
136
- time_unit=TimeUnit.SECOND,
137
- interval=10,
138
- market_data_sources=[bitvavo_btc_eur_ticker, bitvavo_btc_eur_ohlcv_2h]
156
+ class MyStrategy(TradingStrategy):
157
+ interval = 2
158
+ time_unit = TimeUnit.HOUR
159
+ data_sources = [bitvavo_btc_eur_ohlcv_2h, bitvavo_btc_eur_ticker]
160
+
161
+ def run_strategy(self, context: Context, market_data):
162
+
163
+ if context.has_open_orders(target_symbol="BTC"):
164
+ logger.info("There are open orders, skipping strategy iteration.")
165
+ return
166
+
167
+ print(market_data)
168
+
169
+ data = convert_polars_to_pandas(market_data["BTC-ohlcv"])
170
+ data = ema(data, source_column="Close", period=20, result_column="ema_20")
171
+ data = ema(data, source_column="Close", period=50, result_column="ema_50")
172
+ data = ema(data, source_column="Close", period=100, result_column="ema_100")
173
+ data = rsi(data, source_column="Close", period=14, result_column="rsi_14")
174
+
175
+ if context.has_position("BTC") and self.sell_signal(data):
176
+ context.create_limit_sell_order(
177
+ "BTC", percentage_of_position=100, price=data["Close"].iloc[-1]
178
+ )
179
+ return
180
+
181
+ if not context.has_position("BTC") and self.buy_signal(data):
182
+ context.create_limit_buy_order(
183
+ "BTC", percentage_of_portfolio=20, price=data["Close"].iloc[-1]
184
+ )
185
+ return
186
+
187
+ def buy_signal(self, data):
188
+ if len(data) < 100:
189
+ return False
190
+ last_row = data.iloc[-1]
191
+ if last_row["ema_20"] > last_row["ema_50"] and last_row["ema_50"] > last_row["ema_100"]:
192
+ return True
193
+ return False
194
+
195
+ def sell_signal(self, data):
196
+
197
+ if data["ema_20"].iloc[-1] < data["ema_50"].iloc[-1] and \
198
+ data["ema_20"].iloc[-2] >= data["ema_50"].iloc[-2]:
199
+ return True
200
+
201
+ return False
202
+
203
+ date_range = BacktestDateRange(
204
+ start_date="2023-08-24 00:00:00", end_date="2023-12-02 00:00:00"
139
205
  )
140
- def perform_strategy(context: Context, market_data: dict):
141
- # Access the data sources with the indentifier
142
- polars_df = market_data["BTC-ohlcv"]
143
- ticker_data = market_data["BTC-ticker"]
144
- unallocated_balance = context.get_unallocated()
145
- positions = context.get_positions()
146
- trades = context.get_trades()
147
- open_trades = context.get_open_trades()
148
- closed_trades = context.get_closed_trades()
206
+ app.add_strategy(MyStrategy)
149
207
 
150
208
  if __name__ == "__main__":
151
- app.run()
209
+ # Run the backtest with a daily snapshot interval for end-of-day granular reporting
210
+ backtest_report = app.run_backtest(
211
+ backtest_date_range=date_range, initial_amount=100, snapshot_interval=SnapshotInterval.STRATEGY_ITERATION
212
+ )
213
+ backtest_report.show()
152
214
  ```
153
215
 
154
216
  > You can find more examples [here](./examples) folder.
@@ -9,13 +9,20 @@
9
9
 
10
10
  > If you like what we do, consider starring, sharing and contributing!
11
11
 
12
+ <div align="center">
13
+ <img src="static/showcase.svg" alt="Investing Algorithm Framework Logo" style="height: 50vh; max-height: 750px;">
14
+ </div>
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.
18
+
12
19
  ## Sponsors
13
20
 
14
21
  <a href="https://www.finterion.com/" target="_blank">
15
22
  <picture style="height: 30px;">
16
23
  <source media="(prefers-color-scheme: dark)" srcset="static/sponsors/finterion-dark.png">
17
24
  <source media="(prefers-color-scheme: light)" srcset="static/sponsors/finterion-light.png">
18
- <img src="static/sponsors/finterion-light.svg" alt="Finterion Logo" width="200px" height="50px">
25
+ <img src="static/sponsors/finterion-light.png" alt="Finterion Logo" width="200px" height="50px">
19
26
  </picture>
20
27
  </a>
21
28
 
@@ -66,17 +73,30 @@ This will create:
66
73
  ---
67
74
 
68
75
  ## 📈 Example: A Simple Trading Bot
69
- The following example connects to Binance and buys BTC every 2 hours.
76
+ The following example trading bot implements a simple moving average strategy.
77
+ The strategy will use data from bitvavo exchange and will calculate
78
+ the 20, 50 and 100 period exponential moving averages (EMA) and the
79
+ 14 period relative strength index (RSI).
80
+
81
+ > This example uses [PyIndicators](https://github.com/coding-kitties/pyindicators) for technical analysis.
82
+ > This dependency is not part of the framework, but is used to perform technical analysis on the dataframes.
83
+ > You can install it using pip: pip install pyindicators.
84
+
85
+ ```bash
70
86
 
71
87
  ```python
72
88
  import logging.config
73
89
  from dotenv import load_dotenv
74
90
 
75
- from investing_algorithm_framework import create_app, TimeUnit, Context, \
76
- CCXTOHLCVMarketDataSource, CCXTTickerMarketDataSource, DEFAULT_LOGGING_CONFIG
91
+ from pyindicators import ema, rsi
92
+
93
+ from investing_algorithm_framework import create_app, TimeUnit, Context, BacktestDateRange, \
94
+ CCXTOHLCVMarketDataSource, CCXTTickerMarketDataSource, DEFAULT_LOGGING_CONFIG, \
95
+ TradingStrategy, SnapshotInterval, convert_polars_to_pandas
77
96
 
78
97
  load_dotenv()
79
98
  logging.config.dictConfig(DEFAULT_LOGGING_CONFIG)
99
+ logger = logging.getLogger(__name__)
80
100
 
81
101
  # OHLCV data for candles
82
102
  bitvavo_btc_eur_ohlcv_2h = CCXTOHLCVMarketDataSource(
@@ -97,24 +117,64 @@ app = create_app()
97
117
  # Registered bitvavo market, credentials are read from .env file by default
98
118
  app.add_market(market="BITVAVO", trading_symbol="EUR", initial_balance=100)
99
119
 
100
- # Define a strategy for the algorithm that will run every 10 seconds
101
- @app.strategy(
102
- time_unit=TimeUnit.SECOND,
103
- interval=10,
104
- market_data_sources=[bitvavo_btc_eur_ticker, bitvavo_btc_eur_ohlcv_2h]
120
+ class MyStrategy(TradingStrategy):
121
+ interval = 2
122
+ time_unit = TimeUnit.HOUR
123
+ data_sources = [bitvavo_btc_eur_ohlcv_2h, bitvavo_btc_eur_ticker]
124
+
125
+ def run_strategy(self, context: Context, market_data):
126
+
127
+ if context.has_open_orders(target_symbol="BTC"):
128
+ logger.info("There are open orders, skipping strategy iteration.")
129
+ return
130
+
131
+ print(market_data)
132
+
133
+ data = convert_polars_to_pandas(market_data["BTC-ohlcv"])
134
+ data = ema(data, source_column="Close", period=20, result_column="ema_20")
135
+ data = ema(data, source_column="Close", period=50, result_column="ema_50")
136
+ data = ema(data, source_column="Close", period=100, result_column="ema_100")
137
+ data = rsi(data, source_column="Close", period=14, result_column="rsi_14")
138
+
139
+ if context.has_position("BTC") and self.sell_signal(data):
140
+ context.create_limit_sell_order(
141
+ "BTC", percentage_of_position=100, price=data["Close"].iloc[-1]
142
+ )
143
+ return
144
+
145
+ if not context.has_position("BTC") and self.buy_signal(data):
146
+ context.create_limit_buy_order(
147
+ "BTC", percentage_of_portfolio=20, price=data["Close"].iloc[-1]
148
+ )
149
+ return
150
+
151
+ def buy_signal(self, data):
152
+ if len(data) < 100:
153
+ return False
154
+ last_row = data.iloc[-1]
155
+ if last_row["ema_20"] > last_row["ema_50"] and last_row["ema_50"] > last_row["ema_100"]:
156
+ return True
157
+ return False
158
+
159
+ def sell_signal(self, data):
160
+
161
+ if data["ema_20"].iloc[-1] < data["ema_50"].iloc[-1] and \
162
+ data["ema_20"].iloc[-2] >= data["ema_50"].iloc[-2]:
163
+ return True
164
+
165
+ return False
166
+
167
+ date_range = BacktestDateRange(
168
+ start_date="2023-08-24 00:00:00", end_date="2023-12-02 00:00:00"
105
169
  )
106
- def perform_strategy(context: Context, market_data: dict):
107
- # Access the data sources with the indentifier
108
- polars_df = market_data["BTC-ohlcv"]
109
- ticker_data = market_data["BTC-ticker"]
110
- unallocated_balance = context.get_unallocated()
111
- positions = context.get_positions()
112
- trades = context.get_trades()
113
- open_trades = context.get_open_trades()
114
- closed_trades = context.get_closed_trades()
170
+ app.add_strategy(MyStrategy)
115
171
 
116
172
  if __name__ == "__main__":
117
- app.run()
173
+ # Run the backtest with a daily snapshot interval for end-of-day granular reporting
174
+ backtest_report = app.run_backtest(
175
+ backtest_date_range=date_range, initial_amount=100, snapshot_interval=SnapshotInterval.STRATEGY_ITERATION
176
+ )
177
+ backtest_report.show()
118
178
  ```
119
179
 
120
180
  > You can find more examples [here](./examples) folder.
@@ -1,38 +1,29 @@
1
1
  from investing_algorithm_framework.app import App, Algorithm, \
2
- TradingStrategy, StatelessAction, Task, AppHook, Context
2
+ TradingStrategy, StatelessAction, Task, AppHook, Context, \
3
+ add_html_report, add_metrics, BacktestReport, \
4
+ BacktestReportsEvaluation, pretty_print_trades, pretty_print_positions, \
5
+ pretty_print_orders, pretty_print_backtest
3
6
  from investing_algorithm_framework.domain import ApiException, \
4
7
  TradingDataType, TradingTimeFrame, OrderType, OperationalException, \
5
8
  OrderStatus, OrderSide, TimeUnit, TimeInterval, Order, Portfolio, \
6
9
  Position, TimeFrame, BACKTESTING_INDEX_DATETIME, MarketCredential, \
7
- PortfolioConfiguration, RESOURCE_DIRECTORY, pretty_print_backtest, \
10
+ PortfolioConfiguration, RESOURCE_DIRECTORY, \
8
11
  Trade, OHLCVMarketDataSource, OrderBookMarketDataSource, SYMBOLS, \
9
- TickerMarketDataSource, MarketService, BacktestReportsEvaluation, \
10
- pretty_print_backtest_reports_evaluation, load_backtest_reports, \
12
+ TickerMarketDataSource, MarketService, \
11
13
  RESERVED_BALANCES, APP_MODE, AppMode, DATETIME_FORMAT, \
12
- load_backtest_report, BacktestDateRange, convert_polars_to_pandas, \
13
- DateRange, get_backtest_report, DEFAULT_LOGGING_CONFIG, \
14
- BacktestReport, TradeStatus, MarketDataType, TradeRiskType, \
15
- APPLICATION_DIRECTORY, pretty_print_orders, pretty_print_trades, \
16
- pretty_print_positions, DataSource, OrderExecutor, PortfolioProvider, \
17
- SnapshotInterval
14
+ BacktestDateRange, convert_polars_to_pandas, \
15
+ DateRange, DEFAULT_LOGGING_CONFIG, \
16
+ BacktestResult, TradeStatus, MarketDataType, TradeRiskType, \
17
+ APPLICATION_DIRECTORY, DataSource, OrderExecutor, PortfolioProvider, \
18
+ SnapshotInterval, AWS_S3_STATE_BUCKET_NAME
18
19
  from investing_algorithm_framework.infrastructure import \
19
20
  CCXTOrderBookMarketDataSource, CCXTOHLCVMarketDataSource, \
20
21
  CCXTTickerMarketDataSource, CSVOHLCVMarketDataSource, \
21
22
  CSVTickerMarketDataSource, AzureBlobStorageStateHandler, \
22
- PandasOHLCVBacktestMarketDataSource, PandasOHLCVMarketDataSource
23
+ PandasOHLCVBacktestMarketDataSource, PandasOHLCVMarketDataSource, \
24
+ AWSS3StorageStateHandler
23
25
  from .create_app import create_app
24
26
  from .download_data import download
25
- from .overfitting import create_ohlcv_shuffle_permutation, \
26
- create_ohlcv_shuffle_returns_and_reconstruct_permutation, \
27
- create_ohlcv_shuffle_block_permutation
28
- from .metrics import get_volatility, get_sortino_ratio, get_profit_factor, \
29
- get_cumulative_profit_factor_series, get_rolling_profit_factor_series, \
30
- get_sharpe_ratio, get_price_efficiency_ratio, get_equity_curve, \
31
- get_drawdown_series, get_max_drawdown, get_cagr, \
32
- get_standard_deviation_returns, get_standard_deviation_downside_returns, \
33
- get_max_drawdown_absolute, get_exposure_time, get_average_trade_duration, \
34
- get_net_profit, get_win_rate, get_win_loss_ratio, get_calmar_ratio, \
35
- get_trade_frequency
36
27
 
37
28
  __all__ = [
38
29
  "Algorithm",
@@ -70,19 +61,16 @@ __all__ = [
70
61
  "MarketCredential",
71
62
  "MarketService",
72
63
  "OperationalException",
73
- "pretty_print_backtest_reports_evaluation",
74
64
  "BacktestReportsEvaluation",
75
- "load_backtest_reports",
76
65
  "SYMBOLS",
77
66
  "RESERVED_BALANCES",
78
67
  "APP_MODE",
79
68
  "AppMode",
80
69
  "DATETIME_FORMAT",
81
- "load_backtest_report",
70
+ "BacktestResult",
82
71
  "BacktestDateRange",
83
72
  "convert_polars_to_pandas",
84
73
  "DateRange",
85
- "get_backtest_report",
86
74
  "AzureBlobStorageStateHandler",
87
75
  "DEFAULT_LOGGING_CONFIG",
88
76
  "BacktestReport",
@@ -98,31 +86,11 @@ __all__ = [
98
86
  "DataSource",
99
87
  "OrderExecutor",
100
88
  "PortfolioProvider",
101
- "get_profit_factor",
102
- "get_cumulative_profit_factor_series",
103
- "get_rolling_profit_factor_series",
104
- "get_sharpe_ratio",
105
- "get_price_efficiency_ratio",
106
- "get_equity_curve",
107
- "get_drawdown_series",
108
- "get_max_drawdown",
109
- "create_ohlcv_shuffle_permutation",
110
- "create_ohlcv_shuffle_returns_and_reconstruct_permutation",
111
- "create_ohlcv_shuffle_block_permutation",
112
89
  "PandasOHLCVBacktestMarketDataSource",
113
90
  "PandasOHLCVMarketDataSource",
114
- "get_volatility",
115
- "get_sortino_ratio",
116
- "get_cagr",
117
- "get_standard_deviation_returns",
118
- "get_standard_deviation_downside_returns",
119
91
  "SnapshotInterval",
120
- "get_max_drawdown_absolute",
121
- "get_exposure_time",
122
- "get_average_trade_duration",
123
- "get_net_profit",
124
- "get_win_rate",
125
- "get_win_loss_ratio",
126
- "get_calmar_ratio",
127
- "get_trade_frequency",
92
+ "add_metrics",
93
+ "add_html_report",
94
+ "AWSS3StorageStateHandler",
95
+ "AWS_S3_STATE_BUCKET_NAME"
128
96
  ]
@@ -5,6 +5,9 @@ from investing_algorithm_framework.app.task import Task
5
5
  from investing_algorithm_framework.app.web import create_flask_app
6
6
  from .algorithm import Algorithm
7
7
  from .context import Context
8
+ from .reporting import add_html_report, add_metrics, \
9
+ BacktestReport, pretty_print_backtest, BacktestReportsEvaluation, \
10
+ pretty_print_trades, pretty_print_positions, pretty_print_orders
8
11
 
9
12
 
10
13
  __all__ = [
@@ -16,4 +19,12 @@ __all__ = [
16
19
  "Task",
17
20
  "AppHook",
18
21
  "Context",
22
+ "add_html_report",
23
+ "add_metrics",
24
+ "BacktestReport",
25
+ "pretty_print_backtest",
26
+ "BacktestReportsEvaluation",
27
+ "pretty_print_trades",
28
+ "pretty_print_positions",
29
+ "pretty_print_orders"
19
30
  ]
@@ -16,16 +16,18 @@ from investing_algorithm_framework.app.web import create_flask_app
16
16
  from investing_algorithm_framework.domain import DATABASE_NAME, TimeUnit, \
17
17
  DATABASE_DIRECTORY_PATH, RESOURCE_DIRECTORY, ENVIRONMENT, Environment, \
18
18
  SQLALCHEMY_DATABASE_URI, OperationalException, StateHandler, \
19
- BACKTESTING_START_DATE, BACKTESTING_END_DATE, BacktestReport, \
20
- APP_MODE, MarketCredential, AppMode, BacktestDateRange, \
21
- DATABASE_DIRECTORY_NAME, BACKTESTING_INITIAL_AMOUNT, SNAPSHOT_INTERVAL, \
19
+ BACKTESTING_START_DATE, BACKTESTING_END_DATE, APP_MODE, MarketCredential, \
20
+ AppMode, BacktestDateRange, DATABASE_DIRECTORY_NAME, \
21
+ BACKTESTING_INITIAL_AMOUNT, SNAPSHOT_INTERVAL, \
22
22
  MarketDataSource, PortfolioConfiguration, SnapshotInterval, \
23
23
  PortfolioProvider, OrderExecutor, ImproperlyConfigured
24
24
  from investing_algorithm_framework.infrastructure import setup_sqlalchemy, \
25
25
  create_all_tables, CCXTOrderExecutor, CCXTPortfolioProvider
26
26
  from investing_algorithm_framework.services import OrderBacktestService, \
27
- BacktestMarketDataSourceService, BacktestPortfolioService
27
+ BacktestMarketDataSourceService, BacktestPortfolioService, \
28
+ BacktestService
28
29
  from .app_hook import AppHook
30
+ from .reporting import BacktestReport
29
31
 
30
32
  logger = logging.getLogger("investing_algorithm_framework")
31
33
  COLOR_RESET = '\033[0m'
@@ -712,8 +714,10 @@ class App:
712
714
  algorithm=None,
713
715
  strategy=None,
714
716
  strategies: List = None,
715
- save_strategy=False,
716
- snapshot_interval: SnapshotInterval = SnapshotInterval.TRADE_CLOSE
717
+ save_strategy=True,
718
+ snapshot_interval: SnapshotInterval = SnapshotInterval.TRADE_CLOSE,
719
+ strategy_directory_path: Optional[str] = None,
720
+ report_name: Optional[str] = None
717
721
  ) -> BacktestReport:
718
722
  """
719
723
  Run a backtest for an algorithm.
@@ -741,6 +745,15 @@ class App:
741
745
  how often the portfolio snapshot should be taken during the
742
746
  backtest. The default is TRADE_CLOSE, which means that the
743
747
  portfolio snapshot will be taken at the end of each trade.
748
+ strategy_directory_path (Optional[str]): The directory path
749
+ where the strategy is located. This is used to save the
750
+ strategy if save_strategy is True. If not provided,
751
+ the framework tries to determine the path via the
752
+ algorithm or strategy object.
753
+ report_name (Optional[str]): The name of the report. If not
754
+ provided, the framework will generate a name based on the
755
+ algorithm name and the backtest date range and the current
756
+ date and time.
744
757
 
745
758
  Returns:
746
759
  Instance of BacktestReport
@@ -783,7 +796,6 @@ class App:
783
796
  on_strategy_run_hooks=self._on_strategy_run_hooks,
784
797
  )
785
798
  self.initialize_data_sources(algorithm)
786
-
787
799
  strategy_orchestrator_service = \
788
800
  self.container.strategy_orchestrator_service()
789
801
  strategy_orchestrator_service.initialize(algorithm)
@@ -804,19 +816,37 @@ class App:
804
816
 
805
817
  # Run the backtest with the backtest_service and collect and
806
818
  # save the report
807
- report = backtest_service.run_backtest(
819
+ results = backtest_service.run_backtest(
808
820
  algorithm=algorithm,
809
821
  context=context,
810
822
  strategy_orchestrator_service=strategy_orchestrator_service,
811
823
  initial_amount=initial_amount,
812
824
  backtest_date_range=backtest_date_range
813
825
  )
814
- backtest_service.save_report(
815
- report=report,
826
+ report = BacktestReport(results=results)
827
+
828
+ if output_directory is None:
829
+ output_directory = os.path.join(
830
+ config[RESOURCE_DIRECTORY], "backtest_reports"
831
+ )
832
+
833
+ if report_name is None:
834
+ report_name = BacktestService.create_report_directory_name(report)
835
+
836
+ output_directory = os.path.join(output_directory, report_name)
837
+ report.save(
838
+ path=output_directory,
816
839
  algorithm=algorithm,
817
- output_directory=output_directory,
818
- save_strategy=save_strategy,
840
+ strategy_directory_path=strategy_directory_path,
841
+ save_strategy=save_strategy
819
842
  )
843
+ # print(report.html_report)
844
+ # backtest_service.save_report(
845
+ # report=report,
846
+ # algorithm=algorithm,
847
+ # output_directory=output_directory,
848
+ # save_strategy=save_strategy,
849
+ # )
820
850
  return report
821
851
 
822
852
  def run_backtests(