nautechsystems/nautilus_trader · error
Binance Spot 24-hour ticker custom data requires JSON…
Error message
Binance Spot 24-hour ticker custom data requires JSON market-data mode
What it means
Subscribing to BinanceSpot 24-hour ticker custom data is only supported when the data client runs in JSON market-data mode; the SBE mode does not deliver this custom data type. The client rejects the Subscribe command with anyhow::ensure! before touching the WebSocket.
Solutions
- Configure the Binance Spot data client to use JSON market-data mode (BinanceSpotMarketDataMode::Json) before connecting.
- Or remove/replace the 24-hour ticker subscription with a data type supported in SBE mode.
- Check the adapter factory/config that selects market-data mode and align it with requested data types.
Example fix
// before let config = BinanceDataClientConfig::builder().spot_market_data_mode(BinanceSpotMarketDataMode::Sbe).build(); // after let config = BinanceDataClientConfig::builder().spot_market_data_mode(BinanceSpotMarketDataMode::Json).build();
Defensive patterns
Strategy: validation
Validate before calling
fn ticker_requires_json_mode(mode: BinanceSpotMarketDataMode) -> Result<(), String> {
if mode == BinanceSpotMarketDataMode::Json { Ok(()) } else { Err("24hr ticker requires JSON market-data mode".into()) }
} Try / catch
match client.subscribe(cmd) {
Err(e) if e.to_string().contains("requires JSON market-data mode") => {
log::warn!("restart client in JSON mode or drop ticker subscription");
}
r => r?,
} Prevention
- Align requested custom data types with the configured market-data mode at startup.
- Validate strategy data requirements against adapter capabilities before launching the node.
- Document which data types are SBE-only vs JSON-only for your team.
- Fail fast in config loading if mode and data-type requests conflict.
When it happens
Trigger: Calling subscribe with a custom data type of Binance spot 24hr ticker while spot_market_data_mode == Sbe (e.g. client created in SBE mode, or defaulting to SBE).
Common situations: User requests ticker subscriptions via a strategy or node config but the adapter was launched with SBE market-data mode; switching adapters without updating data-type config.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Binance Spot kline subscriptions require JSON market-data…
- Binance does not support
- Binance Futures supports L1_MBP and L2_MBP order book…
- Binance Futures ticker custom data requires BINANCE venue…
- Binance liquidation custom data requires BINANCE venue…
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/5d88068ec6508cbc.
Report an issue: GitHub.
Appendix: source
Thrown at crates/adapters/binance/src/spot/data.rs:1784
}
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 18893faf8b)