investing-algorithm-framework 6.5.4__tar.gz → 6.6.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 (211) hide show
  1. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/PKG-INFO +8 -6
  2. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/README.md +6 -5
  3. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/__init__.py +9 -0
  4. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/__init__.py +5 -0
  5. investing_algorithm_framework-6.6.0/investing_algorithm_framework/app/metrics/__init__.py +14 -0
  6. investing_algorithm_framework-6.6.0/investing_algorithm_framework/app/metrics/equity_curve.py +25 -0
  7. investing_algorithm_framework-6.6.0/investing_algorithm_framework/app/metrics/profit_factor.py +121 -0
  8. investing_algorithm_framework-6.6.0/investing_algorithm_framework/app/metrics/sharp_ratio.py +81 -0
  9. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/dependency_container.py +1 -0
  10. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/__init__.py +5 -4
  11. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/data_provider.py +1 -0
  12. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/backtesting/backtest_report.py +41 -29
  13. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/portfolio/portfolio_snapshot.py +53 -9
  14. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/services/market_data_sources.py +0 -3
  15. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/utils/__init__.py +4 -0
  16. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/utils/backtesting.py +81 -38
  17. investing_algorithm_framework-6.6.0/investing_algorithm_framework/domain/utils/dates.py +57 -0
  18. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/utils/polars.py +2 -2
  19. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/download_data.py +3 -2
  20. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/__init__.py +3 -1
  21. investing_algorithm_framework-6.6.0/investing_algorithm_framework/infrastructure/data_providers/__init__.py +33 -0
  22. investing_algorithm_framework-6.6.0/investing_algorithm_framework/infrastructure/data_providers/ccxt.py +878 -0
  23. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/models/market_data_sources/ccxt.py +11 -7
  24. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/models/portfolio/portfolio_snapshot.py +7 -0
  25. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/backtesting/backtest_service.py +6 -2
  26. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/market_data_source_service/data_provider_service.py +148 -36
  27. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/portfolios/portfolio_snapshot_service.py +1 -3
  28. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/trade_service/trade_service.py +3 -1
  29. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/pyproject.toml +2 -1
  30. investing_algorithm_framework-6.5.4/investing_algorithm_framework/domain/metrics/__init__.py +0 -6
  31. investing_algorithm_framework-6.5.4/investing_algorithm_framework/infrastructure/data_providers/__init__.py +0 -19
  32. investing_algorithm_framework-6.5.4/investing_algorithm_framework/infrastructure/data_providers/ccxt.py +0 -313
  33. investing_algorithm_framework-6.5.4/investing_algorithm_framework/infrastructure/models/market_data_sources/us_treasury_yield.py +0 -47
  34. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/LICENSE +0 -0
  35. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/algorithm/__init__.py +0 -0
  36. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/algorithm/algorithm.py +0 -0
  37. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/algorithm/algorithm_factory.py +0 -0
  38. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/app.py +0 -0
  39. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/app_hook.py +0 -0
  40. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/context.py +0 -0
  41. {investing_algorithm_framework-6.5.4/investing_algorithm_framework/domain → investing_algorithm_framework-6.6.0/investing_algorithm_framework/app}/metrics/price_efficiency.py +0 -0
  42. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/stateless/__init__.py +0 -0
  43. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/stateless/action_handlers/__init__.py +0 -0
  44. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/stateless/action_handlers/action_handler_strategy.py +0 -0
  45. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/stateless/action_handlers/check_online_handler.py +0 -0
  46. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/stateless/action_handlers/run_strategy_handler.py +0 -0
  47. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/stateless/exception_handler.py +0 -0
  48. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/strategy.py +0 -0
  49. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/task.py +0 -0
  50. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/web/__init__.py +0 -0
  51. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/web/controllers/__init__.py +0 -0
  52. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/web/controllers/orders.py +0 -0
  53. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/web/controllers/portfolio.py +0 -0
  54. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/web/controllers/positions.py +0 -0
  55. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/web/create_app.py +0 -0
  56. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/web/error_handler.py +0 -0
  57. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/web/responses.py +0 -0
  58. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/web/run_strategies.py +0 -0
  59. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/web/schemas/__init__.py +0 -0
  60. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/web/schemas/order.py +0 -0
  61. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/web/schemas/portfolio.py +0 -0
  62. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/web/schemas/position.py +0 -0
  63. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/app/web/setup_cors.py +0 -0
  64. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/cli/__init__.py +0 -0
  65. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/cli/cli.py +0 -0
  66. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/cli/deploy_to_azure_function.py +0 -0
  67. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/cli/initialize_app.py +0 -0
  68. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/cli/templates/.gitignore.template +0 -0
  69. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/cli/templates/app-web.py.template +0 -0
  70. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/cli/templates/app.py.template +0 -0
  71. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/cli/templates/app_azure_function.py.template +0 -0
  72. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/cli/templates/app_web.py.template +0 -0
  73. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/cli/templates/azure_function_function_app.py.template +0 -0
  74. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/cli/templates/azure_function_host.json.template +0 -0
  75. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/cli/templates/azure_function_local.settings.json.template +0 -0
  76. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/cli/templates/data_providers.py.template +0 -0
  77. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/cli/templates/env.example.template +0 -0
  78. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/cli/templates/env_azure_function.example.template +0 -0
  79. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/cli/templates/market_data_providers.py.template +0 -0
  80. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/cli/templates/readme.md.template +0 -0
  81. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/cli/templates/requirements.txt.template +0 -0
  82. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/cli/templates/requirements_azure_function.txt.template +0 -0
  83. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/cli/templates/run_backtest.py.template +0 -0
  84. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/cli/templates/strategy.py.template +0 -0
  85. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/create_app.py +0 -0
  86. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/config.py +0 -0
  87. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/constants.py +0 -0
  88. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/data_structures.py +0 -0
  89. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/decimal_parsing.py +0 -0
  90. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/exceptions.py +0 -0
  91. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/__init__.py +0 -0
  92. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/app_mode.py +0 -0
  93. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/backtesting/__init__.py +0 -0
  94. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/backtesting/backtest_date_range.py +0 -0
  95. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/backtesting/backtest_position.py +0 -0
  96. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/backtesting/backtest_reports_evaluation.py +0 -0
  97. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/base_model.py +0 -0
  98. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/data_source.py +0 -0
  99. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/date_range.py +0 -0
  100. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/market/__init__.py +0 -0
  101. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/market/market_credential.py +0 -0
  102. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/market_data_type.py +0 -0
  103. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/order/__init__.py +0 -0
  104. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/order/order.py +0 -0
  105. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/order/order_side.py +0 -0
  106. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/order/order_status.py +0 -0
  107. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/order/order_type.py +0 -0
  108. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/portfolio/__init__.py +0 -0
  109. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/portfolio/portfolio.py +0 -0
  110. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/portfolio/portfolio_configuration.py +0 -0
  111. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/position/__init__.py +0 -0
  112. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/position/position.py +0 -0
  113. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/position/position_snapshot.py +0 -0
  114. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/strategy_profile.py +0 -0
  115. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/time_frame.py +0 -0
  116. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/time_interval.py +0 -0
  117. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/time_unit.py +0 -0
  118. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/tracing/__init__.py +0 -0
  119. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/tracing/trace.py +0 -0
  120. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/trade/__init__.py +0 -0
  121. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/trade/trade.py +0 -0
  122. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/trade/trade_risk_type.py +0 -0
  123. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/trade/trade_status.py +0 -0
  124. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/trade/trade_stop_loss.py +0 -0
  125. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/trade/trade_take_profit.py +0 -0
  126. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/trading_data_types.py +0 -0
  127. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/models/trading_time_frame.py +0 -0
  128. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/order_executor.py +0 -0
  129. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/portfolio_provider.py +0 -0
  130. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/services/__init__.py +0 -0
  131. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/services/market_credential_service.py +0 -0
  132. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/services/market_service.py +0 -0
  133. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/services/portfolios/__init__.py +0 -0
  134. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/services/portfolios/portfolio_sync_service.py +0 -0
  135. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/services/rounding_service.py +0 -0
  136. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/services/state_handler.py +0 -0
  137. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/stateless_actions.py +0 -0
  138. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/strategy.py +0 -0
  139. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/utils/csv.py +0 -0
  140. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/utils/random.py +0 -0
  141. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/utils/signatures.py +0 -0
  142. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/utils/stoppable_thread.py +0 -0
  143. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/domain/utils/synchronized.py +0 -0
  144. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/data_providers/csv.py +0 -0
  145. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/database/__init__.py +0 -0
  146. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/database/sql_alchemy.py +0 -0
  147. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/models/__init__.py +0 -0
  148. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/models/decimal_parser.py +0 -0
  149. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/models/market_data_sources/__init__.py +0 -0
  150. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/models/market_data_sources/csv.py +0 -0
  151. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/models/market_data_sources/pandas.py +0 -0
  152. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/models/model_extension.py +0 -0
  153. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/models/order/__init__.py +0 -0
  154. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/models/order/order.py +0 -0
  155. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/models/order/order_metadata.py +0 -0
  156. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/models/order_trade_association.py +0 -0
  157. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/models/portfolio/__init__.py +0 -0
  158. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/models/portfolio/sql_portfolio.py +0 -0
  159. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/models/position/__init__.py +0 -0
  160. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/models/position/position.py +0 -0
  161. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/models/position/position_snapshot.py +0 -0
  162. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/models/trades/__init__.py +0 -0
  163. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/models/trades/trade.py +0 -0
  164. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/models/trades/trade_stop_loss.py +0 -0
  165. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/models/trades/trade_take_profit.py +0 -0
  166. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/order_executors/__init__.py +0 -0
  167. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/order_executors/ccxt_order_executor.py +0 -0
  168. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/portfolio_providers/__init__.py +0 -0
  169. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/portfolio_providers/ccxt_portfolio_provider.py +0 -0
  170. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/repositories/__init__.py +0 -0
  171. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/repositories/order_metadata_repository.py +0 -0
  172. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/repositories/order_repository.py +0 -0
  173. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/repositories/portfolio_repository.py +0 -0
  174. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/repositories/portfolio_snapshot_repository.py +0 -0
  175. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/repositories/position_repository.py +0 -0
  176. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/repositories/position_snapshot_repository.py +0 -0
  177. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/repositories/repository.py +0 -0
  178. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/repositories/trade_repository.py +0 -0
  179. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/repositories/trade_stop_loss_repository.py +0 -0
  180. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/repositories/trade_take_profit_repository.py +0 -0
  181. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/services/__init__.py +0 -0
  182. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/services/azure/__init__.py +0 -0
  183. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/services/azure/state_handler.py +0 -0
  184. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/services/market_service/__init__.py +0 -0
  185. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/services/market_service/ccxt_market_service.py +0 -0
  186. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/services/performance_service/__init__.py +0 -0
  187. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/services/performance_service/backtest_performance_service.py +0 -0
  188. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/infrastructure/services/performance_service/performance_service.py +0 -0
  189. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/__init__.py +0 -0
  190. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/backtesting/__init__.py +0 -0
  191. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/configuration_service.py +0 -0
  192. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/market_credential_service.py +0 -0
  193. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/market_data_source_service/__init__.py +0 -0
  194. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/market_data_source_service/backtest_market_data_source_service.py +0 -0
  195. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/market_data_source_service/market_data_source_service.py +0 -0
  196. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/order_service/__init__.py +0 -0
  197. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/order_service/order_backtest_service.py +0 -0
  198. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/order_service/order_executor_lookup.py +0 -0
  199. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/order_service/order_service.py +0 -0
  200. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/portfolios/__init__.py +0 -0
  201. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/portfolios/backtest_portfolio_service.py +0 -0
  202. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/portfolios/portfolio_configuration_service.py +0 -0
  203. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/portfolios/portfolio_provider_lookup.py +0 -0
  204. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/portfolios/portfolio_service.py +0 -0
  205. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/portfolios/portfolio_sync_service.py +0 -0
  206. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/positions/__init__.py +0 -0
  207. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/positions/position_service.py +0 -0
  208. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/positions/position_snapshot_service.py +0 -0
  209. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/repository_service.py +0 -0
  210. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/strategy_orchestrator_service.py +0 -0
  211. {investing_algorithm_framework-6.5.4 → investing_algorithm_framework-6.6.0}/investing_algorithm_framework/services/trade_service/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: investing-algorithm-framework
3
- Version: 6.5.4
3
+ Version: 6.6.0
4
4
  Summary: A framework for creating trading bots
5
5
  Author: MDUYN
6
6
  Requires-Python: >=3.10
@@ -29,13 +29,14 @@ Requires-Dist: schedule (>=1.1.0)
29
29
  Requires-Dist: tabulate (>=0.9.0)
30
30
  Requires-Dist: tqdm (>=4.66.1)
31
31
  Requires-Dist: wrapt (>=1.16.0)
32
+ Requires-Dist: yfinance (>=0.2.61,<0.3.0)
32
33
  Description-Content-Type: text/markdown
33
34
 
34
- <div align="center"> <h1><a href="https://investing-algorithm-framework.com" target="_blank">Investing Algorithm Framework</a></h1> <p><b>Rapidly build, backtest, and deploy quantitative strategies and trading bots</b></p> <a target="_blank" href="https://investing-algorithm-framework.com">📖 View Documentation</a> | <a href="https://investing-algorithm-framework.com/Getting%20Started/installation">🚀 Getting Started</a> </div>
35
+ <div align="center"> <h1><a href="https://coding-kitties.github.io/investing-algorithm-framework/" target="_blank">Investing Algorithm Framework</a></h1> <p><b>Rapidly build, backtest, and deploy quantitative strategies and trading bots</b></p> <a target="_blank" href="https://coding-kitties.github.io/investing-algorithm-framework/">📖 View Documentation</a> | <a href="https://coding-kitties.github.io/investing-algorithm-framework/Getting%20Started/installation">🚀 Getting Started</a> </div>
35
36
 
36
37
  ---
37
38
 
38
- <div align="center"> <a href="https://investing-algorithm-framework.com">
39
+ <div align="center"> <a href="https://coding-kitties.github.io/investing-algorithm-framework/">
39
40
  <a target="_blank" href="https://discord.gg/dQsRmGZP"><img src="https://img.shields.io/discord/1345358169777635410.svg?color=7289da&label=TradeBotLab%20Discord&logo=discord&style=flat"></a>
40
41
  <img src="https://img.shields.io/badge/docs-website-brightgreen"></a> <a href="https://github.com/coding-kitties/investing-algorithm-framework/actions/workflows/publish.yml"><img src="https://github.com/coding-kitties/investing-algorithm-framework/actions/workflows/publish.yml/badge.svg"></a> <a href="https://github.com/coding-kitties/investing-algorithm-framework/actions/workflows/test.yml"><img src="https://github.com/coding-kitties/investing-algorithm-framework/actions/workflows/test.yml/badge.svg"></a> <a href="https://pepy.tech/project/investing-algorithm-framework"><img src="https://pepy.tech/badge/investing-algorithm-framework"></a> <a href="https://pypi.org/project/investing-algorithm-framework/"><img src="https://img.shields.io/pypi/v/investing-algorithm-framework.svg"></a> <a href="https://www.reddit.com/r/InvestingBots/"><img src="https://img.shields.io/reddit/subreddit-subscribers/investingbots?style=social"></a> <a href="https://github.com/coding-kitties/investing-algorithm-framework/stargazers"><img src="https://img.shields.io/github/stars/coding-kitties/investing-algorithm-framework.svg?style=social&label=Star"></a>
41
42
  </div>
@@ -290,7 +291,7 @@ This script:
290
291
  * Deploys your bot to Azure.
291
292
 
292
293
  ## 📚 Documentation
293
- Comprehensive documentation is available at [investing-algorithm-framework.com](https://investing-algorithm-framework.com).
294
+ Comprehensive documentation is available at [github pages](https://coding-kitties.github.io/investing-algorithm-framework/).
294
295
 
295
296
  ## 🛠️ Development
296
297
 
@@ -319,7 +320,6 @@ python -m unittest discover -s tests
319
320
 
320
321
  ## ⚠️ Disclaimer
321
322
 
322
-
323
323
  If you use this framework for your investments, do not risk money
324
324
  which you are afraid to lose, until you have clear understanding how the framework works. We can't stress this enough:
325
325
 
@@ -335,7 +335,7 @@ We welcome contributions! Check out the project board and issues to get started.
335
335
  ## Documentation
336
336
 
337
337
  All the documentation can be found online
338
- at the [documentation webstie](https://investing-algorithm-framework.com)
338
+ at the [documentation webstie](https://coding-kitties.github.io/investing-algorithm-framework/)
339
339
 
340
340
  In most cases, you'll probably never have to change code on this repo directly
341
341
  if you are building your algorithm/bot. But if you do, check out the
@@ -349,6 +349,8 @@ and developers, [join us on Slack](https://inv-algo-framework.slack.com) or [joi
349
349
  The investing algorithm framework is a community driven project.
350
350
  We welcome you to participate, contribute and together help build the future trading bots developed in python.
351
351
 
352
+ To get started, please read the [contributing guide](https://coding-kitties.github.io/investing-algorithm-framework/Contributing&20Guide/contributing).
353
+
352
354
  Feel like the framework is missing a feature? We welcome your pull requests!
353
355
  If you want to contribute to the project roadmap, please take a look at the [project board](https://github.com/coding-kitties/investing-algorithm-framework/projects?query=is%3Aopen).
354
356
  You can pick up a task by assigning yourself to it.
@@ -1,8 +1,8 @@
1
- <div align="center"> <h1><a href="https://investing-algorithm-framework.com" target="_blank">Investing Algorithm Framework</a></h1> <p><b>Rapidly build, backtest, and deploy quantitative strategies and trading bots</b></p> <a target="_blank" href="https://investing-algorithm-framework.com">📖 View Documentation</a> | <a href="https://investing-algorithm-framework.com/Getting%20Started/installation">🚀 Getting Started</a> </div>
1
+ <div align="center"> <h1><a href="https://coding-kitties.github.io/investing-algorithm-framework/" target="_blank">Investing Algorithm Framework</a></h1> <p><b>Rapidly build, backtest, and deploy quantitative strategies and trading bots</b></p> <a target="_blank" href="https://coding-kitties.github.io/investing-algorithm-framework/">📖 View Documentation</a> | <a href="https://coding-kitties.github.io/investing-algorithm-framework/Getting%20Started/installation">🚀 Getting Started</a> </div>
2
2
 
3
3
  ---
4
4
 
5
- <div align="center"> <a href="https://investing-algorithm-framework.com">
5
+ <div align="center"> <a href="https://coding-kitties.github.io/investing-algorithm-framework/">
6
6
  <a target="_blank" href="https://discord.gg/dQsRmGZP"><img src="https://img.shields.io/discord/1345358169777635410.svg?color=7289da&label=TradeBotLab%20Discord&logo=discord&style=flat"></a>
7
7
  <img src="https://img.shields.io/badge/docs-website-brightgreen"></a> <a href="https://github.com/coding-kitties/investing-algorithm-framework/actions/workflows/publish.yml"><img src="https://github.com/coding-kitties/investing-algorithm-framework/actions/workflows/publish.yml/badge.svg"></a> <a href="https://github.com/coding-kitties/investing-algorithm-framework/actions/workflows/test.yml"><img src="https://github.com/coding-kitties/investing-algorithm-framework/actions/workflows/test.yml/badge.svg"></a> <a href="https://pepy.tech/project/investing-algorithm-framework"><img src="https://pepy.tech/badge/investing-algorithm-framework"></a> <a href="https://pypi.org/project/investing-algorithm-framework/"><img src="https://img.shields.io/pypi/v/investing-algorithm-framework.svg"></a> <a href="https://www.reddit.com/r/InvestingBots/"><img src="https://img.shields.io/reddit/subreddit-subscribers/investingbots?style=social"></a> <a href="https://github.com/coding-kitties/investing-algorithm-framework/stargazers"><img src="https://img.shields.io/github/stars/coding-kitties/investing-algorithm-framework.svg?style=social&label=Star"></a>
8
8
  </div>
@@ -257,7 +257,7 @@ This script:
257
257
  * Deploys your bot to Azure.
258
258
 
259
259
  ## 📚 Documentation
260
- Comprehensive documentation is available at [investing-algorithm-framework.com](https://investing-algorithm-framework.com).
260
+ Comprehensive documentation is available at [github pages](https://coding-kitties.github.io/investing-algorithm-framework/).
261
261
 
262
262
  ## 🛠️ Development
263
263
 
@@ -286,7 +286,6 @@ python -m unittest discover -s tests
286
286
 
287
287
  ## ⚠️ Disclaimer
288
288
 
289
-
290
289
  If you use this framework for your investments, do not risk money
291
290
  which you are afraid to lose, until you have clear understanding how the framework works. We can't stress this enough:
292
291
 
@@ -302,7 +301,7 @@ We welcome contributions! Check out the project board and issues to get started.
302
301
  ## Documentation
303
302
 
304
303
  All the documentation can be found online
305
- at the [documentation webstie](https://investing-algorithm-framework.com)
304
+ at the [documentation webstie](https://coding-kitties.github.io/investing-algorithm-framework/)
306
305
 
307
306
  In most cases, you'll probably never have to change code on this repo directly
308
307
  if you are building your algorithm/bot. But if you do, check out the
@@ -316,6 +315,8 @@ and developers, [join us on Slack](https://inv-algo-framework.slack.com) or [joi
316
315
  The investing algorithm framework is a community driven project.
317
316
  We welcome you to participate, contribute and together help build the future trading bots developed in python.
318
317
 
318
+ To get started, please read the [contributing guide](https://coding-kitties.github.io/investing-algorithm-framework/Contributing&20Guide/contributing).
319
+
319
320
  Feel like the framework is missing a feature? We welcome your pull requests!
320
321
  If you want to contribute to the project roadmap, please take a look at the [project board](https://github.com/coding-kitties/investing-algorithm-framework/projects?query=is%3Aopen).
321
322
  You can pick up a task by assigning yourself to it.
@@ -20,6 +20,9 @@ from investing_algorithm_framework.infrastructure import \
20
20
  CSVTickerMarketDataSource, AzureBlobStorageStateHandler
21
21
  from .create_app import create_app
22
22
  from .download_data import download
23
+ from .app.metrics import get_profit_factor, \
24
+ get_cumulative_profit_factor_series, get_rolling_profit_factor_series, \
25
+ get_sharpe_ratio, get_price_efficiency_ratio, get_equity_curve
23
26
 
24
27
  __all__ = [
25
28
  "Algorithm",
@@ -85,4 +88,10 @@ __all__ = [
85
88
  "DataSource",
86
89
  "OrderExecutor",
87
90
  "PortfolioProvider",
91
+ "get_profit_factor",
92
+ "get_cumulative_profit_factor_series",
93
+ "get_rolling_profit_factor_series",
94
+ "get_sharpe_ratio",
95
+ "get_price_efficiency_ratio",
96
+ "get_equity_curve",
88
97
  ]
@@ -5,6 +5,8 @@ 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
  __all__ = [
10
12
  "Algorithm",
@@ -15,4 +17,7 @@ __all__ = [
15
17
  "Task",
16
18
  "AppHook",
17
19
  "Context",
20
+ "get_cumulative_profit_factor_series",
21
+ "get_rolling_profit_factor_series",
22
+ "get_price_efficiency_ratio"
18
23
  ]
@@ -0,0 +1,14 @@
1
+ from .price_efficiency import get_price_efficiency_ratio
2
+ from .profit_factor import get_cumulative_profit_factor_series, \
3
+ get_rolling_profit_factor_series, get_profit_factor
4
+ from .sharp_ratio import get_sharpe_ratio
5
+ from .equity_curve import get_equity_curve
6
+
7
+ __all__ = [
8
+ "get_price_efficiency_ratio",
9
+ "get_rolling_profit_factor_series",
10
+ "get_cumulative_profit_factor_series",
11
+ "get_profit_factor",
12
+ "get_sharpe_ratio",
13
+ "get_equity_curve"
14
+ ]
@@ -0,0 +1,25 @@
1
+ from datetime import datetime
2
+ from investing_algorithm_framework.domain import BacktestReport
3
+
4
+
5
+ def get_equity_curve(
6
+ backtest_report: BacktestReport
7
+ ) -> list[tuple[datetime, float]]:
8
+ """
9
+ Calculate the total size of the portfolio at each snapshot timestamp.
10
+
11
+ Args:
12
+ backtest_report (BacktestReport): The backtest report
13
+ containing history of the portfolio.
14
+
15
+ Returns:
16
+ list[tuple[datetime, float]]: A list of tuples with
17
+ timestamps and total sizes.
18
+ """
19
+ series = []
20
+ for snapshot in backtest_report.get_snapshots():
21
+ timestamp = snapshot.created_at
22
+ total_size = snapshot.net_size
23
+ series.append((timestamp, total_size))
24
+
25
+ return series
@@ -0,0 +1,121 @@
1
+ from collections import deque
2
+ from datetime import datetime
3
+ from typing import List, Tuple
4
+
5
+ from investing_algorithm_framework.domain.models import BacktestReport, \
6
+ TradeStatus
7
+
8
+
9
+ def get_cumulative_profit_factor_series(
10
+ backtest_report: BacktestReport
11
+ ) -> list[tuple[datetime, float]]:
12
+ """
13
+ Calculates the cumulative profit factor over time from a backtest report.
14
+
15
+ Args:
16
+ backtest_report (BacktestReport): Instance containing closed trades.
17
+
18
+ Returns:
19
+ List of (datetime, float) tuples: (timestamp, cumulative profit factor)
20
+ """
21
+ results = []
22
+ gross_profit = 0.0
23
+ gross_loss = 0.0
24
+
25
+ for trade in backtest_report.get_trades(
26
+ trade_status=TradeStatus.CLOSED.value
27
+ ):
28
+ close_time = trade.closed_at
29
+ profit = trade.net_gain
30
+
31
+ if profit >= 0:
32
+ gross_profit += profit
33
+ else:
34
+ gross_loss += abs(profit)
35
+
36
+ # Calculate profit factor with division-by-zero protection
37
+ if gross_loss > 0:
38
+ profit_factor = gross_profit / gross_loss
39
+ else:
40
+ profit_factor = float('inf') if gross_profit > 0 else 0.0
41
+
42
+ results.append((close_time, profit_factor))
43
+
44
+ return results
45
+
46
+
47
+ def get_rolling_profit_factor_series(
48
+ backtest_report: BacktestReport, window_size: int = 20
49
+ ) -> List[Tuple[datetime, float]]:
50
+ """
51
+ Calculates the rolling profit factor over time from a backtest report.
52
+
53
+ The rolling profit factor is computed using the most recent
54
+ `window_size` trades and updated after each closed trade.
55
+
56
+ Args:
57
+ backtest_report (BacktestReport): A instance of BacktestReport
58
+ containing closed trades.
59
+ window_size: The number of most recent trades to include in
60
+ each rolling calculation.
61
+
62
+ Returns:
63
+ A list of tuples, where each tuple contains:
64
+ - datetime: The close time of the trade (or aligned date).
65
+ - float: The rolling profit factor at that time.
66
+ """
67
+
68
+ results = []
69
+ trade_window = deque(maxlen=window_size)
70
+
71
+ for trade in backtest_report.get_trades(
72
+ trade_status=TradeStatus.CLOSED.value
73
+ ):
74
+ close_time = trade.closed_at
75
+ profit = trade.net_gain
76
+
77
+ trade_window.append(profit)
78
+
79
+ gross_profit = sum(p for p in trade_window if p >= 0)
80
+ gross_loss = sum(abs(p) for p in trade_window if p < 0)
81
+
82
+ if gross_loss > 0:
83
+ profit_factor = gross_profit / gross_loss
84
+ else:
85
+ profit_factor = float('inf') if gross_profit > 0 else 0.0
86
+
87
+ results.append((close_time, profit_factor))
88
+
89
+ return results
90
+
91
+
92
+ def get_profit_factor(backtest_report: BacktestReport) -> float:
93
+ """
94
+ Calculates the total profit factor at the end of the backtest.
95
+
96
+ The profit factor is defined as:
97
+ Total Gross Profit / Total Gross Loss
98
+
99
+ Args:
100
+ backtest_report (BacktestReport): An instance of BacktestReport
101
+ containing closed trades.
102
+
103
+ Returns:
104
+ float: The profit factor at the end of the backtest.
105
+ Returns float('inf') if there are no losses,
106
+ and 0.0 if there are no profits and losses.
107
+ """
108
+ gross_profit = 0.0
109
+ gross_loss = 0.0
110
+
111
+ for trade in backtest_report.get_trades(trade_status=TradeStatus.CLOSED):
112
+ profit = trade.net_gain
113
+ if profit > 0:
114
+ gross_profit += profit
115
+ elif profit < 0:
116
+ gross_loss += abs(profit)
117
+
118
+ if gross_loss == 0:
119
+ return float('inf') if gross_profit > 0 else 0.0
120
+
121
+ return gross_profit / gross_loss
@@ -0,0 +1,81 @@
1
+ from typing import Optional
2
+
3
+ import pandas as pd
4
+ import yfinance as yf
5
+
6
+ from investing_algorithm_framework.domain.models import TradeStatus
7
+
8
+
9
+ def get_sharpe_ratio(
10
+ backtest_report,
11
+ region: str = 'us',
12
+ risk_free_rate: Optional[float] = None,
13
+ frequency: str = 'weekly' # 'daily' or 'weekly'
14
+ ) -> float:
15
+ """
16
+ Calculate the Sharpe Ratio from a backtest report using daily or
17
+ weekly returns.
18
+
19
+ The Sharpe Ratio is calculated as:
20
+ (Annualized Return - Risk-Free Rate) / Annualized Std Dev of Returns
21
+
22
+ Args:
23
+ backtest_report: Object with get_trades(trade_status=...) and
24
+ `number_of_days` attributes.
25
+ region (str): Used to fetch the default risk-free rate if not
26
+ provided. Defaults to 'us'. 'eu' for Europe, 'us' for the
27
+ United States.
28
+ risk_free_rate (float, optional): Annual risk-free rate as a
29
+ decimal (e.g., 0.047 for 4.7%).
30
+ frequency (str): Either 'daily' or 'weekly', determines return
31
+ interval.
32
+
33
+ Returns:
34
+ float: The Sharpe Ratio.
35
+ """
36
+ if risk_free_rate is None:
37
+ if region.lower() == 'us':
38
+ risk_free_rate = get_risk_free_rate_us()
39
+ else:
40
+ raise ValueError(f"Unsupported region: {region}")
41
+
42
+ trades = backtest_report.get_trades(trade_status=TradeStatus.CLOSED)
43
+ if not trades:
44
+ return 0.0
45
+
46
+ data = [(trade.closed_at, trade.net_gain) for trade in trades]
47
+ df = pd.DataFrame(data, columns=['timestamp', 'net_gain'])
48
+ df.set_index('timestamp', inplace=True)
49
+
50
+ # Resample net gains
51
+ if frequency == 'weekly':
52
+ returns = df['net_gain'].resample('W').sum()
53
+ elif frequency == 'daily':
54
+ returns = df['net_gain'].resample('D').sum()
55
+ else:
56
+ raise ValueError("frequency must be 'daily' or 'weekly'")
57
+
58
+ returns = returns[returns != 0]
59
+ if len(returns) < 2:
60
+ return 0.0
61
+
62
+ duration_years = backtest_report.number_of_days / 365.25
63
+
64
+ total_return = returns.sum()
65
+ annualized_return = total_return / duration_years
66
+
67
+ std_dev = returns.std()
68
+ annualized_std = std_dev * (len(returns) ** 0.5) / duration_years ** 0.5
69
+
70
+ if annualized_std == 0:
71
+ return 0.0
72
+
73
+ sharpe_ratio = (annualized_return - risk_free_rate) / annualized_std
74
+ return sharpe_ratio
75
+
76
+
77
+ def get_risk_free_rate_us():
78
+ ten_year = yf.Ticker("^TNX")
79
+ hist = ten_year.history(period="5d")
80
+ latest_yield = hist["Close"].iloc[-1] / 100
81
+ return latest_yield
@@ -155,6 +155,7 @@ class DependencyContainer(containers.DeclarativeContainer):
155
155
  market_data_source_service=market_data_source_service,
156
156
  portfolio_configuration_service=portfolio_configuration_service,
157
157
  strategy_orchestrator_service=strategy_orchestrator_service,
158
+ portfolio_snapshot_service=portfolio_snapshot_service,
158
159
  )
159
160
  context = providers.Factory(
160
161
  Context,
@@ -33,8 +33,7 @@ from .utils import random_string, append_dict_as_row_to_csv, \
33
33
  csv_to_list, StoppableThread, pretty_print_backtest_reports_evaluation, \
34
34
  pretty_print_backtest, load_csv_into_dict, load_backtest_reports, \
35
35
  get_backtest_report, pretty_print_positions, pretty_print_trades, \
36
- pretty_print_orders
37
- from .metrics import get_price_efficiency_ratio
36
+ pretty_print_orders, is_timezone_aware, sync_timezones, get_timezone
38
37
  from .data_provider import DataProvider
39
38
  from .order_executor import OrderExecutor
40
39
  from .portfolio_provider import PortfolioProvider
@@ -119,7 +118,6 @@ __all__ = [
119
118
  "RoundingService",
120
119
  "BacktestDateRange",
121
120
  "load_backtest_report",
122
- "get_price_efficiency_ratio",
123
121
  "convert_polars_to_pandas",
124
122
  "DateRange",
125
123
  "get_backtest_report",
@@ -140,5 +138,8 @@ __all__ = [
140
138
  "DataSource",
141
139
  "OrderExecutor",
142
140
  "PortfolioProvider",
143
- "random_number"
141
+ "random_number",
142
+ "is_timezone_aware",
143
+ "sync_timezones",
144
+ "get_timezone"
144
145
  ]
@@ -148,6 +148,7 @@ class DataProvider(ABC):
148
148
  storage_path=None,
149
149
  window_size=None,
150
150
  pandas=False,
151
+ save: bool = True,
151
152
  ):
152
153
  """
153
154
  Fetches data for a given symbol and date range.
@@ -5,12 +5,12 @@ from logging import getLogger
5
5
  from pandas import DataFrame
6
6
 
7
7
  from investing_algorithm_framework.domain.constants import DATETIME_FORMAT
8
- from investing_algorithm_framework.domain.metrics import \
9
- get_price_efficiency_ratio
10
8
  from investing_algorithm_framework.domain.models \
11
9
  .backtesting.backtest_date_range import BacktestDateRange
12
10
  from investing_algorithm_framework.domain.models.base_model import BaseModel
13
11
  from investing_algorithm_framework.domain.models.position import Position
12
+ from investing_algorithm_framework.domain.models.portfolio\
13
+ .portfolio_snapshot import PortfolioSnapshot
14
14
  from investing_algorithm_framework.domain.models.trade import Trade, \
15
15
  TradeStatus
16
16
  from investing_algorithm_framework.domain.models.order import Order
@@ -60,6 +60,7 @@ class BacktestReport(BaseModel):
60
60
  orders=None,
61
61
  created_at: datetime = None,
62
62
  context=None,
63
+ portfolio_snapshots=None,
63
64
  ):
64
65
  self._traces = {}
65
66
  self.metrics = {}
@@ -94,7 +95,7 @@ class BacktestReport(BaseModel):
94
95
  self._interval = interval
95
96
  self._time_unit = time_unit
96
97
  self._context = context
97
-
98
+ self._portfolio_snapshots = portfolio_snapshots
98
99
  self._symbols = symbols
99
100
 
100
101
  if self._symbols is None:
@@ -124,6 +125,28 @@ class BacktestReport(BaseModel):
124
125
  def portfolio_id(self, portfolio_id):
125
126
  self._portfolio_id = portfolio_id
126
127
 
128
+ def set_portfolio_snapshots(self, portfolio_snapshots):
129
+ """
130
+ Set the portfolio snapshots of the backtest report.
131
+
132
+ Args:
133
+ portfolio_snapshots (list): The portfolio snapshots of the
134
+ backtest report.
135
+
136
+ Returns:
137
+ None
138
+ """
139
+ self._portfolio_snapshots = portfolio_snapshots
140
+
141
+ def get_snapshots(self):
142
+ """
143
+ Get the portfolio snapshots of the backtest report.
144
+
145
+ Returns:
146
+ list: The portfolio snapshots of the backtest report.
147
+ """
148
+ return self._portfolio_snapshots
149
+
127
150
  @property
128
151
  def symbols(self):
129
152
  return self._symbols
@@ -452,6 +475,10 @@ class BacktestReport(BaseModel):
452
475
  order.to_dict(datetime_format=DATETIME_FORMAT)
453
476
  for order in self.orders
454
477
  ],
478
+ "portfolio_snapshots": [
479
+ snapshot.to_dict(datetime_format=DATETIME_FORMAT)
480
+ for snapshot in self.get_snapshots()
481
+ ],
455
482
  "created_at": self.created_at.strftime(DATETIME_FORMAT),
456
483
  }
457
484
 
@@ -501,16 +528,24 @@ class BacktestReport(BaseModel):
501
528
  Position.from_dict(position) for position in positions
502
529
  ]
503
530
 
504
- trades = data["trades"]
531
+ trades = data.get("trades", None)
505
532
 
506
533
  if trades is not None:
507
534
  report.trades = [Trade.from_dict(trade) for trade in trades]
508
535
 
509
- orders = data["orders"]
536
+ orders = data.get("orders", None)
510
537
 
511
538
  if orders is not None:
512
539
  report.orders = [Order.from_dict(order) for order in orders]
513
540
 
541
+ portfolio_snapshots = data.get("portfolio_snapshots", None)
542
+
543
+ if portfolio_snapshots is not None:
544
+ report.set_portfolio_snapshots(
545
+ [PortfolioSnapshot.from_dict(snapshot)
546
+ for snapshot in portfolio_snapshots]
547
+ )
548
+
514
549
  return report
515
550
 
516
551
  def get_profit(self) -> float:
@@ -536,29 +571,6 @@ class BacktestReport(BaseModel):
536
571
  if symbol not in self.symbols:
537
572
  self.symbols.append(symbol)
538
573
 
539
- def calculate_metrics(self):
540
- """
541
- Parent method to calculate all metrics.
542
-
543
- returns:
544
- None
545
- """
546
- if self.traces is not None:
547
- self.metrics['efficiency_ratio'] = {}
548
-
549
- for strategy_id in self.traces:
550
- entries = self.traces[strategy_id]
551
-
552
- if entries is None:
553
- continue
554
-
555
- for symbol in entries:
556
-
557
- self.metrics['efficiency_ratio'][symbol] = \
558
- get_price_efficiency_ratio(
559
- self.traces[strategy_id][symbol]
560
- )
561
-
562
574
  @property
563
575
  def traces(self):
564
576
  """
@@ -662,7 +674,7 @@ class BacktestReport(BaseModel):
662
674
 
663
675
  Args:
664
676
  target_symbol (str): The target_symbol
665
- trade_status (str): The trade_status
677
+ trade_status: The trade_status
666
678
 
667
679
  Returns:
668
680
  list: The trades of the backtest report
@@ -5,15 +5,16 @@ class PortfolioSnapshot(BaseModel):
5
5
 
6
6
  def __init__(
7
7
  self,
8
- portfolio_id,
9
- trading_symbol,
10
- pending_value,
11
- unallocated,
12
- total_net_gain,
13
- total_revenue,
14
- total_cost,
15
- cash_flow,
16
- created_at,
8
+ portfolio_id=None,
9
+ trading_symbol=None,
10
+ pending_value=None,
11
+ unallocated=None,
12
+ net_size=None,
13
+ total_net_gain=None,
14
+ total_revenue=None,
15
+ total_cost=None,
16
+ cash_flow=None,
17
+ created_at=None,
17
18
  position_snapshots=None
18
19
  ):
19
20
  self.portfolio_id = portfolio_id
@@ -22,6 +23,7 @@ class PortfolioSnapshot(BaseModel):
22
23
  self.unallocated = unallocated
23
24
  self.total_net_gain = total_net_gain
24
25
  self.total_revenue = total_revenue
26
+ self.net_size = net_size
25
27
  self.total_cost = total_cost
26
28
  self.cash_flow = cash_flow
27
29
  self.created_at = created_at
@@ -102,6 +104,7 @@ class PortfolioSnapshot(BaseModel):
102
104
  portfolio_id=self.portfolio_id,
103
105
  created_at=self.created_at.strftime("%Y-%m-%d %H:%M:%S"),
104
106
  trading_symbol=self.trading_symbol,
107
+ net_size=self.net_size,
105
108
  unallocated=self.unallocated,
106
109
  pending_value=self.pending_value,
107
110
  total_net_gain=self.total_net_gain,
@@ -109,3 +112,44 @@ class PortfolioSnapshot(BaseModel):
109
112
  total_cost=self.total_cost,
110
113
  cash_flow=self.cash_flow,
111
114
  )
115
+
116
+ def to_dict(self, datetime_format=None):
117
+ """
118
+ Convert the portfolio snapshot object to a dictionary
119
+
120
+ Args:
121
+ datetime_format (str): The format to use for the datetime fields.
122
+ If None, the datetime fields will be returned as is.
123
+ Defaults to None.
124
+
125
+ Returns:
126
+ dict: A dictionary representation of the portfolio snapshot object.
127
+ """
128
+
129
+ if datetime_format is not None:
130
+ created_at = self.created_at.strftime(datetime_format) \
131
+ if self.created_at else None
132
+
133
+ else:
134
+ created_at = self.created_at
135
+
136
+ return {
137
+ "net_size": self.net_size,
138
+ "created_at": created_at
139
+ }
140
+
141
+ @staticmethod
142
+ def from_dict(data):
143
+ """
144
+ Create a PortfolioSnapshot object from a dictionary.
145
+
146
+ Args:
147
+ data (dict): A dictionary containing the portfolio snapshot data.
148
+
149
+ Returns:
150
+ PortfolioSnapshot: An instance of PortfolioSnapshot.
151
+ """
152
+ return PortfolioSnapshot(
153
+ net_size=data.get("net_size", 0.0),
154
+ created_at=data.get("created_at"),
155
+ )