investing-algorithm-framework 6.6.1__tar.gz → 6.7.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 (226) hide show
  1. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/PKG-INFO +1 -1
  2. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/__init__.py +30 -4
  3. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/__init__.py +1 -5
  4. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/app.py +26 -4
  5. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/context.py +0 -1
  6. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/dependency_container.py +4 -0
  7. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/__init__.py +9 -4
  8. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/constants.py +1 -0
  9. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/__init__.py +5 -1
  10. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/backtesting/backtest_report.py +0 -3
  11. investing_algorithm_framework-6.7.0/investing_algorithm_framework/domain/models/event.py +35 -0
  12. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/portfolio/portfolio_snapshot.py +11 -1
  13. investing_algorithm_framework-6.7.0/investing_algorithm_framework/domain/models/snapshot_interval.py +45 -0
  14. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/services/__init__.py +5 -1
  15. investing_algorithm_framework-6.7.0/investing_algorithm_framework/domain/services/observable.py +51 -0
  16. investing_algorithm_framework-6.7.0/investing_algorithm_framework/domain/services/observer.py +19 -0
  17. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/__init__.py +4 -1
  18. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/models/__init__.py +4 -1
  19. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/models/market_data_sources/__init__.py +5 -1
  20. investing_algorithm_framework-6.7.0/investing_algorithm_framework/infrastructure/models/market_data_sources/pandas.py +312 -0
  21. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/models/portfolio/portfolio_snapshot.py +1 -0
  22. investing_algorithm_framework-6.7.0/investing_algorithm_framework/metrics/__init__.py +39 -0
  23. investing_algorithm_framework-6.7.0/investing_algorithm_framework/metrics/cagr.py +67 -0
  24. investing_algorithm_framework-6.7.0/investing_algorithm_framework/metrics/drawdown.py +113 -0
  25. {investing_algorithm_framework-6.6.1/investing_algorithm_framework/app → investing_algorithm_framework-6.7.0/investing_algorithm_framework}/metrics/equity_curve.py +1 -1
  26. investing_algorithm_framework-6.7.0/investing_algorithm_framework/metrics/exposure.py +55 -0
  27. investing_algorithm_framework-6.7.0/investing_algorithm_framework/metrics/net_profit.py +17 -0
  28. investing_algorithm_framework-6.7.0/investing_algorithm_framework/metrics/recovery.py +115 -0
  29. investing_algorithm_framework-6.7.0/investing_algorithm_framework/metrics/risk_free_rate.py +8 -0
  30. investing_algorithm_framework-6.7.0/investing_algorithm_framework/metrics/sharp_ratio.py +38 -0
  31. investing_algorithm_framework-6.7.0/investing_algorithm_framework/metrics/sortino_ratio.py +65 -0
  32. investing_algorithm_framework-6.7.0/investing_algorithm_framework/metrics/standard_deviation.py +92 -0
  33. investing_algorithm_framework-6.7.0/investing_algorithm_framework/metrics/volatility.py +56 -0
  34. investing_algorithm_framework-6.7.0/investing_algorithm_framework/overfitting/__init__.py +9 -0
  35. investing_algorithm_framework-6.7.0/investing_algorithm_framework/overfitting/permutations.py +101 -0
  36. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/services/backtesting/backtest_service.py +16 -17
  37. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/services/market_data_source_service/backtest_market_data_source_service.py +53 -0
  38. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/services/market_data_source_service/market_data_source_service.py +2 -1
  39. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/services/order_service/order_backtest_service.py +10 -9
  40. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/services/order_service/order_service.py +39 -41
  41. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/services/portfolios/backtest_portfolio_service.py +1 -0
  42. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/services/portfolios/portfolio_service.py +13 -24
  43. investing_algorithm_framework-6.7.0/investing_algorithm_framework/services/portfolios/portfolio_snapshot_service.py +172 -0
  44. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/pyproject.toml +1 -1
  45. investing_algorithm_framework-6.6.1/investing_algorithm_framework/app/metrics/__init__.py +0 -14
  46. investing_algorithm_framework-6.6.1/investing_algorithm_framework/app/metrics/sharp_ratio.py +0 -81
  47. investing_algorithm_framework-6.6.1/investing_algorithm_framework/infrastructure/models/market_data_sources/pandas.py +0 -144
  48. investing_algorithm_framework-6.6.1/investing_algorithm_framework/services/portfolios/portfolio_snapshot_service.py +0 -65
  49. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/LICENSE +0 -0
  50. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/README.md +0 -0
  51. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/algorithm/__init__.py +0 -0
  52. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/algorithm/algorithm.py +0 -0
  53. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/algorithm/algorithm_factory.py +0 -0
  54. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/app_hook.py +0 -0
  55. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/stateless/__init__.py +0 -0
  56. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/stateless/action_handlers/__init__.py +0 -0
  57. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/stateless/action_handlers/action_handler_strategy.py +0 -0
  58. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/stateless/action_handlers/check_online_handler.py +0 -0
  59. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/stateless/action_handlers/run_strategy_handler.py +0 -0
  60. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/stateless/exception_handler.py +0 -0
  61. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/strategy.py +0 -0
  62. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/task.py +0 -0
  63. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/web/__init__.py +0 -0
  64. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/web/controllers/__init__.py +0 -0
  65. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/web/controllers/orders.py +0 -0
  66. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/web/controllers/portfolio.py +0 -0
  67. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/web/controllers/positions.py +0 -0
  68. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/web/create_app.py +0 -0
  69. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/web/error_handler.py +0 -0
  70. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/web/responses.py +0 -0
  71. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/web/run_strategies.py +0 -0
  72. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/web/schemas/__init__.py +0 -0
  73. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/web/schemas/order.py +0 -0
  74. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/web/schemas/portfolio.py +0 -0
  75. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/web/schemas/position.py +0 -0
  76. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/app/web/setup_cors.py +0 -0
  77. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/cli/__init__.py +0 -0
  78. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/cli/cli.py +0 -0
  79. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/cli/deploy_to_azure_function.py +0 -0
  80. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/cli/initialize_app.py +0 -0
  81. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/cli/templates/.gitignore.template +0 -0
  82. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/cli/templates/app-web.py.template +0 -0
  83. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/cli/templates/app.py.template +0 -0
  84. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/cli/templates/app_azure_function.py.template +0 -0
  85. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/cli/templates/app_web.py.template +0 -0
  86. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/cli/templates/azure_function_function_app.py.template +0 -0
  87. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/cli/templates/azure_function_host.json.template +0 -0
  88. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/cli/templates/azure_function_local.settings.json.template +0 -0
  89. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/cli/templates/data_providers.py.template +0 -0
  90. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/cli/templates/env.example.template +0 -0
  91. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/cli/templates/env_azure_function.example.template +0 -0
  92. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/cli/templates/market_data_providers.py.template +0 -0
  93. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/cli/templates/readme.md.template +0 -0
  94. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/cli/templates/requirements.txt.template +0 -0
  95. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/cli/templates/requirements_azure_function.txt.template +0 -0
  96. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/cli/templates/run_backtest.py.template +0 -0
  97. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/cli/templates/strategy.py.template +0 -0
  98. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/create_app.py +0 -0
  99. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/config.py +0 -0
  100. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/data_provider.py +0 -0
  101. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/data_structures.py +0 -0
  102. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/decimal_parsing.py +0 -0
  103. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/exceptions.py +0 -0
  104. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/app_mode.py +0 -0
  105. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/backtesting/__init__.py +0 -0
  106. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/backtesting/backtest_date_range.py +0 -0
  107. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/backtesting/backtest_position.py +0 -0
  108. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/backtesting/backtest_reports_evaluation.py +0 -0
  109. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/base_model.py +0 -0
  110. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/data_source.py +0 -0
  111. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/date_range.py +0 -0
  112. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/market/__init__.py +0 -0
  113. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/market/market_credential.py +0 -0
  114. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/market_data_type.py +0 -0
  115. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/order/__init__.py +0 -0
  116. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/order/order.py +0 -0
  117. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/order/order_side.py +0 -0
  118. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/order/order_status.py +0 -0
  119. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/order/order_type.py +0 -0
  120. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/portfolio/__init__.py +0 -0
  121. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/portfolio/portfolio.py +0 -0
  122. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/portfolio/portfolio_configuration.py +0 -0
  123. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/position/__init__.py +0 -0
  124. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/position/position.py +0 -0
  125. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/position/position_snapshot.py +0 -0
  126. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/strategy_profile.py +0 -0
  127. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/time_frame.py +0 -0
  128. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/time_interval.py +0 -0
  129. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/time_unit.py +0 -0
  130. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/tracing/__init__.py +0 -0
  131. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/tracing/trace.py +0 -0
  132. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/trade/__init__.py +0 -0
  133. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/trade/trade.py +0 -0
  134. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/trade/trade_risk_type.py +0 -0
  135. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/trade/trade_status.py +0 -0
  136. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/trade/trade_stop_loss.py +0 -0
  137. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/trade/trade_take_profit.py +0 -0
  138. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/trading_data_types.py +0 -0
  139. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/models/trading_time_frame.py +0 -0
  140. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/order_executor.py +0 -0
  141. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/portfolio_provider.py +0 -0
  142. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/services/market_credential_service.py +0 -0
  143. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/services/market_data_sources.py +0 -0
  144. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/services/market_service.py +0 -0
  145. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/services/portfolios/__init__.py +0 -0
  146. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/services/portfolios/portfolio_sync_service.py +0 -0
  147. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/services/rounding_service.py +0 -0
  148. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/services/state_handler.py +0 -0
  149. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/stateless_actions.py +0 -0
  150. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/strategy.py +0 -0
  151. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/utils/__init__.py +0 -0
  152. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/utils/backtesting.py +0 -0
  153. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/utils/csv.py +0 -0
  154. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/utils/dates.py +0 -0
  155. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/utils/polars.py +0 -0
  156. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/utils/random.py +0 -0
  157. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/utils/signatures.py +0 -0
  158. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/utils/stoppable_thread.py +0 -0
  159. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/domain/utils/synchronized.py +0 -0
  160. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/download_data.py +0 -0
  161. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/data_providers/__init__.py +0 -0
  162. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/data_providers/ccxt.py +0 -0
  163. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/data_providers/csv.py +0 -0
  164. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/database/__init__.py +0 -0
  165. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/database/sql_alchemy.py +0 -0
  166. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/models/decimal_parser.py +0 -0
  167. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/models/market_data_sources/ccxt.py +0 -0
  168. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/models/market_data_sources/csv.py +0 -0
  169. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/models/model_extension.py +0 -0
  170. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/models/order/__init__.py +0 -0
  171. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/models/order/order.py +0 -0
  172. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/models/order/order_metadata.py +0 -0
  173. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/models/order_trade_association.py +0 -0
  174. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/models/portfolio/__init__.py +0 -0
  175. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/models/portfolio/sql_portfolio.py +0 -0
  176. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/models/position/__init__.py +0 -0
  177. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/models/position/position.py +0 -0
  178. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/models/position/position_snapshot.py +0 -0
  179. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/models/trades/__init__.py +0 -0
  180. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/models/trades/trade.py +0 -0
  181. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/models/trades/trade_stop_loss.py +0 -0
  182. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/models/trades/trade_take_profit.py +0 -0
  183. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/order_executors/__init__.py +0 -0
  184. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/order_executors/ccxt_order_executor.py +0 -0
  185. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/portfolio_providers/__init__.py +0 -0
  186. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/portfolio_providers/ccxt_portfolio_provider.py +0 -0
  187. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/repositories/__init__.py +0 -0
  188. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/repositories/order_metadata_repository.py +0 -0
  189. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/repositories/order_repository.py +0 -0
  190. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/repositories/portfolio_repository.py +0 -0
  191. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/repositories/portfolio_snapshot_repository.py +0 -0
  192. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/repositories/position_repository.py +0 -0
  193. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/repositories/position_snapshot_repository.py +0 -0
  194. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/repositories/repository.py +0 -0
  195. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/repositories/trade_repository.py +0 -0
  196. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/repositories/trade_stop_loss_repository.py +0 -0
  197. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/repositories/trade_take_profit_repository.py +0 -0
  198. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/services/__init__.py +0 -0
  199. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/services/azure/__init__.py +0 -0
  200. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/services/azure/state_handler.py +0 -0
  201. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/services/market_service/__init__.py +0 -0
  202. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/services/market_service/ccxt_market_service.py +0 -0
  203. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/services/performance_service/__init__.py +0 -0
  204. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/services/performance_service/backtest_performance_service.py +0 -0
  205. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/infrastructure/services/performance_service/performance_service.py +0 -0
  206. {investing_algorithm_framework-6.6.1/investing_algorithm_framework/app → investing_algorithm_framework-6.7.0/investing_algorithm_framework}/metrics/price_efficiency.py +0 -0
  207. {investing_algorithm_framework-6.6.1/investing_algorithm_framework/app → investing_algorithm_framework-6.7.0/investing_algorithm_framework}/metrics/profit_factor.py +0 -0
  208. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/services/__init__.py +0 -0
  209. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/services/backtesting/__init__.py +0 -0
  210. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/services/configuration_service.py +0 -0
  211. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/services/market_credential_service.py +0 -0
  212. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/services/market_data_source_service/__init__.py +0 -0
  213. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/services/market_data_source_service/data_provider_service.py +0 -0
  214. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/services/order_service/__init__.py +0 -0
  215. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/services/order_service/order_executor_lookup.py +0 -0
  216. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/services/portfolios/__init__.py +0 -0
  217. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/services/portfolios/portfolio_configuration_service.py +0 -0
  218. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/services/portfolios/portfolio_provider_lookup.py +0 -0
  219. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/services/portfolios/portfolio_sync_service.py +0 -0
  220. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/services/positions/__init__.py +0 -0
  221. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/services/positions/position_service.py +0 -0
  222. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/services/positions/position_snapshot_service.py +0 -0
  223. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/services/repository_service.py +0 -0
  224. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/services/strategy_orchestrator_service.py +0 -0
  225. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.0}/investing_algorithm_framework/services/trade_service/__init__.py +0 -0
  226. {investing_algorithm_framework-6.6.1 → investing_algorithm_framework-6.7.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.6.1
3
+ Version: 6.7.0
4
4
  Summary: A framework for creating trading bots
5
5
  Author: MDUYN
6
6
  Requires-Python: >=3.10
@@ -13,16 +13,25 @@ from investing_algorithm_framework.domain import ApiException, \
13
13
  DateRange, get_backtest_report, DEFAULT_LOGGING_CONFIG, \
14
14
  BacktestReport, TradeStatus, MarketDataType, TradeRiskType, \
15
15
  APPLICATION_DIRECTORY, pretty_print_orders, pretty_print_trades, \
16
- pretty_print_positions, DataSource, OrderExecutor, PortfolioProvider
16
+ pretty_print_positions, DataSource, OrderExecutor, PortfolioProvider, \
17
+ SnapshotInterval
17
18
  from investing_algorithm_framework.infrastructure import \
18
19
  CCXTOrderBookMarketDataSource, CCXTOHLCVMarketDataSource, \
19
20
  CCXTTickerMarketDataSource, CSVOHLCVMarketDataSource, \
20
- CSVTickerMarketDataSource, AzureBlobStorageStateHandler
21
+ CSVTickerMarketDataSource, AzureBlobStorageStateHandler, \
22
+ PandasOHLCVBacktestMarketDataSource, PandasOHLCVMarketDataSource
21
23
  from .create_app import create_app
22
24
  from .download_data import download
23
- from .app.metrics import get_profit_factor, \
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, \
24
29
  get_cumulative_profit_factor_series, get_rolling_profit_factor_series, \
25
- get_sharpe_ratio, get_price_efficiency_ratio, get_equity_curve
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
26
35
 
27
36
  __all__ = [
28
37
  "Algorithm",
@@ -94,4 +103,21 @@ __all__ = [
94
103
  "get_sharpe_ratio",
95
104
  "get_price_efficiency_ratio",
96
105
  "get_equity_curve",
106
+ "get_drawdown_series",
107
+ "get_max_drawdown",
108
+ "create_ohlcv_shuffle_permutation",
109
+ "create_ohlcv_shuffle_returns_and_reconstruct_permutation",
110
+ "create_ohlcv_shuffle_block_permutation",
111
+ "PandasOHLCVBacktestMarketDataSource",
112
+ "PandasOHLCVMarketDataSource",
113
+ "get_volatility",
114
+ "get_sortino_ratio",
115
+ "get_cagr",
116
+ "get_standard_deviation_returns",
117
+ "get_standard_deviation_downside_returns",
118
+ "SnapshotInterval",
119
+ "get_max_drawdown_absolute",
120
+ "get_exposure_time",
121
+ "get_average_trade_duration",
122
+ "get_net_profit",
97
123
  ]
@@ -5,8 +5,7 @@ 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 .metrics import get_cumulative_profit_factor_series, \
9
- get_rolling_profit_factor_series, get_price_efficiency_ratio
8
+
10
9
 
11
10
  __all__ = [
12
11
  "Algorithm",
@@ -17,7 +16,4 @@ __all__ = [
17
16
  "Task",
18
17
  "AppHook",
19
18
  "Context",
20
- "get_cumulative_profit_factor_series",
21
- "get_rolling_profit_factor_series",
22
- "get_price_efficiency_ratio"
23
19
  ]
@@ -18,8 +18,8 @@ from investing_algorithm_framework.domain import DATABASE_NAME, TimeUnit, \
18
18
  SQLALCHEMY_DATABASE_URI, OperationalException, StateHandler, \
19
19
  BACKTESTING_START_DATE, BACKTESTING_END_DATE, BacktestReport, \
20
20
  APP_MODE, MarketCredential, AppMode, BacktestDateRange, \
21
- DATABASE_DIRECTORY_NAME, BACKTESTING_INITIAL_AMOUNT, \
22
- MarketDataSource, PortfolioConfiguration, \
21
+ DATABASE_DIRECTORY_NAME, BACKTESTING_INITIAL_AMOUNT, SNAPSHOT_INTERVAL, \
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
@@ -703,12 +703,14 @@ class App:
703
703
  def run_backtest(
704
704
  self,
705
705
  backtest_date_range: BacktestDateRange,
706
+ name: str = None,
706
707
  initial_amount=None,
707
708
  output_directory=None,
708
709
  algorithm=None,
709
710
  strategy=None,
710
711
  strategies: List = None,
711
712
  save_strategy=False,
713
+ snapshot_interval: SnapshotInterval = SnapshotInterval.TRADE_CLOSE
712
714
  ) -> BacktestReport:
713
715
  """
714
716
  Run a backtest for an algorithm.
@@ -716,6 +718,8 @@ class App:
716
718
  Args:
717
719
  backtest_date_range: The date range to run the backtest for
718
720
  (instance of BacktestDateRange)
721
+ name: The name of the backtest. This is used to identify the
722
+ backtest report in the output directory.
719
723
  initial_amount: The initial amount to start the backtest with.
720
724
  This will be the amount of trading currency that the backtest
721
725
  portfolio will start with.
@@ -729,6 +733,11 @@ class App:
729
733
  save_strategy: bool - Whether to save the strategy
730
734
  as part of the backtest report. You can only save in-memory
731
735
  strategies when running multiple backtests. This is because
736
+ snapshot_interval (SnapshotInterval): The snapshot
737
+ interval to use for the backtest. This is used to determine
738
+ how often the portfolio snapshot should be taken during the
739
+ backtest. The default is TRADE_CLOSE, which means that the
740
+ portfolio snapshot will be taken at the end of each trade.
732
741
 
733
742
  Returns:
734
743
  Instance of BacktestReport
@@ -741,7 +750,8 @@ class App:
741
750
  BACKTESTING_END_DATE: backtest_date_range.end_date,
742
751
  DATABASE_NAME: "backtest-database.sqlite3",
743
752
  DATABASE_DIRECTORY_NAME: "backtest_databases",
744
- BACKTESTING_INITIAL_AMOUNT: initial_amount
753
+ BACKTESTING_INITIAL_AMOUNT: initial_amount,
754
+ SNAPSHOT_INTERVAL: snapshot_interval.value,
745
755
  })
746
756
 
747
757
  self.initialize_config()
@@ -759,7 +769,7 @@ class App:
759
769
 
760
770
  algorithm_factory = self.container.algorithm_factory()
761
771
  algorithm = algorithm_factory.create_algorithm(
762
- name=self.name if self.name is not None else "Backtest Algorithm",
772
+ name=name if name else self._name,
763
773
  strategies=(
764
774
  self._strategies if strategies is None else strategies
765
775
  ),
@@ -775,7 +785,19 @@ class App:
775
785
  self.container.strategy_orchestrator_service()
776
786
  strategy_orchestrator_service.initialize(algorithm)
777
787
  backtest_service = self.container.backtest_service()
788
+
789
+ # Setup snapshot service as observer
790
+ backtest_service.clear_observers()
791
+ portfolio_snapshot_service = \
792
+ self.container.portfolio_snapshot_service()
793
+ backtest_service.add_observer(portfolio_snapshot_service)
778
794
  context = self.container.context()
795
+ order_service = self.container.order_service()
796
+ order_service.clear_observers()
797
+ order_service.add_observer(portfolio_snapshot_service)
798
+ portfolio_service = self.container.portfolio_service()
799
+ portfolio_service.clear_observers()
800
+ portfolio_service.add_observer(portfolio_snapshot_service)
779
801
 
780
802
  # Run the backtest with the backtest_service and collect and
781
803
  # save the report
@@ -1334,7 +1334,6 @@ class Context:
1334
1334
  ticker = self.market_data_source_service.get_ticker(
1335
1335
  symbol=trade.symbol, market=portfolio.market
1336
1336
  )
1337
-
1338
1337
  logger.info(f"Closing trade {trade.id} {trade.symbol}")
1339
1338
  self.order_service.create(
1340
1339
  {
@@ -71,9 +71,13 @@ class DependencyContainer(containers.DeclarativeContainer):
71
71
  )
72
72
  portfolio_snapshot_service = providers.Factory(
73
73
  PortfolioSnapshotService,
74
+ order_repository=order_repository,
74
75
  repository=portfolio_snapshot_repository,
76
+ portfolio_repository=portfolio_repository,
75
77
  position_snapshot_service=position_snapshot_service,
76
78
  position_repository=position_repository,
79
+ datasource_service=market_data_source_service,
80
+ configuration_service=configuration_service
77
81
  )
78
82
  portfolio_configuration_service = providers.ThreadSafeSingleton(
79
83
  PortfolioConfigurationService,
@@ -8,7 +8,7 @@ from .constants import ITEMIZE, ITEMIZED, PER_PAGE, PAGE, ENVIRONMENT, \
8
8
  CURRENT_UTC_DATETIME, BACKTESTING_END_DATE, SYMBOLS, \
9
9
  CCXT_DATETIME_FORMAT_WITH_TIMEZONE, RESERVED_BALANCES, \
10
10
  APP_MODE, DATABASE_DIRECTORY_NAME, BACKTESTING_INITIAL_AMOUNT, \
11
- APPLICATION_DIRECTORY
11
+ APPLICATION_DIRECTORY, SNAPSHOT_INTERVAL
12
12
  from .data_structures import PeekableQueue
13
13
  from .decimal_parsing import parse_decimal_to_string, parse_string_to_decimal
14
14
  from .exceptions import OperationalException, ApiException, \
@@ -20,11 +20,11 @@ from .models import OrderStatus, OrderSide, OrderType, TimeInterval, \
20
20
  BacktestPosition, Trade, MarketCredential, PositionSnapshot, \
21
21
  BacktestReportsEvaluation, AppMode, BacktestDateRange, DateRange, \
22
22
  MarketDataType, TradeRiskType, TradeTakeProfit, TradeStopLoss, \
23
- DataSource
23
+ DataSource, Event, SnapshotInterval
24
24
  from .services import TickerMarketDataSource, OrderBookMarketDataSource, \
25
25
  OHLCVMarketDataSource, BacktestMarketDataSource, MarketDataSource, \
26
26
  MarketService, MarketCredentialService, AbstractPortfolioSyncService, \
27
- RoundingService, StateHandler
27
+ RoundingService, StateHandler, Observable, Observer
28
28
  from .stateless_actions import StatelessActions
29
29
  from .strategy import Strategy
30
30
  from .utils import random_string, append_dict_as_row_to_csv, \
@@ -141,5 +141,10 @@ __all__ = [
141
141
  "random_number",
142
142
  "is_timezone_aware",
143
143
  "sync_timezones",
144
- "get_timezone"
144
+ "get_timezone",
145
+ "Observer",
146
+ "Observable",
147
+ "Event",
148
+ "SNAPSHOT_INTERVAL",
149
+ "SnapshotInterval",
145
150
  ]
@@ -74,3 +74,4 @@ BACKTESTING_INITIAL_AMOUNT = "BACKTESTING_INITIAL_AMOUNT"
74
74
  TICKER_DATA_TYPE = "TICKER"
75
75
  OHLCV_DATA_TYPE = "OHLCV"
76
76
  CURRENT_UTC_DATETIME = "CURRENT_UTC_DATETIME"
77
+ SNAPSHOT_INTERVAL = "SNAPSHOT_INTERVAL"
@@ -16,6 +16,8 @@ from .trading_time_frame import TradingTimeFrame
16
16
  from .date_range import DateRange
17
17
  from .market_data_type import MarketDataType
18
18
  from .data_source import DataSource
19
+ from .snapshot_interval import SnapshotInterval
20
+ from .event import Event
19
21
 
20
22
  __all__ = [
21
23
  "OrderStatus",
@@ -46,5 +48,7 @@ __all__ = [
46
48
  "TradeStopLoss",
47
49
  "TradeTakeProfit",
48
50
  "TradeRiskType",
49
- "DataSource"
51
+ "DataSource",
52
+ "SnapshotInterval",
53
+ "Event",
50
54
  ]
@@ -419,9 +419,6 @@ class BacktestReport(BaseModel):
419
419
  Convert the backtest report to a dictionary. So it can be
420
420
  saved to a file.
421
421
 
422
- Args:
423
- None
424
-
425
422
  Returns:
426
423
  dict: The backtest report as a dictionary
427
424
  """
@@ -0,0 +1,35 @@
1
+ from enum import Enum
2
+
3
+
4
+ class Event(Enum):
5
+ PORTFOLIO_CREATED = "PORTFOLIO_CREATED"
6
+ ORDER_CREATED = "ORDER_CREATED"
7
+ TRADE_CLOSED = "TRADE_CLOSED"
8
+ STRATEGY_RUN = "STRATEGY_RUN"
9
+
10
+ @staticmethod
11
+ def from_string(value: str):
12
+
13
+ if isinstance(value, str):
14
+ for status in Event:
15
+
16
+ if value.upper() == status.value:
17
+ return status
18
+
19
+ raise ValueError("Could not convert value to Event")
20
+
21
+ @staticmethod
22
+ def from_value(value):
23
+
24
+ if isinstance(value, Event):
25
+ for status in Event:
26
+
27
+ if value == status:
28
+ return status
29
+ elif isinstance(value, str):
30
+ return Event.from_string(value)
31
+
32
+ raise ValueError(f"Could not convert value {value} to Event")
33
+
34
+ def equals(self, other):
35
+ return Event.from_value(other) == self
@@ -13,6 +13,7 @@ class PortfolioSnapshot(BaseModel):
13
13
  total_net_gain=None,
14
14
  total_revenue=None,
15
15
  total_cost=None,
16
+ total_value=None,
16
17
  cash_flow=None,
17
18
  created_at=None,
18
19
  position_snapshots=None
@@ -23,6 +24,7 @@ class PortfolioSnapshot(BaseModel):
23
24
  self.unallocated = unallocated
24
25
  self.total_net_gain = total_net_gain
25
26
  self.total_revenue = total_revenue
27
+ self.total_value = total_value if total_value is not None else 0.0
26
28
  self.net_size = net_size
27
29
  self.total_cost = total_cost
28
30
  self.cash_flow = cash_flow
@@ -69,6 +71,12 @@ class PortfolioSnapshot(BaseModel):
69
71
  def set_total_revenue(self, total_revenue):
70
72
  self.total_revenue = total_revenue
71
73
 
74
+ def get_total_value(self):
75
+ return self.total_value
76
+
77
+ def set_total_value(self, total_value):
78
+ self.total_value = total_value
79
+
72
80
  def get_total_cost(self):
73
81
  return self.total_cost
74
82
 
@@ -135,7 +143,8 @@ class PortfolioSnapshot(BaseModel):
135
143
 
136
144
  return {
137
145
  "net_size": self.net_size,
138
- "created_at": created_at
146
+ "created_at": created_at,
147
+ "total_value": self.total_value,
139
148
  }
140
149
 
141
150
  @staticmethod
@@ -152,4 +161,5 @@ class PortfolioSnapshot(BaseModel):
152
161
  return PortfolioSnapshot(
153
162
  net_size=data.get("net_size", 0.0),
154
163
  created_at=data.get("created_at"),
164
+ total_value=data.get("total_value", 0.0),
155
165
  )
@@ -0,0 +1,45 @@
1
+ from enum import Enum
2
+
3
+
4
+ class SnapshotInterval(Enum):
5
+ TRADE_CLOSE = "TRADE_CLOSE"
6
+ STRATEGY_ITERATION = "STRATEGY_ITERATION"
7
+
8
+ @staticmethod
9
+ def from_string(value: str):
10
+
11
+ if isinstance(value, str):
12
+
13
+ for entry in SnapshotInterval:
14
+
15
+ if value.upper() == entry.value:
16
+ return entry
17
+
18
+ raise ValueError(
19
+ f"Could not convert {value} to SnapshotInterval"
20
+ )
21
+ return None
22
+
23
+ @staticmethod
24
+ def from_value(value):
25
+
26
+ if isinstance(value, str):
27
+ return SnapshotInterval.from_string(value)
28
+
29
+ if isinstance(value, SnapshotInterval):
30
+
31
+ for entry in SnapshotInterval:
32
+
33
+ if value == entry:
34
+ return entry
35
+
36
+ raise ValueError(
37
+ f"Could not convert {value} to SnapshotInterval"
38
+ )
39
+
40
+ def equals(self, other):
41
+
42
+ if isinstance(other, Enum):
43
+ return self.value == other.value
44
+ else:
45
+ return SnapshotInterval.from_string(other) == self
@@ -5,6 +5,8 @@ from .market_service import MarketService
5
5
  from .portfolios import AbstractPortfolioSyncService
6
6
  from .rounding_service import RoundingService
7
7
  from .state_handler import StateHandler
8
+ from .observer import Observer
9
+ from .observable import Observable
8
10
 
9
11
  __all__ = [
10
12
  "MarketDataSource",
@@ -16,5 +18,7 @@ __all__ = [
16
18
  "MarketCredentialService",
17
19
  "AbstractPortfolioSyncService",
18
20
  "RoundingService",
19
- "StateHandler"
21
+ "StateHandler",
22
+ "Observer",
23
+ "Observable"
20
24
  ]
@@ -0,0 +1,51 @@
1
+ from investing_algorithm_framework.domain.models import Event
2
+
3
+
4
+ class Observable:
5
+ """
6
+ Abstract base class for observable objects.
7
+ Observables can be observed by observers that
8
+ implement the Observer interface.
9
+ """
10
+
11
+ def __init__(self):
12
+ super().__init__() # Important in diamond inheritance
13
+ self._observers = []
14
+
15
+ def add_observer(self, observer):
16
+ """
17
+ Add an observer to the observable.
18
+
19
+ Args:
20
+ observer: An object that implements the Observer interface.
21
+ """
22
+ if observer not in self._observers:
23
+ self._observers.append(observer)
24
+
25
+ def remove_observer(self, observer):
26
+ """
27
+ Remove an observer from the observable.
28
+
29
+ Args:
30
+ observer: An object that implements the Observer interface.
31
+ """
32
+ if observer in self._observers:
33
+ self._observers.remove(observer)
34
+
35
+ def notify_observers(self, event_type: Event, payload):
36
+ """
37
+ Notify all observers about an event.
38
+
39
+ Args:
40
+ event_type (Event): The type of event to notify observers about.
41
+ payload: The data to pass to the observers.
42
+ """
43
+ for observer in self._observers:
44
+ observer.notify(event_type, payload)
45
+
46
+ def clear_observers(self):
47
+ """
48
+ Clear all observers from the observable.
49
+ This is useful for resetting the state of the observable.
50
+ """
51
+ self._observers.clear()
@@ -0,0 +1,19 @@
1
+ from investing_algorithm_framework.domain.models import Event
2
+
3
+
4
+ class Observer:
5
+
6
+ """
7
+ Abstract base class for observers.
8
+ Observers can be notified by observables about events.
9
+ """
10
+
11
+ def notify(self, event_type: Event, payload):
12
+ """
13
+ Update the observer with the event type and payload.
14
+
15
+ Args:
16
+ event_type: The type of event that occurred.
17
+ payload: The data associated with the event.
18
+ """
19
+ raise NotImplementedError("Subclasses must implement this method.")
@@ -5,7 +5,8 @@ from .models import SQLPortfolio, SQLOrder, SQLPosition, \
5
5
  CCXTOHLCVBacktestMarketDataSource, CCXTOrderBookMarketDataSource, \
6
6
  CCXTTickerMarketDataSource, CCXTOHLCVMarketDataSource, \
7
7
  CSVOHLCVMarketDataSource, CSVTickerMarketDataSource, SQLTradeTakeProfit, \
8
- SQLTradeStopLoss
8
+ SQLTradeStopLoss, PandasOHLCVBacktestMarketDataSource, \
9
+ PandasOHLCVMarketDataSource
9
10
  from .repositories import SQLOrderRepository, SQLPositionRepository, \
10
11
  SQLPortfolioRepository, SQLTradeRepository, \
11
12
  SQLPortfolioSnapshotRepository, SQLPositionSnapshotRepository, \
@@ -55,4 +56,6 @@ __all__ = [
55
56
  "CCXTPortfolioProvider",
56
57
  "get_default_data_providers",
57
58
  "get_default_ohlcv_data_providers",
59
+ "PandasOHLCVBacktestMarketDataSource",
60
+ "PandasOHLCVMarketDataSource"
58
61
  ]
@@ -1,7 +1,8 @@
1
1
  from .market_data_sources import CCXTOrderBookMarketDataSource, \
2
2
  CCXTTickerMarketDataSource, CCXTOHLCVMarketDataSource, \
3
3
  CCXTOHLCVBacktestMarketDataSource, CSVOHLCVMarketDataSource, \
4
- CSVTickerMarketDataSource
4
+ CSVTickerMarketDataSource, PandasOHLCVBacktestMarketDataSource, \
5
+ PandasOHLCVMarketDataSource
5
6
  from .order import SQLOrder, SQLOrderMetadata
6
7
  from .portfolio import SQLPortfolio, SQLPortfolioSnapshot
7
8
  from .position import SQLPosition, SQLPositionSnapshot
@@ -23,4 +24,6 @@ __all__ = [
23
24
  "SQLTradeStopLoss",
24
25
  "SQLTradeTakeProfit",
25
26
  "SQLOrderMetadata",
27
+ "PandasOHLCVBacktestMarketDataSource",
28
+ "PandasOHLCVMarketDataSource"
26
29
  ]
@@ -1,6 +1,8 @@
1
1
  from .ccxt import CCXTOrderBookMarketDataSource, CCXTTickerMarketDataSource, \
2
2
  CCXTOHLCVMarketDataSource, CCXTOHLCVBacktestMarketDataSource
3
3
  from .csv import CSVOHLCVMarketDataSource, CSVTickerMarketDataSource
4
+ from .pandas import PandasOHLCVBacktestMarketDataSource, \
5
+ PandasOHLCVMarketDataSource
4
6
 
5
7
  __all__ = [
6
8
  'CCXTOrderBookMarketDataSource',
@@ -8,5 +10,7 @@ __all__ = [
8
10
  'CCXTOHLCVMarketDataSource',
9
11
  "CCXTOHLCVBacktestMarketDataSource",
10
12
  "CSVOHLCVMarketDataSource",
11
- "CSVTickerMarketDataSource"
13
+ "CSVTickerMarketDataSource",
14
+ "PandasOHLCVBacktestMarketDataSource",
15
+ "PandasOHLCVMarketDataSource"
12
16
  ]