investing-algorithm-framework 3.8__tar.gz → 3.8.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 (161) hide show
  1. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/PKG-INFO +20 -17
  2. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/README.md +19 -16
  3. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/__init__.py +19 -1
  4. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/app/algorithm.py +285 -17
  5. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/app/app.py +52 -16
  6. investing_algorithm_framework-3.8.1/investing_algorithm_framework/app/strategy.py +559 -0
  7. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/backtesting/backtest_date_range.py +6 -2
  8. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/date_range.py +8 -0
  9. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/services/market_data_sources.py +9 -2
  10. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/utils/polars.py +6 -1
  11. investing_algorithm_framework-3.8.1/investing_algorithm_framework/indicators/__init__.py +37 -0
  12. investing_algorithm_framework-3.8.1/investing_algorithm_framework/indicators/advanced.py +404 -0
  13. investing_algorithm_framework-3.8.1/investing_algorithm_framework/indicators/momentum.py +41 -0
  14. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/indicators/trend.py +154 -96
  15. investing_algorithm_framework-3.8.1/investing_algorithm_framework/indicators/utils.py +467 -0
  16. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/models/market_data_sources/ccxt.py +45 -9
  17. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/services/market_service/ccxt_market_service.py +1 -1
  18. investing_algorithm_framework-3.8.1/investing_algorithm_framework/services/backtesting/backtest_report_writer_service.py +91 -0
  19. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/services/backtesting/backtest_service.py +152 -9
  20. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/services/market_data_source_service/market_data_source_service.py +19 -4
  21. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/services/order_service/order_backtest_service.py +17 -1
  22. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/pyproject.toml +5 -1
  23. investing_algorithm_framework-3.8/investing_algorithm_framework/app/strategy.py +0 -213
  24. investing_algorithm_framework-3.8/investing_algorithm_framework/indicators/__init__.py +0 -13
  25. investing_algorithm_framework-3.8/investing_algorithm_framework/indicators/advanced.py +0 -224
  26. investing_algorithm_framework-3.8/investing_algorithm_framework/services/backtesting/backtest_report_writer_service.py +0 -53
  27. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/LICENSE +0 -0
  28. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/app/__init__.py +0 -0
  29. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/app/stateless/__init__.py +0 -0
  30. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/app/stateless/action_handlers/__init__.py +0 -0
  31. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/app/stateless/action_handlers/action_handler_strategy.py +0 -0
  32. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/app/stateless/action_handlers/check_online_handler.py +0 -0
  33. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/app/stateless/action_handlers/run_strategy_handler.py +0 -0
  34. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/app/stateless/exception_handler.py +0 -0
  35. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/app/task.py +0 -0
  36. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/app/web/__init__.py +0 -0
  37. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/app/web/controllers/__init__.py +0 -0
  38. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/app/web/controllers/orders.py +0 -0
  39. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/app/web/controllers/portfolio.py +0 -0
  40. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/app/web/controllers/positions.py +0 -0
  41. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/app/web/create_app.py +0 -0
  42. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/app/web/error_handler.py +0 -0
  43. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/app/web/responses.py +0 -0
  44. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/app/web/run_strategies.py +0 -0
  45. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/app/web/schemas/__init__.py +0 -0
  46. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/app/web/schemas/order.py +0 -0
  47. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/app/web/schemas/portfolio.py +0 -0
  48. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/app/web/schemas/position.py +0 -0
  49. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/app/web/setup_cors.py +0 -0
  50. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/create_app.py +0 -0
  51. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/dependency_container.py +0 -0
  52. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/deployment/__init__.py +0 -0
  53. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/deployment/azure/__init__.py +0 -0
  54. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/deployment/azure/azure_functions.py +0 -0
  55. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/__init__.py +0 -0
  56. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/config.py +0 -0
  57. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/constants.py +0 -0
  58. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/data_structures.py +0 -0
  59. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/decimal_parsing.py +0 -0
  60. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/exceptions.py +0 -0
  61. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/metrics/__init__.py +0 -0
  62. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/metrics/price_efficiency.py +0 -0
  63. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/__init__.py +0 -0
  64. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/app_mode.py +0 -0
  65. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/backtesting/__init__.py +0 -0
  66. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/backtesting/backtest_position.py +0 -0
  67. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/backtesting/backtest_report.py +0 -0
  68. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/backtesting/backtest_reports_evaluation.py +0 -0
  69. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/base_model.py +0 -0
  70. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/market/__init__.py +0 -0
  71. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/market/market_credential.py +0 -0
  72. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/order/__init__.py +0 -0
  73. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/order/order.py +0 -0
  74. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/order/order_side.py +0 -0
  75. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/order/order_status.py +0 -0
  76. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/order/order_type.py +0 -0
  77. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/portfolio/__init__.py +0 -0
  78. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/portfolio/portfolio.py +0 -0
  79. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/portfolio/portfolio_configuration.py +0 -0
  80. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/portfolio/portfolio_snapshot.py +0 -0
  81. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/position/__init__.py +0 -0
  82. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/position/position.py +0 -0
  83. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/position/position_snapshot.py +0 -0
  84. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/strategy_profile.py +0 -0
  85. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/time_frame.py +0 -0
  86. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/time_interval.py +0 -0
  87. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/time_unit.py +0 -0
  88. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/tracing/__init__.py +0 -0
  89. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/tracing/trace.py +0 -0
  90. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/trade/__init__.py +0 -0
  91. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/trade/trade.py +0 -0
  92. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/trade/trade_status.py +0 -0
  93. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/trading_data_types.py +0 -0
  94. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/models/trading_time_frame.py +0 -0
  95. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/services/__init__.py +0 -0
  96. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/services/market_credential_service.py +0 -0
  97. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/services/market_service.py +0 -0
  98. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/services/portfolios/__init__.py +0 -0
  99. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/services/portfolios/portfolio_sync_service.py +0 -0
  100. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/services/rounding_service.py +0 -0
  101. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/singleton.py +0 -0
  102. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/stateless_actions.py +0 -0
  103. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/strategy.py +0 -0
  104. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/utils/__init__.py +0 -0
  105. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/utils/backtesting.py +0 -0
  106. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/utils/csv.py +0 -0
  107. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/utils/random.py +0 -0
  108. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/utils/signatures.py +0 -0
  109. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/utils/stoppable_thread.py +0 -0
  110. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/domain/utils/synchronized.py +0 -0
  111. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/__init__.py +0 -0
  112. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/database/__init__.py +0 -0
  113. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/database/sql_alchemy.py +0 -0
  114. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/models/__init__.py +0 -0
  115. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/models/decimal_parser.py +0 -0
  116. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/models/market_data_sources/__init__.py +0 -0
  117. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/models/market_data_sources/csv.py +0 -0
  118. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/models/market_data_sources/pandas.py +0 -0
  119. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/models/market_data_sources/us_treasury_yield.py +0 -0
  120. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/models/model_extension.py +0 -0
  121. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/models/order/__init__.py +0 -0
  122. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/models/order/order.py +0 -0
  123. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/models/portfolio/__init__.py +0 -0
  124. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/models/portfolio/portfolio.py +0 -0
  125. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/models/portfolio/portfolio_snapshot.py +0 -0
  126. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/models/position/__init__.py +0 -0
  127. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/models/position/position.py +0 -0
  128. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/models/position/position_snapshot.py +0 -0
  129. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/repositories/__init__.py +0 -0
  130. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/repositories/order_repository.py +0 -0
  131. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/repositories/portfolio_repository.py +0 -0
  132. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/repositories/portfolio_snapshot_repository.py +0 -0
  133. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/repositories/position_repository.py +0 -0
  134. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/repositories/position_snapshot_repository.py +0 -0
  135. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/repositories/repository.py +0 -0
  136. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/services/__init__.py +0 -0
  137. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/services/market_service/__init__.py +0 -0
  138. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/services/performance_service/__init__.py +0 -0
  139. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/services/performance_service/backtest_performance_service.py +0 -0
  140. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/infrastructure/services/performance_service/performance_service.py +0 -0
  141. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/services/__init__.py +0 -0
  142. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/services/backtesting/__init__.py +0 -0
  143. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/services/backtesting/graphs.py +0 -0
  144. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/services/configuration_service.py +0 -0
  145. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/services/market_credential_service.py +0 -0
  146. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/services/market_data_source_service/__init__.py +0 -0
  147. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/services/market_data_source_service/backtest_market_data_source_service.py +0 -0
  148. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/services/order_service/__init__.py +0 -0
  149. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/services/order_service/order_service.py +0 -0
  150. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/services/portfolios/__init__.py +0 -0
  151. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/services/portfolios/backtest_portfolio_service.py +0 -0
  152. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/services/portfolios/portfolio_configuration_service.py +0 -0
  153. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/services/portfolios/portfolio_service.py +0 -0
  154. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/services/portfolios/portfolio_snapshot_service.py +0 -0
  155. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/services/portfolios/portfolio_sync_service.py +0 -0
  156. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/services/position_service.py +0 -0
  157. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/services/position_snapshot_service.py +0 -0
  158. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/services/repository_service.py +0 -0
  159. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/services/strategy_orchestrator_service.py +0 -0
  160. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.1}/investing_algorithm_framework/services/trade_service/__init__.py +0 -0
  161. {investing_algorithm_framework-3.8 → investing_algorithm_framework-3.8.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: 3.8
3
+ Version: 3.8.1
4
4
  Summary: A framework for creating trading bots
5
5
  Author: MDUYN
6
6
  Requires-Python: >=3.10
@@ -46,12 +46,11 @@ Description-Content-Type: text/markdown
46
46
 
47
47
  # [Investing Algorithm Framework](https://github.com/coding-kitties/investing-algorithm-framework)
48
48
 
49
- The Investing Algorithm Framework is a Python tool that enables swift and
50
- elegant development of trading bots. It comes with all the necessary
51
- components for creating algorithms, including data provisioning,
52
- portfolio management, and order execution.
49
+ The Investing Algorithm Framework is a Python framework that enables swift and elegant development of trading bots. It comes with all the necessary components for creating trading strategies, including data management, portfolio, order, position and trades management.
53
50
 
54
- Features:
51
+ Features:
52
+
53
+ * Indicators module: A collection of indicators and utility functions that can be used in your trading strategies.
55
54
  * Order execution and tracking
56
55
  * Broker and exchange connections through [ccxt](https://github.com/ccxt/ccxt)
57
56
  * Backtesting and performance analysis reports [example](./examples/backtest_example)
@@ -63,12 +62,10 @@ Features:
63
62
  * Stateless running for cloud function deployments
64
63
  * Polars dataframes support out of the box for fast data processing [pola.rs](https://pola.rs/)
65
64
 
66
- Additional features:
67
- * Indicators (python >= 3.10 required): Set of indicators that can be used in your trading bot. You can donwload the package with `pip install investing-algorithm-framework[indicators]` or `poetry add investing-algorithm-framework[indicators]]`
68
-
69
65
  ## Example implementation
70
- The following algorithm connects to binance and buys BTC every 5 seconds.
71
- It also exposes an REST API that allows you to interact with the algorithm.
66
+
67
+ The following algorithm connects to binance and buys BTC every 5 seconds. It also exposes an REST API that allows you to interact with the algorithm.
68
+
72
69
  ```python
73
70
  import pathlib
74
71
  from investing_algorithm_framework import create_app, PortfolioConfiguration, \
@@ -160,12 +157,13 @@ if __name__ == "__main__":
160
157
  > You can find more examples [here](./examples) folder.
161
158
 
162
159
  ## Backtesting and experiments
163
- The framework also supports backtesting and performing backtest experiments. After
164
- a backtest, you can print a report that shows the performance of your trading bot.
160
+
161
+ The framework also supports backtesting and performing backtest experiments. After a backtest, you can print a report that shows the performance of your trading bot.
165
162
 
166
163
  To run a single backtest you can use the example code that can be found [here](./examples/backtest).
167
164
 
168
165
  ### Backtesting report
166
+
169
167
  You can use the ```pretty_print_backtest``` function to print a backtest report.
170
168
  For example if you run the [moving average example trading bot](./examples/crossover_moving_average_trading_bot)
171
169
  you will get the following backtesting report:
@@ -252,6 +250,7 @@ Trades overview
252
250
  ```
253
251
 
254
252
  ### Backtest experiments
253
+
255
254
  The framework also supports backtest experiments. Backtest experiments allows you to
256
255
  compare multiple algorithms and evaluate their performance. Ideally,
257
256
  you would do this by parameterizing your strategy and creating a factory function that
@@ -259,6 +258,7 @@ creates the algorithm with the different parameters. You can find an example of
259
258
  in the [backtest experiments example](./examples/backtest_experiment).
260
259
 
261
260
  ## Broker/Exchange configuration
261
+
262
262
  The framework has by default support for [ccxt](https://github.com/ccxt/ccxt).
263
263
  This should allow you to connect to a lot of brokers/exchanges.
264
264
 
@@ -284,10 +284,12 @@ app.add_portfolio_configuration(
284
284
  ```
285
285
 
286
286
  ## Performance
287
+
287
288
  We are continuously working on improving the performance of the framework. If
288
289
  you have any suggestions, please let us know.
289
290
 
290
291
  ## Download
292
+
291
293
  You can download the framework with pypi.
292
294
 
293
295
  ```bash
@@ -295,6 +297,7 @@ pip install investing-algorithm-framework
295
297
  ```
296
298
 
297
299
  ## Disclaimer
300
+
298
301
  If you use this framework for your investments, do not risk money
299
302
  which you are afraid to lose, until you have clear understanding how
300
303
  the framework works. We can't stress this enough:
@@ -319,8 +322,8 @@ If you'd like to chat with investing-algorithm-framework users
319
322
  and developers, [join us on Slack](https://inv-algo-framework.slack.com) or [join us on reddit](https://www.reddit.com/r/InvestingBots/)
320
323
 
321
324
  ## Acknowledgements
322
- We want to thank all contributors to this project. A full list of all
323
- the people that contributed to the project can be
325
+
326
+ We want to thank all contributors to this project. A full list of all the people that contributed to the project can be
324
327
  found [here](https://github.com/investing-algorithms/investing-algorithm-framework/blob/master/AUTHORS.md)
325
328
 
326
329
  ### [Bugs / Issues](https://github.com/investing-algorithms/investing-algorithm-framework/issues?q=is%3Aissue)
@@ -329,9 +332,9 @@ If you discover a bug in the framework, please [search our issue tracker](https:
329
332
  first. If it hasn't been reported, please [create a new issue](https://github.com/investing-algorithms/investing-algorithm-framework/issues/new).
330
333
 
331
334
  ### Contributing
335
+
332
336
  The investing algorithm framework is a community driven project.
333
- We welcome you to participate, contribute and together help build
334
- the future trading bots developed in python.
337
+ We welcome you to participate, contribute and together help build the future trading bots developed in python.
335
338
 
336
339
  Feel like the framework is missing a feature? We welcome your pull requests!
337
340
  If you want to contribute to the project roadmap, please take a look at the [project board](https://github.com/coding-kitties/investing-algorithm-framework/projects?query=is%3Aopen).
@@ -15,12 +15,11 @@
15
15
 
16
16
  # [Investing Algorithm Framework](https://github.com/coding-kitties/investing-algorithm-framework)
17
17
 
18
- The Investing Algorithm Framework is a Python tool that enables swift and
19
- elegant development of trading bots. It comes with all the necessary
20
- components for creating algorithms, including data provisioning,
21
- portfolio management, and order execution.
18
+ The Investing Algorithm Framework is a Python framework that enables swift and elegant development of trading bots. It comes with all the necessary components for creating trading strategies, including data management, portfolio, order, position and trades management.
22
19
 
23
- Features:
20
+ Features:
21
+
22
+ * Indicators module: A collection of indicators and utility functions that can be used in your trading strategies.
24
23
  * Order execution and tracking
25
24
  * Broker and exchange connections through [ccxt](https://github.com/ccxt/ccxt)
26
25
  * Backtesting and performance analysis reports [example](./examples/backtest_example)
@@ -32,12 +31,10 @@ Features:
32
31
  * Stateless running for cloud function deployments
33
32
  * Polars dataframes support out of the box for fast data processing [pola.rs](https://pola.rs/)
34
33
 
35
- Additional features:
36
- * Indicators (python >= 3.10 required): Set of indicators that can be used in your trading bot. You can donwload the package with `pip install investing-algorithm-framework[indicators]` or `poetry add investing-algorithm-framework[indicators]]`
37
-
38
34
  ## Example implementation
39
- The following algorithm connects to binance and buys BTC every 5 seconds.
40
- It also exposes an REST API that allows you to interact with the algorithm.
35
+
36
+ The following algorithm connects to binance and buys BTC every 5 seconds. It also exposes an REST API that allows you to interact with the algorithm.
37
+
41
38
  ```python
42
39
  import pathlib
43
40
  from investing_algorithm_framework import create_app, PortfolioConfiguration, \
@@ -129,12 +126,13 @@ if __name__ == "__main__":
129
126
  > You can find more examples [here](./examples) folder.
130
127
 
131
128
  ## Backtesting and experiments
132
- The framework also supports backtesting and performing backtest experiments. After
133
- a backtest, you can print a report that shows the performance of your trading bot.
129
+
130
+ The framework also supports backtesting and performing backtest experiments. After a backtest, you can print a report that shows the performance of your trading bot.
134
131
 
135
132
  To run a single backtest you can use the example code that can be found [here](./examples/backtest).
136
133
 
137
134
  ### Backtesting report
135
+
138
136
  You can use the ```pretty_print_backtest``` function to print a backtest report.
139
137
  For example if you run the [moving average example trading bot](./examples/crossover_moving_average_trading_bot)
140
138
  you will get the following backtesting report:
@@ -221,6 +219,7 @@ Trades overview
221
219
  ```
222
220
 
223
221
  ### Backtest experiments
222
+
224
223
  The framework also supports backtest experiments. Backtest experiments allows you to
225
224
  compare multiple algorithms and evaluate their performance. Ideally,
226
225
  you would do this by parameterizing your strategy and creating a factory function that
@@ -228,6 +227,7 @@ creates the algorithm with the different parameters. You can find an example of
228
227
  in the [backtest experiments example](./examples/backtest_experiment).
229
228
 
230
229
  ## Broker/Exchange configuration
230
+
231
231
  The framework has by default support for [ccxt](https://github.com/ccxt/ccxt).
232
232
  This should allow you to connect to a lot of brokers/exchanges.
233
233
 
@@ -253,10 +253,12 @@ app.add_portfolio_configuration(
253
253
  ```
254
254
 
255
255
  ## Performance
256
+
256
257
  We are continuously working on improving the performance of the framework. If
257
258
  you have any suggestions, please let us know.
258
259
 
259
260
  ## Download
261
+
260
262
  You can download the framework with pypi.
261
263
 
262
264
  ```bash
@@ -264,6 +266,7 @@ pip install investing-algorithm-framework
264
266
  ```
265
267
 
266
268
  ## Disclaimer
269
+
267
270
  If you use this framework for your investments, do not risk money
268
271
  which you are afraid to lose, until you have clear understanding how
269
272
  the framework works. We can't stress this enough:
@@ -288,8 +291,8 @@ If you'd like to chat with investing-algorithm-framework users
288
291
  and developers, [join us on Slack](https://inv-algo-framework.slack.com) or [join us on reddit](https://www.reddit.com/r/InvestingBots/)
289
292
 
290
293
  ## Acknowledgements
291
- We want to thank all contributors to this project. A full list of all
292
- the people that contributed to the project can be
294
+
295
+ We want to thank all contributors to this project. A full list of all the people that contributed to the project can be
293
296
  found [here](https://github.com/investing-algorithms/investing-algorithm-framework/blob/master/AUTHORS.md)
294
297
 
295
298
  ### [Bugs / Issues](https://github.com/investing-algorithms/investing-algorithm-framework/issues?q=is%3Aissue)
@@ -298,9 +301,9 @@ If you discover a bug in the framework, please [search our issue tracker](https:
298
301
  first. If it hasn't been reported, please [create a new issue](https://github.com/investing-algorithms/investing-algorithm-framework/issues/new).
299
302
 
300
303
  ### Contributing
304
+
301
305
  The investing algorithm framework is a community driven project.
302
- We welcome you to participate, contribute and together help build
303
- the future trading bots developed in python.
306
+ We welcome you to participate, contribute and together help build the future trading bots developed in python.
304
307
 
305
308
  Feel like the framework is missing a feature? We welcome your pull requests!
306
309
  If you want to contribute to the project roadmap, please take a look at the [project board](https://github.com/coding-kitties/investing-algorithm-framework/projects?query=is%3Aopen).
@@ -66,5 +66,23 @@ __all__ = [
66
66
  "load_backtest_report",
67
67
  "BacktestDateRange",
68
68
  "convert_polars_to_pandas",
69
- "DateRange"
69
+ "DateRange",
70
+ "get_rsi",
71
+ "get_peaks",
72
+ "is_uptrend",
73
+ "is_downtrend",
74
+ "is_crossover",
75
+ "is_crossunder",
76
+ "is_above",
77
+ "is_below",
78
+ "has_crossed_upward",
79
+ "get_sma",
80
+ "get_up_and_downtrends",
81
+ "get_rsi",
82
+ "get_ema",
83
+ "get_adx",
84
+ "has_crossed_downward",
85
+ "get_willr",
86
+ "is_bearish_divergence",
87
+ "is_bullish_divergence",
70
88
  ]
@@ -1,11 +1,12 @@
1
1
  import inspect
2
2
  import logging
3
3
  from typing import List, Dict
4
+ import re
4
5
 
5
6
  from investing_algorithm_framework.domain import OrderStatus, \
6
7
  Position, Order, Portfolio, OrderType, OrderSide, \
7
8
  BACKTESTING_FLAG, BACKTESTING_INDEX_DATETIME, MarketService, TimeUnit, \
8
- OperationalException, random_string, RoundingService
9
+ OperationalException, random_string, RoundingService, Trade
9
10
  from investing_algorithm_framework.services import MarketCredentialService, \
10
11
  MarketDataSourceService, PortfolioService, PositionService, TradeService, \
11
12
  OrderService, ConfigurationService, StrategyOrchestratorService, \
@@ -73,6 +74,32 @@ class Algorithm:
73
74
  if data_sources is not None:
74
75
  self.add_data_sources(data_sources)
75
76
 
77
+ def _validate_name(self, name):
78
+ """
79
+ Function to validate the name of the algorithm. This function
80
+ will check if the name of the algorithm is a string and raise
81
+ an exception if it is not.
82
+
83
+ Name can only contain letters, numbers
84
+
85
+ Parameters:
86
+ name: The name of the algorithm
87
+
88
+ Returns:
89
+ None
90
+ """
91
+ if not isinstance(name, str):
92
+ raise OperationalException(
93
+ "The name of the algorithm must be a string"
94
+ )
95
+
96
+ pattern = re.compile(r"^[a-zA-Z0-9]*$")
97
+ if not pattern.match(name):
98
+ raise OperationalException(
99
+ "The name of the algorithm can only contain" +
100
+ " letters and numbers"
101
+ )
102
+
76
103
  def initialize_services(
77
104
  self,
78
105
  configuration_service,
@@ -235,12 +262,40 @@ class Algorithm:
235
262
  order_data, execute=execute, validate=validate, sync=sync
236
263
  )
237
264
 
265
+ def has_balance(self, symbol, amount, market=None):
266
+ """
267
+ Function to check if the portfolio has enough balance to
268
+ create an order. This function will return True if the
269
+ portfolio has enough balance to create an order, False
270
+ otherwise.
271
+
272
+ Parameters:
273
+ symbol: The symbol of the asset
274
+ amount: The amount of the asset
275
+ market: The market of the asset
276
+
277
+ Returns:
278
+ Boolean: True if the portfolio has enough balance
279
+ """
280
+
281
+ portfolio = self.portfolio_service.find({"market": market})
282
+ position = self.position_service.find(
283
+ {"portfolio": portfolio.id, "symbol": symbol}
284
+ )
285
+
286
+ if position is None:
287
+ return False
288
+
289
+ return position.get_amount() >= amount
290
+
238
291
  def create_limit_order(
239
292
  self,
240
293
  target_symbol,
241
294
  price,
242
295
  order_side,
243
296
  amount=None,
297
+ amount_trading_symbol=None,
298
+ percentage=None,
244
299
  percentage_of_portfolio=None,
245
300
  percentage_of_position=None,
246
301
  precision=None,
@@ -249,6 +304,39 @@ class Algorithm:
249
304
  validate=True,
250
305
  sync=True
251
306
  ):
307
+ """
308
+ Function to create a limit order. This function will create a limit
309
+ order and execute it if the execute parameter is set to True. If the
310
+ validate parameter is set to True, the order will be validated
311
+
312
+ Parameters:
313
+ target_symbol: The symbol of the asset to trade
314
+ price: The price of the asset
315
+ order_side: The side of the order
316
+ amount (optional): The amount of the asset to trade
317
+ amount_trading_symbol (optional): The amount of the
318
+ trading symbol to trade
319
+ percentage (optional): The percentage of the portfolio
320
+ to allocate to the
321
+ order
322
+ percentage_of_portfolio (optional): The percentage
323
+ of the portfolio to allocate to the order
324
+ percentage_of_position (optional): The percentage
325
+ of the position to allocate to
326
+ the order. (Only supported for SELL orders)
327
+ precision (optional): The precision of the amount
328
+ market (optional): The market to trade the asset
329
+ execute (optional): Default True. If set to True,
330
+ the order will be executed
331
+ validate (optional): Default True. If set to
332
+ True, the order will be validated
333
+ sync (optional): Default True. If set to True,
334
+ the created order will be synced with the
335
+ portfolio of the algorithm
336
+
337
+ Returns:
338
+ Order: Instance of the order created
339
+ """
252
340
  portfolio = self.portfolio_service.find({"market": market})
253
341
 
254
342
  if percentage_of_portfolio is not None:
@@ -277,9 +365,25 @@ class Algorithm:
277
365
  )
278
366
  amount = position.get_amount() * (percentage_of_position / 100)
279
367
 
368
+ elif percentage is not None:
369
+ net_size = portfolio.get_net_size()
370
+ size = net_size * (percentage / 100)
371
+ amount = size / price
372
+
280
373
  if precision is not None:
281
374
  amount = RoundingService.round_down(amount, precision)
282
375
 
376
+ if amount_trading_symbol is not None:
377
+ amount = amount_trading_symbol / price
378
+
379
+ if amount is None:
380
+ raise OperationalException(
381
+ "The amount parameter is required to create a limit order." +
382
+ "Either the amount, amount_trading_symbol, percentage, " +
383
+ "percentage_of_portfolio or percentage_of_position "
384
+ "parameter must be specified."
385
+ )
386
+
283
387
  order_data = {
284
388
  "target_symbol": target_symbol,
285
389
  "price": price,
@@ -310,6 +414,24 @@ class Algorithm:
310
414
  validate=False,
311
415
  sync=True
312
416
  ):
417
+ """
418
+ Function to create a market order. This function will create a market
419
+ order and execute it if the execute parameter is set to True. If the
420
+ validate parameter is set to True, the order will be validated
421
+
422
+ Parameters:
423
+ target_symbol: The symbol of the asset to trade
424
+ order_side: The side of the order
425
+ amount: The amount of the asset to trade
426
+ market: The market to trade the asset
427
+ execute: If set to True, the order will be executed
428
+ validate: If set to True, the order will be validated
429
+ sync: If set to True, the created order will be synced with the
430
+ portfolio of the algorithm
431
+
432
+ Returns:
433
+ Order: Instance of the order created
434
+ """
313
435
 
314
436
  if market is None:
315
437
  portfolio = self.portfolio_service.get_all()[0]
@@ -335,6 +457,18 @@ class Algorithm:
335
457
  )
336
458
 
337
459
  def get_portfolio(self, market=None) -> Portfolio:
460
+ """
461
+ Function to get the portfolio of the algorithm. This function
462
+ will return the portfolio of the algorithm. If the market
463
+ parameter is specified, the portfolio of the specified market
464
+ will be returned.
465
+
466
+ Parameters:
467
+ market: The market of the portfolio
468
+
469
+ Returns:
470
+ Portfolio: The portfolio of the algorithm
471
+ """
338
472
 
339
473
  if market is None:
340
474
  return self.portfolio_service.find({})
@@ -342,6 +476,18 @@ class Algorithm:
342
476
  return self.portfolio_service.find({{"market": market}})
343
477
 
344
478
  def get_unallocated(self, market=None) -> float:
479
+ """
480
+ Function to get the unallocated balance of the portfolio. This
481
+ function will return the unallocated balance of the portfolio.
482
+ If the market parameter is specified, the unallocated balance
483
+ of the specified market will be returned.
484
+
485
+ Parameters:
486
+ market: The market of the portfolio
487
+
488
+ Returns:
489
+ float: The unallocated balance of the portfolio
490
+ """
345
491
 
346
492
  if market:
347
493
  portfolio = self.portfolio_service.find({{"market": market}})
@@ -356,6 +502,12 @@ class Algorithm:
356
502
  def get_total_size(self):
357
503
  """
358
504
  Returns the total size of the portfolio.
505
+
506
+ The total size of the portfolio is the unallocated balance and the
507
+ allocated balance of the portfolio.
508
+
509
+ Returns:
510
+ float: The total size of the portfolio
359
511
  """
360
512
  return self.get_unallocated() + self.get_allocated()
361
513
 
@@ -432,6 +584,34 @@ class Algorithm:
432
584
  amount_lt=None,
433
585
  amount_lte=None
434
586
  ) -> List[Position]:
587
+ """
588
+ Function to get all positions. This function will return all
589
+ positions that match the specified query parameters. If the
590
+ market parameter is specified, the positions of the specified
591
+ market will be returned. If the identifier parameter is
592
+ specified, the positions of the specified portfolio will be
593
+ returned. If the amount_gt parameter is specified, the positions
594
+ with an amount greater than the specified amount will be returned.
595
+ If the amount_gte parameter is specified, the positions with an
596
+ amount greater than or equal to the specified amount will be
597
+ returned. If the amount_lt parameter is specified, the positions
598
+ with an amount less than the specified amount will be returned.
599
+ If the amount_lte parameter is specified, the positions with an
600
+ amount less than or equal to the specified amount will be returned.
601
+
602
+ Parameters:
603
+ market: The market of the portfolio where the positions are
604
+ identifier: The identifier of the portfolio
605
+ amount_gt: The amount of the asset must be greater than this
606
+ amount_gte: The amount of the asset must be greater than or
607
+ equal to this
608
+ amount_lt: The amount of the asset must be less than this
609
+ amount_lte: The amount of the asset must be less than or equal
610
+ to this
611
+
612
+ Returns:
613
+ List[Position]: A list of positions that match the query parameters
614
+ """
435
615
  query_params = {}
436
616
 
437
617
  if market is not None:
@@ -463,6 +643,23 @@ class Algorithm:
463
643
  )
464
644
 
465
645
  def get_position(self, symbol, market=None, identifier=None) -> Position:
646
+ """
647
+ Function to get a position. This function will return the
648
+ position that matches the specified query parameters. If the
649
+ market parameter is specified, the position of the specified
650
+ market will be returned. If the identifier parameter is
651
+ specified, the position of the specified portfolio will be
652
+ returned.
653
+
654
+ Parameters:
655
+ symbol: The symbol of the asset that represents the position
656
+ market: The market of the portfolio where the position is located
657
+ identifier: The identifier of the portfolio
658
+
659
+ Returns:
660
+ Position: The position that matches the query parameters
661
+ """
662
+
466
663
  query_params = {}
467
664
 
468
665
  if market is not None:
@@ -500,17 +697,19 @@ class Algorithm:
500
697
  True if a position exists, False otherwise. This function will check
501
698
  if the amount > 0 condition by default.
502
699
 
503
- param symbol: The symbol of the asset
504
- param market: The market of the asset
505
- param identifier: The identifier of the portfolio
506
- param amount_gt: The amount of the asset must be greater than this
507
- param amount_gte: The amount of the asset must be greater than
508
- or equal to this
509
- param amount_lt: The amount of the asset must be less than this
510
- param amount_lte: The amount of the asset must be less than
511
- or equal to this
512
-
513
- return: True if a position exists, False otherwise
700
+ Parameters:
701
+ param symbol: The symbol of the asset
702
+ param market: The market of the asset
703
+ param identifier: The identifier of the portfolio
704
+ param amount_gt: The amount of the asset must be greater than this
705
+ param amount_gte: The amount of the asset must be greater than
706
+ or equal to this
707
+ param amount_lt: The amount of the asset must be less than this
708
+ param amount_lte: The amount of the asset must be less than
709
+ or equal to this
710
+
711
+ Returns:
712
+ Boolean: True if a position exists, False otherwise
514
713
  """
515
714
 
516
715
  return self.position_exists(
@@ -654,6 +853,21 @@ class Algorithm:
654
853
  def close_position(
655
854
  self, symbol, market=None, identifier=None, precision=None
656
855
  ):
856
+ """
857
+ Function to close a position. This function will close a position
858
+ by creating a market order to sell the position. If the precision
859
+ parameter is specified, the amount of the order will be rounded
860
+ down to the specified precision.
861
+
862
+ Parameters:
863
+ symbol: The symbol of the asset
864
+ market: The market of the asset
865
+ identifier: The identifier of the portfolio
866
+ precision: The precision of the amount
867
+
868
+ Returns:
869
+ None
870
+ """
657
871
  portfolio = self.portfolio_service.find(
658
872
  {"market": market, "identifier": identifier}
659
873
  )
@@ -941,18 +1155,68 @@ class Algorithm:
941
1155
  return self.order_service.exists(query_params)
942
1156
 
943
1157
  def check_pending_orders(self):
1158
+ """
1159
+ Function to check pending orders
1160
+ """
944
1161
  self.order_service.check_pending_orders()
945
1162
 
946
- def get_trades(self, market=None):
1163
+ def get_trades(self, market=None) -> List[Trade]:
1164
+ """
1165
+ Function to get all trades. This function will return all trades
1166
+ that match the specified query parameters. If the market parameter
1167
+ is specified, the trades with the specified market will be returned.
1168
+
1169
+ Parameters:
1170
+ market: The market of the asset
1171
+
1172
+ Returns:
1173
+ List[Trade]: A list of trades that match the query parameters
1174
+ """
947
1175
  return self.trade_service.get_trades(market)
948
1176
 
949
- def get_closed_trades(self):
1177
+ def get_closed_trades(self) -> List[Trade]:
1178
+ """
1179
+ Function to get all closed trades. This function will return all
1180
+ closed trades of the algorithm.
1181
+
1182
+ Returns:
1183
+ List[Trade]: A list of closed trades
1184
+ """
950
1185
  return self.trade_service.get_closed_trades()
951
1186
 
952
- def get_open_trades(self, target_symbol=None, market=None):
1187
+ def get_open_trades(self, target_symbol=None, market=None) -> List[Trade]:
1188
+ """
1189
+ Function to get all open trades. This function will return all
1190
+ open trades that match the specified query parameters. If the
1191
+ target_symbol parameter is specified, the open trades with the
1192
+ specified target symbol will be returned. If the market parameter
1193
+ is specified, the open trades with the specified market will be
1194
+ returned.
1195
+
1196
+ Parameters:
1197
+ target_symbol: The symbol of the asset
1198
+ market: The market of the asset
1199
+
1200
+ Returns:
1201
+ List[Trade]: A list of open trades that match the query parameters
1202
+ """
953
1203
  return self.trade_service.get_open_trades(target_symbol, market)
954
1204
 
955
1205
  def close_trade(self, trade, market=None, precision=None) -> None:
1206
+ """
1207
+ Function to close a trade. This function will close a trade by
1208
+ creating a market order to sell the position. If the precision
1209
+ parameter is specified, the amount of the order will be rounded
1210
+ down to the specified precision.
1211
+
1212
+ Parameters:
1213
+ trade: Trade - The trade to close
1214
+ market: str - The market of the trade
1215
+ precision: float - The precision of the amount
1216
+
1217
+ Returns:
1218
+ None
1219
+ """
956
1220
  self.trade_service.close_trade(
957
1221
  trade=trade, market=market, precision=precision
958
1222
  )
@@ -960,6 +1224,9 @@ class Algorithm:
960
1224
  def get_number_of_positions(self):
961
1225
  """
962
1226
  Returns the number of positions that have a positive amount.
1227
+
1228
+ Returns:
1229
+ int: The number of positions
963
1230
  """
964
1231
  return self.position_service.count({"amount_gt": 0})
965
1232
 
@@ -978,8 +1245,9 @@ class Algorithm:
978
1245
  the position must be greater than the net_size of the
979
1246
  portfolio.
980
1247
 
981
- :param amount_gt: The amount of the position must be greater than
982
- this amount.
1248
+ Parameters:
1249
+ amount_gt: The amount of the position must be greater than this
1250
+ amount.
983
1251
  :param amount_gte: The amount of the position must be greater than
984
1252
  or equal to this amount.
985
1253
  :param percentage_of_portfolio: The amount of the position must be