investing-algorithm-framework 3.5.2__tar.gz → 3.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/PKG-INFO +69 -51
  2. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/README.md +65 -49
  3. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/__init__.py +13 -1
  4. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/app/algorithm.py +73 -9
  5. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/app/app.py +153 -134
  6. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/app/strategy.py +76 -0
  7. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/dependency_container.py +1 -3
  8. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/__init__.py +11 -3
  9. investing_algorithm_framework-3.7.0/investing_algorithm_framework/domain/graphs.py +382 -0
  10. investing_algorithm_framework-3.7.0/investing_algorithm_framework/domain/metrics/__init__.py +6 -0
  11. investing_algorithm_framework-3.7.0/investing_algorithm_framework/domain/metrics/price_efficiency.py +57 -0
  12. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/__init__.py +4 -4
  13. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/backtesting/__init__.py +2 -0
  14. investing_algorithm_framework-3.7.0/investing_algorithm_framework/domain/models/backtesting/backtest_date_range.py +43 -0
  15. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/backtesting/backtest_position.py +14 -0
  16. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/backtesting/backtest_report.py +197 -62
  17. investing_algorithm_framework-3.7.0/investing_algorithm_framework/domain/models/backtesting/backtest_reports_evaluation.py +243 -0
  18. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/order/__init__.py +1 -2
  19. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/order/order.py +71 -24
  20. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/time_frame.py +5 -5
  21. investing_algorithm_framework-3.7.0/investing_algorithm_framework/domain/models/tracing/__init__.py +0 -0
  22. investing_algorithm_framework-3.7.0/investing_algorithm_framework/domain/models/tracing/trace.py +23 -0
  23. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/trade/trade.py +17 -0
  24. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/services/market_data_sources.py +74 -125
  25. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/services/market_service.py +9 -0
  26. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/utils/__init__.py +2 -1
  27. investing_algorithm_framework-3.7.0/investing_algorithm_framework/domain/utils/backtesting.py +472 -0
  28. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/__init__.py +2 -4
  29. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/models/__init__.py +1 -2
  30. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/models/market_data_sources/ccxt.py +103 -58
  31. investing_algorithm_framework-3.7.0/investing_algorithm_framework/infrastructure/models/market_data_sources/csv.py +254 -0
  32. investing_algorithm_framework-3.7.0/investing_algorithm_framework/infrastructure/models/market_data_sources/us_treasury_yield.py +47 -0
  33. investing_algorithm_framework-3.7.0/investing_algorithm_framework/infrastructure/models/order/__init__.py +3 -0
  34. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/models/order/order.py +21 -8
  35. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/repositories/__init__.py +0 -2
  36. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/services/market_service/ccxt_market_service.py +20 -14
  37. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/services/__init__.py +5 -2
  38. investing_algorithm_framework-3.7.0/investing_algorithm_framework/services/backtesting/__init__.py +12 -0
  39. investing_algorithm_framework-3.7.0/investing_algorithm_framework/services/backtesting/backtest_report_writer_service.py +53 -0
  40. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/services/backtesting/backtest_service.py +143 -79
  41. investing_algorithm_framework-3.7.0/investing_algorithm_framework/services/backtesting/graphs.py +61 -0
  42. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/services/market_data_source_service/backtest_market_data_source_service.py +18 -3
  43. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/services/market_data_source_service/market_data_source_service.py +15 -1
  44. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/services/order_service/order_backtest_service.py +0 -2
  45. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/services/order_service/order_service.py +0 -28
  46. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/pyproject.toml +4 -2
  47. investing_algorithm_framework-3.5.2/investing_algorithm_framework/domain/models/backtesting/backtest_reports_evaluation.py +0 -66
  48. investing_algorithm_framework-3.5.2/investing_algorithm_framework/domain/models/order/order_fee.py +0 -49
  49. investing_algorithm_framework-3.5.2/investing_algorithm_framework/domain/utils/backtesting.py +0 -490
  50. investing_algorithm_framework-3.5.2/investing_algorithm_framework/infrastructure/models/market_data_sources/csv.py +0 -177
  51. investing_algorithm_framework-3.5.2/investing_algorithm_framework/infrastructure/models/order/__init__.py +0 -4
  52. investing_algorithm_framework-3.5.2/investing_algorithm_framework/infrastructure/models/order/order_fee.py +0 -21
  53. investing_algorithm_framework-3.5.2/investing_algorithm_framework/infrastructure/repositories/order_fee_repository.py +0 -15
  54. investing_algorithm_framework-3.5.2/investing_algorithm_framework/services/backtesting/__init__.py +0 -8
  55. investing_algorithm_framework-3.5.2/investing_algorithm_framework/services/backtesting/backtest_report_writer_service.py +0 -42
  56. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/LICENSE +0 -0
  57. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/app/__init__.py +0 -0
  58. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/app/stateless/__init__.py +0 -0
  59. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/app/stateless/action_handlers/__init__.py +0 -0
  60. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/app/stateless/action_handlers/action_handler_strategy.py +0 -0
  61. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/app/stateless/action_handlers/check_online_handler.py +0 -0
  62. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/app/stateless/action_handlers/run_strategy_handler.py +0 -0
  63. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/app/stateless/exception_handler.py +0 -0
  64. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/app/task.py +0 -0
  65. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/app/web/__init__.py +0 -0
  66. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/app/web/controllers/__init__.py +0 -0
  67. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/app/web/controllers/orders.py +0 -0
  68. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/app/web/controllers/portfolio.py +0 -0
  69. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/app/web/controllers/positions.py +0 -0
  70. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/app/web/create_app.py +0 -0
  71. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/app/web/error_handler.py +0 -0
  72. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/app/web/responses.py +0 -0
  73. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/app/web/run_strategies.py +0 -0
  74. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/app/web/schemas/__init__.py +0 -0
  75. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/app/web/schemas/order.py +0 -0
  76. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/app/web/schemas/portfolio.py +0 -0
  77. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/app/web/schemas/position.py +0 -0
  78. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/app/web/setup_cors.py +0 -0
  79. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/create_app.py +0 -0
  80. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/config.py +0 -0
  81. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/constants.py +0 -0
  82. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/data_structures.py +0 -0
  83. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/decimal_parsing.py +0 -0
  84. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/exceptions.py +0 -0
  85. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/app_mode.py +0 -0
  86. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/base_model.py +0 -0
  87. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/market/__init__.py +0 -0
  88. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/market/market_credential.py +0 -0
  89. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/order/order_side.py +0 -0
  90. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/order/order_status.py +0 -0
  91. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/order/order_type.py +0 -0
  92. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/portfolio/__init__.py +0 -0
  93. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/portfolio/portfolio.py +0 -0
  94. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/portfolio/portfolio_configuration.py +0 -0
  95. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/portfolio/portfolio_snapshot.py +0 -0
  96. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/position/__init__.py +0 -0
  97. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/position/position.py +0 -0
  98. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/position/position_snapshot.py +0 -0
  99. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/strategy_profile.py +0 -0
  100. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/time_interval.py +0 -0
  101. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/time_unit.py +0 -0
  102. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/trade/__init__.py +0 -0
  103. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/trade/trade_status.py +0 -0
  104. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/trading_data_types.py +0 -0
  105. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/models/trading_time_frame.py +0 -0
  106. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/services/__init__.py +0 -0
  107. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/services/market_credential_service.py +0 -0
  108. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/services/portfolios/__init__.py +0 -0
  109. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/services/portfolios/portfolio_sync_service.py +0 -0
  110. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/services/rounding_service.py +0 -0
  111. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/singleton.py +0 -0
  112. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/stateless_actions.py +0 -0
  113. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/strategy.py +0 -0
  114. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/utils/csv.py +0 -0
  115. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/utils/random.py +0 -0
  116. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/utils/signatures.py +0 -0
  117. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/utils/stoppable_thread.py +0 -0
  118. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/domain/utils/synchronized.py +0 -0
  119. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/database/__init__.py +0 -0
  120. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/database/sql_alchemy.py +0 -0
  121. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/models/decimal_parser.py +0 -0
  122. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/models/market_data_sources/__init__.py +0 -0
  123. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/models/model_extension.py +0 -0
  124. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/models/portfolio/__init__.py +0 -0
  125. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/models/portfolio/portfolio.py +0 -0
  126. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/models/portfolio/portfolio_snapshot.py +0 -0
  127. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/models/position/__init__.py +0 -0
  128. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/models/position/position.py +0 -0
  129. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/models/position/position_snapshot.py +0 -0
  130. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/repositories/order_repository.py +0 -0
  131. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/repositories/portfolio_repository.py +0 -0
  132. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/repositories/portfolio_snapshot_repository.py +0 -0
  133. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/repositories/position_repository.py +0 -0
  134. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/repositories/position_snapshot_repository.py +0 -0
  135. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/repositories/repository.py +0 -0
  136. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/services/__init__.py +0 -0
  137. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/services/market_service/__init__.py +0 -0
  138. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/services/performance_service/__init__.py +0 -0
  139. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/services/performance_service/backtest_performance_service.py +0 -0
  140. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/infrastructure/services/performance_service/performance_service.py +0 -0
  141. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/services/configuration_service.py +0 -0
  142. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/services/market_credential_service.py +0 -0
  143. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/services/market_data_source_service/__init__.py +0 -0
  144. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/services/order_service/__init__.py +0 -0
  145. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/services/portfolios/__init__.py +0 -0
  146. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/services/portfolios/backtest_portfolio_service.py +0 -0
  147. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/services/portfolios/portfolio_configuration_service.py +0 -0
  148. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/services/portfolios/portfolio_service.py +0 -0
  149. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/services/portfolios/portfolio_snapshot_service.py +0 -0
  150. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/services/portfolios/portfolio_sync_service.py +0 -0
  151. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/services/position_service.py +0 -0
  152. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/services/position_snapshot_service.py +0 -0
  153. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/services/repository_service.py +0 -0
  154. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/services/strategy_orchestrator_service.py +0 -0
  155. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/services/trade_service/__init__.py +0 -0
  156. {investing_algorithm_framework-3.5.2 → investing_algorithm_framework-3.7.0}/investing_algorithm_framework/services/trade_service/trade_service.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: investing-algorithm-framework
3
- Version: 3.5.2
3
+ Version: 3.7.0
4
4
  Summary: A framework for creating trading bots
5
5
  Author: MDUYN
6
6
  Requires-Python: >=3.8.1,<4.0.0
@@ -10,13 +10,15 @@ Classifier: Programming Language :: Python :: 3.10
10
10
  Classifier: Programming Language :: Python :: 3.11
11
11
  Classifier: Programming Language :: Python :: 3.12
12
12
  Requires-Dist: Flask (>=2.3.2,<3.0.0)
13
- Requires-Dist: Flask-Cors (>=3.0.9,<4.0.0)
13
+ Requires-Dist: Flask-Cors (>=3.0.9,<5.0.0)
14
14
  Requires-Dist: Flask-Migrate (>=2.6.0,<3.0.0)
15
15
  Requires-Dist: MarkupSafe (>=2.1.2,<3.0.0)
16
16
  Requires-Dist: SQLAlchemy (>=2.0.18,<3.0.0)
17
17
  Requires-Dist: ccxt (>=4.2.48,<5.0.0)
18
18
  Requires-Dist: dependency-injector (>=4.40.0,<5.0.0)
19
+ Requires-Dist: jupyter (>=1.0.0,<2.0.0)
19
20
  Requires-Dist: marshmallow (>=3.5.0,<4.0.0)
21
+ Requires-Dist: plotly (>=5.22.0,<6.0.0)
20
22
  Requires-Dist: polars[numpy,pandas] (>=0.20.10,<0.21.0)
21
23
  Requires-Dist: python-dateutil (>=2.8.2,<3.0.0)
22
24
  Requires-Dist: schedule (>=1.1.0,<2.0.0)
@@ -48,11 +50,12 @@ components for creating algorithms, including data provisioning,
48
50
  portfolio management, and order execution.
49
51
 
50
52
  Features:
51
- * Order execution
53
+ * Order execution and tracking
52
54
  * Broker and exchange connections through [ccxt](https://github.com/ccxt/ccxt)
53
- * Backtesting and performance analysis reports [example](./examples/backtest)
54
- * Backtest experiments to optimize your trading strategy [example](./examples/backtest_experiment)
55
- * Portfolio management
55
+ * Backtesting and performance analysis reports [example](./examples/backtest_example)
56
+ * Backtesting multiple algorithms with different backtest date ranges [example](./examples/backtests_example)
57
+ * Portfolio management and tracking
58
+ * Tracing for analyzing and debugging your trading bot
56
59
  * Web API for interacting with your deployed trading bot
57
60
  * Data persistence through sqlite db or an in-memory db
58
61
  * Stateless running for cloud function deployments
@@ -95,9 +98,6 @@ bitvavo_btc_eur_ticker = CCXTTickerMarketDataSource(
95
98
  )
96
99
  app = create_app(config=config)
97
100
  algorithm = Algorithm()
98
-
99
- app.add_market_data_source(bitvavo_btc_eur_ohlcv_2h)
100
- app.add_market_data_source(bitvavo_btc_eur_ticker)
101
101
  app.add_market_credential(MarketCredential(
102
102
  market="bitvavo",
103
103
  api_key="<your api key>",
@@ -117,7 +117,7 @@ app.add_algorithm(algorithm)
117
117
  time_unit=TimeUnit.HOUR,
118
118
  interval=2,
119
119
  # Specify market data sources that need to be passed to the strategy
120
- market_data_sources=["BTC-ticker", "BTC-ohlcv"]
120
+ market_data_sources=[bitvavo_btc_eur_ticker, bitvavo_btc_eur_ohlcv_2h]
121
121
  )
122
122
  def perform_strategy(algorithm: Algorithm, market_data: dict):
123
123
  # By default, ohlcv data is passed as polars df in the form of
@@ -167,64 +167,82 @@ you will get the following backtesting report:
167
167
 
168
168
  ```bash
169
169
 
170
- /&# #&( Backtest report
171
- &&&&&&&&&&&# &&&&&&&&&&&& ---------------------------
172
- &&&&&&&&&&&&&&&& (&&&&&&&&&&&&&&& Start date: 2023-08-24 00:00:00
173
- &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& End date: 2023-12-02 00:00:00
174
- &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Number of days: 100
175
- &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Number of runs: 1201
176
- .&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Number of orders: 10
177
- &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&. Initial balance: 400.0
178
- &&&&&&&# /((( &&&&&&&&&&&&*((( .&&&&&&&. Final balance: 431.1499
179
- &&&&&&&&&&&&&&&&&&& (((( &&&&&&&& (((( &&&&&&&&&&&&&&&&&&& Total net gain: 28.5542 7.139%
180
- (((&&&&&&&& (((( &&&&&& (((( &&&&&&&&&(( Growth: 31.1499 7.787%
181
- /((((((((((&&&&&&&&&& (((, &&&&&& (((**&&&&&&&&&((((((((((( Number of trades closed: 4
182
- &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Number of trades open(end of backtest): 2
183
- &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Percentage positive trades: 60.0%
184
- &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Percentage negative trades: 20.0%
185
- ((((( &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&( Average trade size: 98.9886 EUR
186
- ((((( &&&&&&&&&&&&&&&&&&&&&&&&, Average trade duration: 184.0 hours
187
- ((((( &&&&&&&&&&&&&#
188
- ((((( #&&&&&&&&&&###
189
- ((((( &&&&&&&&&&&###.
190
- .((((( &&&&&&&&&&&&&&###(
191
- ((((( &&&&&&&&&&&&&&&&#(((/
192
- ((((( &&&&&&&&&&&&&&&&&&&@((((
193
- ((((( &&&&&&&&&&&&&&&&&&&&&&((((
194
- ((((( &&&&&&&&&&&&&&&&&&&&&&&&((((,
195
- .((((( &&&&&&&&&&&&&&&&&&&&&&&&&&((((
196
- ((((( &&&&&&&&&&&&&&&&&&&&&&&&&&&&((((
197
- ((((( &&&&&&&&&&&&&&&&&&&&&&&&&&&&&((((
198
- ((((( &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&((((
199
- ((((( &&&&&&&&&&&&&&&&&&&&&&&&&&&&&#((((
200
- (((((((((((((((((((#########&&&&&&&&&&&&&&&&&&&&&&&&&&&&(((((
201
- (((((((((((((((((((((######&&&&&&&&&&&&&&&&&&&&&&&&&&&&((((
170
+ :%%%#+- .=*#%%% Backtest report
171
+ *%%%%%%%+------=*%%%%%%%- ---------------------------
172
+ *%%%%%%%%%%%%%%%%%%%%%%%- Start date: 2023-08-24 00:00:00
173
+ .%%%%%%%%%%%%%%%%%%%%%%# End date: 2023-12-02 00:00:00
174
+ #%%%####%%%%%%%%**#%%%+ Number of days: 100
175
+ .:-+*%%%%- -+..#%%%+.+- +%%%#*=-: Number of runs: 1201
176
+ .:-=*%%%%. += .%%# -+.-%%%%=-:.. Number of orders: 40
177
+ .:=+#%%%%%*###%%%%#*+#%%%%%%*+-: Initial balance: 400.0
178
+ +%%%%%%%%%%%%%%%%%%%= Final balance: 428.2434
179
+ :++ .=#%%%%%%%%%%%%%*- Total net gain: 28.2434 7.061%
180
+ :++: :+%%%%%%#-. Growth: 28.2434 7.061%
181
+ :++: .%%%%%#= Number of trades closed: 20
182
+ :++: .#%%%%%#*= Number of trades open(end of backtest): 0
183
+ :++- :%%%%%%%%%+= Percentage positive trades: 30.0%
184
+ .++- -%%%%%%%%%%%+= Percentage negative trades: 70.0%
185
+ .++- .%%%%%%%%%%%%%+= Average trade size: 100.9692 EUR
186
+ .++- *%%%%%%%%%%%%%*+: Average trade duration: 83.6 hours
187
+ .++- %%%%%%%%%%%%%%#+=
188
+ =++........:::%%%%%%%%%%%%%%*+-
189
+ .=++++++++++**#%%%%%%%%%%%%%++.
202
190
 
191
+ Price noise
192
+
203
193
  Positions overview
204
194
  ╭────────────┬──────────┬──────────────────────┬───────────────────────┬──────────────┬───────────────┬───────────────────────────┬────────────────┬───────────────╮
205
195
  │ Position │ Amount │ Pending buy amount │ Pending sell amount │ Cost (EUR) │ Value (EUR) │ Percentage of portfolio │ Growth (EUR) │ Growth_rate │
206
196
  ├────────────┼──────────┼──────────────────────┼───────────────────────┼──────────────┼───────────────┼───────────────────────────┼────────────────┼───────────────┤
207
- │ EUR │ 217.044 │ 0 │ 0 │ 217.044217.04450.3407% 0 │ 0.0000% │
197
+ │ EUR │ 428.243 │ 0 │ 0 │ 428.243428.243100.0000% 0 │ 0.0000% │
208
198
  ├────────────┼──────────┼──────────────────────┼───────────────────────┼──────────────┼───────────────┼───────────────────────────┼────────────────┼───────────────┤
209
- BTC 0.003 │ 0 │ 0 │ 104.372 106.84 24.7802% 2.46782.3644% │
199
+ DOT 0 │ 0 │ 0 │ 0 0 0.0000% 00.0000% │
210
200
  ├────────────┼──────────┼──────────────────────┼───────────────────────┼──────────────┼───────────────┼───────────────────────────┼────────────────┼───────────────┤
211
- DOT 21.3295 │ 0 │ 0 │ 107.138 107.266 24.8791% 0.128 │ 0.1195% │
201
+ BTC 0 │ 0 │ 0 │ 0 0 0.0000% 0 │ 0.0000% │
212
202
  ╰────────────┴──────────┴──────────────────────┴───────────────────────┴──────────────┴───────────────┴───────────────────────────┴────────────────┴───────────────╯
213
203
  Trades overview
214
204
  ╭─────────┬─────────────────────┬─────────────────────┬────────────────────┬──────────────┬──────────────────┬───────────────────────┬────────────────────┬─────────────────────╮
215
205
  │ Pair │ Open date │ Close date │ Duration (hours) │ Size (EUR) │ Net gain (EUR) │ Net gain percentage │ Open price (EUR) │ Close price (EUR) │
216
206
  ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
217
- │ DOT-EUR │ 2023-11-30 18:00:00 │ 3207.26 │ 107.138 0 0.0000% 5.023
207
+ │ DOT-EUR │ 2023-11-24 12:00:00 │ 2023-11-27 14:00:00 74 │ 107.55 -1.9587 -1.8212% 4.777 4.69
208
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
209
+ │ DOT-EUR │ 2023-11-20 00:00:00 │ 2023-11-21 08:00:00 │ 32 │ 109.39 │ -4.5949 │ -4.2005% │ 4.9875 │ 4.778 │
210
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
211
+ │ BTC-EUR │ 2023-11-19 22:00:00 │ 2023-11-22 00:00:00 │ 50 │ 109.309 │ -2.7624 │ -2.5272% │ 34159.1 │ 33295.9 │
212
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
213
+ │ BTC-EUR │ 2023-11-06 12:00:00 │ 2023-11-13 14:00:00 │ 170 │ 107.864 │ 6.1015 │ 5.6567% │ 32685.9 │ 34534.9 │
214
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
215
+ │ DOT-EUR │ 2023-10-20 12:00:00 │ 2023-10-27 08:00:00 │ 164 │ 99.085 │ 10.9799 │ 11.0813% │ 3.5465 │ 3.9395 │
216
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
217
+ │ BTC-EUR │ 2023-10-14 04:00:00 │ 2023-10-27 22:00:00 │ 330 │ 97.4278 │ 24.137 │ 24.7742% │ 25638.9 │ 31990.7 │
218
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
219
+ │ DOT-EUR │ 2023-10-14 04:00:00 │ 2023-10-17 14:00:00 │ 82 │ 99.5572 │ -1.8877 │ -1.8961% │ 3.56 │ 3.4925 │
220
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
221
+ │ DOT-EUR │ 2023-10-07 08:00:00 │ 2023-10-08 08:00:00 │ 24 │ 99.9498 │ -1.5708 │ -1.5716% │ 3.8815 │ 3.8205 │
222
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
223
+ │ BTC-EUR │ 2023-09-27 10:00:00 │ 2023-10-05 20:00:00 │ 202 │ 98.2888 │ 3.433 │ 3.4927% │ 25202.2 │ 26082.5 │
224
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
225
+ │ DOT-EUR │ 2023-09-27 10:00:00 │ 2023-10-03 20:00:00 │ 154 │ 98.7893 │ 1.2085 │ 1.2233% │ 3.842 │ 3.889 │
226
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
227
+ │ DOT-EUR │ 2023-09-25 12:00:00 │ 2023-09-27 04:00:00 │ 40 │ 98.9193 │ -0.5194 │ -0.5251% │ 3.809 │ 3.789 │
228
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
229
+ │ DOT-EUR │ 2023-09-14 16:00:00 │ 2023-09-18 02:00:00 │ 82 │ 98.9419 │ -0.0912 │ -0.0921% │ 3.799 │ 3.7955 │
230
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
231
+ │ BTC-EUR │ 2023-09-07 06:00:00 │ 2023-09-10 16:00:00 │ 82 │ 98.6093 │ 0.3412 │ 0.3460% │ 24051 │ 24134.3 │
232
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
233
+ │ DOT-EUR │ 2023-09-07 00:00:00 │ 2023-09-09 02:00:00 │ 50 │ 98.9158 │ -0.2358 │ -0.2383% │ 3.986 │ 3.9765 │
234
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
235
+ │ DOT-EUR │ 2023-09-05 14:00:00 │ 2023-09-06 12:00:00 │ 22 │ 99.2132 │ -1.1909 │ -1.2003% │ 3.999 │ 3.951 │
218
236
  ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
219
- BTC-EUR │ 2023-11-29 12:00:00 │ 3237.26 104.372 0 │ 0.0000% 34790.7
237
+ DOT-EUR │ 2023-09-04 16:00:00 │ 2023-09-04 22:00:00 6 99.355 -0.5671 -0.5708% 3.942 3.9195
220
238
  ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
221
- BTC-EUR │ 2023-11-07 22:00:00 │ 2023-11-14 14:00:00 │ 160 │ 99.2337 2.53952.5591% 33077.9 33924.4
239
+ DOT-EUR │ 2023-09-04 10:00:00 │ 2023-09-04 14:00:00 │ 4 │ 99.4774 -0.4889-0.4914% 3.968 3.9485
222
240
  ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
223
- │ BTC-EUR │ 2023-11-06 14:00:00 │ 2023-11-06 18:00:00 │ 4 98.2854 │ -0.4248 │ -0.4322% │ 32761.832620.2
241
+ │ BTC-EUR │ 2023-08-26 10:00:00 │ 2023-08-26 18:00:00 │ 8 99.0829 │ -0.03 │ -0.0302% │ 24166.624159.3
224
242
  ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
225
- │ DOT-EUR │ 2023-10-30 04:00:00 │ 2023-11-14 00:00:00 │ 356 100.53724.288624.1588% │ 4.05655.0365
243
+ │ DOT-EUR │ 2023-08-25 10:00:00 │ 2023-08-28 10:00:00 │ 72 99.659-0.6975-0.6999% │ 4.14354.1145
226
244
  ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
227
- BTC-EUR │ 2023-09-13 14:00:00 │ 2023-09-22 14:00:00 │ 216 97.8976 2.15082.1970% 24474.4 │ 25012.1
245
+ DOT-EUR │ 2023-08-24 00:00:00 │ 2023-08-25 00:00:00 │ 24 99.9999 -1.3626-1.3626% 4.1465 │ 4.09
228
246
  ╰─────────┴─────────────────────┴─────────────────────┴────────────────────┴──────────────┴──────────────────┴───────────────────────┴────────────────────┴─────────────────────╯
229
247
  ```
230
248
 
@@ -21,11 +21,12 @@ components for creating algorithms, including data provisioning,
21
21
  portfolio management, and order execution.
22
22
 
23
23
  Features:
24
- * Order execution
24
+ * Order execution and tracking
25
25
  * Broker and exchange connections through [ccxt](https://github.com/ccxt/ccxt)
26
- * Backtesting and performance analysis reports [example](./examples/backtest)
27
- * Backtest experiments to optimize your trading strategy [example](./examples/backtest_experiment)
28
- * Portfolio management
26
+ * Backtesting and performance analysis reports [example](./examples/backtest_example)
27
+ * Backtesting multiple algorithms with different backtest date ranges [example](./examples/backtests_example)
28
+ * Portfolio management and tracking
29
+ * Tracing for analyzing and debugging your trading bot
29
30
  * Web API for interacting with your deployed trading bot
30
31
  * Data persistence through sqlite db or an in-memory db
31
32
  * Stateless running for cloud function deployments
@@ -68,9 +69,6 @@ bitvavo_btc_eur_ticker = CCXTTickerMarketDataSource(
68
69
  )
69
70
  app = create_app(config=config)
70
71
  algorithm = Algorithm()
71
-
72
- app.add_market_data_source(bitvavo_btc_eur_ohlcv_2h)
73
- app.add_market_data_source(bitvavo_btc_eur_ticker)
74
72
  app.add_market_credential(MarketCredential(
75
73
  market="bitvavo",
76
74
  api_key="<your api key>",
@@ -90,7 +88,7 @@ app.add_algorithm(algorithm)
90
88
  time_unit=TimeUnit.HOUR,
91
89
  interval=2,
92
90
  # Specify market data sources that need to be passed to the strategy
93
- market_data_sources=["BTC-ticker", "BTC-ohlcv"]
91
+ market_data_sources=[bitvavo_btc_eur_ticker, bitvavo_btc_eur_ohlcv_2h]
94
92
  )
95
93
  def perform_strategy(algorithm: Algorithm, market_data: dict):
96
94
  # By default, ohlcv data is passed as polars df in the form of
@@ -140,64 +138,82 @@ you will get the following backtesting report:
140
138
 
141
139
  ```bash
142
140
 
143
- /&# #&( Backtest report
144
- &&&&&&&&&&&# &&&&&&&&&&&& ---------------------------
145
- &&&&&&&&&&&&&&&& (&&&&&&&&&&&&&&& Start date: 2023-08-24 00:00:00
146
- &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& End date: 2023-12-02 00:00:00
147
- &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Number of days: 100
148
- &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Number of runs: 1201
149
- .&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Number of orders: 10
150
- &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&. Initial balance: 400.0
151
- &&&&&&&# /((( &&&&&&&&&&&&*((( .&&&&&&&. Final balance: 431.1499
152
- &&&&&&&&&&&&&&&&&&& (((( &&&&&&&& (((( &&&&&&&&&&&&&&&&&&& Total net gain: 28.5542 7.139%
153
- (((&&&&&&&& (((( &&&&&& (((( &&&&&&&&&(( Growth: 31.1499 7.787%
154
- /((((((((((&&&&&&&&&& (((, &&&&&& (((**&&&&&&&&&((((((((((( Number of trades closed: 4
155
- &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Number of trades open(end of backtest): 2
156
- &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Percentage positive trades: 60.0%
157
- &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Percentage negative trades: 20.0%
158
- ((((( &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&( Average trade size: 98.9886 EUR
159
- ((((( &&&&&&&&&&&&&&&&&&&&&&&&, Average trade duration: 184.0 hours
160
- ((((( &&&&&&&&&&&&&#
161
- ((((( #&&&&&&&&&&###
162
- ((((( &&&&&&&&&&&###.
163
- .((((( &&&&&&&&&&&&&&###(
164
- ((((( &&&&&&&&&&&&&&&&#(((/
165
- ((((( &&&&&&&&&&&&&&&&&&&@((((
166
- ((((( &&&&&&&&&&&&&&&&&&&&&&((((
167
- ((((( &&&&&&&&&&&&&&&&&&&&&&&&((((,
168
- .((((( &&&&&&&&&&&&&&&&&&&&&&&&&&((((
169
- ((((( &&&&&&&&&&&&&&&&&&&&&&&&&&&&((((
170
- ((((( &&&&&&&&&&&&&&&&&&&&&&&&&&&&&((((
171
- ((((( &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&((((
172
- ((((( &&&&&&&&&&&&&&&&&&&&&&&&&&&&&#((((
173
- (((((((((((((((((((#########&&&&&&&&&&&&&&&&&&&&&&&&&&&&(((((
174
- (((((((((((((((((((((######&&&&&&&&&&&&&&&&&&&&&&&&&&&&((((
141
+ :%%%#+- .=*#%%% Backtest report
142
+ *%%%%%%%+------=*%%%%%%%- ---------------------------
143
+ *%%%%%%%%%%%%%%%%%%%%%%%- Start date: 2023-08-24 00:00:00
144
+ .%%%%%%%%%%%%%%%%%%%%%%# End date: 2023-12-02 00:00:00
145
+ #%%%####%%%%%%%%**#%%%+ Number of days: 100
146
+ .:-+*%%%%- -+..#%%%+.+- +%%%#*=-: Number of runs: 1201
147
+ .:-=*%%%%. += .%%# -+.-%%%%=-:.. Number of orders: 40
148
+ .:=+#%%%%%*###%%%%#*+#%%%%%%*+-: Initial balance: 400.0
149
+ +%%%%%%%%%%%%%%%%%%%= Final balance: 428.2434
150
+ :++ .=#%%%%%%%%%%%%%*- Total net gain: 28.2434 7.061%
151
+ :++: :+%%%%%%#-. Growth: 28.2434 7.061%
152
+ :++: .%%%%%#= Number of trades closed: 20
153
+ :++: .#%%%%%#*= Number of trades open(end of backtest): 0
154
+ :++- :%%%%%%%%%+= Percentage positive trades: 30.0%
155
+ .++- -%%%%%%%%%%%+= Percentage negative trades: 70.0%
156
+ .++- .%%%%%%%%%%%%%+= Average trade size: 100.9692 EUR
157
+ .++- *%%%%%%%%%%%%%*+: Average trade duration: 83.6 hours
158
+ .++- %%%%%%%%%%%%%%#+=
159
+ =++........:::%%%%%%%%%%%%%%*+-
160
+ .=++++++++++**#%%%%%%%%%%%%%++.
175
161
 
162
+ Price noise
163
+
176
164
  Positions overview
177
165
  ╭────────────┬──────────┬──────────────────────┬───────────────────────┬──────────────┬───────────────┬───────────────────────────┬────────────────┬───────────────╮
178
166
  │ Position │ Amount │ Pending buy amount │ Pending sell amount │ Cost (EUR) │ Value (EUR) │ Percentage of portfolio │ Growth (EUR) │ Growth_rate │
179
167
  ├────────────┼──────────┼──────────────────────┼───────────────────────┼──────────────┼───────────────┼───────────────────────────┼────────────────┼───────────────┤
180
- │ EUR │ 217.044 │ 0 │ 0 │ 217.044217.04450.3407% 0 │ 0.0000% │
168
+ │ EUR │ 428.243 │ 0 │ 0 │ 428.243428.243100.0000% 0 │ 0.0000% │
181
169
  ├────────────┼──────────┼──────────────────────┼───────────────────────┼──────────────┼───────────────┼───────────────────────────┼────────────────┼───────────────┤
182
- BTC 0.003 │ 0 │ 0 │ 104.372 106.84 24.7802% 2.46782.3644% │
170
+ DOT 0 │ 0 │ 0 │ 0 0 0.0000% 00.0000% │
183
171
  ├────────────┼──────────┼──────────────────────┼───────────────────────┼──────────────┼───────────────┼───────────────────────────┼────────────────┼───────────────┤
184
- DOT 21.3295 │ 0 │ 0 │ 107.138 107.266 24.8791% 0.128 │ 0.1195% │
172
+ BTC 0 │ 0 │ 0 │ 0 0 0.0000% 0 │ 0.0000% │
185
173
  ╰────────────┴──────────┴──────────────────────┴───────────────────────┴──────────────┴───────────────┴───────────────────────────┴────────────────┴───────────────╯
186
174
  Trades overview
187
175
  ╭─────────┬─────────────────────┬─────────────────────┬────────────────────┬──────────────┬──────────────────┬───────────────────────┬────────────────────┬─────────────────────╮
188
176
  │ Pair │ Open date │ Close date │ Duration (hours) │ Size (EUR) │ Net gain (EUR) │ Net gain percentage │ Open price (EUR) │ Close price (EUR) │
189
177
  ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
190
- │ DOT-EUR │ 2023-11-30 18:00:00 │ 3207.26 │ 107.138 0 0.0000% 5.023
178
+ │ DOT-EUR │ 2023-11-24 12:00:00 │ 2023-11-27 14:00:00 74 │ 107.55 -1.9587 -1.8212% 4.777 4.69
179
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
180
+ │ DOT-EUR │ 2023-11-20 00:00:00 │ 2023-11-21 08:00:00 │ 32 │ 109.39 │ -4.5949 │ -4.2005% │ 4.9875 │ 4.778 │
181
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
182
+ │ BTC-EUR │ 2023-11-19 22:00:00 │ 2023-11-22 00:00:00 │ 50 │ 109.309 │ -2.7624 │ -2.5272% │ 34159.1 │ 33295.9 │
183
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
184
+ │ BTC-EUR │ 2023-11-06 12:00:00 │ 2023-11-13 14:00:00 │ 170 │ 107.864 │ 6.1015 │ 5.6567% │ 32685.9 │ 34534.9 │
185
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
186
+ │ DOT-EUR │ 2023-10-20 12:00:00 │ 2023-10-27 08:00:00 │ 164 │ 99.085 │ 10.9799 │ 11.0813% │ 3.5465 │ 3.9395 │
187
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
188
+ │ BTC-EUR │ 2023-10-14 04:00:00 │ 2023-10-27 22:00:00 │ 330 │ 97.4278 │ 24.137 │ 24.7742% │ 25638.9 │ 31990.7 │
189
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
190
+ │ DOT-EUR │ 2023-10-14 04:00:00 │ 2023-10-17 14:00:00 │ 82 │ 99.5572 │ -1.8877 │ -1.8961% │ 3.56 │ 3.4925 │
191
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
192
+ │ DOT-EUR │ 2023-10-07 08:00:00 │ 2023-10-08 08:00:00 │ 24 │ 99.9498 │ -1.5708 │ -1.5716% │ 3.8815 │ 3.8205 │
193
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
194
+ │ BTC-EUR │ 2023-09-27 10:00:00 │ 2023-10-05 20:00:00 │ 202 │ 98.2888 │ 3.433 │ 3.4927% │ 25202.2 │ 26082.5 │
195
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
196
+ │ DOT-EUR │ 2023-09-27 10:00:00 │ 2023-10-03 20:00:00 │ 154 │ 98.7893 │ 1.2085 │ 1.2233% │ 3.842 │ 3.889 │
197
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
198
+ │ DOT-EUR │ 2023-09-25 12:00:00 │ 2023-09-27 04:00:00 │ 40 │ 98.9193 │ -0.5194 │ -0.5251% │ 3.809 │ 3.789 │
199
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
200
+ │ DOT-EUR │ 2023-09-14 16:00:00 │ 2023-09-18 02:00:00 │ 82 │ 98.9419 │ -0.0912 │ -0.0921% │ 3.799 │ 3.7955 │
201
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
202
+ │ BTC-EUR │ 2023-09-07 06:00:00 │ 2023-09-10 16:00:00 │ 82 │ 98.6093 │ 0.3412 │ 0.3460% │ 24051 │ 24134.3 │
203
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
204
+ │ DOT-EUR │ 2023-09-07 00:00:00 │ 2023-09-09 02:00:00 │ 50 │ 98.9158 │ -0.2358 │ -0.2383% │ 3.986 │ 3.9765 │
205
+ ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
206
+ │ DOT-EUR │ 2023-09-05 14:00:00 │ 2023-09-06 12:00:00 │ 22 │ 99.2132 │ -1.1909 │ -1.2003% │ 3.999 │ 3.951 │
191
207
  ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
192
- BTC-EUR │ 2023-11-29 12:00:00 │ 3237.26 104.372 0 │ 0.0000% 34790.7
208
+ DOT-EUR │ 2023-09-04 16:00:00 │ 2023-09-04 22:00:00 6 99.355 -0.5671 -0.5708% 3.942 3.9195
193
209
  ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
194
- BTC-EUR │ 2023-11-07 22:00:00 │ 2023-11-14 14:00:00 │ 160 │ 99.2337 2.53952.5591% 33077.9 33924.4
210
+ DOT-EUR │ 2023-09-04 10:00:00 │ 2023-09-04 14:00:00 │ 4 │ 99.4774 -0.4889-0.4914% 3.968 3.9485
195
211
  ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
196
- │ BTC-EUR │ 2023-11-06 14:00:00 │ 2023-11-06 18:00:00 │ 4 98.2854 │ -0.4248 │ -0.4322% │ 32761.832620.2
212
+ │ BTC-EUR │ 2023-08-26 10:00:00 │ 2023-08-26 18:00:00 │ 8 99.0829 │ -0.03 │ -0.0302% │ 24166.624159.3
197
213
  ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
198
- │ DOT-EUR │ 2023-10-30 04:00:00 │ 2023-11-14 00:00:00 │ 356 100.53724.288624.1588% │ 4.05655.0365
214
+ │ DOT-EUR │ 2023-08-25 10:00:00 │ 2023-08-28 10:00:00 │ 72 99.659-0.6975-0.6999% │ 4.14354.1145
199
215
  ├─────────┼─────────────────────┼─────────────────────┼────────────────────┼──────────────┼──────────────────┼───────────────────────┼────────────────────┼─────────────────────┤
200
- BTC-EUR │ 2023-09-13 14:00:00 │ 2023-09-22 14:00:00 │ 216 97.8976 2.15082.1970% 24474.4 │ 25012.1
216
+ DOT-EUR │ 2023-08-24 00:00:00 │ 2023-08-25 00:00:00 │ 24 99.9999 -1.3626-1.3626% 4.1465 │ 4.09
201
217
  ╰─────────┴─────────────────────┴─────────────────────┴────────────────────┴──────────────┴──────────────────┴───────────────────────┴────────────────────┴─────────────────────╯
202
218
  ```
203
219
 
@@ -9,12 +9,16 @@ from investing_algorithm_framework.domain import ApiException, \
9
9
  Trade, OHLCVMarketDataSource, OrderBookMarketDataSource, SYMBOLS, \
10
10
  TickerMarketDataSource, MarketService, BacktestReportsEvaluation, \
11
11
  pretty_print_backtest_reports_evaluation, load_backtest_reports, \
12
- RESERVED_BALANCES, APP_MODE, AppMode, DATETIME_FORMAT
12
+ RESERVED_BALANCES, APP_MODE, AppMode, DATETIME_FORMAT, \
13
+ load_backtest_report, BacktestDateRange, create_ema_graph, \
14
+ create_prices_graph, create_rsi_graph, get_price_efficiency_ratio
13
15
  from investing_algorithm_framework.infrastructure import \
14
16
  CCXTOrderBookMarketDataSource, CCXTOHLCVMarketDataSource, \
15
17
  CCXTTickerMarketDataSource, CSVOHLCVMarketDataSource, \
16
18
  CSVTickerMarketDataSource
17
19
  from .create_app import create_app
20
+ from investing_algorithm_framework.services import \
21
+ create_trade_exit_markers_chart, create_trade_entry_markers_chart
18
22
 
19
23
  __all__ = [
20
24
  "Algorithm",
@@ -61,4 +65,12 @@ __all__ = [
61
65
  "APP_MODE",
62
66
  "AppMode",
63
67
  "DATETIME_FORMAT",
68
+ "load_backtest_report",
69
+ "BacktestDateRange",
70
+ "create_trade_exit_markers_chart",
71
+ "create_trade_entry_markers_chart",
72
+ "create_ema_graph",
73
+ "create_prices_graph",
74
+ "create_rsi_graph",
75
+ "get_price_efficiency_ratio"
64
76
  ]
@@ -1,8 +1,8 @@
1
1
  import inspect
2
2
  import logging
3
- from typing import List
3
+ from typing import List, Dict
4
4
 
5
- from investing_algorithm_framework.domain import OrderStatus, OrderFee, \
5
+ from investing_algorithm_framework.domain import OrderStatus, \
6
6
  Position, Order, Portfolio, OrderType, OrderSide, \
7
7
  BACKTESTING_FLAG, BACKTESTING_INDEX_DATETIME, MarketService, TimeUnit, \
8
8
  OperationalException, random_string, RoundingService
@@ -16,9 +16,30 @@ logger = logging.getLogger("investing_algorithm_framework")
16
16
 
17
17
 
18
18
  class Algorithm:
19
-
20
- def __init__(self, name=None, description=None):
19
+ """
20
+ Class to represent an algorithm. An algorithm is a collection of
21
+ strategies that are executed in a specific order. The algorithm
22
+ class is responsible for managing the strategies and executing
23
+ them in the correct order.
24
+
25
+ :param (optional) name: The name of the algorithm
26
+ :param (optional) description: The description of the algorithm
27
+ :param (optional) context: The context of the algorithm,
28
+ for backtest references
29
+ :param (optional) strategy: A single strategy to add to the algorithm
30
+ :param (optional) data_sources: The list of data sources to
31
+ add to the algorithm
32
+ """
33
+ def __init__(
34
+ self,
35
+ name: str = None,
36
+ description: str = None,
37
+ context: Dict = None,
38
+ strategy=None,
39
+ data_sources=None
40
+ ):
21
41
  self._name = name
42
+ self._context = {}
22
43
 
23
44
  if name is None:
24
45
  self._name = f"algorithm_{random_string(10)}"
@@ -28,6 +49,9 @@ class Algorithm:
28
49
  if description is not None:
29
50
  self._description = description
30
51
 
52
+ if context is not None:
53
+ self.add_context(context)
54
+
31
55
  self._strategies = []
32
56
  self._tasks = []
33
57
  self.portfolio_service: PortfolioService
@@ -37,12 +61,18 @@ class Algorithm:
37
61
  self.configuration_service: ConfigurationService
38
62
  self.portfolio_configuration_service: PortfolioConfigurationService
39
63
  self.strategy_orchestrator_service: StrategyOrchestratorService
40
- self._market_data_sources = {}
64
+ self._data_sources = {}
41
65
  self._strategies = []
42
66
  self._market_credential_service: MarketCredentialService
43
67
  self._market_data_source_service: MarketDataSourceService
44
68
  self.trade_service: TradeService
45
69
 
70
+ if strategy is not None:
71
+ self.add_strategy(strategy)
72
+
73
+ if data_sources is not None:
74
+ self.add_data_sources(data_sources)
75
+
46
76
  def initialize_services(
47
77
  self,
48
78
  configuration_service,
@@ -66,7 +96,7 @@ class Algorithm:
66
96
  = portfolio_configuration_service
67
97
  self.strategy_orchestrator_service: StrategyOrchestratorService \
68
98
  = strategy_orchestrator_service
69
- self._market_data_sources = {}
99
+ self._data_sources = {}
70
100
  self._market_credential_service: MarketCredentialService \
71
101
  = market_credential_service
72
102
  self._market_data_source_service: MarketDataSourceService \
@@ -90,6 +120,10 @@ class Algorithm:
90
120
  def name(self):
91
121
  return self._name
92
122
 
123
+ @property
124
+ def data_sources(self):
125
+ return self._data_sources
126
+
93
127
  @property
94
128
  def identifier(self):
95
129
  """
@@ -108,6 +142,33 @@ class Algorithm:
108
142
  """
109
143
  return self.configuration_service.config
110
144
 
145
+ @property
146
+ def description(self):
147
+ """
148
+ Function to get the description of the algorithm
149
+ """
150
+ return self._description
151
+
152
+ @property
153
+ def context(self):
154
+ """
155
+ Function to get the context of the algorithm
156
+ """
157
+ return self._context
158
+
159
+ def add_context(self, context: Dict):
160
+ # Check if the context is a dictionary with only string,
161
+ # float or int values
162
+ for key, value in self.context.items():
163
+ if not isinstance(key, str) or \
164
+ not isinstance(value, (str, float, int)):
165
+ raise OperationalException(
166
+ "The context for an algorithm must be a dictionary with "
167
+ "only string, float or int values."
168
+ )
169
+
170
+ self._context = context
171
+
111
172
  @property
112
173
  def running(self) -> bool:
113
174
  """
@@ -362,9 +423,6 @@ class Algorithm:
362
423
  }
363
424
  )
364
425
 
365
- def get_order_fee(self, order_id) -> OrderFee:
366
- return self.order_service.get_order_fee(order_id)
367
-
368
426
  def get_positions(
369
427
  self,
370
428
  market=None,
@@ -699,6 +757,9 @@ class Algorithm:
699
757
  "with the same id in the algorithm"
700
758
  )
701
759
 
760
+ if strategy.market_data_sources is not None:
761
+ self.add_data_sources(strategy.market_data_sources)
762
+
702
763
  self._strategies.append(strategy)
703
764
 
704
765
  @property
@@ -989,6 +1050,9 @@ class Algorithm:
989
1050
 
990
1051
  self._tasks.append(task)
991
1052
 
1053
+ def add_data_sources(self, data_sources):
1054
+ self._data_sources = data_sources
1055
+
992
1056
  @property
993
1057
  def tasks(self):
994
1058
  return self._tasks