investing-algorithm-framework 4.0.1__tar.gz → 4.1.1__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 (166) hide show
  1. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/PKG-INFO +1 -1
  2. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/__init__.py +4 -2
  3. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/algorithm.py +26 -11
  4. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/app.py +23 -30
  5. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/dependency_container.py +3 -6
  6. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/backtesting/backtest_report.py +4 -10
  7. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/portfolio/portfolio.py +31 -0
  8. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/portfolio/portfolio_configuration.py +22 -3
  9. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/services/market_data_sources.py +15 -0
  10. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/services/market_service.py +1 -1
  11. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/market_data_sources/ccxt.py +14 -6
  12. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/repositories/portfolio_repository.py +1 -1
  13. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/repositories/repository.py +1 -0
  14. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/services/performance_service/performance_service.py +4 -0
  15. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/__init__.py +1 -5
  16. investing_algorithm_framework-4.1.1/investing_algorithm_framework/services/backtesting/__init__.py +5 -0
  17. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/backtesting/backtest_service.py +176 -25
  18. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/market_data_source_service/market_data_source_service.py +20 -20
  19. investing_algorithm_framework-4.1.1/investing_algorithm_framework/services/portfolios/backtest_portfolio_service.py +46 -0
  20. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/portfolios/portfolio_configuration_service.py +9 -6
  21. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/portfolios/portfolio_service.py +6 -1
  22. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/pyproject.toml +1 -1
  23. investing_algorithm_framework-4.0.1/investing_algorithm_framework/services/backtesting/__init__.py +0 -12
  24. investing_algorithm_framework-4.0.1/investing_algorithm_framework/services/backtesting/backtest_report_writer_service.py +0 -91
  25. investing_algorithm_framework-4.0.1/investing_algorithm_framework/services/backtesting/graphs.py +0 -61
  26. investing_algorithm_framework-4.0.1/investing_algorithm_framework/services/portfolios/backtest_portfolio_service.py +0 -21
  27. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/LICENSE +0 -0
  28. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/README.md +0 -0
  29. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/__init__.py +0 -0
  30. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/stateless/__init__.py +0 -0
  31. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/stateless/action_handlers/__init__.py +0 -0
  32. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/stateless/action_handlers/action_handler_strategy.py +0 -0
  33. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/stateless/action_handlers/check_online_handler.py +0 -0
  34. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/stateless/action_handlers/run_strategy_handler.py +0 -0
  35. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/stateless/exception_handler.py +0 -0
  36. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/strategy.py +0 -0
  37. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/task.py +0 -0
  38. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/__init__.py +0 -0
  39. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/controllers/__init__.py +0 -0
  40. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/controllers/orders.py +0 -0
  41. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/controllers/portfolio.py +0 -0
  42. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/controllers/positions.py +0 -0
  43. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/create_app.py +0 -0
  44. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/error_handler.py +0 -0
  45. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/responses.py +0 -0
  46. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/run_strategies.py +0 -0
  47. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/schemas/__init__.py +0 -0
  48. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/schemas/order.py +0 -0
  49. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/schemas/portfolio.py +0 -0
  50. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/schemas/position.py +0 -0
  51. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/app/web/setup_cors.py +0 -0
  52. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/cli/__init__.py +0 -0
  53. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/cli/create_azure_function_app_skeleton.py +0 -0
  54. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/cli/deploy_to_azure_function.py +0 -0
  55. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/cli/templates/azure_function_framework_app.py.template +0 -0
  56. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/cli/templates/azure_function_function_app.py.template +0 -0
  57. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/cli/templates/azure_function_host.json.template +0 -0
  58. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/cli/templates/azure_function_local.settings.json.template +0 -0
  59. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/cli/templates/azure_function_requirements.txt.template +0 -0
  60. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/create_app.py +0 -0
  61. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/__init__.py +0 -0
  62. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/config.py +0 -0
  63. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/constants.py +0 -0
  64. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/data_structures.py +0 -0
  65. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/decimal_parsing.py +0 -0
  66. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/exceptions.py +0 -0
  67. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/metrics/__init__.py +0 -0
  68. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/metrics/price_efficiency.py +0 -0
  69. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/__init__.py +0 -0
  70. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/app_mode.py +0 -0
  71. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/backtesting/__init__.py +0 -0
  72. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/backtesting/backtest_date_range.py +0 -0
  73. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/backtesting/backtest_position.py +0 -0
  74. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/backtesting/backtest_reports_evaluation.py +0 -0
  75. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/base_model.py +0 -0
  76. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/date_range.py +0 -0
  77. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/market/__init__.py +0 -0
  78. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/market/market_credential.py +0 -0
  79. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/order/__init__.py +0 -0
  80. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/order/order.py +0 -0
  81. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/order/order_side.py +0 -0
  82. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/order/order_status.py +0 -0
  83. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/order/order_type.py +0 -0
  84. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/portfolio/__init__.py +0 -0
  85. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/portfolio/portfolio_snapshot.py +0 -0
  86. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/position/__init__.py +0 -0
  87. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/position/position.py +0 -0
  88. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/position/position_snapshot.py +0 -0
  89. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/strategy_profile.py +0 -0
  90. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/time_frame.py +0 -0
  91. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/time_interval.py +0 -0
  92. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/time_unit.py +0 -0
  93. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/tracing/__init__.py +0 -0
  94. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/tracing/trace.py +0 -0
  95. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/trade/__init__.py +0 -0
  96. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/trade/trade.py +0 -0
  97. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/trade/trade_status.py +0 -0
  98. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/trading_data_types.py +0 -0
  99. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/models/trading_time_frame.py +0 -0
  100. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/services/__init__.py +0 -0
  101. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/services/market_credential_service.py +0 -0
  102. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/services/portfolios/__init__.py +0 -0
  103. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/services/portfolios/portfolio_sync_service.py +0 -0
  104. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/services/rounding_service.py +0 -0
  105. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/singleton.py +0 -0
  106. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/stateless_actions.py +0 -0
  107. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/strategy.py +0 -0
  108. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/utils/__init__.py +0 -0
  109. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/utils/backtesting.py +0 -0
  110. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/utils/csv.py +0 -0
  111. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/utils/polars.py +0 -0
  112. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/utils/random.py +0 -0
  113. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/utils/signatures.py +0 -0
  114. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/utils/stoppable_thread.py +0 -0
  115. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/domain/utils/synchronized.py +0 -0
  116. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/indicators/__init__.py +0 -0
  117. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/indicators/advanced.py +0 -0
  118. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/indicators/momentum.py +0 -0
  119. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/indicators/trend.py +0 -0
  120. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/indicators/utils.py +0 -0
  121. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/__init__.py +0 -0
  122. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/database/__init__.py +0 -0
  123. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/database/sql_alchemy.py +0 -0
  124. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/__init__.py +0 -0
  125. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/decimal_parser.py +0 -0
  126. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/market_data_sources/__init__.py +0 -0
  127. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/market_data_sources/csv.py +0 -0
  128. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/market_data_sources/pandas.py +0 -0
  129. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/market_data_sources/us_treasury_yield.py +0 -0
  130. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/model_extension.py +0 -0
  131. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/order/__init__.py +0 -0
  132. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/order/order.py +0 -0
  133. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/portfolio/__init__.py +0 -0
  134. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/portfolio/portfolio_snapshot.py +0 -0
  135. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/portfolio/sql_portfolio.py +0 -0
  136. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/position/__init__.py +0 -0
  137. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/position/position.py +0 -0
  138. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/models/position/position_snapshot.py +0 -0
  139. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/repositories/__init__.py +0 -0
  140. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/repositories/order_repository.py +0 -0
  141. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/repositories/portfolio_snapshot_repository.py +0 -0
  142. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/repositories/position_repository.py +0 -0
  143. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/repositories/position_snapshot_repository.py +0 -0
  144. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/services/__init__.py +0 -0
  145. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/services/azure/__init__.py +0 -0
  146. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/services/azure/state_handler.py +0 -0
  147. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/services/market_service/__init__.py +0 -0
  148. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/services/market_service/ccxt_market_service.py +0 -0
  149. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/services/performance_service/__init__.py +0 -0
  150. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/infrastructure/services/performance_service/backtest_performance_service.py +0 -0
  151. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/configuration_service.py +0 -0
  152. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/market_credential_service.py +0 -0
  153. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/market_data_source_service/__init__.py +0 -0
  154. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/market_data_source_service/backtest_market_data_source_service.py +0 -0
  155. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/order_service/__init__.py +0 -0
  156. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/order_service/order_backtest_service.py +0 -0
  157. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/order_service/order_service.py +0 -0
  158. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/portfolios/__init__.py +0 -0
  159. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/portfolios/portfolio_snapshot_service.py +0 -0
  160. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/portfolios/portfolio_sync_service.py +0 -0
  161. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/position_service.py +0 -0
  162. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/position_snapshot_service.py +0 -0
  163. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/repository_service.py +0 -0
  164. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/strategy_orchestrator_service.py +0 -0
  165. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/investing_algorithm_framework/services/trade_service/__init__.py +0 -0
  166. {investing_algorithm_framework-4.0.1 → investing_algorithm_framework-4.1.1}/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: 4.0.1
3
+ Version: 4.1.1
4
4
  Summary: A framework for creating trading bots
5
5
  Author: MDUYN
6
6
  Requires-Python: >=3.10
@@ -11,7 +11,8 @@ from investing_algorithm_framework.domain import ApiException, \
11
11
  pretty_print_backtest_reports_evaluation, load_backtest_reports, \
12
12
  RESERVED_BALANCES, APP_MODE, AppMode, DATETIME_FORMAT, \
13
13
  load_backtest_report, BacktestDateRange, convert_polars_to_pandas, \
14
- DateRange, get_backtest_report, DEFAULT_LOGGING_CONFIG
14
+ DateRange, get_backtest_report, DEFAULT_LOGGING_CONFIG, \
15
+ BacktestReport
15
16
  from investing_algorithm_framework.infrastructure import \
16
17
  CCXTOrderBookMarketDataSource, CCXTOHLCVMarketDataSource, \
17
18
  CCXTTickerMarketDataSource, CSVOHLCVMarketDataSource, \
@@ -88,5 +89,6 @@ __all__ = [
88
89
  "is_divergence",
89
90
  "get_backtest_report",
90
91
  "AzureBlobStorageStateHandler",
91
- "DEFAULT_LOGGING_CONFIG"
92
+ "DEFAULT_LOGGING_CONFIG",
93
+ "BacktestReport"
92
94
  ]
@@ -94,12 +94,21 @@ class Algorithm:
94
94
  )
95
95
 
96
96
  pattern = re.compile(r"^[a-zA-Z0-9]*$")
97
+
97
98
  if not pattern.match(name):
98
99
  raise OperationalException(
99
100
  "The name of the algorithm can only contain" +
100
101
  " letters and numbers"
101
102
  )
102
103
 
104
+ illegal_chars = r"[\/:*?\"<>|]"
105
+
106
+ if re.search(illegal_chars, name):
107
+ raise OperationalException(
108
+ f"Illegal characters detected in algorithm: {name}. "
109
+ f"Illegal characters: / \\ : * ? \" < > |"
110
+ )
111
+
103
112
  def initialize_services(
104
113
  self,
105
114
  configuration_service,
@@ -159,19 +168,15 @@ class Algorithm:
159
168
  def name(self):
160
169
  return self._name
161
170
 
171
+ @name.setter
172
+ def name(self, name):
173
+ self._validate_name(name)
174
+ self._name = name
175
+
162
176
  @property
163
177
  def data_sources(self):
164
178
  return self._data_sources
165
179
 
166
- @property
167
- def identifier(self):
168
- """
169
- Function to get a config instance. This allows users when
170
- having access to the algorithm instance also to read the
171
- configs of the app.
172
- """
173
- return self.configuration_service.config
174
-
175
180
  @property
176
181
  def config(self):
177
182
  """
@@ -179,7 +184,7 @@ class Algorithm:
179
184
  having access to the algorithm instance also to read the
180
185
  configs of the app.
181
186
  """
182
- return self.configuration_service.config
187
+ return self.configuration_service.get_config()
183
188
 
184
189
  @property
185
190
  def description(self):
@@ -489,6 +494,16 @@ class Algorithm:
489
494
 
490
495
  return self.portfolio_service.find({{"market": market}})
491
496
 
497
+ def get_portfolios(self):
498
+ """
499
+ Function to get all portfolios of the algorithm. This function
500
+ will return all portfolios of the algorithm.
501
+
502
+ Returns:
503
+ List[Portfolio]: A list of all portfolios of the algorithm
504
+ """
505
+ return self.portfolio_service.get_all()
506
+
492
507
  def get_unallocated(self, market=None) -> float:
493
508
  """
494
509
  Function to get the unallocated balance of the portfolio. This
@@ -834,7 +849,7 @@ class Algorithm:
834
849
  return (position.amount * ticker["bid"] / total) * 100
835
850
 
836
851
  def get_position_percentage_of_portfolio_by_net_size(
837
- self, symbol, market=None, identifier=None
852
+ self, symbol, market=None, identifier=None
838
853
  ) -> float:
839
854
  """
840
855
  Returns the percentage of the portfolio that is allocated to a
@@ -518,17 +518,6 @@ class App:
518
518
  trade_service=self.container.trade_service(),
519
519
  )
520
520
 
521
- # Create all portfolios
522
- portfolio_configuration_service = self.container \
523
- .portfolio_configuration_service()
524
- portfolio_configurations = portfolio_configuration_service.get_all()
525
- portfolio_service = self.container.portfolio_service()
526
-
527
- for portfolio_configuration in portfolio_configurations:
528
- portfolio_service.create_portfolio_from_configuration(
529
- portfolio_configuration
530
- )
531
-
532
521
  def run(
533
522
  self,
534
523
  payload: dict = None,
@@ -774,20 +763,24 @@ class App:
774
763
 
775
764
  def run_backtest(
776
765
  self,
777
- algorithm,
778
766
  backtest_date_range: BacktestDateRange,
767
+ initial_amount=None,
779
768
  pending_order_check_interval=None,
780
- output_directory=None
769
+ output_directory=None,
770
+ algorithm: Algorithm = None
781
771
  ) -> BacktestReport:
782
772
  """
783
773
  Run a backtest for an algorithm. This method should be called when
784
774
  running a backtest.
785
775
 
786
- Parameters:
787
- algorithm: The algorithm to run a backtest for (instance of
788
- Algorithm)
776
+ Args:
789
777
  backtest_date_range: The date range to run the backtest for
790
778
  (instance of BacktestDateRange)
779
+ initial_amount: The initial amount to start the backtest with.
780
+ This will be the amount of trading currency that the backtest
781
+ portfolio will start with.
782
+ algorithm: The algorithm to run a backtest for (instance of
783
+ Algorithm)
791
784
  pending_order_check_interval: str - pending_order_check_interval:
792
785
  The interval at which to check pending orders (e.g. 1h, 1d, 1w)
793
786
  output_directory: str - The directory to
@@ -796,8 +789,11 @@ class App:
796
789
  Returns:
797
790
  Instance of BacktestReport
798
791
  """
799
- logger.info("Initializing backtest")
800
- self.algorithm = algorithm
792
+ if algorithm is not None:
793
+ self.algorithm = algorithm
794
+
795
+ if self.algorithm is None:
796
+ raise OperationalException("No algorithm registered")
801
797
 
802
798
  self._initialize_app_for_backtest(
803
799
  backtest_date_range=backtest_date_range,
@@ -807,24 +803,24 @@ class App:
807
803
  self._initialize_algorithm_for_backtest(
808
804
  algorithm=self.algorithm
809
805
  )
806
+
810
807
  backtest_service = self.container.backtest_service()
811
- configuration_service = self.container.configuration_service()
812
- config = configuration_service.get_config()
813
- backtest_service.resource_directory = config[RESOURCE_DIRECTORY]
814
808
 
815
809
  # Run the backtest with the backtest_service and collect the report
816
810
  report = backtest_service.run_backtest(
817
- algorithm=self.algorithm, backtest_date_range=backtest_date_range
811
+ algorithm=self.algorithm,
812
+ initial_amount=initial_amount,
813
+ backtest_date_range=backtest_date_range
818
814
  )
819
- backtest_report_writer_service = self.container \
820
- .backtest_report_writer_service()
815
+
816
+ config = self.container.configuration_service().get_config()
821
817
 
822
818
  if output_directory is None:
823
819
  output_directory = os.path.join(
824
820
  config[RESOURCE_DIRECTORY], "backtest_reports"
825
821
  )
826
822
 
827
- backtest_report_writer_service.write_report_to_json(
823
+ backtest_service.write_report_to_json(
828
824
  report=report, output_directory=output_directory
829
825
  )
830
826
 
@@ -842,7 +838,7 @@ class App:
842
838
  Run a backtest for a set algorithm. This method should be called when
843
839
  running a backtest.
844
840
 
845
- Parameters:
841
+ Args:
846
842
  Algorithms: List[Algorithm] - The algorithms to run backtests for
847
843
  date_ranges: List[BacktestDateRange] - The date ranges to run the
848
844
  backtests for
@@ -918,15 +914,12 @@ class App:
918
914
  if date_range.name is not None:
919
915
  report.date_range_name = date_range.name
920
916
 
921
- backtest_report_writer_service = self.container \
922
- .backtest_report_writer_service()
923
-
924
917
  if output_directory is None:
925
918
  output_directory = os.path.join(
926
919
  self.config[RESOURCE_DIRECTORY], "backtest_reports"
927
920
  )
928
921
 
929
- backtest_report_writer_service.write_report_to_json(
922
+ backtest_service.write_report_to_json(
930
923
  report=report, output_directory=output_directory
931
924
  )
932
925
  reports.append(report)
@@ -9,8 +9,7 @@ from investing_algorithm_framework.services import OrderService, \
9
9
  PositionService, PortfolioService, StrategyOrchestratorService, \
10
10
  PortfolioConfigurationService, MarketDataSourceService, BacktestService, \
11
11
  ConfigurationService, PortfolioSnapshotService, PositionSnapshotService, \
12
- MarketCredentialService, TradeService, BacktestReportWriterService, \
13
- PortfolioSyncService
12
+ MarketCredentialService, TradeService, PortfolioSyncService
14
13
 
15
14
 
16
15
  def setup_dependency_container(app, modules=None, packages=None):
@@ -126,13 +125,11 @@ class DependencyContainer(containers.DeclarativeContainer):
126
125
  BacktestService,
127
126
  configuration_service=configuration_service,
128
127
  order_service=order_service,
129
- portfolio_repository=portfolio_repository,
128
+ portfolio_service=portfolio_service,
130
129
  performance_service=performance_service,
131
130
  position_repository=position_repository,
132
131
  market_data_source_service=market_data_source_service,
133
- )
134
- backtest_report_writer_service = providers.Factory(
135
- BacktestReportWriterService,
132
+ portfolio_configuration_service=portfolio_configuration_service,
136
133
  )
137
134
  algorithm = providers.Factory(
138
135
  Algorithm,
@@ -9,7 +9,6 @@ from investing_algorithm_framework.domain.metrics import \
9
9
  from investing_algorithm_framework.domain.models \
10
10
  .backtesting.backtest_date_range import BacktestDateRange
11
11
  from investing_algorithm_framework.domain.models.base_model import BaseModel
12
- from investing_algorithm_framework.domain.models.time_unit import TimeUnit
13
12
  from investing_algorithm_framework.domain.models.position import Position
14
13
  from investing_algorithm_framework.domain.models.trade import Trade
15
14
  from investing_algorithm_framework.domain.models.order import Order
@@ -358,15 +357,7 @@ class BacktestReport(BaseModel):
358
357
  self._time_unit = value
359
358
 
360
359
  def get_runs_per_day(self):
361
-
362
- if self.time_unit is None:
363
- return 0
364
- elif TimeUnit.SECOND.equals(self.time_unit):
365
- return 86400 / self.interval
366
- elif TimeUnit.MINUTE.equals(self.time_unit):
367
- return 1440 / self.interval
368
- else:
369
- return 24 / self.interval
360
+ return self.number_of_runs / self.number_of_days
370
361
 
371
362
  @property
372
363
  def backtest_start_date(self):
@@ -525,6 +516,9 @@ class BacktestReport(BaseModel):
525
516
  def get_trading_symbol(self) -> str:
526
517
  return self.trading_symbol
527
518
 
519
+ def get_initial_unallocated(self) -> float:
520
+ return self.initial_unallocated
521
+
528
522
  def add_symbol(self, symbol):
529
523
 
530
524
  if symbol not in self.symbols:
@@ -2,6 +2,37 @@ from investing_algorithm_framework.domain.models.base_model import BaseModel
2
2
 
3
3
 
4
4
  class Portfolio(BaseModel):
5
+ """
6
+ Portfolio base class.
7
+
8
+ A portfolio is a collection of positions that are managed by an algorithm.
9
+
10
+ Attributes:
11
+ * identifier: str, unique identifier of the portfolio
12
+ * trading_symbol: str, trading symbol of the portfolio
13
+ * unallocated: float, the size of the trading symbol that is not
14
+ allocated. For example, if the trading symbol is USDT and the unallocated
15
+ is 1000, it means that the portfolio has 1000 USDT that is not
16
+ allocated to any position.
17
+ * net_size: float, net size of the portfolio is the initial balance of the
18
+ portfolio plus the all the net gains of the trades. The
19
+ * realized: float, the realized gain of the portfolio is the sum of all the
20
+ realized gains of the trades.
21
+ * total_revenue: float, the total revenue of the portfolio is the sum
22
+ of all the orders (price * size)
23
+ * total_cost: float, the total cost of the portfolio is the sum of all the
24
+ costs of the trades (price * size (for buy orders)
25
+ or -price * size (for sell orders))
26
+ * total_net_gain: float, the total net gain of the portfolio is the sum of
27
+ all the net gains of the trades
28
+ * total_trade_volume: float, the total trade volume of the
29
+ portfolio is the sum of all the sizes of the trades
30
+ * market: str, the market of the portfolio (e.g. BITVAVO, BINANCE)
31
+ * created_at: datetime, the datetime when the portfolio was created
32
+ * updated_at: datetime, the datetime when the portfolio was last updated
33
+ * initialized: bool, whether the portfolio is initialized or not
34
+ * initial_balance: float, the initial balance of the portfolio
35
+ """
5
36
 
6
37
  def __init__(
7
38
  self,
@@ -6,6 +6,23 @@ from investing_algorithm_framework.domain.models.base_model import BaseModel
6
6
 
7
7
 
8
8
  class PortfolioConfiguration(BaseModel):
9
+ """
10
+ This class represents a portfolio configuration. It is used to
11
+ configure the portfolio that the user wants to create.
12
+
13
+ The portfolio configuration will have the following attributes:
14
+ - market: The market where the portfolio will be created
15
+ - trading_symbol: The trading symbol of the portfolio
16
+ - track_from: The date from which the portfolio will be tracked
17
+ - identifier: The identifier of the portfolio
18
+ - initial_balance: The initial balance of the portfolio
19
+
20
+ For backtesting, a portfolio configuration is used to create a
21
+ portfolio that will be used to simulate the trading of the algorithm. if
22
+ the user does not provide an initial balance, the portfolio will be created
23
+ with a balance of according to the initial balanace of
24
+ the PortfolioConfiguration class.
25
+ """
9
26
 
10
27
  def __init__(
11
28
  self,
@@ -22,7 +39,9 @@ class PortfolioConfiguration(BaseModel):
22
39
  self._initial_balance = initial_balance
23
40
 
24
41
  if self.identifier is None:
25
- self._identifier = market.lower()
42
+ self._identifier = market.upper()
43
+ else:
44
+ self._identifier = identifier.upper()
26
45
 
27
46
  if track_from:
28
47
  self._track_from = parse(track_from)
@@ -35,8 +54,8 @@ class PortfolioConfiguration(BaseModel):
35
54
  @property
36
55
  def market(self):
37
56
 
38
- if hasattr(self._market, "lower"):
39
- return self._market.lower()
57
+ if hasattr(self._market, "upper"):
58
+ return self._market.upper()
40
59
 
41
60
  return self._market
42
61
 
@@ -49,6 +49,12 @@ class BacktestMarketDataSource(ABC):
49
49
 
50
50
  This function prevents the backtest datasource to download the data
51
51
  every time the backtest is run.
52
+
53
+ Args:
54
+ file_path: str - the file path of the data storage file
55
+
56
+ Returns:
57
+ bool - True if the file exists and the column names are correct,
52
58
  """
53
59
  try:
54
60
  if os.path.isfile(file_path):
@@ -444,6 +450,15 @@ class OHLCVMarketDataSource(MarketDataSource, ABC):
444
450
  Function to get the date ranges of the market data source based
445
451
  on the window size and the time_frame. The date ranges
446
452
  will be calculated based on the start date and the end date.
453
+
454
+ Args:
455
+ start_date: datetime - The start date
456
+ end_date: datetime - The end date
457
+ window_size: int - The window size
458
+ time_frame: str - The time frame
459
+
460
+ Returns:
461
+ list - A list of tuples with the date ranges
447
462
  """
448
463
 
449
464
  if start_date > end_date:
@@ -140,7 +140,7 @@ class MarketService(ABC):
140
140
 
141
141
  for market_data_credentials in self.market_credentials:
142
142
 
143
- if market_data_credentials.market.lower() == market.lower():
143
+ if market_data_credentials.market.upper() == market.upper():
144
144
  return market_data_credentials
145
145
 
146
146
  return None
@@ -74,12 +74,12 @@ class CCXTOHLCVBacktestMarketDataSource(
74
74
 
75
75
  When downloading the data it will use the ccxt library.
76
76
 
77
- Parameters:
78
- config: dict - the configuration of the data source
79
- backtest_start_date: datetime - the start date of the backtest
80
- backtest_end_date: datetime - the end date of the backtest
81
- time_frame: string - the time frame of the data
82
- window_size: int - the total amount of candle sticks that need to
77
+ Args:
78
+ config (dict): the configuration of the data source
79
+ backtest_start_date (datetime): the start date of the backtest
80
+ backtest_end_date (datetime): the end date of the backtest
81
+ time_frame (string): the time frame of the data
82
+ window_size (int): the total amount of candle sticks that need to
83
83
  be returned
84
84
 
85
85
  Returns:
@@ -137,6 +137,14 @@ class CCXTOHLCVBacktestMarketDataSource(
137
137
  to_timestamp=backtest_end_date,
138
138
  market=self.market
139
139
  )
140
+
141
+ if len(ohlcv) == 0:
142
+ raise OperationalException(
143
+ f"No data found for {self.symbol} " +
144
+ f"for date range: {backtest_data_start_date} " +
145
+ f"to {backtest_end_date}. Please make sure that " +
146
+ "the market has data for this date range."
147
+ )
140
148
  self.write_data_to_file_path(file_path, ohlcv)
141
149
 
142
150
  self.load_data()
@@ -20,7 +20,7 @@ class SQLPortfolioRepository(Repository):
20
20
  query = query.filter_by(market=market_query_param.upper())
21
21
 
22
22
  if identifier_query_param:
23
- query = query.filter_by(identifier=identifier_query_param.lower())
23
+ query = query.filter_by(identifier=identifier_query_param.upper())
24
24
 
25
25
  if position_query_param:
26
26
  position = db.query(SQLPosition)\
@@ -71,6 +71,7 @@ class Repository(ABC):
71
71
  try:
72
72
  delete_object = self.get(object_id)
73
73
  db.delete(delete_object)
74
+ db.commit()
74
75
  return delete_object
75
76
  except SQLAlchemyError as e:
76
77
  logger.error(e)
@@ -193,6 +193,10 @@ class PerformanceService:
193
193
  return: The total net gain percentage of the backtest
194
194
  """
195
195
  portfolio = self.portfolio_repository.find({"id": portfolio_id})
196
+
197
+ if portfolio.total_net_gain == 0:
198
+ return 0
199
+
196
200
  return portfolio.total_net_gain \
197
201
  / backtest_profile.initial_unallocated * 100
198
202
 
@@ -1,5 +1,4 @@
1
- from .backtesting import BacktestService, BacktestReportWriterService, \
2
- create_trade_exit_markers_chart, create_trade_entry_markers_chart
1
+ from .backtesting import BacktestService
3
2
  from .configuration_service import ConfigurationService
4
3
  from .market_credential_service import MarketCredentialService
5
4
  from .market_data_source_service import MarketDataSourceService, \
@@ -23,7 +22,6 @@ __all__ = [
23
22
  "PortfolioConfigurationService",
24
23
  "MarketDataSourceService",
25
24
  "BacktestService",
26
- "BacktestReportWriterService",
27
25
  "OrderBacktestService",
28
26
  "ConfigurationService",
29
27
  "PortfolioSyncService",
@@ -33,6 +31,4 @@ __all__ = [
33
31
  "BacktestMarketDataSourceService",
34
32
  "BacktestPortfolioService",
35
33
  "TradeService",
36
- "create_trade_entry_markers_chart",
37
- "create_trade_exit_markers_chart"
38
34
  ]
@@ -0,0 +1,5 @@
1
+ from .backtest_service import BacktestService
2
+
3
+ __all__ = [
4
+ "BacktestService",
5
+ ]