nautechsystems/nautilus_trader · error · anyhow::Error

Binance Futures ticker custom data requires BINANCE venue in

Error message

Binance Futures ticker custom data requires BINANCE venue instrument, received {instrument_id}

What it means

subscribe_ticker for BinanceFuturesTicker custom data requires the instrument embedded in the DataType metadata to belong to the client's venue (BINANCE). The guard fires when instrument_id.venue differs from client.venue(), meaning the subscription was routed to the wrong adapter. It is the subscribe-side twin of the identical check in unsubscribe_ticker (data.rs:3191).

Source

Thrown at crates/adapters/binance/src/futures/data.rs:3150

                "{}@bookTicker",
                format_binance_stream_symbol(&instrument_id)
            );
            self.spawn_ws(
                async move {
                    ws.unsubscribe(vec![stream])
                        .await
                        .context("top-of-book unsubscribe")
                },
                "top-of-book unsubscribe",
            );
        }
    }
}

fn subscribe_ticker(client: &BinanceFuturesDataClient, data_type: &DataType) -> anyhow::Result<()> {
    let instrument_id = BinanceFuturesDataClient::required_instrument_id_metadata(data_type)?;
    if instrument_id.venue != client.venue() {
        anyhow::bail!(
            "Binance Futures ticker custom data requires BINANCE venue instrument, received {instrument_id}"
        );
    }

    let should_subscribe = {
        let prev = client
            .ticker_refs
            .load()
            .get(&instrument_id)
            .copied()
            .unwrap_or(0);
        client.ticker_refs.rcu(|m| {
            let count = m.entry(instrument_id).or_insert(0);
            *count += 1;
        });
        prev == 0
    };

View on GitHub (pinned to a4b06ed870)

Solutions

  1. Ensure the instrument id venue matches the client, e.g. BTCUSDT-PERP.BINANCE
  2. Fix the routing configuration so BINANCE-venue custom ticker types reach the Binance Futures client
  3. Subscribe to the ticker on the venue-matching client instead of forcing it onto the Binance futures one

Example fix

// before
let instrument_id = InstrumentId::from_str("BTCUSDT.BYBIT")?;
client.subscribe_data(DataType::new::<BinanceFuturesTicker>(instrument_id.metadata()))?;

// after
let instrument_id = InstrumentId::from_str("BTCUSDT-PERP.BINANCE")?;
client.subscribe_data(DataType::new::<BinanceFuturesTicker>(instrument_id.metadata()))?;
Defensive patterns

Strategy: validation

Validate before calling

use nautilus_model::identifiers::{InstrumentId, Venue};

let instrument_id = InstrumentId::from_str(&cfg_symbol)?;
anyhow::ensure!(
    instrument_id.venue == Venue::new("BINANCE"),
    "wrong routing: {instrument_id} is not a BINANCE instrument"
);
// then subscribe_data for the BinanceFuturesTicker type

Type guard

fn matches_client_venue(instrument_id: &InstrumentId, client_venue: &Venue) -> bool {
    instrument_id.venue == *client_venue
}

Prevention

When it happens

Trigger: Subscribing to a BinanceFuturesTicker DataType whose instrument id is e.g. BTCUSDT.BYBIT or BTCUSDT.OKX while the Binance Futures client handles the call; typically caused by a routing table entry keyed only on data type name, or a venue suffix typo in a config string.

Common situations: Multi-venue nodes where the DataEngine routes custom ticker types without matching venue; instrument ids parsed from user config with the wrong venue suffix; subscribe/unsubscribe bookkeeping left inconsistent after a prior venue error.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@a4b06ed870 (2026-08-16). Data as JSON: /api/errors/4ce154a6b5b96bf4. Report an issue: GitHub.