nautechsystems/nautilus_trader · error

Bybit does not support kline/bar data for options

Error message

Bybit does not support kline/bar data for options

What it means

This error is raised when requesting bar (candlestick/kline) subscriptions for an Option instrument on Bybit. Bybit's kline WebSocket topic does not cover options, so the adapter rejects the bar subscription before opening a stream.

Source

Thrown at crates/adapters/bybit/src/data.rs:1241

                    ws.subscribe_ticker(instrument_id)
                        .await
                        .context("ticker subscription for index prices")
                },
                "index price subscription",
            );
        }
        Ok(())
    }

    fn subscribe_bars(&mut self, cmd: SubscribeBars) -> anyhow::Result<()> {
        let bar_type = cmd.bar_type;
        let instrument_id = bar_type.instrument_id();
        let product_type = self
            .get_product_type_for_instrument(instrument_id)
            .unwrap_or(BybitProductType::Linear);

        if product_type == BybitProductType::Option {
            anyhow::bail!("Bybit does not support kline/bar data for options");
        }

        let ws = self
            .get_ws_client_for_product(product_type)
            .context("no WebSocket client for product type")?
            .clone();

        self.spawn_ws(
            async move {
                ws.subscribe_bars(bar_type)
                    .await
                    .context("bars subscription")
            },
            "bar subscription",
        );
        Ok(())
    }

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Use Linear/Inverse/Spot instruments for bar data on Bybit
  2. Obtain options OHLC via REST history requests if needed, or a different data provider
  3. Filter options out of bar subscription loops

Example fix

// before
let bar_type = BarType::from("BTC-28JUN24-65000-C.SBYBIT-1-MINUTE-LAST");
data_engine.subscribe_bars(bar_type); // error
// after
let bar_type = BarType::from("BTCUSDT-PERP.SBYBIT-1-MINUTE-LAST");
data_engine.subscribe_bars(bar_type);
Defensive patterns

Strategy: validation

Validate before calling

let instrument = cache.instrument(&bar_type.instrument_id()).expect("instrument not found");
if is_option_product(&instrument) {
    // Bybit has no kline stream for options; fetch history via REST or skip
    return Ok(());
}
data_engine.subscribe_bars(bar_type)?;

Try / catch

match data_engine.subscribe_bars(bar_type) {
    Err(e) if e.to_string().contains("does not support kline/bar data for options") => {
        // request historical bars via REST or use a different provider
    }
    r => r?,
}

Prevention

When it happens

Trigger: Calling subscribe_bars with a BarType whose instrument resolves to BybitProductType::Option (e.g. option symbols like BTC-28JUN24-65000-C.SBYBIT).

Common situations: Building bar-based strategies on option chains; a generic data loader that subscribes bars for every instrument in a portfolio including options.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/8bb4a23dca82d213. Report an issue: GitHub.