binaryoptionstoolsv2 0.2.8__tar.gz → 0.2.9__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 (158) hide show
  1. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/BinaryOptionsToolsV2/rust/Cargo.toml +4 -4
  2. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/BinaryOptionsToolsV2/rust/build.rs +5 -2
  3. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/BinaryOptionsToolsV2/rust/src/framework.rs +118 -139
  4. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/BinaryOptionsToolsV2/rust/src/pocketoption.rs +8 -2
  5. {binaryoptionstoolsv2-0.2.8/BinaryOptionsToolsV2/rust → binaryoptionstoolsv2-0.2.9}/Cargo.lock +725 -208
  6. binaryoptionstoolsv2-0.2.9/Cargo.toml +18 -0
  7. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/PKG-INFO +1 -1
  8. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/Cargo.toml +5 -6
  9. binaryoptionstoolsv2-0.2.9/crates/binary_options_tools/src/error.rs +33 -0
  10. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/modules/balance.rs +2 -2
  11. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/modules/deals.rs +44 -124
  12. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/modules/keep_alive.rs +9 -1
  13. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/modules/mod.rs +3 -0
  14. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/modules/pending_trades.rs +7 -3
  15. binaryoptionstoolsv2-0.2.9/crates/binary_options_tools/src/pocketoption/modules/resilient_parsing_tests.rs +118 -0
  16. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/modules/subscriptions.rs +8 -11
  17. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/modules/trades.rs +20 -2
  18. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/modules/trades_tests/concurrency.rs +40 -16
  19. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/pocket_client.rs +127 -40
  20. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/ssid.rs +43 -21
  21. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/state.rs +408 -405
  22. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/types.rs +16 -7
  23. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/utils.rs +226 -223
  24. binaryoptionstoolsv2-0.2.9/crates/core/Cargo.lock +1994 -0
  25. binaryoptionstoolsv2-0.2.9/crates/core/Cargo.toml +38 -0
  26. binaryoptionstoolsv2-0.2.9/crates/core/data/batching.rs +218 -0
  27. binaryoptionstoolsv2-0.2.9/crates/core/data/client2.rs +1001 -0
  28. binaryoptionstoolsv2-0.2.9/crates/core/data/client_enhanced.rs +1011 -0
  29. binaryoptionstoolsv2-0.2.9/crates/core/data/connection.rs +294 -0
  30. binaryoptionstoolsv2-0.2.9/crates/core/data/events.rs +242 -0
  31. binaryoptionstoolsv2-0.2.9/crates/core/data/websocket_config.rs +228 -0
  32. binaryoptionstoolsv2-0.2.9/crates/core/errors.log +0 -0
  33. binaryoptionstoolsv2-0.2.9/crates/core/readme.md +37 -0
  34. binaryoptionstoolsv2-0.2.9/crates/core/src/constants.rs +7 -0
  35. binaryoptionstoolsv2-0.2.9/crates/core/src/error.rs +82 -0
  36. binaryoptionstoolsv2-0.2.9/crates/core/src/general/client.rs +700 -0
  37. binaryoptionstoolsv2-0.2.9/crates/core/src/general/config.rs +63 -0
  38. binaryoptionstoolsv2-0.2.9/crates/core/src/general/mod.rs +8 -0
  39. binaryoptionstoolsv2-0.2.9/crates/core/src/general/send.rs +304 -0
  40. binaryoptionstoolsv2-0.2.9/crates/core/src/general/stream.rs +121 -0
  41. binaryoptionstoolsv2-0.2.9/crates/core/src/general/traits.rs +113 -0
  42. binaryoptionstoolsv2-0.2.9/crates/core/src/general/types.rs +163 -0
  43. binaryoptionstoolsv2-0.2.9/crates/core/src/general/validate.rs +19 -0
  44. binaryoptionstoolsv2-0.2.9/crates/core/src/lib.rs +9 -0
  45. binaryoptionstoolsv2-0.2.9/crates/core/src/reimports.rs +5 -0
  46. binaryoptionstoolsv2-0.2.9/crates/core/src/utils/mod.rs +2 -0
  47. binaryoptionstoolsv2-0.2.9/crates/core/src/utils/time.rs +19 -0
  48. binaryoptionstoolsv2-0.2.9/crates/core/src/utils/tracing.rs +109 -0
  49. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/Cargo.toml +3 -3
  50. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/src/builder.rs +15 -15
  51. binaryoptionstoolsv2-0.2.9/crates/macros/.gitignore +2 -0
  52. binaryoptionstoolsv2-0.2.9/crates/macros/LICENSE +100 -0
  53. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/python/BinaryOptionsToolsV2/config.py +151 -143
  54. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/python/BinaryOptionsToolsV2/pocketoption/asynchronous.py +1 -1
  55. binaryoptionstoolsv2-0.2.9/python/BinaryOptionsToolsV2/tracing.py +96 -0
  56. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/python/BinaryOptionsToolsV2/validator.py +198 -271
  57. binaryoptionstoolsv2-0.2.8/crates/binary_options_tools/src/error.rs +0 -79
  58. binaryoptionstoolsv2-0.2.8/python/BinaryOptionsToolsV2/tracing.py +0 -159
  59. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/BinaryOptionsToolsV2/rust/LICENSE +0 -0
  60. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/BinaryOptionsToolsV2/rust/Readme.md +0 -0
  61. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/BinaryOptionsToolsV2/rust/src/config.rs +0 -0
  62. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/BinaryOptionsToolsV2/rust/src/error.rs +0 -0
  63. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/BinaryOptionsToolsV2/rust/src/lib.rs +0 -0
  64. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/BinaryOptionsToolsV2/rust/src/logs.rs +0 -0
  65. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/BinaryOptionsToolsV2/rust/src/runtime.rs +0 -0
  66. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/BinaryOptionsToolsV2/rust/src/stream.rs +0 -0
  67. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/BinaryOptionsToolsV2/rust/src/validator.rs +0 -0
  68. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/LICENSE +0 -0
  69. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/Readme.md +0 -0
  70. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/Cargo.lock +0 -0
  71. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/LICENSE +0 -0
  72. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/Readme.md +0 -0
  73. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/data/expert_options_regions.json +0 -0
  74. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/data/pocket_options_regions.json +0 -0
  75. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/config.rs +0 -0
  76. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/expertoptions/action.rs +0 -0
  77. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/expertoptions/client.rs +0 -0
  78. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/expertoptions/connect.rs +0 -0
  79. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/expertoptions/error.rs +0 -0
  80. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/expertoptions/mod.rs +0 -0
  81. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/expertoptions/modules/keep_alive.rs +0 -0
  82. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/expertoptions/modules/mod.rs +0 -0
  83. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/expertoptions/modules/profile.rs +0 -0
  84. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/expertoptions/regions.rs +0 -0
  85. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/expertoptions/state.rs +0 -0
  86. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/expertoptions/types.rs +0 -0
  87. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/framework/market.rs +0 -0
  88. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/framework/mod.rs +0 -0
  89. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/framework/virtual_market.rs +0 -0
  90. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/lib.rs +0 -0
  91. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/candle.rs +0 -0
  92. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/connect.rs +0 -0
  93. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/error.rs +0 -0
  94. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/mod.rs +0 -0
  95. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/modules/assets.rs +0 -0
  96. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/modules/get_candles.rs +0 -0
  97. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/modules/historical_data.rs +0 -0
  98. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/modules/pending_trades_tests.rs +0 -0
  99. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/modules/raw.rs +0 -0
  100. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/modules/server_time.rs +0 -0
  101. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/modules/trades_tests/common.rs +0 -0
  102. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/modules/trades_tests/mod.rs +0 -0
  103. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/pocketoption/regions.rs +0 -0
  104. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/reimports.rs +0 -0
  105. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/traits.rs +0 -0
  106. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/utils/mod.rs +0 -0
  107. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/utils/serialize.rs +0 -0
  108. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/binary_options_tools/src/validator.rs +0 -0
  109. {binaryoptionstoolsv2-0.2.8/crates/macros → binaryoptionstoolsv2-0.2.9/crates/core}/.gitignore +0 -0
  110. {binaryoptionstoolsv2-0.2.8/crates/macros → binaryoptionstoolsv2-0.2.9/crates/core}/LICENSE +0 -0
  111. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/.gitignore +0 -0
  112. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/.vscode/mcp.json +0 -0
  113. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/LICENSE +0 -0
  114. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/README.md +0 -0
  115. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/diagrams/architecture.txt +0 -0
  116. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/diagrams/diagram.txt +0 -0
  117. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/docs/testing-framework.md +0 -0
  118. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/examples/basic_connector_usage.rs +0 -0
  119. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/examples/echo_client.rs +0 -0
  120. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/examples/middleware_example.rs +0 -0
  121. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/examples/testing_echo_client.rs +0 -0
  122. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/src/callback.rs +0 -0
  123. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/src/client.rs +0 -0
  124. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/src/connector.rs +0 -0
  125. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/src/error.rs +0 -0
  126. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/src/lib.rs +0 -0
  127. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/src/message.rs +0 -0
  128. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/src/middleware.rs +0 -0
  129. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/src/reimports.rs +0 -0
  130. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/src/signals.rs +0 -0
  131. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/src/statistics.rs +0 -0
  132. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/src/testing.rs +0 -0
  133. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/src/traits.rs +0 -0
  134. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/src/utils/mod.rs +0 -0
  135. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/src/utils/stream.rs +0 -0
  136. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/src/utils/time.rs +0 -0
  137. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/src/utils/tracing.rs +0 -0
  138. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/tests/middleware_tests.rs +0 -0
  139. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/core-pre/tests/testing_wrapper_tests.rs +0 -0
  140. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/macros/ActionImpl_README.md +0 -0
  141. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/macros/Cargo.lock +0 -0
  142. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/macros/Cargo.toml +0 -0
  143. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/macros/examples/action_example.rs +0 -0
  144. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/macros/readme.md +0 -0
  145. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/macros/src/action.rs +0 -0
  146. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/macros/src/config.rs +0 -0
  147. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/macros/src/deserialize.rs +0 -0
  148. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/macros/src/impls/config_impl.rs +0 -0
  149. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/macros/src/impls/mod.rs +0 -0
  150. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/macros/src/lib.rs +0 -0
  151. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/macros/src/region.rs +0 -0
  152. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/macros/src/serialize.rs +0 -0
  153. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/crates/macros/src/timeout.rs +0 -0
  154. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/pyproject.toml +0 -0
  155. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/python/BinaryOptionsToolsV2/BinaryOptionsToolsV2.pyi +0 -0
  156. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/python/BinaryOptionsToolsV2/__init__.py +0 -0
  157. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/python/BinaryOptionsToolsV2/pocketoption/__init__.py +0 -0
  158. {binaryoptionstoolsv2-0.2.8 → binaryoptionstoolsv2-0.2.9}/python/BinaryOptionsToolsV2/pocketoption/synchronous.py +0 -0
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "BinaryOptionsToolsV2"
3
- version = "0.2.8"
3
+ version = "0.2.9"
4
4
  edition = "2021"
5
5
  authors = ["ChipaDevTeam"]
6
6
  description = "Python bindings for binary-options-tools. High-performance library for PocketOption trading automation with async/sync support, real-time data streaming, and WebSocket API access."
@@ -18,17 +18,17 @@ name = "BinaryOptionsToolsV2"
18
18
  crate-type = ["cdylib"]
19
19
 
20
20
  [dependencies]
21
- pyo3 = "0.28.2"
21
+ pyo3 = { version = "0.28.2", features = ["abi3-py39"] }
22
22
  pyo3-async-runtimes = { version = "0.28.0", features = ["tokio-runtime"] }
23
23
 
24
24
  binary_options_tools = { path = "../../crates/binary_options_tools", version = "0.2.0" }
25
25
 
26
- thiserror = "2.0.17"
26
+ thiserror = "2.0.18"
27
27
  serde = { version = "1.0.228", features = ["derive"] }
28
28
  serde_json = "1.0.142"
29
29
  uuid = "1.18.0"
30
30
  tracing = "0.1.41"
31
- tokio = "1.49.0"
31
+ tokio = { version = "1.49.0", features = ["rt-multi-thread", "macros", "net", "time", "sync"] }
32
32
  futures-util = "0.3.31"
33
33
  tracing-subscriber = { version = "0.3.22", features = ["env-filter"] }
34
34
  chrono = "0.4.42"
@@ -7,12 +7,15 @@ use std::path::PathBuf;
7
7
  fn main() {
8
8
  #[cfg(feature = "stubgen")]
9
9
  {
10
-
11
10
  // Define stub info gatherer function
12
11
  define_stub_info_gatherer!(stub_info);
13
12
 
14
13
  let crate_root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
15
- let python_package_path = crate_root.parent().unwrap().join("python").join("BinaryOptionsToolsV2");
14
+ let python_package_path = crate_root
15
+ .parent()
16
+ .unwrap()
17
+ .join("python")
18
+ .join("BinaryOptionsToolsV2");
16
19
 
17
20
  // Ensure the target directory exists
18
21
  std::fs::create_dir_all(&python_package_path)
@@ -2,46 +2,36 @@ use crate::error::BinaryErrorPy;
2
2
  use crate::pocketoption::RawPocketOption;
3
3
  use crate::runtime::get_runtime;
4
4
 
5
- use binary_options_tools::utils::f64_to_decimal;
6
5
  use binary_options_tools::framework::market::Market;
7
6
  use binary_options_tools::framework::virtual_market::VirtualMarket;
8
7
  use binary_options_tools::framework::{Bot, Context, Strategy};
9
8
  use binary_options_tools::pocketoption::candle::Candle;
10
- use binary_options_tools::pocketoption::error::{PocketResult, PocketError};
9
+ use binary_options_tools::pocketoption::error::{PocketError, PocketResult};
10
+ use binary_options_tools::utils::f64_to_decimal;
11
11
 
12
12
  use pyo3::prelude::*;
13
13
 
14
- use rust_decimal::Decimal;
15
- use tracing::info;
16
14
  use async_trait::async_trait;
17
15
  use rust_decimal::prelude::ToPrimitive;
18
- use uuid::Uuid;
16
+ use rust_decimal::Decimal;
19
17
  use std::collections::HashMap;
20
18
  use std::sync::Arc;
21
19
  use std::time::Duration;
20
+ use tracing::info;
21
+ use uuid::Uuid;
22
22
 
23
23
  #[pyclass(from_py_object)]
24
24
  #[derive(Clone)]
25
25
  pub enum Action {
26
26
  Call,
27
- Put,
27
+ Put,
28
28
  }
29
29
 
30
30
  #[pyclass(subclass)]
31
31
  pub struct PyStrategy {
32
- /// A list of the indicators to use
33
- /// Each indicator must implement:
34
- /// - A method to update its value given a new candle (e.g. `update(candle_json: str)`)
35
- /// - A method to reset its state (e.g. `reset()`)
36
- /// - A method to get its period (e.g. `period() -> int`)
37
- /// No other methods are required as once the loading period is over e.g. the amount of candles passed is greater than
38
- /// the biggest period of the indicators then the strategy will call the on_candle method and pass the update of the
39
- /// indicators to the user.
40
32
  indicators: HashMap<String, Py<PyAny>>,
41
- // The current candle number, starting from 0. It is incremented by 1 every time a new candle is received.
42
- // Used to know when the loading period is over and the strategy can start trading. It is also useful for the user to know how many candles have passed since the strategy started.
43
33
  #[pyo3(get)]
44
- current_candle: u32
34
+ pub current_candle: u32,
45
35
  }
46
36
 
47
37
  #[pymethods]
@@ -61,89 +51,93 @@ impl PyStrategy {
61
51
  pub fn on_candle(&self, _ctx: PyContext, _asset: String, _candle_json: String) -> PyResult<()> {
62
52
  Ok(())
63
53
  }
64
-
54
+
65
55
  pub fn on_balance(&self, _ctx: PyContext, _balance: f64) -> PyResult<()> {
66
56
  Ok(())
67
57
  }
68
-
69
- /// A way to place a trade synchronously from inside a PyStrategy. The function will block until the trade is executed and return the trade ID and deal information as a JSON string.
70
- /// This function should be relativelly fast and should not block the trading loop at all.
71
- pub fn trade<'py>(&self, py: Python<'py>, ctx: PyContext, asset: String, amount: f64, timeframe: u32, direction: Action) -> PyResult<Vec<String>>{
58
+
59
+ pub fn trade<'py>(
60
+ &self,
61
+ py: Python<'py>,
62
+ ctx: PyContext,
63
+ asset: String,
64
+ amount: f64,
65
+ timeframe: u32,
66
+ direction: Action,
67
+ ) -> PyResult<Vec<String>> {
72
68
  let market = ctx.market.clone();
73
69
  let decimal_amount = f64_to_decimal(amount)
74
70
  .ok_or_else(|| BinaryErrorPy::NotAllowed(format!("Invalid amount: {}", amount)))?;
75
71
  let trade_future = async move {
76
72
  let (id, deal) = match direction {
77
- Action::Call =>
78
- market.buy(&asset, decimal_amount, timeframe).await.map_err(BinaryErrorPy::from),
79
-
80
- Action::Put =>
81
- market.sell(&asset, decimal_amount, timeframe).await.map_err(BinaryErrorPy::from)
73
+ Action::Call => market
74
+ .buy(&asset, decimal_amount, timeframe)
75
+ .await
76
+ .map_err(BinaryErrorPy::from),
77
+
78
+ Action::Put => market
79
+ .sell(&asset, decimal_amount, timeframe)
80
+ .await
81
+ .map_err(BinaryErrorPy::from),
82
82
  }?;
83
83
  let trades = Vec::from([
84
84
  id.to_string(),
85
- serde_json::to_string(&deal).map_err(BinaryErrorPy::from)?
85
+ serde_json::to_string(&deal).map_err(BinaryErrorPy::from)?,
86
86
  ]);
87
87
  Result::<Vec<String>, BinaryErrorPy>::Ok(trades)
88
88
  };
89
-
89
+
90
90
  Ok(get_runtime(py)?.block_on(trade_future)?)
91
91
  }
92
-
93
- /// Returns the result of a trade given its UUID. The result is serialized as a JSON string.
94
- /// The function is synchronous from Python's perspective, but internally it awaits the market's result asynchronously.
95
- /// So it's important to call this method when the trade was completed (as it will return the result really fast otherwhise the whole script would be blocked until the trade is completed).
92
+
96
93
  pub fn result<'py>(&self, py: Python<'py>, ctx: PyContext, id: String) -> PyResult<String> {
97
94
  let market = ctx.market.clone();
98
- let uuid = Uuid::parse_str(&id).map_err(|e| BinaryErrorPy::NotAllowed(format!("Invalid UUID: {}", e)))?;
95
+ let uuid = Uuid::parse_str(&id)
96
+ .map_err(|e| BinaryErrorPy::NotAllowed(format!("Invalid UUID: {}", e)))?;
99
97
  let future = async move {
100
98
  let res = market.result(uuid).await.map_err(BinaryErrorPy::from)?;
101
99
  serde_json::to_string(&res).map_err(BinaryErrorPy::from)
102
100
  };
103
101
  Ok(get_runtime(py)?.block_on(future)?)
104
102
  }
105
-
106
- /// Adds an indicator to the strategy. The indicator must be a Python object that implements the required methods (update, reset, period).
107
- /// All the indicators of the `chipa-ta` library are compatible with this method as they implement the required methods.
108
- /// The name parameter is just a string that will be used to identify the indicator and can be any string.
103
+
109
104
  pub fn add(&mut self, name: String, indicator: Py<PyAny>) -> PyResult<()> {
110
105
  self.indicators.insert(name.clone(), indicator);
111
106
  info!(target: "PyStrategy", "Added indicator '{}' to strategy", name);
112
107
  Ok(())
113
108
  }
114
-
115
- /// Gets an indicator by its name. Returns None if the indicator is not found.
109
+
116
110
  pub fn get(&self, name: String) -> PyResult<Option<&Py<PyAny>>> {
117
111
  Ok(self.indicators.get(&name))
118
112
  }
119
-
120
- /// Returns the list of current indicators as a tuple (name, indicator_str) where name is the name of the indicator and indicator_str is the string representation of the indicator (`__str__`).
113
+
121
114
  pub fn list_indicators(&self) -> PyResult<Vec<(String, String)>> {
122
- self.indicators.iter().map(|(name, indicator)| {
123
- let indicator_str = Python::attach(|py| {
124
- indicator.call_method0(py, "__str__")?.extract::<String>(py)
125
-
126
- })?;
127
- Ok((name.clone(), indicator_str))
128
- }).collect()
129
-
115
+ self.indicators
116
+ .iter()
117
+ .map(|(name, indicator)| {
118
+ let indicator_str = Python::attach(|py| {
119
+ indicator.call_method0(py, "__str__")?.extract::<String>(py)
120
+ })?;
121
+ Ok((name.clone(), indicator_str))
122
+ })
123
+ .collect()
130
124
  }
131
-
132
- /// Called internally by the framework when a new candle is received. It updates all the indicators with the new candle. The candle is serialized as a JSON string.
133
- /// It works untill period() is completed
125
+
134
126
  pub fn update<'py>(&mut self, candle: String) -> PyResult<()> {
135
127
  self.current_candle += 1;
136
128
  for indicator in self.indicators.values() {
137
129
  Python::attach(|py| {
138
- indicator.call_method1(py, "update", (candle.clone(), )).map_err(|e| {
139
- BinaryErrorPy::NotAllowed(format!("Failed to update indicator: {}", e))
140
- })
130
+ indicator
131
+ .call_method1(py, "update", (candle.clone(),))
132
+ .map_err(|e| {
133
+ BinaryErrorPy::NotAllowed(format!("Failed to update indicator: {}", e))
134
+ })
141
135
  })?;
142
136
  }
143
137
  info!(target: "PyStrategy", "Updated indicators with new candle: {}", self.current_candle);
144
138
  Ok(())
145
139
  }
146
-
140
+
147
141
  pub fn reset(&mut self) -> PyResult<()> {
148
142
  for indicator in self.indicators.values() {
149
143
  Python::attach(|py| {
@@ -155,16 +149,23 @@ impl PyStrategy {
155
149
  self.current_candle = 0;
156
150
  Ok(())
157
151
  }
158
-
152
+
159
153
  pub fn period(&self) -> PyResult<u32> {
160
154
  let mut max_period = 0;
161
155
  for indicator in self.indicators.values() {
162
156
  let period: u32 = Python::attach(|py| {
163
- indicator.call_method0(py, "period").map_err(|e| {
164
- BinaryErrorPy::NotAllowed(format!("Failed to get period from indicator: {}", e))
165
- })?.extract(py).map_err(|e| {
166
- BinaryErrorPy::NotAllowed(format!("Failed to extract period as u32: {}", e))
167
- })
157
+ indicator
158
+ .call_method0(py, "period")
159
+ .map_err(|e| {
160
+ BinaryErrorPy::NotAllowed(format!(
161
+ "Failed to get period from indicator: {}",
162
+ e
163
+ ))
164
+ })?
165
+ .extract(py)
166
+ .map_err(|e| {
167
+ BinaryErrorPy::NotAllowed(format!("Failed to extract period as u32: {}", e))
168
+ })
168
169
  })?;
169
170
  if period > max_period {
170
171
  max_period = period;
@@ -191,73 +192,52 @@ impl Strategy for StrategyWrapper {
191
192
  client: Some(client),
192
193
  market,
193
194
  };
194
- inner.call_method1(py, "on_start", (py_ctx,)).map_err(|e| {
195
- PocketError::General(format!(
196
- "Python on_start error: {}",
197
- e
198
- ))
199
- })
195
+ inner
196
+ .call_method1(py, "on_start", (py_ctx,))
197
+ .map_err(|e| PocketError::General(format!("Python on_start error: {}", e)))
200
198
  })
201
199
  .map(|_| ())
202
200
  })
203
201
  .await
204
- .map_err(|e| {
205
- PocketError::General(format!(
206
- "Spawn blocking error: {}",
207
- e
208
- ))
209
- })??;
202
+ .map_err(|e| PocketError::General(format!("Spawn blocking error: {}", e)))??;
210
203
  Ok(())
211
204
  }
212
205
 
213
206
  async fn on_candle(&self, ctx: &Context, asset: &str, candle: &Candle) -> PocketResult<()> {
214
- let candle_json = serde_json::to_string(candle).map_err(|e| {
215
- PocketError::General(e.to_string())
216
- })?;
207
+ let candle_json =
208
+ serde_json::to_string(candle).map_err(|e| PocketError::General(e.to_string()))?;
217
209
  let asset = asset.to_string();
218
210
  let inner = Python::attach(|py| self.inner.clone_ref(py));
219
211
  let client = ctx.client.clone();
220
212
  let market = ctx.market.clone();
221
- let period = Python::attach(|py| inner.call_method0(py, "period").map_err(|e| {
222
- PocketError::General(format!(
223
- "Python period error: {}",
224
- e
225
- ))
226
- }).map(|obj| obj.extract::<u32>(py)))?
227
- .map_err(|e| {
228
- PocketError::General(format!(
229
- "Python period extract error: {}",
230
- e
231
- ))
213
+ let period = Python::attach(|py| {
214
+ inner
215
+ .call_method0(py, "period")
216
+ .map_err(|e| PocketError::General(format!("Python period error: {}", e)))
217
+ .map(|obj| obj.extract::<u32>(py))
218
+ })?
219
+ .map_err(|e| PocketError::General(format!("Python period extract error: {}", e)))?;
220
+ let current_candle = Python::attach(|py| {
221
+ inner
222
+ .getattr(py, "current_candle")
223
+ .map_err(|e| PocketError::General(format!("Python current_candle error: {}", e)))
224
+ .and_then(|obj| {
225
+ obj.extract::<u32>(py).map_err(|e| {
226
+ PocketError::General(format!("Python current_candle extract error: {}", e))
227
+ })
228
+ })
232
229
  })?;
233
- let current_candle = Python::attach(|py| inner.getattr(py, "current_candle").map_err(|e| {
234
- PocketError::General(format!(
235
- "Python current_candle error: {}",
236
- e
237
- ))
238
- }).and_then(|obj| obj.extract::<u32>(py).map_err(|e| {
239
- PocketError::General(format!(
240
- "Python current_candle extract error: {}",
241
- e
242
- ))
243
- })))?;
244
-
230
+
245
231
  if current_candle < period {
246
- // Just update the indicators and return, the strategy is not ready to trade yet
247
-
248
232
  Python::attach(|py| {
249
- inner.call_method1(py, "update", (candle_json.clone(),)).map_err(|e| {
250
- PocketError::General(format!(
251
- "Python update error: {}",
252
- e
253
- ))
254
- })
233
+ inner
234
+ .call_method1(py, "update", (candle_json.clone(),))
235
+ .map_err(|e| PocketError::General(format!("Python update error: {}", e)))
255
236
  })?;
256
- // Since the method update is called current_candles is incremented by 1, so we add 1 to it to show the user the correct number of candles that have passed since the strategy started.
257
237
  info!(target: "StrategyWrapper", "Loading period: candle {} of {}", current_candle +1, period);
258
238
  return Ok(());
259
239
  }
260
-
240
+
261
241
  tokio::task::spawn_blocking(move || -> PocketResult<()> {
262
242
  Python::attach(|py| {
263
243
  let py_ctx = PyContext {
@@ -266,28 +246,18 @@ impl Strategy for StrategyWrapper {
266
246
  };
267
247
  inner
268
248
  .call_method1(py, "on_candle", (py_ctx, asset, candle_json))
269
- .map_err(|e| {
270
- PocketError::General(format!(
271
- "Python on_candle error: {}",
272
- e
273
- ))
274
- })
249
+ .map_err(|e| PocketError::General(format!("Python on_candle error: {}", e)))
275
250
  })
276
251
  .map(|_| ())
277
252
  })
278
253
  .await
279
- .map_err(|e| {
280
- PocketError::General(format!(
281
- "Spawn blocking error: {}",
282
- e
283
- ))
284
- })??;
285
-
254
+ .map_err(|e| PocketError::General(format!("Spawn blocking error: {}", e)))??;
255
+
286
256
  Ok(())
287
257
  }
288
-
258
+
289
259
  async fn on_balance_update(&self, ctx: &Context, balance: Decimal) -> PocketResult<()> {
290
- let balance = balance.to_f64().unwrap_or(-1.0); // -1 default to know there is an error converting the balance to f64, but it should never happen as the balance should be always a valid decimal that can be converted to f64 without losing too much precision (the balance is usually a small number with few decimals).
260
+ let balance = balance.to_f64().unwrap_or(-1.0); // -1.0 indicates a conversion error, though it shouldnt happen often- awaiting this should be fine and if anything u can just asyncio wait like 5 seconds
291
261
  let inner = Python::attach(|py| self.inner.clone_ref(py));
292
262
  let client = ctx.client.clone();
293
263
  let market = ctx.market.clone();
@@ -299,22 +269,12 @@ impl Strategy for StrategyWrapper {
299
269
  };
300
270
  inner
301
271
  .call_method1(py, "on_balance", (py_ctx, balance))
302
- .map_err(|e| {
303
- PocketError::General(format!(
304
- "Python on_balance error: {}",
305
- e
306
- ))
307
- })
272
+ .map_err(|e| PocketError::General(format!("Python on_balance error: {}", e)))
308
273
  })
309
274
  .map(|_| ())
310
275
  })
311
276
  .await
312
- .map_err(|e| {
313
- PocketError::General(format!(
314
- "Spawn blocking error: {}",
315
- e
316
- ))
317
- })??;
277
+ .map_err(|e| PocketError::General(format!("Spawn blocking error: {}", e)))??;
318
278
 
319
279
  Ok(())
320
280
  }
@@ -329,6 +289,12 @@ pub struct PyContext {
329
289
 
330
290
  #[pymethods]
331
291
  impl PyContext {
292
+ /// Places a buy (Call) order asynchronously.
293
+ ///
294
+ /// :param asset: The asset to trade (e.g. "EURUSD_otc").
295
+ /// :param amount: The amount to trade.
296
+ /// :param time: The duration of the trade in seconds.
297
+ /// :return: A list [trade_id, deal_json].
332
298
  pub fn buy<'py>(
333
299
  &self,
334
300
  py: Python<'py>,
@@ -350,6 +316,9 @@ impl PyContext {
350
316
  })
351
317
  }
352
318
 
319
+ /// Fetches the current balance asynchronously.
320
+ ///
321
+ /// :return: The current balance as a float.
353
322
  pub fn balance<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>> {
354
323
  let market = self.market.clone();
355
324
  pyo3_async_runtimes::tokio::future_into_py(py, async move {
@@ -378,6 +347,12 @@ impl PyVirtualMarket {
378
347
  })
379
348
  }
380
349
 
350
+ /// Updates the price of an asset in the virtual market.
351
+ /// This is an asynchronous method.
352
+ ///
353
+ /// :param asset: The asset identifier.
354
+ /// :param price: The new price.
355
+ /// :return: None
381
356
  pub fn update_price<'py>(
382
357
  &self,
383
358
  py: Python<'py>,
@@ -415,7 +390,7 @@ impl PyBot {
415
390
  }
416
391
  Self { inner: Some(bot) }
417
392
  }
418
-
393
+
419
394
  pub fn with_update_interval(&mut self, millis: u64) -> PyResult<()> {
420
395
  if let Some(bot) = &mut self.inner {
421
396
  bot.with_update_interval(Duration::from_millis(millis));
@@ -444,6 +419,10 @@ impl PyBot {
444
419
  }
445
420
  }
446
421
 
422
+ /// Runs the bot's execution loop.
423
+ /// This is an asynchronous method that will block the current task until the bot is stopped.
424
+ ///
425
+ /// :return: None
447
426
  pub fn run<'py>(&mut self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>> {
448
427
  let mut bot = self.inner.take().ok_or_else(|| {
449
428
  PyErr::new::<pyo3::exceptions::PyRuntimeError, _>("Bot already running or consumed")
@@ -504,10 +504,16 @@ impl RawPocketOption {
504
504
  lookback_period: u32,
505
505
  ) -> PyResult<Bound<'py, PyAny>> {
506
506
  if custom_period == 0 {
507
- return Err(BinaryErrorPy::InvalidParameter("custom_period must be non-zero".to_string()).into());
507
+ return Err(BinaryErrorPy::InvalidParameter(
508
+ "custom_period must be non-zero".to_string(),
509
+ )
510
+ .into());
508
511
  }
509
512
  if lookback_period == 0 {
510
- return Err(BinaryErrorPy::InvalidParameter("lookback_period must be non-zero".to_string()).into());
513
+ return Err(BinaryErrorPy::InvalidParameter(
514
+ "lookback_period must be non-zero".to_string(),
515
+ )
516
+ .into());
511
517
  }
512
518
  let client = self.client.clone();
513
519
  future_into_py(py, async move {