Qubx 3.17.3.dev1__tar.gz → 3.17.3.dev3__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.
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/PKG-INFO +1 -1
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/_version.py +2 -2
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/connector.py +36 -20
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/exchanges/bybit/bybit.py +2 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/exchanges/bybit/connector.py +25 -24
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/handlers/ohlc.py +23 -5
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/rate_limits.py +83 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/utils.py +14 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/account_manager/state.py +7 -1
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/basics.py +31 -10
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/mixins/processing.py +10 -2
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/utils.pyx +4 -2
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/data/storages/ccxt.py +8 -76
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/.gitignore +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/LICENSE +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/README.md +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/pyproject.toml +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/scripts/build.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/_nb_magic.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/backtester/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/backtester/connector.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/backtester/data.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/backtester/iteratedstream.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/backtester/management.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/backtester/ome.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/backtester/optimization.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/backtester/runner.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/backtester/sentinels.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/backtester/simulated_data.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/backtester/simulated_exchange.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/backtester/simulator.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/backtester/transfers.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/backtester/utils.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/cli/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/cli/commands.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/cli/deploy.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/cli/misc.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/cli/release.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/cli/resolver.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/cli/s3.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/cli/theme.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/cli/tui.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/cli/user_config.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/config.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/adapters/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/adapters/polling_adapter.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/connection_manager.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/data.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/exceptions.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/exchange_manager.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/exchanges/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/exchanges/_two_stream.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/exchanges/base.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/exchanges/binance/connector.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/exchanges/binance/exchange.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/exchanges/bitfinex/bitfinex.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/exchanges/bitfinex/connector.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/exchanges/bybit/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/exchanges/gateio/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/exchanges/gateio/gateio.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/exchanges/hyperliquid/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/exchanges/hyperliquid/hyperliquid.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/exchanges/kraken/kraken.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/exchanges/okx/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/exchanges/okx/connector.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/exchanges/okx/okx.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/factory.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/handlers/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/handlers/base.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/handlers/factory.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/handlers/funding_rate.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/handlers/liquidation.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/handlers/open_interest.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/handlers/orderbook.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/handlers/quote.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/handlers/trade.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/plugin.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/subscription_config.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/subscription_manager.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/subscription_orchestrator.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/ccxt/warmup_service.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/plugin.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/registry.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/tardis/data.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/tardis/plugin.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/connectors/tardis/utils.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/control/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/control/builtin.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/control/decorator.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/control/executor.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/control/interfaces.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/control/server.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/control/types.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/account_manager/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/account_manager/config.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/account_manager/diffs.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/account_manager/manager.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/account_manager/reconciler.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/account_manager/reducer.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/account_manager/state_machine.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/boot.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/connector.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/context.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/detectors/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/detectors/delisting.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/detectors/stale.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/errors.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/events.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/exceptions.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/fit_context.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/fit_executor.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/helpers.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/initializer.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/instrument_service.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/interfaces.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/loggers.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/lookups.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/metrics.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/mixins/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/mixins/instrument_service.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/mixins/market.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/mixins/subscription.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/mixins/trading.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/mixins/universe.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/mixins/utils.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/series.pxd +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/series.pyi +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/series.pyx +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/state_snapshot.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/status.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/subscription_watchdog.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/core/utils.pyi +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/data/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/data/cache.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/data/containers.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/data/guards.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/data/registry.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/data/storage.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/data/storages/csv.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/data/storages/handy.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/data/storages/multi.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/data/storages/questdb.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/data/storages/stub.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/data/storages/utils.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/data/transformers.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/emitters/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/emitters/base.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/emitters/composite.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/emitters/csv.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/emitters/indicator.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/emitters/inmemory.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/emitters/prometheus.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/emitters/questdb.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/exporters/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/exporters/composite.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/exporters/formatters/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/exporters/formatters/base.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/exporters/formatters/incremental.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/exporters/formatters/slack.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/exporters/formatters/target_position.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/exporters/redis_streams.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/exporters/slack.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/gathering/simplest.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/health/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/health/base.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/health/dummy.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/health/status.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/loggers/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/loggers/csv.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/loggers/factory.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/loggers/inmemory.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/loggers/mongo.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/loggers/postgres.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/notifications/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/notifications/composite.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/notifications/slack.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/notifications/throttler.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/pandaz/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/pandaz/stats.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/pandaz/ta.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/pandaz/utils.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/plugins/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/plugins/loader.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/rate_limiting/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/rate_limiting/backend.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/rate_limiting/config.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/rate_limiting/engine.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/rate_limiting/ip_resolver.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/rate_limiting/manager.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/rate_limiting/pools.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/rate_limiting/redis_backend.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/rate_limiting/resilient.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/resources/_build.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/resources/crypto-fees.ini +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/resources/instruments/hyperliquid-spot.json +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/resources/instruments/hyperliquid.f-perpetual.json +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/resources/instruments/symbols-binance-spot.json +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/resources/instruments/symbols-binance.cm-future.json +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/resources/instruments/symbols-binance.cm-perpetual.json +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/resources/instruments/symbols-binance.um-future.json +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/resources/instruments/symbols-binance.um-perpetual.json +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/resources/instruments/symbols-bitfinex.f-perpetual.json +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/resources/instruments/symbols-kraken-spot.json +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/resources/instruments/symbols-kraken.f-future.json +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/resources/instruments/symbols-kraken.f-perpetual.json +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/restarts/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/restarts/state_resolvers.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/restarts/time_finders.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/restorers/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/restorers/balance.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/restorers/factory.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/restorers/interfaces.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/restorers/position.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/restorers/signal.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/restorers/state.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/restorers/utils.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/state/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/state/dummy.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/state/redis.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/state/runtime_info.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/state/safe.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/ta/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/ta/indicators.pxd +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/ta/indicators.pyi +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/ta/indicators.pyx +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/base.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/project/accounts.toml.j2 +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/project/config.yml.j2 +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/project/jlive.sh.j2 +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/project/jpaper.sh.j2 +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/project/pyproject.toml.j2 +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/project/src/{{ strategy_name }}/__init__.py.j2 +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/project/src/{{ strategy_name }}/strategy.py.j2 +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/project/template.yml +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/repo/.claude/skills/qubx-cli/SKILL.md +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/repo/.claude/skills/qubx-indicators/SKILL.md +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/repo/.claude/skills/simulation-explorer/SKILL.md +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/repo/.claude/skills/strategy-release/SKILL.md +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/repo/.github/workflows/ci.yml.j2 +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/repo/.gitignore.j2 +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/repo/.python-version +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/repo/.vscode/launch.json +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/repo/.vscode/settings.json +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/repo/.vscode/tasks.json +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/repo/CLAUDE.md.j2 +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/repo/README.md.j2 +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/repo/configs/.gitkeep +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/repo/justfile.j2 +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/repo/pyproject.toml.j2 +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/repo/research/.gitkeep +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/repo/src/{{ strategy_name }}/__init__.py.j2 +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/repo/src/{{ strategy_name }}/cli.py.j2 +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/repo/src/{{ strategy_name }}/strategy.py.j2 +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/repo/template.yml +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/repo/tests/test_strategy.py.j2 +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/simple/__init__.py.j2 +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/simple/accounts.toml.j2 +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/simple/config.yml.j2 +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/simple/jlive.sh.j2 +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/simple/jpaper.sh.j2 +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/simple/strategy.py.j2 +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/templates/simple/template.yml +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/trackers/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/trackers/advanced.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/trackers/composite.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/trackers/rebalancers.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/trackers/riskctrl.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/trackers/sizers.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/_pyxreloader.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/charting/lookinglass.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/charting/mpl_helpers.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/charting/orderbook.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/clock.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/collections.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/hft/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/hft/numba_utils.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/hft/orderbook.pyi +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/hft/orderbook.pyx +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/marketdata/binance.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/marketdata/ccxt.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/marketdata/dukas.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/misc.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/nonce.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/numbers_utils.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/orderbook.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/plotting/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/plotting/dashboard.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/plotting/data.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/plotting/interfaces.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/plotting/renderers/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/plotting/renderers/plotly.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/questdb.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/rate_limiter.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/results.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/ringbuffer.pxd +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/ringbuffer.pyi +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/ringbuffer.pyx +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/runner/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/runner/_jupyter_runner.pyt +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/runner/accounts.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/runner/configs.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/runner/factory.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/runner/kernel_service.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/runner/runner.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/runner/textual/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/runner/textual/app.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/runner/textual/handlers.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/runner/textual/init_code.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/runner/textual/kernel.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/runner/textual/styles.tcss +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/runner/textual/widgets/__init__.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/runner/textual/widgets/account_summary.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/runner/textual/widgets/command_input.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/runner/textual/widgets/debug_log.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/runner/textual/widgets/log_filter.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/runner/textual/widgets/orders_table.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/runner/textual/widgets/positions_table.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/runner/textual/widgets/quotes_table.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/runner/textual/widgets/repl_output.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/s3.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/slack.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/threading.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/throttler.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/time.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/src/qubx/utils/websocket_manager.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/tests/strategies/macd_crossover/src/macd_crossover/indicators/macd.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/tests/strategies/macd_crossover/src/macd_crossover/models/macd_crossover.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/tests/strategies/macd_crossover/src/macd_crossover/models/utils.py +0 -0
- {qubx-3.17.3.dev1 → qubx-3.17.3.dev3}/tests/strategies/obi_trader/src/obi_trader/models/obi_trader.py +0 -0
|
@@ -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.3.
|
|
22
|
-
__version_tuple__ = version_tuple = (3, 17, 3, '
|
|
21
|
+
__version__ = version = '3.17.3.dev3'
|
|
22
|
+
__version_tuple__ = version_tuple = (3, 17, 3, 'dev3')
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
|
@@ -97,6 +97,7 @@ from .utils import (
|
|
|
97
97
|
ccxt_convert_positions,
|
|
98
98
|
ccxt_extract_deals_from_exec,
|
|
99
99
|
ccxt_extract_leverage_settings,
|
|
100
|
+
ccxt_extract_margin_modes,
|
|
100
101
|
ccxt_find_instrument,
|
|
101
102
|
info_float,
|
|
102
103
|
instrument_to_ccxt_symbol,
|
|
@@ -131,6 +132,7 @@ class _LeverageInfo:
|
|
|
131
132
|
configured: float | None
|
|
132
133
|
maximum: int | None
|
|
133
134
|
max_notional: float | None = None
|
|
135
|
+
margin_mode: str | None = None
|
|
134
136
|
|
|
135
137
|
|
|
136
138
|
_VENUE_VERDICT_ERRORS: tuple[type[Exception], ...] = (
|
|
@@ -909,16 +911,18 @@ class CcxtConnector(ChannelEmitter):
|
|
|
909
911
|
return
|
|
910
912
|
# - adopt what we just set, so the next call for the same value is skipped without
|
|
911
913
|
# waiting for the poller; the poller corrects it if the venue disagrees
|
|
912
|
-
cached = self._leverage_cache.get(symbol)
|
|
913
914
|
# The cap belongs to the bracket we just left, so the new one is read here rather than
|
|
914
915
|
# carried or dropped: dropping left the position reading null for up to an hour, until
|
|
915
916
|
# the sweep — a snapshot only copies a cap across when the Differ flags that position
|
|
916
917
|
# for a size or margin change, which a leverage edit does not cause.
|
|
917
|
-
max_notional = await self.
|
|
918
|
+
max_notional, margin_mode = await self._read_leverage_row(symbol)
|
|
919
|
+
# read after the await: an hourly sweep landing inside it must not be rolled back here
|
|
920
|
+
cached = self._leverage_cache.get(symbol)
|
|
918
921
|
self._leverage_cache[symbol] = _LeverageInfo(
|
|
919
922
|
configured=leverage,
|
|
920
923
|
maximum=cached.maximum if cached is not None else None,
|
|
921
924
|
max_notional=max_notional,
|
|
925
|
+
margin_mode=margin_mode or (cached.margin_mode if cached is not None else None),
|
|
922
926
|
)
|
|
923
927
|
# the cache is private to the connector; the Position is what every reader sees, and
|
|
924
928
|
# only the snapshot writes it — so announce the ack rather than wait for one
|
|
@@ -928,21 +932,22 @@ class CcxtConnector(ChannelEmitter):
|
|
|
928
932
|
)
|
|
929
933
|
)
|
|
930
934
|
|
|
931
|
-
async def
|
|
932
|
-
"""One symbol's notional cap at its current leverage, from symbolConfig.
|
|
935
|
+
async def _read_leverage_row(self, symbol: str) -> tuple[float | None, str | None]:
|
|
936
|
+
"""One symbol's notional cap at its current leverage, and its margin mode, from symbolConfig.
|
|
933
937
|
|
|
934
|
-
None on any failure — and on a venue without the endpoint — which the AM reads
|
|
935
|
-
known", clearing the stale value rather than keeping a cap from the wrong bracket.
|
|
938
|
+
The cap is None on any failure — and on a venue without the endpoint — which the AM reads
|
|
939
|
+
as "not known", clearing the stale value rather than keeping a cap from the wrong bracket.
|
|
936
940
|
"""
|
|
937
941
|
if not self._em.exchange.has.get("fetchLeverages"):
|
|
938
|
-
return None
|
|
942
|
+
return None, None
|
|
939
943
|
try:
|
|
940
944
|
rows = await self._em.exchange.fetch_leverages([symbol])
|
|
941
945
|
except Exception as e: # noqa: BLE001 — the ack itself already landed
|
|
942
946
|
logger.warning(f"[{self.exchange_name}] cap read for {symbol} after the leverage ack: {e}")
|
|
943
|
-
return None
|
|
944
|
-
|
|
945
|
-
|
|
947
|
+
return None, None
|
|
948
|
+
leverage_rows = list(rows.values()) if isinstance(rows, dict) else rows
|
|
949
|
+
settings = ccxt_extract_leverage_settings(leverage_rows)
|
|
950
|
+
return settings.get(symbol, (None, None))[1], ccxt_extract_margin_modes(leverage_rows).get(symbol)
|
|
946
951
|
|
|
947
952
|
def _start_leverage_poller(self) -> None:
|
|
948
953
|
if self._leverage_future is None or self._leverage_future.done():
|
|
@@ -976,6 +981,7 @@ class CcxtConnector(ChannelEmitter):
|
|
|
976
981
|
configured: dict[str, float] = {}
|
|
977
982
|
notionals: dict[str, float] = {}
|
|
978
983
|
maxima: dict[str, float] = {}
|
|
984
|
+
modes: dict[str, str] = {}
|
|
979
985
|
configured_read = True
|
|
980
986
|
# - annotated locals: ccxt's BASE Exchange declares both methods as an unconditional
|
|
981
987
|
# `raise NotSupported`, so their inferred return type is NoReturn. Only the venue
|
|
@@ -983,12 +989,14 @@ class CcxtConnector(ChannelEmitter):
|
|
|
983
989
|
# override does raise, and the except below is what handles it.
|
|
984
990
|
try:
|
|
985
991
|
rows: dict[str, Any] = await ex.fetch_leverages()
|
|
986
|
-
|
|
992
|
+
leverage_rows = list(rows.values()) if isinstance(rows, dict) else rows
|
|
993
|
+
settings = ccxt_extract_leverage_settings(leverage_rows)
|
|
987
994
|
for symbol, (leverage, max_notional) in settings.items():
|
|
988
995
|
if leverage is not None:
|
|
989
996
|
configured[symbol] = int(leverage)
|
|
990
997
|
if max_notional is not None:
|
|
991
998
|
notionals[symbol] = max_notional
|
|
999
|
+
modes = ccxt_extract_margin_modes(leverage_rows)
|
|
992
1000
|
except Exception as e: # noqa: BLE001
|
|
993
1001
|
configured_read = False
|
|
994
1002
|
logger.debug(f"[{self.exchange_name}] configured-leverage read failed: {type(e).__name__}: {e}")
|
|
@@ -1028,8 +1036,9 @@ class CcxtConnector(ChannelEmitter):
|
|
|
1028
1036
|
configured=configured.get(symbol),
|
|
1029
1037
|
maximum=maxima.get(symbol),
|
|
1030
1038
|
max_notional=notionals.get(symbol),
|
|
1039
|
+
margin_mode=modes.get(symbol),
|
|
1031
1040
|
)
|
|
1032
|
-
for symbol in configured.keys() | maxima.keys() | notionals.keys()
|
|
1041
|
+
for symbol in configured.keys() | maxima.keys() | notionals.keys() | modes.keys()
|
|
1033
1042
|
}
|
|
1034
1043
|
if configured_read:
|
|
1035
1044
|
# rebuilt wholesale, so a symbol the venue stopped reporting leaves the cache with it
|
|
@@ -1038,11 +1047,16 @@ class CcxtConnector(ChannelEmitter):
|
|
|
1038
1047
|
# The `configured` read failed (bybit has no fetch_leverages), so this sweep cannot
|
|
1039
1048
|
# speak for it: a wholesale rebuild would erase what the write path adopted and evict
|
|
1040
1049
|
# every symbol the tier read left out — on bybit, everything past its pagination cap.
|
|
1041
|
-
# max_notional
|
|
1050
|
+
# max_notional and margin_mode ride the same failed read, so they are preserved too.
|
|
1042
1051
|
for symbol, info in rebuilt.items():
|
|
1043
1052
|
held = self._leverage_cache.get(symbol)
|
|
1044
1053
|
self._leverage_cache[symbol] = (
|
|
1045
|
-
replace(
|
|
1054
|
+
replace(
|
|
1055
|
+
info,
|
|
1056
|
+
configured=held.configured,
|
|
1057
|
+
max_notional=held.max_notional,
|
|
1058
|
+
margin_mode=held.margin_mode,
|
|
1059
|
+
)
|
|
1046
1060
|
if held is not None
|
|
1047
1061
|
else info
|
|
1048
1062
|
)
|
|
@@ -1256,8 +1270,10 @@ class CcxtConnector(ChannelEmitter):
|
|
|
1256
1270
|
return cached.max_notional if cached is not None and cached.max_notional is not None else float("inf")
|
|
1257
1271
|
|
|
1258
1272
|
def get_margin_mode(self, instrument: Instrument) -> str | None:
|
|
1259
|
-
|
|
1260
|
-
|
|
1273
|
+
"""Cache-only, like the leverage getters; the sweep fills it from symbolConfig, which
|
|
1274
|
+
covers flat symbols."""
|
|
1275
|
+
cached = self._leverage_cache.get(instrument_to_ccxt_symbol(instrument))
|
|
1276
|
+
return cached.margin_mode if cached is not None else None
|
|
1261
1277
|
|
|
1262
1278
|
def get_adl_level(self, instrument: Instrument) -> int | None:
|
|
1263
1279
|
row = self._fetch_position_row(instrument)
|
|
@@ -1947,10 +1963,10 @@ class CcxtConnector(ChannelEmitter):
|
|
|
1947
1963
|
|
|
1948
1964
|
include_orders=True -> open orders + algo/trigger orders + positions + balances (startup
|
|
1949
1965
|
discovery + periodic sweep). include_orders=False -> positions + balances ONLY (steady
|
|
1950
|
-
state): the open-orders / algo legs carry
|
|
1951
|
-
|
|
1952
|
-
(open_orders=None -> reconcile leaves order state untouched; orders
|
|
1953
|
-
stream + the periodic full sweep).
|
|
1966
|
+
state): the open-orders / algo legs carry the highest REST weight, and with Qubx rate
|
|
1967
|
+
limiting off they share ccxt's serialised throttler with order placement — so steady
|
|
1968
|
+
snapshots skip them (open_orders=None -> reconcile leaves order state untouched; orders
|
|
1969
|
+
are tracked via the WS stream + the periodic full sweep).
|
|
1954
1970
|
|
|
1955
1971
|
Reconcile applies a snapshot as authoritative, so a leg that failed to fetch skips the
|
|
1956
1972
|
emit entirely and the AM asks again on its next tick. A single row that will not convert
|
|
@@ -65,6 +65,8 @@ class BybitF(CcxtFuturePatchMixin, cxp.bybit):
|
|
|
65
65
|
},
|
|
66
66
|
"options": {
|
|
67
67
|
"fetchOrder": {"acknowledged": True},
|
|
68
|
+
# matches ccxt's 10s HTTP timeout: requests are signed before the socket opens
|
|
69
|
+
"recvWindow": 10 * 1000,
|
|
68
70
|
# caps the cursor walk armed by params={"paginate": True}; read by the
|
|
69
71
|
# pagination driver only, so it cannot re-arm on the recursive call
|
|
70
72
|
"fetchOpenOrders": {"paginationCalls": 20},
|
|
@@ -56,45 +56,46 @@ class BybitCcxtConnector(_TwoStreamCcxtConnector):
|
|
|
56
56
|
ccxt's ``bybit.parse_position`` hardcodes ``marginMode: None``; the symbol only feeds
|
|
57
57
|
``safe_symbol``, so any held instrument answers for all of them.
|
|
58
58
|
|
|
59
|
-
Served from the cache once
|
|
60
|
-
placement, and ``set_margin_mode`` drops the cache when the value can have changed.
|
|
59
|
+
Served from the cache once warm; the hourly sweep re-reads it.
|
|
61
60
|
"""
|
|
62
61
|
if not positions:
|
|
63
62
|
return
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
if self._margin_mode is None:
|
|
64
|
+
try:
|
|
65
|
+
self._margin_mode = await self._read_margin_mode(instrument_to_ccxt_symbol(positions[0].instrument))
|
|
66
|
+
except Exception as e: # noqa: BLE001
|
|
67
|
+
logger.debug(f"[{self.exchange_name}] fetch_margin_mode: {e}")
|
|
68
|
+
return
|
|
69
|
+
if self._margin_mode is None:
|
|
66
70
|
return
|
|
67
|
-
self._margin_mode = mode
|
|
68
71
|
for pos in positions:
|
|
69
|
-
pos.margin_mode =
|
|
72
|
+
pos.margin_mode = self._margin_mode
|
|
70
73
|
|
|
71
74
|
async def _read_margin_mode(self, symbol: str) -> Literal["cross", "isolated"] | None:
|
|
72
|
-
"""PORTFOLIO_MARGIN has no framework equivalent and normalizes to None.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
except Exception as e: # noqa: BLE001
|
|
76
|
-
logger.debug(f"[{self.exchange_name}] fetch_margin_mode for {symbol}: {e}")
|
|
77
|
-
return None
|
|
75
|
+
"""PORTFOLIO_MARGIN has no framework equivalent and normalizes to None. Raises on a
|
|
76
|
+
venue error, which a caller must not confuse with that None."""
|
|
77
|
+
row = await self._em.exchange.fetch_margin_mode(symbol)
|
|
78
78
|
return normalize_margin_mode(row.get("marginMode"))
|
|
79
79
|
|
|
80
|
+
async def _refresh_leverage_cache(self) -> None:
|
|
81
|
+
await super()._refresh_leverage_cache()
|
|
82
|
+
# changeable from the venue UI; nothing else invalidates it
|
|
83
|
+
symbol = next(iter(self._leverage_cache), None) or next(iter(self._symbol_to_instrument), None)
|
|
84
|
+
if symbol is None:
|
|
85
|
+
return
|
|
86
|
+
try:
|
|
87
|
+
self._margin_mode = await self._read_margin_mode(symbol)
|
|
88
|
+
except Exception as e: # noqa: BLE001 — keep the cached mode rather than blanking it
|
|
89
|
+
logger.debug(f"[{self.exchange_name}] margin mode re-read: {e}")
|
|
90
|
+
|
|
80
91
|
def set_margin_mode(self, instrument: Instrument, mode: str) -> bool:
|
|
81
|
-
"""
|
|
92
|
+
"""Adopt the written value; the getter is cache-only."""
|
|
82
93
|
ok = super().set_margin_mode(instrument, mode)
|
|
83
94
|
if ok:
|
|
84
|
-
self._margin_mode =
|
|
95
|
+
self._margin_mode = normalize_margin_mode(mode)
|
|
85
96
|
return ok
|
|
86
97
|
|
|
87
98
|
def get_margin_mode(self, instrument: Instrument) -> str | None:
|
|
88
|
-
"""Serve what the snapshot cached; a cold cache costs one REST hop on the strategy
|
|
89
|
-
thread, every later call a field read. Never raises at the caller: a venue read that
|
|
90
|
-
fails or times out reports None, as the base connector's does."""
|
|
91
|
-
if self._margin_mode is not None:
|
|
92
|
-
return self._margin_mode
|
|
93
|
-
try:
|
|
94
|
-
self._margin_mode = self._run_sync(self._read_margin_mode(instrument_to_ccxt_symbol(instrument)))
|
|
95
|
-
except Exception as e: # noqa: BLE001
|
|
96
|
-
logger.debug(f"[{self.exchange_name}] margin mode read for {instrument.symbol}: {e}")
|
|
97
|
-
return None
|
|
98
99
|
return self._margin_mode
|
|
99
100
|
|
|
100
101
|
def _extract_venue_figures(
|
|
@@ -14,6 +14,7 @@ from qubx.core.exceptions import NotSupported
|
|
|
14
14
|
from qubx.core.series import Bar, Quote
|
|
15
15
|
from qubx.utils.time import to_timedelta
|
|
16
16
|
|
|
17
|
+
from ..rate_limits import retryable_fetch
|
|
17
18
|
from ..subscription_config import SubscriptionConfiguration
|
|
18
19
|
from ..utils import ccxt_find_instrument, create_market_type_batched_subscriber, instrument_to_ccxt_symbol
|
|
19
20
|
from .base import BaseDataTypeHandler
|
|
@@ -31,6 +32,23 @@ class OhlcDataHandler(BaseDataTypeHandler):
|
|
|
31
32
|
def data_type(self) -> str:
|
|
32
33
|
return "ohlc"
|
|
33
34
|
|
|
35
|
+
async def _fetch_ohlcv_page(self, symbol: str, timeframe: str, since: int, limit: int) -> list:
|
|
36
|
+
"""One kline page, retried once on a venue refusal.
|
|
37
|
+
|
|
38
|
+
The retry is paced by the gate the reported hit closes, so it is only armed when a
|
|
39
|
+
limiter is attached — an unpaced re-send is worse than none on a venue already
|
|
40
|
+
refusing. One attempt, not the helper's default five: ``get_ohlc`` blocks the caller
|
|
41
|
+
on a 60s future, which five gate waits would blow.
|
|
42
|
+
"""
|
|
43
|
+
limiter = self._exchange_manager.rate_limiter
|
|
44
|
+
return await retryable_fetch(
|
|
45
|
+
# read the exchange late: a one-shot REST path must follow a recreation
|
|
46
|
+
lambda: self._exchange_manager.exchange.fetch_ohlcv(symbol, timeframe, since=since, limit=limit),
|
|
47
|
+
rate_limiter=limiter,
|
|
48
|
+
max_attempts=2 if limiter is not None else 1,
|
|
49
|
+
context=f"{self._exchange_id} {symbol} {timeframe}",
|
|
50
|
+
)
|
|
51
|
+
|
|
34
52
|
def prepare_subscription(
|
|
35
53
|
self,
|
|
36
54
|
name: str,
|
|
@@ -107,11 +125,11 @@ class OhlcDataHandler(BaseDataTypeHandler):
|
|
|
107
125
|
# Paginate: exchanges may return fewer bars than requested per call
|
|
108
126
|
ohlcv_map: dict[int, list] = {}
|
|
109
127
|
while len(ohlcv_map) < nbarsback:
|
|
110
|
-
batch = await self.
|
|
128
|
+
batch = await self._fetch_ohlcv_page(
|
|
111
129
|
ccxt_symbol,
|
|
112
130
|
exch_timeframe,
|
|
113
|
-
|
|
114
|
-
|
|
131
|
+
start_since,
|
|
132
|
+
min(nbarsback - len(ohlcv_map), self.MAX_BARS_PER_REQUEST_FOR_PROVIDER) + 1,
|
|
115
133
|
)
|
|
116
134
|
if not batch:
|
|
117
135
|
break
|
|
@@ -176,8 +194,8 @@ class OhlcDataHandler(BaseDataTypeHandler):
|
|
|
176
194
|
while len(loaded_bars) < nbarsback:
|
|
177
195
|
bars_to_request = min((nbarsback - len(loaded_bars)), self.MAX_BARS_PER_REQUEST_FOR_PROVIDER)
|
|
178
196
|
if not (
|
|
179
|
-
ohlcv_data := await self.
|
|
180
|
-
ccxt_symbol, exch_timeframe,
|
|
197
|
+
ohlcv_data := await self._fetch_ohlcv_page(
|
|
198
|
+
ccxt_symbol, exch_timeframe, start_since, bars_to_request + 1
|
|
181
199
|
)
|
|
182
200
|
):
|
|
183
201
|
break
|
|
@@ -16,8 +16,14 @@ References:
|
|
|
16
16
|
- Bybit: https://bybit-exchange.github.io/docs/v5/rate-limit
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
|
+
import asyncio
|
|
20
|
+
import random
|
|
21
|
+
from collections.abc import Awaitable, Callable
|
|
22
|
+
from typing import Any
|
|
19
23
|
from weakref import WeakKeyDictionary
|
|
20
24
|
|
|
25
|
+
import ccxt
|
|
26
|
+
|
|
21
27
|
from qubx import logger
|
|
22
28
|
from qubx.rate_limiting import EndpointCosts, ExchangeRateLimitConfig, PoolConfig
|
|
23
29
|
|
|
@@ -429,3 +435,80 @@ def install_rate_limiter_hooks(exchange, rate_limiter, label: str = "") -> None:
|
|
|
429
435
|
return original_on_rest(code, reason, url, method, headers, body, req_headers, req_body)
|
|
430
436
|
|
|
431
437
|
exchange.on_rest_response = _header_sync_hook
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
_T = Any # explicit alias keeps the retry helper signature readable
|
|
441
|
+
|
|
442
|
+
# retry defaults — conservative. tuned for warmup OHLCV bursts where transient
|
|
443
|
+
# RateLimitExceeded / NetworkError are the dominant failure modes (see #264).
|
|
444
|
+
_RETRY_MAX_ATTEMPTS = 5
|
|
445
|
+
_RETRY_BASE_DELAY_S = 1.0
|
|
446
|
+
_RETRY_MAX_DELAY_S = 30.0
|
|
447
|
+
_RETRY_JITTER_S = 1.0
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
async def retryable_fetch(
|
|
451
|
+
call: Callable[[], Awaitable[_T]],
|
|
452
|
+
*,
|
|
453
|
+
rate_limiter: Any = None,
|
|
454
|
+
rate_limit_pool: str = "ccxt_rest",
|
|
455
|
+
max_attempts: int = _RETRY_MAX_ATTEMPTS,
|
|
456
|
+
base_delay: float = _RETRY_BASE_DELAY_S,
|
|
457
|
+
max_delay: float = _RETRY_MAX_DELAY_S,
|
|
458
|
+
jitter: float = _RETRY_JITTER_S,
|
|
459
|
+
context: str = "",
|
|
460
|
+
sleep: Callable[[float], Awaitable[None]] = asyncio.sleep,
|
|
461
|
+
) -> _T:
|
|
462
|
+
"""
|
|
463
|
+
Invoke ``call()`` with exponential backoff + jitter on transient CCXT errors.
|
|
464
|
+
|
|
465
|
+
Retryable errors:
|
|
466
|
+
* ``ccxt.RateLimitExceeded`` — exchange-level 429 / OKX 50011.
|
|
467
|
+
* ``ccxt.NetworkError`` (parent; also covers ``ExchangeNotAvailable``
|
|
468
|
+
and ``OnMaintenance``).
|
|
469
|
+
* ``asyncio.TimeoutError``.
|
|
470
|
+
|
|
471
|
+
Everything else (``ccxt.ExchangeError`` and subclasses like ``BadSymbol``,
|
|
472
|
+
``AuthenticationError``, plus any non-CCXT exception) is re-raised
|
|
473
|
+
immediately — permanent errors should not consume retry budget.
|
|
474
|
+
|
|
475
|
+
Budget is acquired inside CCXT's own pipeline by the throttle hook, not here; this function only
|
|
476
|
+
reports ``RateLimitExceeded`` back so the pool's gate closes for ``cooldown`` seconds.
|
|
477
|
+
|
|
478
|
+
Args:
|
|
479
|
+
call: Zero-arg callable returning the coroutine to invoke.
|
|
480
|
+
rate_limiter: Optional ``ExchangeRateLimiter``; if provided, rate-limit
|
|
481
|
+
hits are reported back to it.
|
|
482
|
+
rate_limit_pool: Pool whose gate is closed on ``RateLimitExceeded``.
|
|
483
|
+
max_attempts: Total attempts including the initial one.
|
|
484
|
+
base_delay: First retry delay in seconds; doubles each attempt.
|
|
485
|
+
max_delay: Cap on the exponential delay.
|
|
486
|
+
jitter: Uniform jitter (0..jitter) added to each delay.
|
|
487
|
+
context: Short human label included in log lines (e.g. ``"OKX BTCUSDT"``).
|
|
488
|
+
sleep: Async sleep function (injectable for tests).
|
|
489
|
+
|
|
490
|
+
Raises:
|
|
491
|
+
The last retryable exception once ``max_attempts`` is exhausted.
|
|
492
|
+
"""
|
|
493
|
+
last_exc: BaseException | None = None
|
|
494
|
+
for attempt in range(1, max_attempts + 1):
|
|
495
|
+
try:
|
|
496
|
+
return await call()
|
|
497
|
+
except (ccxt.NetworkError, asyncio.TimeoutError) as e:
|
|
498
|
+
last_exc = e
|
|
499
|
+
if isinstance(e, ccxt.RateLimitExceeded) and rate_limiter is not None:
|
|
500
|
+
rate_limiter.report_limit_hit(
|
|
501
|
+
pool_name=rate_limit_pool,
|
|
502
|
+
reason=(f"{context}: " if context else "") + str(e)[:120],
|
|
503
|
+
)
|
|
504
|
+
if attempt >= max_attempts:
|
|
505
|
+
break
|
|
506
|
+
delay = min(base_delay * (2 ** (attempt - 1)), max_delay) + random.uniform(0, jitter)
|
|
507
|
+
logger.warning(
|
|
508
|
+
f"[CCXT] transient error on {context or 'fetch'} "
|
|
509
|
+
f"(attempt {attempt}/{max_attempts}): {type(e).__name__}: {e}; "
|
|
510
|
+
f"retrying in {delay:.2f}s"
|
|
511
|
+
)
|
|
512
|
+
await sleep(delay)
|
|
513
|
+
assert last_exc is not None # unreachable: the loop always raises or returns
|
|
514
|
+
raise last_exc
|
|
@@ -392,6 +392,20 @@ def ccxt_extract_leverage_settings(rows: list[dict] | None) -> dict[str, tuple[f
|
|
|
392
392
|
return out
|
|
393
393
|
|
|
394
394
|
|
|
395
|
+
def ccxt_extract_margin_modes(rows: list[dict] | None) -> dict[str, str]:
|
|
396
|
+
"""Map ccxt symbol -> margin mode from ``fetch_leverages`` rows.
|
|
397
|
+
|
|
398
|
+
symbolConfig reports it for every symbol; positionRisk omits flat ones.
|
|
399
|
+
"""
|
|
400
|
+
out: dict[str, str] = {}
|
|
401
|
+
for row in rows or []:
|
|
402
|
+
symbol = row.get("symbol")
|
|
403
|
+
mode = normalize_margin_mode(row.get("marginMode"))
|
|
404
|
+
if symbol and mode is not None:
|
|
405
|
+
out[symbol] = mode
|
|
406
|
+
return out
|
|
407
|
+
|
|
408
|
+
|
|
395
409
|
def ccxt_convert_orderbook(
|
|
396
410
|
ob: dict,
|
|
397
411
|
instr: Instrument,
|
|
@@ -477,7 +477,13 @@ class AccountState:
|
|
|
477
477
|
)
|
|
478
478
|
return True
|
|
479
479
|
|
|
480
|
-
|
|
480
|
+
# half-lot / half-tick like the Differ: n * lot_size is not always the double the
|
|
481
|
+
# venue's decimal parses to
|
|
482
|
+
inst = snapshot.instrument
|
|
483
|
+
changed = (
|
|
484
|
+
abs(existing.quantity - snapshot.quantity) > inst.lot_size * 0.5
|
|
485
|
+
or abs(existing.position_avg_price - snapshot.position_avg_price) > inst.tick_size * 0.5
|
|
486
|
+
)
|
|
481
487
|
if changed:
|
|
482
488
|
logger.info(
|
|
483
489
|
f"[{self.exchange}] reconcile: position <y>{snapshot.instrument}</y> from snapshot -> "
|
|
@@ -328,6 +328,25 @@ class MarketType(StrEnum):
|
|
|
328
328
|
INDEX = "INDEX"
|
|
329
329
|
|
|
330
330
|
|
|
331
|
+
# fixed multiplier set, not any digit run (1INCH, 10Y, KODEX200 survive); the lookahead rejects
|
|
332
|
+
# a bare "1000", which would otherwise strip to ""
|
|
333
|
+
_MULTIPLIER_PREFIX = re.compile(r"^1(0{3,7})(?=[A-Z])")
|
|
334
|
+
_MULTIPLIER_SUFFIX = re.compile(r"^(.+[A-Z])1000$")
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
def multiplier_coin(base: str) -> str:
|
|
338
|
+
"""The coin under a multiplier contract: 1000PEPE, 10000SATS, SHIB1000 -> PEPE, SATS, SHIB.
|
|
339
|
+
|
|
340
|
+
The multiplier itself is not recoverable from the result, so this names the coin, never a
|
|
341
|
+
tradeable unit: 1000PEPE and 10000PEPE both answer PEPE.
|
|
342
|
+
"""
|
|
343
|
+
if m := _MULTIPLIER_PREFIX.match(base):
|
|
344
|
+
return base[m.end() :]
|
|
345
|
+
if m := _MULTIPLIER_SUFFIX.match(base):
|
|
346
|
+
return m.group(1)
|
|
347
|
+
return base
|
|
348
|
+
|
|
349
|
+
|
|
331
350
|
@dataclass(order=True)
|
|
332
351
|
class Instrument:
|
|
333
352
|
"""
|
|
@@ -382,12 +401,7 @@ class Instrument:
|
|
|
382
401
|
|
|
383
402
|
@property
|
|
384
403
|
def asset(self) -> str:
|
|
385
|
-
|
|
386
|
-
return self.base.replace("1000", "")
|
|
387
|
-
elif self.base.startswith("1000000"):
|
|
388
|
-
return self.base.replace("1000000", "")
|
|
389
|
-
else:
|
|
390
|
-
return self.base
|
|
404
|
+
return multiplier_coin(self.base)
|
|
391
405
|
|
|
392
406
|
def is_futures(self) -> bool:
|
|
393
407
|
return self.market_type in [MarketType.FUTURE, MarketType.SWAP]
|
|
@@ -1984,13 +1998,11 @@ class InstrumentsLookup:
|
|
|
1984
1998
|
- as_of is a string in format YYYY-MM-DD or pd.Timestamp or None
|
|
1985
1999
|
"""
|
|
1986
2000
|
_limit_time = pd.Timestamp(as_of) if as_of else None
|
|
1987
|
-
|
|
2001
|
+
matched = [
|
|
1988
2002
|
i
|
|
1989
2003
|
for i in self.get_lookup().values()
|
|
1990
2004
|
if i.exchange == exchange
|
|
1991
|
-
and (
|
|
1992
|
-
base is None or (i.base == base or i.base == f"1000{base}")
|
|
1993
|
-
) # this is a hack to support 1000DOGEUSDT and others
|
|
2005
|
+
and (base is None or i.base == base or multiplier_coin(i.base) == base)
|
|
1994
2006
|
and (quote is None or i.quote == quote)
|
|
1995
2007
|
and (market_type is None or i.market_type == market_type)
|
|
1996
2008
|
and (
|
|
@@ -2002,6 +2014,15 @@ class InstrumentsLookup:
|
|
|
2002
2014
|
or (i.delist_date is None or pd.Timestamp(i.delist_date).tz_localize(None) >= _limit_time)
|
|
2003
2015
|
)
|
|
2004
2016
|
]
|
|
2017
|
+
if base is not None:
|
|
2018
|
+
aliases = sorted({i.base for i in matched} - {base})
|
|
2019
|
+
if aliases and any(i.base == base for i in matched):
|
|
2020
|
+
logger.warning(
|
|
2021
|
+
f"[lookup] {exchange} base <y>{base}</y> also matches {aliases} through a contract "
|
|
2022
|
+
f"multiplier; the exact base is listed first — pass the venue base to disambiguate"
|
|
2023
|
+
)
|
|
2024
|
+
matched.sort(key=lambda i: i.base != base)
|
|
2025
|
+
return matched
|
|
2005
2026
|
|
|
2006
2027
|
def find_aux_instrument_for(
|
|
2007
2028
|
self, instrument: Instrument, base_currency: str, market_type: MarketType | None = None
|
|
@@ -1486,25 +1486,33 @@ class ProcessingManager(IProcessingManager):
|
|
|
1486
1486
|
_fit_is_running. Returning None hands control to
|
|
1487
1487
|
_run_strategy_pipeline, which processes the drained signals immediately.
|
|
1488
1488
|
"""
|
|
1489
|
+
# A raised op leaves the mutation it was replaying half-applied — set_universe adds the
|
|
1490
|
+
# subscriptions before on_universe_change, so a failure there subscribes the instruments
|
|
1491
|
+
# but never updates ctx.instruments. Latching success on that trades a stale universe
|
|
1492
|
+
# until the next fit, so a replay failure fails the fit.
|
|
1493
|
+
replay_error: BaseException | None = None
|
|
1489
1494
|
try:
|
|
1490
1495
|
for op in commit.ops:
|
|
1491
1496
|
try:
|
|
1492
1497
|
op()
|
|
1493
1498
|
except Exception as op_error:
|
|
1499
|
+
replay_error = replay_error or op_error
|
|
1494
1500
|
logger.error(f"[{self.__class__.__name__}] :: deferred fit operation failed: {op_error}")
|
|
1495
1501
|
logger.opt(colors=False).error(traceback.format_exc())
|
|
1496
1502
|
try:
|
|
1497
1503
|
self._subscription_manager.commit() # apply pending operations (mirrors __invoke_on_fit)
|
|
1498
1504
|
except Exception as commit_error:
|
|
1505
|
+
replay_error = replay_error or commit_error
|
|
1499
1506
|
logger.error(f"[{self.__class__.__name__}] :: post-fit subscription commit failed: {commit_error}")
|
|
1500
1507
|
logger.opt(colors=False).error(traceback.format_exc())
|
|
1501
1508
|
finally:
|
|
1502
1509
|
if commit.signals:
|
|
1503
1510
|
self._emitted_signals.extend(commit.signals)
|
|
1504
|
-
|
|
1511
|
+
failed = commit.error is not None or replay_error is not None
|
|
1512
|
+
if not failed:
|
|
1505
1513
|
self._context._strategy_state.is_on_fit_called = True
|
|
1506
1514
|
self._fit_is_running = False
|
|
1507
|
-
self._report_boot_fit(
|
|
1515
|
+
self._report_boot_fit(not failed)
|
|
1508
1516
|
|
|
1509
1517
|
def _handle_subscription_swap(self, instrument: Instrument | None, event_type: str, apply_swap: Callable) -> None:
|
|
1510
1518
|
"""Apply a deferred subscription commit's swap on the ProcessorThread. Posted by
|
|
@@ -186,11 +186,13 @@ cpdef double grid_ceil(double a, double step):
|
|
|
186
186
|
return copysign(ceil(_snap_tick_noise(fabs(a) / step)) * step, a)
|
|
187
187
|
|
|
188
188
|
|
|
189
|
-
cpdef double add_in_lots(double quantity, double amount, double lot_size)
|
|
189
|
+
cpdef double add_in_lots(double quantity, double amount, double lot_size):
|
|
190
190
|
"""
|
|
191
191
|
Sum two lot multiples in whole lots, so a subtraction cannot land a few ulp off the grid.
|
|
192
|
+
|
|
193
|
+
Snapped onto the grid: n * lot_size is not always the double the venue's decimal parses to.
|
|
192
194
|
"""
|
|
193
|
-
return (round(quantity / lot_size) + round(amount / lot_size)) * lot_size
|
|
195
|
+
return grid_floor((round(quantity / lot_size) + round(amount / lot_size)) * lot_size, lot_size)
|
|
194
196
|
|
|
195
197
|
|
|
196
198
|
cpdef bint is_lot_multiple(double quantity, double lot_size) noexcept:
|