Qubx 3.17.2__tar.gz → 3.17.3.dev1__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 (335) hide show
  1. {qubx-3.17.2 → qubx-3.17.3.dev1}/PKG-INFO +1 -1
  2. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/_version.py +2 -2
  3. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/connector.py +68 -20
  4. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/exchanges/__init__.py +9 -2
  5. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/exchanges/_two_stream.py +12 -1
  6. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/exchanges/binance/exchange.py +3 -0
  7. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/exchanges/bitfinex/bitfinex.py +0 -10
  8. qubx-3.17.3.dev1/src/qubx/connectors/ccxt/exchanges/bybit/bybit.py +311 -0
  9. qubx-3.17.3.dev1/src/qubx/connectors/ccxt/exchanges/bybit/connector.py +132 -0
  10. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/rate_limits.py +9 -2
  11. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/utils.py +74 -33
  12. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/account_manager/manager.py +7 -1
  13. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/account_manager/reconciler.py +7 -0
  14. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/account_manager/state.py +18 -10
  15. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/basics.py +24 -17
  16. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/lookups.py +3 -1
  17. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/mixins/trading.py +2 -1
  18. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/utils.pyi +4 -0
  19. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/utils.pyx +72 -0
  20. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/emitters/indicator.py +1 -11
  21. qubx-3.17.3.dev1/src/qubx/utils/runner/__init__.py +0 -0
  22. {qubx-3.17.2 → qubx-3.17.3.dev1}/.gitignore +0 -0
  23. {qubx-3.17.2 → qubx-3.17.3.dev1}/LICENSE +0 -0
  24. {qubx-3.17.2 → qubx-3.17.3.dev1}/README.md +0 -0
  25. {qubx-3.17.2 → qubx-3.17.3.dev1}/pyproject.toml +0 -0
  26. {qubx-3.17.2 → qubx-3.17.3.dev1}/scripts/build.py +0 -0
  27. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/__init__.py +0 -0
  28. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/_nb_magic.py +0 -0
  29. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/backtester/__init__.py +0 -0
  30. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/backtester/connector.py +0 -0
  31. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/backtester/data.py +0 -0
  32. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/backtester/iteratedstream.py +0 -0
  33. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/backtester/management.py +0 -0
  34. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/backtester/ome.py +0 -0
  35. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/backtester/optimization.py +0 -0
  36. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/backtester/runner.py +0 -0
  37. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/backtester/sentinels.py +0 -0
  38. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/backtester/simulated_data.py +0 -0
  39. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/backtester/simulated_exchange.py +0 -0
  40. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/backtester/simulator.py +0 -0
  41. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/backtester/transfers.py +0 -0
  42. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/backtester/utils.py +0 -0
  43. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/cli/__init__.py +0 -0
  44. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/cli/commands.py +0 -0
  45. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/cli/deploy.py +0 -0
  46. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/cli/misc.py +0 -0
  47. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/cli/release.py +0 -0
  48. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/cli/resolver.py +0 -0
  49. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/cli/s3.py +0 -0
  50. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/cli/theme.py +0 -0
  51. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/cli/tui.py +0 -0
  52. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/cli/user_config.py +0 -0
  53. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/config.py +0 -0
  54. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/__init__.py +0 -0
  55. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/__init__.py +0 -0
  56. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/adapters/__init__.py +0 -0
  57. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/adapters/polling_adapter.py +0 -0
  58. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/connection_manager.py +0 -0
  59. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/data.py +0 -0
  60. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/exceptions.py +0 -0
  61. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/exchange_manager.py +0 -0
  62. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/exchanges/base.py +0 -0
  63. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/exchanges/binance/connector.py +0 -0
  64. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/exchanges/bitfinex/connector.py +0 -0
  65. {qubx-3.17.2/src/qubx/connectors/ccxt/exchanges/okx → qubx-3.17.3.dev1/src/qubx/connectors/ccxt/exchanges/bybit}/__init__.py +0 -0
  66. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/exchanges/gateio/__init__.py +0 -0
  67. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/exchanges/gateio/gateio.py +0 -0
  68. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/exchanges/hyperliquid/__init__.py +0 -0
  69. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/exchanges/hyperliquid/hyperliquid.py +0 -0
  70. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/exchanges/kraken/kraken.py +0 -0
  71. {qubx-3.17.2/src/qubx/core → qubx-3.17.3.dev1/src/qubx/connectors/ccxt/exchanges/okx}/__init__.py +0 -0
  72. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/exchanges/okx/connector.py +0 -0
  73. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/exchanges/okx/okx.py +0 -0
  74. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/factory.py +0 -0
  75. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/handlers/__init__.py +0 -0
  76. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/handlers/base.py +0 -0
  77. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/handlers/factory.py +0 -0
  78. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/handlers/funding_rate.py +0 -0
  79. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/handlers/liquidation.py +0 -0
  80. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/handlers/ohlc.py +0 -0
  81. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/handlers/open_interest.py +0 -0
  82. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/handlers/orderbook.py +0 -0
  83. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/handlers/quote.py +0 -0
  84. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/handlers/trade.py +0 -0
  85. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/plugin.py +0 -0
  86. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/subscription_config.py +0 -0
  87. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/subscription_manager.py +0 -0
  88. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/subscription_orchestrator.py +0 -0
  89. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/ccxt/warmup_service.py +0 -0
  90. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/plugin.py +0 -0
  91. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/registry.py +0 -0
  92. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/tardis/data.py +0 -0
  93. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/tardis/plugin.py +0 -0
  94. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/connectors/tardis/utils.py +0 -0
  95. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/control/__init__.py +0 -0
  96. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/control/builtin.py +0 -0
  97. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/control/decorator.py +0 -0
  98. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/control/executor.py +0 -0
  99. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/control/interfaces.py +0 -0
  100. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/control/server.py +0 -0
  101. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/control/types.py +0 -0
  102. {qubx-3.17.2/src/qubx/restarts → qubx-3.17.3.dev1/src/qubx/core}/__init__.py +0 -0
  103. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/account_manager/__init__.py +0 -0
  104. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/account_manager/config.py +0 -0
  105. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/account_manager/diffs.py +0 -0
  106. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/account_manager/reducer.py +0 -0
  107. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/account_manager/state_machine.py +0 -0
  108. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/boot.py +0 -0
  109. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/connector.py +0 -0
  110. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/context.py +0 -0
  111. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/detectors/__init__.py +0 -0
  112. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/detectors/delisting.py +0 -0
  113. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/detectors/stale.py +0 -0
  114. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/errors.py +0 -0
  115. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/events.py +0 -0
  116. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/exceptions.py +0 -0
  117. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/fit_context.py +0 -0
  118. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/fit_executor.py +0 -0
  119. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/helpers.py +0 -0
  120. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/initializer.py +0 -0
  121. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/instrument_service.py +0 -0
  122. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/interfaces.py +0 -0
  123. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/loggers.py +0 -0
  124. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/metrics.py +0 -0
  125. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/mixins/__init__.py +0 -0
  126. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/mixins/instrument_service.py +0 -0
  127. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/mixins/market.py +0 -0
  128. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/mixins/processing.py +0 -0
  129. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/mixins/subscription.py +0 -0
  130. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/mixins/universe.py +0 -0
  131. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/mixins/utils.py +0 -0
  132. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/series.pxd +0 -0
  133. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/series.pyi +0 -0
  134. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/series.pyx +0 -0
  135. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/state_snapshot.py +0 -0
  136. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/status.py +0 -0
  137. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/core/subscription_watchdog.py +0 -0
  138. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/data/__init__.py +0 -0
  139. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/data/cache.py +0 -0
  140. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/data/containers.py +0 -0
  141. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/data/guards.py +0 -0
  142. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/data/registry.py +0 -0
  143. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/data/storage.py +0 -0
  144. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/data/storages/ccxt.py +0 -0
  145. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/data/storages/csv.py +0 -0
  146. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/data/storages/handy.py +0 -0
  147. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/data/storages/multi.py +0 -0
  148. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/data/storages/questdb.py +0 -0
  149. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/data/storages/stub.py +0 -0
  150. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/data/storages/utils.py +0 -0
  151. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/data/transformers.py +0 -0
  152. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/emitters/__init__.py +0 -0
  153. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/emitters/base.py +0 -0
  154. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/emitters/composite.py +0 -0
  155. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/emitters/csv.py +0 -0
  156. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/emitters/inmemory.py +0 -0
  157. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/emitters/prometheus.py +0 -0
  158. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/emitters/questdb.py +0 -0
  159. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/exporters/__init__.py +0 -0
  160. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/exporters/composite.py +0 -0
  161. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/exporters/formatters/__init__.py +0 -0
  162. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/exporters/formatters/base.py +0 -0
  163. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/exporters/formatters/incremental.py +0 -0
  164. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/exporters/formatters/slack.py +0 -0
  165. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/exporters/formatters/target_position.py +0 -0
  166. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/exporters/redis_streams.py +0 -0
  167. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/exporters/slack.py +0 -0
  168. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/gathering/simplest.py +0 -0
  169. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/health/__init__.py +0 -0
  170. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/health/base.py +0 -0
  171. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/health/dummy.py +0 -0
  172. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/health/status.py +0 -0
  173. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/loggers/__init__.py +0 -0
  174. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/loggers/csv.py +0 -0
  175. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/loggers/factory.py +0 -0
  176. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/loggers/inmemory.py +0 -0
  177. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/loggers/mongo.py +0 -0
  178. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/loggers/postgres.py +0 -0
  179. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/notifications/__init__.py +0 -0
  180. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/notifications/composite.py +0 -0
  181. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/notifications/slack.py +0 -0
  182. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/notifications/throttler.py +0 -0
  183. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/pandaz/__init__.py +0 -0
  184. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/pandaz/stats.py +0 -0
  185. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/pandaz/ta.py +0 -0
  186. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/pandaz/utils.py +0 -0
  187. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/plugins/__init__.py +0 -0
  188. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/plugins/loader.py +0 -0
  189. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/rate_limiting/__init__.py +0 -0
  190. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/rate_limiting/backend.py +0 -0
  191. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/rate_limiting/config.py +0 -0
  192. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/rate_limiting/engine.py +0 -0
  193. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/rate_limiting/ip_resolver.py +0 -0
  194. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/rate_limiting/manager.py +0 -0
  195. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/rate_limiting/pools.py +0 -0
  196. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/rate_limiting/redis_backend.py +0 -0
  197. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/rate_limiting/resilient.py +0 -0
  198. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/resources/_build.py +0 -0
  199. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/resources/crypto-fees.ini +0 -0
  200. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/resources/instruments/hyperliquid-spot.json +0 -0
  201. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/resources/instruments/hyperliquid.f-perpetual.json +0 -0
  202. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/resources/instruments/symbols-binance-spot.json +0 -0
  203. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/resources/instruments/symbols-binance.cm-future.json +0 -0
  204. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/resources/instruments/symbols-binance.cm-perpetual.json +0 -0
  205. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/resources/instruments/symbols-binance.um-future.json +0 -0
  206. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/resources/instruments/symbols-binance.um-perpetual.json +0 -0
  207. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/resources/instruments/symbols-bitfinex.f-perpetual.json +0 -0
  208. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/resources/instruments/symbols-kraken-spot.json +0 -0
  209. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/resources/instruments/symbols-kraken.f-future.json +0 -0
  210. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/resources/instruments/symbols-kraken.f-perpetual.json +0 -0
  211. {qubx-3.17.2/src/qubx/ta → qubx-3.17.3.dev1/src/qubx/restarts}/__init__.py +0 -0
  212. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/restarts/state_resolvers.py +0 -0
  213. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/restarts/time_finders.py +0 -0
  214. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/restorers/__init__.py +0 -0
  215. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/restorers/balance.py +0 -0
  216. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/restorers/factory.py +0 -0
  217. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/restorers/interfaces.py +0 -0
  218. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/restorers/position.py +0 -0
  219. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/restorers/signal.py +0 -0
  220. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/restorers/state.py +0 -0
  221. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/restorers/utils.py +0 -0
  222. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/state/__init__.py +0 -0
  223. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/state/dummy.py +0 -0
  224. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/state/redis.py +0 -0
  225. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/state/runtime_info.py +0 -0
  226. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/state/safe.py +0 -0
  227. {qubx-3.17.2/src/qubx/utils/plotting → qubx-3.17.3.dev1/src/qubx/ta}/__init__.py +0 -0
  228. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/ta/indicators.pxd +0 -0
  229. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/ta/indicators.pyi +0 -0
  230. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/ta/indicators.pyx +0 -0
  231. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/__init__.py +0 -0
  232. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/base.py +0 -0
  233. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/project/accounts.toml.j2 +0 -0
  234. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/project/config.yml.j2 +0 -0
  235. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/project/jlive.sh.j2 +0 -0
  236. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/project/jpaper.sh.j2 +0 -0
  237. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/project/pyproject.toml.j2 +0 -0
  238. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/project/src/{{ strategy_name }}/__init__.py.j2 +0 -0
  239. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/project/src/{{ strategy_name }}/strategy.py.j2 +0 -0
  240. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/project/template.yml +0 -0
  241. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/repo/.claude/skills/qubx-cli/SKILL.md +0 -0
  242. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/repo/.claude/skills/qubx-indicators/SKILL.md +0 -0
  243. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/repo/.claude/skills/simulation-explorer/SKILL.md +0 -0
  244. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/repo/.claude/skills/strategy-release/SKILL.md +0 -0
  245. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/repo/.github/workflows/ci.yml.j2 +0 -0
  246. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/repo/.gitignore.j2 +0 -0
  247. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/repo/.python-version +0 -0
  248. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/repo/.vscode/launch.json +0 -0
  249. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/repo/.vscode/settings.json +0 -0
  250. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/repo/.vscode/tasks.json +0 -0
  251. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/repo/CLAUDE.md.j2 +0 -0
  252. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/repo/README.md.j2 +0 -0
  253. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/repo/configs/.gitkeep +0 -0
  254. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/repo/justfile.j2 +0 -0
  255. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/repo/pyproject.toml.j2 +0 -0
  256. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/repo/research/.gitkeep +0 -0
  257. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/repo/src/{{ strategy_name }}/__init__.py.j2 +0 -0
  258. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/repo/src/{{ strategy_name }}/cli.py.j2 +0 -0
  259. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/repo/src/{{ strategy_name }}/strategy.py.j2 +0 -0
  260. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/repo/template.yml +0 -0
  261. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/repo/tests/test_strategy.py.j2 +0 -0
  262. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/simple/__init__.py.j2 +0 -0
  263. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/simple/accounts.toml.j2 +0 -0
  264. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/simple/config.yml.j2 +0 -0
  265. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/simple/jlive.sh.j2 +0 -0
  266. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/simple/jpaper.sh.j2 +0 -0
  267. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/simple/strategy.py.j2 +0 -0
  268. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/templates/simple/template.yml +0 -0
  269. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/trackers/__init__.py +0 -0
  270. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/trackers/advanced.py +0 -0
  271. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/trackers/composite.py +0 -0
  272. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/trackers/rebalancers.py +0 -0
  273. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/trackers/riskctrl.py +0 -0
  274. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/trackers/sizers.py +0 -0
  275. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/__init__.py +0 -0
  276. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/_pyxreloader.py +0 -0
  277. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/charting/lookinglass.py +0 -0
  278. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/charting/mpl_helpers.py +0 -0
  279. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/charting/orderbook.py +0 -0
  280. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/clock.py +0 -0
  281. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/collections.py +0 -0
  282. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/hft/__init__.py +0 -0
  283. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/hft/numba_utils.py +0 -0
  284. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/hft/orderbook.pyi +0 -0
  285. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/hft/orderbook.pyx +0 -0
  286. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/marketdata/binance.py +0 -0
  287. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/marketdata/ccxt.py +0 -0
  288. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/marketdata/dukas.py +0 -0
  289. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/misc.py +0 -0
  290. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/nonce.py +0 -0
  291. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/numbers_utils.py +0 -0
  292. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/orderbook.py +0 -0
  293. {qubx-3.17.2/src/qubx/utils/plotting/renderers → qubx-3.17.3.dev1/src/qubx/utils/plotting}/__init__.py +0 -0
  294. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/plotting/dashboard.py +0 -0
  295. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/plotting/data.py +0 -0
  296. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/plotting/interfaces.py +0 -0
  297. {qubx-3.17.2/src/qubx/utils/runner → qubx-3.17.3.dev1/src/qubx/utils/plotting/renderers}/__init__.py +0 -0
  298. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/plotting/renderers/plotly.py +0 -0
  299. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/questdb.py +0 -0
  300. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/rate_limiter.py +0 -0
  301. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/results.py +0 -0
  302. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/ringbuffer.pxd +0 -0
  303. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/ringbuffer.pyi +0 -0
  304. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/ringbuffer.pyx +0 -0
  305. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/runner/_jupyter_runner.pyt +0 -0
  306. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/runner/accounts.py +0 -0
  307. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/runner/configs.py +0 -0
  308. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/runner/factory.py +0 -0
  309. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/runner/kernel_service.py +0 -0
  310. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/runner/runner.py +0 -0
  311. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/runner/textual/__init__.py +0 -0
  312. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/runner/textual/app.py +0 -0
  313. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/runner/textual/handlers.py +0 -0
  314. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/runner/textual/init_code.py +0 -0
  315. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/runner/textual/kernel.py +0 -0
  316. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/runner/textual/styles.tcss +0 -0
  317. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/runner/textual/widgets/__init__.py +0 -0
  318. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/runner/textual/widgets/account_summary.py +0 -0
  319. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/runner/textual/widgets/command_input.py +0 -0
  320. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/runner/textual/widgets/debug_log.py +0 -0
  321. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/runner/textual/widgets/log_filter.py +0 -0
  322. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/runner/textual/widgets/orders_table.py +0 -0
  323. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/runner/textual/widgets/positions_table.py +0 -0
  324. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/runner/textual/widgets/quotes_table.py +0 -0
  325. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/runner/textual/widgets/repl_output.py +0 -0
  326. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/s3.py +0 -0
  327. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/slack.py +0 -0
  328. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/threading.py +0 -0
  329. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/throttler.py +0 -0
  330. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/time.py +0 -0
  331. {qubx-3.17.2 → qubx-3.17.3.dev1}/src/qubx/utils/websocket_manager.py +0 -0
  332. {qubx-3.17.2 → qubx-3.17.3.dev1}/tests/strategies/macd_crossover/src/macd_crossover/indicators/macd.py +0 -0
  333. {qubx-3.17.2 → qubx-3.17.3.dev1}/tests/strategies/macd_crossover/src/macd_crossover/models/macd_crossover.py +0 -0
  334. {qubx-3.17.2 → qubx-3.17.3.dev1}/tests/strategies/macd_crossover/src/macd_crossover/models/utils.py +0 -0
  335. {qubx-3.17.2 → qubx-3.17.3.dev1}/tests/strategies/obi_trader/src/obi_trader/models/obi_trader.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: Qubx
3
- Version: 3.17.2
3
+ Version: 3.17.3.dev1
4
4
  Summary: Qubx - Quantitative Trading Framework
5
5
  Project-URL: homepage, https://xlydian.com
6
6
  Project-URL: repository, https://github.com/xLydianSoftware/Qubx
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '3.17.2'
22
- __version_tuple__ = version_tuple = (3, 17, 2)
21
+ __version__ = version = '3.17.3.dev1'
22
+ __version_tuple__ = version_tuple = (3, 17, 3, 'dev1')
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -33,7 +33,7 @@ import time
33
33
  import uuid
34
34
  from asyncio.exceptions import CancelledError
35
35
  from collections.abc import Coroutine
36
- from dataclasses import dataclass
36
+ from dataclasses import dataclass, replace
37
37
  from typing import Any, Literal
38
38
 
39
39
  import ccxt
@@ -44,6 +44,7 @@ from ccxt import AuthenticationError, ExchangeClosedByUser, ExchangeError, Excha
44
44
  from qubx import connector_logger, logger
45
45
  from qubx.core.basics import (
46
46
  FRAMEWORK_CID_PREFIX,
47
+ OPTION_REPRICE_IF_CROSSING,
47
48
  Balance,
48
49
  CtrlChannel,
49
50
  CurrencyConversion,
@@ -89,6 +90,7 @@ from qubx.utils.time import to_timedelta
89
90
  from .exceptions import CcxtSymbolNotRecognized
90
91
  from .exchange_manager import ExchangeManager
91
92
  from .utils import (
93
+ FRAMEWORK_ONLY_OPTIONS,
92
94
  ccxt_convert_balance,
93
95
  ccxt_convert_deal_info,
94
96
  ccxt_convert_order_info,
@@ -284,17 +286,21 @@ class CcxtConnector(ChannelEmitter):
284
286
  if rate_limiter is not None:
285
287
  await rate_limiter.acquire(endpoint)
286
288
 
287
- def _report_order_limit_hit(self, error: Exception) -> None:
288
- """Close the orders gate when the venue itself reports an order-budget breach.
289
+ def _report_order_limit_hit(self, error: Exception, pool_name: str = "orders") -> None:
290
+ """Close ``pool_name``'s gate when the venue itself reports a budget breach.
289
291
 
290
292
  A no-op for every other error. Without it the pool is proactive-model-only, so it never
291
293
  sees the budget another actor on the same account (manual trading, a second bot) spends.
294
+
295
+ ``pool_name`` must be the one the refused endpoint is billed against — closing ``orders``
296
+ for a set_leverage breach would stop trading over a budget orders never spent. An
297
+ undefined name is a no-op in the limiter.
292
298
  """
293
299
  rate_limiter = self._em.rate_limiter
294
300
  if rate_limiter is None or not isinstance(error, _ORDER_RATE_LIMIT_ERRORS):
295
301
  return
296
302
  # pool_name, never endpoint= — the latter closes every pool in the endpoint's cost list
297
- rate_limiter.report_limit_hit(pool_name="orders", reason=f"venue order rate limit: {error}")
303
+ rate_limiter.report_limit_hit(pool_name=pool_name, reason=f"venue rate limit on {pool_name}: {error}")
298
304
 
299
305
  # ------------------------------------------------------------------ #
300
306
  # Write side — submit
@@ -315,6 +321,8 @@ class CcxtConnector(ChannelEmitter):
315
321
 
316
322
  options = request.options or {}
317
323
  reduce_only = bool(resolve_reduce_only(options))
324
+ post_only = bool(options.get("post_only", False))
325
+ reprice_if_crossing = bool(options.get(OPTION_REPRICE_IF_CROSSING, False))
318
326
 
319
327
  # Quote lookup is the connector's only READ dependency; payload build raises
320
328
  # framework-side rejections (no quote, below min-notional, missing price).
@@ -329,11 +337,13 @@ class CcxtConnector(ChannelEmitter):
329
337
  time_in_force=request.time_in_force,
330
338
  quote=quote,
331
339
  reduce_only=reduce_only,
340
+ post_only=post_only,
341
+ reprice_if_crossing=reprice_if_crossing,
332
342
  )
333
343
  # Forward any remaining venue-specific options ccxt understands (e.g.
334
344
  # lighter_* indices) without clobbering what the payload builder set.
335
345
  for k, v in options.items():
336
- if k in ("reduceOnly", "reduce_only"):
346
+ if k in FRAMEWORK_ONLY_OPTIONS:
337
347
  continue
338
348
  payload["params"].setdefault(k, v)
339
349
 
@@ -856,24 +866,46 @@ class CcxtConnector(ChannelEmitter):
856
866
  )
857
867
  self._spawn(self._do_set_leverage(instrument, symbol, wanted))
858
868
 
869
+ def _report_leverage_failure(self, instrument: Instrument, leverage: int, error: Exception) -> None:
870
+ """The caller of set_instrument_leverage is long gone, so the verdict rides the channel."""
871
+ logger.error(f"[{self.exchange_name}] Failed to set leverage {leverage} for {instrument.symbol}: {error}")
872
+ self.channel.send(
873
+ create_error_event(
874
+ VenueOperationError(
875
+ timestamp=self._time.time(),
876
+ message=f"set leverage {leverage} for {instrument.symbol}",
877
+ level=ErrorLevel.MEDIUM,
878
+ error=error,
879
+ operation="set_instrument_leverage",
880
+ instrument=instrument,
881
+ )
882
+ )
883
+ )
884
+
859
885
  async def _do_set_leverage(self, instrument: Instrument, symbol: str, leverage: int) -> None:
860
886
  try:
861
887
  await self._acquire_endpoint_budget("set_leverage")
862
888
  await self._em.exchange.set_leverage(leverage, symbol)
889
+ except _ORDER_RATE_LIMIT_ERRORS as e:
890
+ # The write is fire-and-forget, so nothing re-sends a leverage that never landed.
891
+ # Retry once, but only where the gate paces it — a venue with no `leverage` pool would
892
+ # re-send instantly, and binance escalates bans for requests sent after a 429.
893
+ self._report_order_limit_hit(e, pool_name="leverage")
894
+ limiter = self._em.rate_limiter
895
+ if limiter is None or not limiter.is_gate_closed("leverage"):
896
+ self._report_leverage_failure(instrument, leverage, e)
897
+ return
898
+ logger.warning(f"[{self.exchange_name}] leverage {leverage} for {instrument.symbol} rate limited; retrying")
899
+ try:
900
+ await self._acquire_endpoint_budget("set_leverage")
901
+ await self._em.exchange.set_leverage(leverage, symbol)
902
+ except Exception as retry_error: # noqa: BLE001 — report the retry's verdict, not the first
903
+ # the gate reopened while we waited; a second refusal must re-close it
904
+ self._report_order_limit_hit(retry_error, pool_name="leverage")
905
+ self._report_leverage_failure(instrument, leverage, retry_error)
906
+ return
863
907
  except Exception as e: # noqa: BLE001 — the caller is long gone; report on the channel
864
- logger.error(f"[{self.exchange_name}] Failed to set leverage {leverage} for {instrument.symbol}: {e}")
865
- self.channel.send(
866
- create_error_event(
867
- VenueOperationError(
868
- timestamp=self._time.time(),
869
- message=f"set leverage {leverage} for {instrument.symbol}",
870
- level=ErrorLevel.MEDIUM,
871
- error=e,
872
- operation="set_instrument_leverage",
873
- instrument=instrument,
874
- )
875
- )
876
- )
908
+ self._report_leverage_failure(instrument, leverage, e)
877
909
  return
878
910
  # - adopt what we just set, so the next call for the same value is skipped without
879
911
  # waiting for the poller; the poller corrects it if the venue disagrees
@@ -944,6 +976,7 @@ class CcxtConnector(ChannelEmitter):
944
976
  configured: dict[str, float] = {}
945
977
  notionals: dict[str, float] = {}
946
978
  maxima: dict[str, float] = {}
979
+ configured_read = True
947
980
  # - annotated locals: ccxt's BASE Exchange declares both methods as an unconditional
948
981
  # `raise NotSupported`, so their inferred return type is NoReturn. Only the venue
949
982
  # subclasses return dicts, and `ex` is typed as the base. A venue without the
@@ -957,6 +990,7 @@ class CcxtConnector(ChannelEmitter):
957
990
  if max_notional is not None:
958
991
  notionals[symbol] = max_notional
959
992
  except Exception as e: # noqa: BLE001
993
+ configured_read = False
960
994
  logger.debug(f"[{self.exchange_name}] configured-leverage read failed: {type(e).__name__}: {e}")
961
995
  try:
962
996
  tiers_by_symbol: dict[str, Any] = await ex.fetch_leverage_tiers()
@@ -989,8 +1023,7 @@ class CcxtConnector(ChannelEmitter):
989
1023
  VenueSettingsUpdate(instrument, leverage=float(value), max_notional=notionals.get(symbol))
990
1024
  )
991
1025
  )
992
- # rebuilt wholesale, so a symbol the venue stopped reporting leaves the cache with it
993
- self._leverage_cache = {
1026
+ rebuilt = {
994
1027
  symbol: _LeverageInfo(
995
1028
  configured=configured.get(symbol),
996
1029
  maximum=maxima.get(symbol),
@@ -998,6 +1031,21 @@ class CcxtConnector(ChannelEmitter):
998
1031
  )
999
1032
  for symbol in configured.keys() | maxima.keys() | notionals.keys()
1000
1033
  }
1034
+ if configured_read:
1035
+ # rebuilt wholesale, so a symbol the venue stopped reporting leaves the cache with it
1036
+ self._leverage_cache = rebuilt
1037
+ else:
1038
+ # The `configured` read failed (bybit has no fetch_leverages), so this sweep cannot
1039
+ # speak for it: a wholesale rebuild would erase what the write path adopted and evict
1040
+ # every symbol the tier read left out — on bybit, everything past its pagination cap.
1041
+ # max_notional rides the same failed read, so it is preserved too.
1042
+ for symbol, info in rebuilt.items():
1043
+ held = self._leverage_cache.get(symbol)
1044
+ self._leverage_cache[symbol] = (
1045
+ replace(info, configured=held.configured, max_notional=held.max_notional)
1046
+ if held is not None
1047
+ else info
1048
+ )
1001
1049
  logger.info(
1002
1050
  f"[{self.exchange_name}] leverage cache refreshed: {len(configured)} configured, "
1003
1051
  f"{len(maxima)} maxima, {len(notionals)} notional caps"
@@ -10,6 +10,8 @@ from ..connector import CcxtConnector
10
10
  from .binance.connector import BinancePmCcxtConnector
11
11
  from .binance.exchange import BINANCE_UM_MM, BinancePortfolioMargin, BinanceQV, BinanceQVUSDM
12
12
  from .bitfinex.connector import BitfinexCcxtConnector
13
+ from .bybit.bybit import BybitF
14
+ from .bybit.connector import BybitCcxtConnector
13
15
  from .gateio.gateio import GateioFutures
14
16
  from .hyperliquid.hyperliquid import Hyperliquid, HyperliquidF
15
17
  from .kraken.kraken import CustomKrakenFutures
@@ -45,14 +47,15 @@ EXCHANGE_ALIASES = {
45
47
  "bitfinex.f": "bitfinex_f",
46
48
  "hyperliquid": "hyperliquid",
47
49
  "hyperliquid.f": "hyperliquid_f",
48
- "bybit.f": "bybit",
50
+ "bybit.f": "bybit_f",
49
51
  "gateio.f": "gateio_futures",
50
52
  "okx.f": "okx_futures",
51
53
  }
52
54
 
53
55
  # CcxtConnector subclasses per exchange. Unlisted exchanges (Binance,
54
56
  # Hyperliquid, ...) use the base CcxtConnector via the factory fallback. OKX/Bitfinex
55
- # need the split orders/fills streams; OKX additionally overrides balance/clOrdId.
57
+ # need the split orders/fills streams; OKX additionally overrides balance/clOrdId. Bybit needs
58
+ # them too: ccxt's parse_order hardcodes ``trades: None``, so fills arrive only on executions.
56
59
  # Keyed by the normalized framework exchange names, plus
57
60
  # the bare ``okx``/``bitfinex`` aliases the factory may receive. Bitfinex's connector
58
61
  # subclass has NO dependency on the optional qubx-bitfinex-api package (it only needs
@@ -65,6 +68,8 @@ CUSTOM_CONNECTORS: dict[str, type[CcxtConnector]] = {
65
68
  "bitfinex": BitfinexCcxtConnector,
66
69
  "bitfinex.f": BitfinexCcxtConnector,
67
70
  "binance.pm": BinancePmCcxtConnector,
71
+ "bybit": BybitCcxtConnector,
72
+ "bybit.f": BybitCcxtConnector,
68
73
  }
69
74
 
70
75
  READER_CAPABILITIES = {
@@ -93,6 +98,7 @@ cxp.hyperliquid = Hyperliquid # type: ignore
93
98
  cxp.hyperliquid_f = HyperliquidF # type: ignore
94
99
  cxp.gateio_futures = GateioFutures # type: ignore
95
100
  cxp.okx_futures = OkxFutures # type: ignore
101
+ cxp.bybit_f = BybitF # type: ignore
96
102
 
97
103
  cxp.exchanges.append("binanceqv")
98
104
  cxp.exchanges.append("binanceqv_usdm")
@@ -105,3 +111,4 @@ cxp.exchanges.append("hyperliquid")
105
111
  cxp.exchanges.append("hyperliquid_f")
106
112
  cxp.exchanges.append("gateio_futures")
107
113
  cxp.exchanges.append("okx_futures")
114
+ cxp.exchanges.append("bybit_f")
@@ -88,12 +88,23 @@ class _TwoStreamCcxtConnector(CcxtConnector):
88
88
  self.send(
89
89
  DealEvent(
90
90
  instrument=instrument,
91
- client_order_id=None, # AM resolves the order by the venue id
91
+ client_order_id=self._trade_client_id(raw),
92
92
  venue_order_id=raw.get("order"),
93
93
  deal=deal,
94
94
  )
95
95
  )
96
96
 
97
+ def _trade_client_id(self, raw: dict[str, Any]) -> str | None:
98
+ """The cid this trade carries, when the venue puts one on its execution frame.
99
+
100
+ Resolving by venue id alone loses the race a market order can create: the trade can
101
+ arrive before the submit ack has mapped that id, and AM then materializes a phantom
102
+ EXTERNAL order which absorbs the fill — leaving the real order at filled=0 with its
103
+ seen-trade-ids on the phantom. The order itself is already in state (registered before
104
+ submit), so a cid resolves it immediately. None keeps the venue-id-only behaviour.
105
+ """
106
+ return None
107
+
97
108
  # ------------------------------------------------------------------ #
98
109
  # Order-status stream — fill branches (override the base's inline-trade reads)
99
110
  # ------------------------------------------------------------------ #
@@ -840,6 +840,9 @@ class BinancePortfolioMargin(BinanceQVUSDM):
840
840
  raise BadRequest(f"{self.id} algo {algo_order_type} requires a price")
841
841
  request["price"] = self.price_to_precision(symbol, price)
842
842
  request["timeInForce"] = self.safe_string_upper(params, "timeInForce", "GTC")
843
+ # The algo endpoint has no postOnly flag — it must be expressed as GTX TIF.
844
+ if self.safe_bool(params, "postOnly", False):
845
+ request["timeInForce"] = "GTX"
843
846
  cid = self.safe_string_2(params, "clientOrderId", "newClientOrderId")
844
847
  if cid is not None:
845
848
  request["clientAlgoId"] = cid
@@ -76,11 +76,6 @@ class BitfinexF(CcxtFuturePatchMixin, cxp.bitfinex):
76
76
  self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}
77
77
  ):
78
78
  params.pop("type", None)
79
- if "timeInForce" in params and params["timeInForce"] == "GTX":
80
- # GTX is not supported by bitfinex, so we need to convert it to PO
81
- params["timeInForce"] = "PO"
82
- params["postOnly"] = True
83
-
84
79
  if "lev" not in params:
85
80
  params["lev"] = 2
86
81
 
@@ -91,11 +86,6 @@ class BitfinexF(CcxtFuturePatchMixin, cxp.bitfinex):
91
86
  self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}
92
87
  ) -> Order:
93
88
  params.pop("type", None)
94
- if "timeInForce" in params and params["timeInForce"] == "GTX":
95
- # GTX is not supported by bitfinex, so we need to convert it to PO
96
- params["timeInForce"] = "PO"
97
- params["postOnly"] = True
98
-
99
89
  if "lev" not in params:
100
90
  params["lev"] = 2
101
91
 
@@ -0,0 +1,311 @@
1
+ import asyncio
2
+ from collections.abc import Awaitable, Callable
3
+ from functools import partial
4
+ from typing import Any
5
+
6
+ import ccxt.pro as cxp
7
+ from ccxt.base.errors import ArgumentsRequired, BadRequest, OrderNotFound
8
+ from ccxt.base.types import Liquidation, Num, Order, OrderSide, OrderType, Position, Str, Strings
9
+
10
+ from ...adapters.polling_adapter import PollingConfig, PollingToWebSocketAdapter
11
+ from ...utils import info_float
12
+ from ..base import CcxtFuturePatchMixin
13
+
14
+ # Bybit answers a redundant set_leverage with this code rather than no-opping.
15
+ _LEVERAGE_NOT_MODIFIED = "110043"
16
+
17
+ # a stop rests on the far side of the market from its own side: BUY above, SELL below
18
+ _TRIGGER_DIRECTION = {"buy": "ascending", "sell": "descending"}
19
+
20
+ # a symbol-less positions/orders read defaults to settleCoin=USDT, so anything settled in
21
+ # another coin reads as absent; the endpoints take one settle coin per call
22
+ _SETTLE_COINS = ("USDT", "USDC")
23
+
24
+ # Bybit ranks the ADL queue 1..5, 0 = not ranked; the framework scale is Binance's 0..4,
25
+ # higher = closer to the front of the queue.
26
+ _ADL_MIN_RANK = 1
27
+ _ADL_MAX_RANK = 5
28
+
29
+ # a crossing post-only order comes back cancelled with this reject-reason family
30
+ _POST_ONLY_REFUSAL = "EC_PostOnly"
31
+
32
+
33
+ def _adl_level(position: Any) -> int | None:
34
+ """Bybit's ``adlRankIndicator`` on the framework scale.
35
+
36
+ A rank outside 1..5 is dropped, not clamped: 0 means "not ranked", not "safest".
37
+ """
38
+ rank = info_float(position, "adlRankIndicator")
39
+ if rank is None or not (_ADL_MIN_RANK <= rank <= _ADL_MAX_RANK):
40
+ return None
41
+ return int(rank) - _ADL_MIN_RANK
42
+
43
+
44
+ FUNDING_RATE_DEFAULT_POLL_MINUTES = 5
45
+
46
+
47
+ class BybitF(CcxtFuturePatchMixin, cxp.bybit):
48
+ """Bybit perpetual futures: ccxt patches for the calls Bybit does not accept as written."""
49
+
50
+ # the only depths Bybit's WS book serves; anything else is a BadRequest at subscribe
51
+ _WS_DEPTHS = (1, 50, 200, 1000)
52
+
53
+ def __init__(self, config=None):
54
+ super().__init__(config or {})
55
+ self._funding_rate_adapter: PollingToWebSocketAdapter | None = None
56
+
57
+ def describe(self):
58
+ return self.deep_extend(
59
+ super().describe(),
60
+ {
61
+ "has": {
62
+ "unWatchBidsAsks": True,
63
+ "watchFundingRates": True,
64
+ "watchLiquidationsForSymbols": True,
65
+ },
66
+ "options": {
67
+ "fetchOrder": {"acknowledged": True},
68
+ # caps the cursor walk armed by params={"paginate": True}; read by the
69
+ # pagination driver only, so it cannot re-arm on the recursive call
70
+ "fetchOpenOrders": {"paginationCalls": 20},
71
+ "fetchPositions": {"paginationCalls": 20},
72
+ },
73
+ },
74
+ )
75
+
76
+ def _settle_filtered(self, params: dict) -> bool:
77
+ return any(params.get(k) is not None for k in ("settleCoin", "baseCoin", "symbol"))
78
+
79
+ async def _per_settle_coin(self, fetch: Callable[[dict], Awaitable[list]], params: dict) -> list:
80
+ """One paginated call per settle coin, concatenated.
81
+
82
+ The row caps — /v5/order/realtime serves 20, ccxt pins /v5/position/list at 200 — need
83
+ the cursor walk, and ``paginate`` must ride params, not options: the recursive call
84
+ carries ``settleCoin``, so it lands back on the filtered branch and ends at ``super()``.
85
+ """
86
+ legs = await asyncio.gather(
87
+ *(fetch(self.extend(params, {"settleCoin": coin, "paginate": True})) for coin in _SETTLE_COINS)
88
+ )
89
+ return [row for leg in legs for row in leg]
90
+
91
+ async def fetch_positions(self, symbols: Strings = None, params={}) -> list[Any]:
92
+ if symbols or self._settle_filtered(params):
93
+ return await super().fetch_positions(symbols, params)
94
+ return await self._per_settle_coin(partial(super(BybitF, self).fetch_positions, symbols), params)
95
+
96
+ def parse_position(self, position, market=None) -> Position:
97
+ """Keep the venue's own maintenance margin and put the ADL rank on the unified key.
98
+
99
+ ccxt reads ``positionMM`` and then replaces it with ``|liqPrice - bustPrice| * size``
100
+ whenever a liquidation price is set; a UTA account reports ``bustPrice=""``, so the
101
+ product is None and the framework falls back to a flat 5% of notional.
102
+
103
+ ``info`` is ccxt's passthrough of the raw row, which is where ``ccxt_convert_position``
104
+ reads ``adl`` — Bybit spells the same figure ``adlRankIndicator`` on a 1-based scale.
105
+ """
106
+ parsed = super().parse_position(position, market)
107
+ if parsed.get("maintenanceMargin") is None:
108
+ venue_mm = info_float(position, "positionMM")
109
+ if venue_mm is not None:
110
+ parsed["maintenanceMargin"] = venue_mm
111
+ adl = _adl_level(position)
112
+ if adl is not None:
113
+ parsed["info"] = {**position, "adl": adl}
114
+ return parsed
115
+
116
+ async def fetch_open_orders(
117
+ self, symbol: Str = None, since: Num = None, limit: Num = None, params={}
118
+ ) -> list[Order]:
119
+ if symbol is not None or self._settle_filtered(params):
120
+ return await super().fetch_open_orders(symbol, since, limit, params)
121
+ return await self._per_settle_coin(partial(super(BybitF, self).fetch_open_orders, symbol, since, limit), params)
122
+
123
+ def create_order_request(
124
+ self,
125
+ symbol: str,
126
+ type: OrderType,
127
+ side: OrderSide,
128
+ amount: float,
129
+ price: Num = None,
130
+ params={},
131
+ isUTA=True,
132
+ ):
133
+ return super().create_order_request(
134
+ symbol, type, side, amount, price, self._with_trigger_direction(side, params), isUTA
135
+ )
136
+
137
+ @staticmethod
138
+ def _with_trigger_direction(side: str, params: dict) -> dict:
139
+ """ccxt refuses every non-spot trigger order that does not carry ``triggerDirection``."""
140
+ if params.get("triggerDirection") is not None:
141
+ return params
142
+ if params.get("triggerPrice") is None and params.get("stopPrice") is None:
143
+ return params
144
+ return {**params, "triggerDirection": _TRIGGER_DIRECTION[side.lower()]}
145
+
146
+ def parse_order(self, order, market=None):
147
+ """Report a post-only refusal as rejected, not cancelled.
148
+
149
+ Bybit accepts a crossing post-only order and then cancels it with
150
+ ``rejectReason=EC_PostOnlyWillTakeLiquidity`` instead of refusing it synchronously.
151
+ """
152
+ parsed = super().parse_order(order, market)
153
+ if parsed.get("status") == "canceled":
154
+ reason = self.safe_string(parsed.get("info") or {}, "rejectReason", "")
155
+ if reason.startswith(_POST_ONLY_REFUSAL):
156
+ parsed["status"] = "rejected"
157
+ return parsed
158
+
159
+ async def set_leverage(self, leverage: int, symbol: Str = None, params={}):
160
+ """Treat a redundant set as the silent no-op every other venue answers with."""
161
+ try:
162
+ return await super().set_leverage(leverage, symbol, params)
163
+ except BadRequest as e:
164
+ if _LEVERAGE_NOT_MODIFIED not in str(e):
165
+ raise
166
+ return {}
167
+
168
+ def cancel_order_request(self, id: str, symbol: Str = None, params={}):
169
+ link_id = self.safe_string_2(params, "orderLinkId", "clientOrderId")
170
+ if link_id is None:
171
+ return super().cancel_order_request(id, symbol, params)
172
+ request = super().cancel_order_request(id, symbol, self.omit(params, ["clientOrderId", "orderLinkId"]))
173
+ request.pop("orderId", None)
174
+ request["orderLinkId"] = link_id
175
+ return request
176
+
177
+ async def fetch_order(self, id: str, symbol: Str = None, params={}) -> Order:
178
+ """Look up an order, retrying without the trigger filter before believing it is gone.
179
+
180
+ ``trigger``/``stop`` becomes ``orderFilter=StopOrder``, which holds only UNTRIGGERED
181
+ conditionals — a fired stop moves to the regular book but still reads back STOP_MARKET.
182
+ """
183
+ try:
184
+ return await self._fetch_order(id, symbol, params)
185
+ except OrderNotFound:
186
+ if not self.safe_bool_2(params, "trigger", "stop", False):
187
+ raise
188
+ return await self._fetch_order(id, symbol, self.omit(params, ["trigger", "stop"]))
189
+
190
+ async def _fetch_order(self, id: str, symbol: Str, params: dict) -> Order:
191
+ """Route a client-id lookup through the order-list endpoints, the only ones that accept
192
+ ``orderLinkId``."""
193
+ link_id = self.safe_string_2(params, "orderLinkId", "clientOrderId")
194
+ if link_id is None:
195
+ return await super().fetch_order(id, symbol, params)
196
+ rest = self.omit(params, ["clientOrderId", "orderLinkId"])
197
+ for fetch in (self.fetch_open_orders, self.fetch_canceled_and_closed_orders):
198
+ rows = await fetch(symbol, None, None, self.extend(rest, {"orderLinkId": link_id}))
199
+ # match explicitly rather than trusting the venue-side filter
200
+ for row in rows:
201
+ if row.get("clientOrderId") == link_id:
202
+ return row
203
+ raise OrderNotFound(f"{self.id} order with orderLinkId {link_id} was not found")
204
+
205
+ async def watch_bids_asks(self, symbols: Strings = None, params={}) -> dict:
206
+ """Take quotes off ``tickers``, not ``orderbook.1``.
207
+
208
+ ccxt's ``watchBidsAsks`` writes its one-level book into the same
209
+ ``self.orderbooks[symbol]`` the depth subscription fills, collapsing the L2 book.
210
+ """
211
+ tickers = await self.watch_tickers(symbols, params)
212
+ return {s: t for s, t in tickers.items() if t.get("bid") is not None and t.get("ask") is not None}
213
+
214
+ async def un_watch_bids_asks(self, symbols: Strings = None, params={}) -> Any:
215
+ """Release the tickers topic ``watch_bids_asks`` subscribed; upstream has no unwatch."""
216
+ return await self.un_watch_tickers(symbols, params)
217
+
218
+ async def watch_funding_rates(
219
+ self, symbols: list[str] | None = None, params: dict[str, Any] | None = None
220
+ ) -> dict[str, Any]:
221
+ """Present ``fetch_funding_rates`` as a watch, on a poll.
222
+
223
+ Bybit has no funding WS channel, and ``tickers`` carries the rate on its snapshot frame
224
+ only — a topic ``watch_bids_asks`` already owns.
225
+ """
226
+ params = params or {}
227
+ await self.load_markets()
228
+ poll_minutes = params.get("poll_interval_minutes", FUNDING_RATE_DEFAULT_POLL_MINUTES)
229
+
230
+ if self._funding_rate_adapter is None:
231
+ self._funding_rate_adapter = PollingToWebSocketAdapter(
232
+ fetch_method=self._fetch_funding_rates_for,
233
+ symbols=symbols or [],
234
+ params=params,
235
+ config=PollingConfig(poll_interval_seconds=poll_minutes * 60),
236
+ )
237
+ elif symbols is not None:
238
+ await self._funding_rate_adapter.update_symbols(symbols)
239
+
240
+ rates = await self._funding_rate_adapter.get_next_data()
241
+ # ccxt's bybit parser writes the next funding time as `fundingTimestamp`;
242
+ # ccxt_convert_funding_rate reads `nextFundingTime`
243
+ return {
244
+ symbol: {**info, "nextFundingTime": info.get("fundingTimestamp")}
245
+ for symbol, info in (rates or {}).items()
246
+ if isinstance(info, dict)
247
+ }
248
+
249
+ async def _fetch_funding_rates_for(self, symbols: list[str], **params) -> dict[str, Any]:
250
+ # bybit's fetch does market(symbols[0]) on an empty list -> IndexError
251
+ return await self.fetch_funding_rates(symbols or None, params)
252
+
253
+ async def un_watch_funding_rates(self, symbols: list[str] | None = None) -> None:
254
+ """The handler's cleanup calls this with no arguments, meaning "stop everything"."""
255
+ adapter = self._funding_rate_adapter
256
+ if adapter is None:
257
+ return
258
+ if symbols:
259
+ await adapter.remove_symbols(symbols)
260
+ if adapter.is_watching():
261
+ return
262
+ await adapter.stop()
263
+ self._funding_rate_adapter = None
264
+
265
+ def _ws_depth(self, limit: int | None) -> int:
266
+ """Round a requested depth up to one Bybit serves; 50 is ccxt's linear default, pinned
267
+ here so the unwatch topic matches the subscribed one."""
268
+ return next((d for d in self._WS_DEPTHS if d >= (limit or 50)), self._WS_DEPTHS[-1])
269
+
270
+ async def watch_order_book_for_symbols(self, symbols: list[str], limit: int | None = None, params={}):
271
+ return await super().watch_order_book_for_symbols(symbols, self._ws_depth(limit), params)
272
+
273
+ async def un_watch_order_book_for_symbols(self, symbols: list[str], limit: int | None = None, params={}) -> Any:
274
+ """Upstream takes the depth via params and otherwise defaults to 500, an illegal topic."""
275
+ return await super().un_watch_order_book_for_symbols(
276
+ symbols, self.extend(params, {"limit": self._ws_depth(limit)})
277
+ )
278
+
279
+ async def un_watch_order_book(self, symbol: str, limit: int | None = None, params={}) -> Any:
280
+ # upstream passes params as the second positional, which is our limit
281
+ return await self.un_watch_order_book_for_symbols([symbol], limit, params)
282
+
283
+ async def watch_liquidations_for_symbols(
284
+ self, symbols: list[str], since: int | None = None, limit: int | None = None, params={}
285
+ ) -> list[Liquidation]:
286
+ """Subscribe ``allLiquidation`` for many symbols at once: ccxt ships only the
287
+ single-symbol watch, and no unwatch for liquidations on any venue."""
288
+ if not symbols:
289
+ raise ArgumentsRequired(f"{self.id} watchLiquidationsForSymbols() requires a non-empty array of symbols")
290
+ await self.load_markets()
291
+ symbols = self.market_symbols(symbols)
292
+ url = await self.get_url_by_market_type(symbols[0], False, "watchLiquidations", params)
293
+ params = self.clean_params(params)
294
+ method, params = self.handle_option_and_params(params, "watchLiquidations", "method", "allLiquidation")
295
+ topics = [method + "." + self.market(symbol)["id"] for symbol in symbols]
296
+ hashes = ["liquidations::" + symbol for symbol in symbols]
297
+ liquidations = await self.watch_topics(url, hashes, topics, params)
298
+ if self.newUpdates:
299
+ return liquidations
300
+ return self.filter_by_symbols_since_limit(self.liquidations, symbols, since, limit, True)
301
+
302
+ def parse_ws_liquidation(self, liquidation, market=None) -> Liquidation:
303
+ """Report the side of the liquidating ORDER, as other venues do.
304
+
305
+ ccxt passes ``'S'`` as ``safe_string_lower``'s default value instead of as a second key,
306
+ and Bybit's ``S`` is the POSITION side — the inverse of Binance's ``forceOrder``.
307
+ """
308
+ parsed = super().parse_ws_liquidation(liquidation, market)
309
+ position_side = self.safe_string_lower_2(liquidation, "side", "S")
310
+ parsed["side"] = "sell" if position_side == "buy" else "buy"
311
+ return parsed