nautechsystems/nautilus_trader · error · anyhow::Error
Binance Spot 24-hour ticker custom data requires JSON market
Error message
Binance Spot 24-hour ticker custom data requires JSON market-data mode
What it means
BinanceSpotTicker (24-hour ticker) custom data subscriptions are implemented only on the JSON public stream; the 24h ticker has no SBE equivalent in this adapter. Subscribing while the Spot data client runs in a non-Json mode fails this hard check. Note the asymmetry: custom types other than BinanceSpotTicker only produce a warning and return Ok, but this one errors.
Source
Thrown at crates/adapters/binance/src/spot/data.rs:1768
}
fn is_connected(&self) -> bool {
self.is_connected.load(Ordering::Relaxed)
}
fn is_disconnected(&self) -> bool {
!self.is_connected()
}
fn subscribe(&mut self, cmd: SubscribeCustomData) -> anyhow::Result<()> {
if cmd.data_type.type_name() != "BinanceSpotTicker" {
log::warn!(
"Unsupported custom data subscription: {}",
cmd.data_type.type_name()
);
return Ok(());
}
anyhow::ensure!(
self.spot_market_data_mode == BinanceSpotMarketDataMode::Json,
"Binance Spot 24-hour ticker custom data requires JSON market-data mode"
);
let instrument_id = Self::required_instrument_id_metadata(&cmd.data_type)?;
anyhow::ensure!(
instrument_id.venue == self.venue(),
"Spot ticker requires a BINANCE instrument"
);
let should_subscribe = {
let previous = self
.ticker_refs
.load()
.get(&instrument_id)
.copied()
.unwrap_or(0);
self.ticker_refs
.rcu(|refs| *refs.entry(instrument_id).or_insert(0) += 1);
previous == 0View on GitHub (pinned to a4b06ed870)
Solutions
- Set spot_market_data_mode to Json in the Binance Spot data client config when you need 24h tickers
- Or remove the BinanceSpotTicker subscription when running SBE mode
Example fix
# before
config = BinanceSpotDataClientConfig(
spot_market_data_mode=BinanceSpotMarketDataMode.SBE,
)
# ... strategy subscribes to BinanceSpotTicker custom data -> error
# after
config = BinanceSpotDataClientConfig(
spot_market_data_mode=BinanceSpotMarketDataMode.JSON,
) Defensive patterns
Strategy: validation
Validate before calling
mode = config.spot_market_data_mode
wants_ticker = any(dt.type_name() == "BinanceSpotTicker" for dt in requested_custom_types)
assert not (wants_ticker and mode != BinanceSpotMarketDataMode.JSON), (
"BinanceSpotTicker requires JSON market-data mode"
) Prevention
- Document per-mode feature support and assert config-vs-subscriptions at startup
- When enabling SBE, audit subscriptions for JSON-only streams (tickers, klines)
When it happens
Trigger: subscribe (SubscribeCustomData) with a DataType whose type_name is 'BinanceSpotTicker' while spot_market_data_mode is not Json (e.g. Sbe).
Common situations: Enabling SBE mode for performance and later adding a 24h-ticker custom data subscription without realizing it is JSON-only; porting a Json-mode strategy config to SBE wholesale.
Related errors
- Binance Spot market data mode SBE requires Ed25519 API crede
- Binance Spot kline subscriptions require JSON market-data mo
- Symbol '{}' is not trading (status: {})
- invalid negative kline trade count {}
- failed to connect Binance Spot SBE WebSocket: {e}
AI-assisted analysis of nautechsystems/nautilus_trader@a4b06ed870 (2026-08-16).
Data as JSON: /api/errors/5d88068ec6508cbc.
Report an issue: GitHub.