nautechsystems/nautilus_trader · error

Invalid L3 depth {depth} for Kraken Spot, valid values: 10,

Error message

Invalid L3 depth {depth} for Kraken Spot, valid values: 10, 100, 1000

What it means

Kraken Spot's L3 order book subscription only accepts snapshot depths of 10, 100, or 1000 levels, matching Kraken's `depth` parameter. A SubscribeBookDeltas command with any other depth is rejected by `subscribe_l3_book` before subscribing.

Source

Thrown at crates/adapters/kraken/src/data/spot.rs:304

        if ws_l3_result.is_ok() {
            self.ws_l3 = None;
            self.l3_handler_task = None;
        }
        let tasks_result = self.finish_tasks().await;
        self.is_connected.store(false, Ordering::Release);
        tasks_result?;
        ws_result?;
        Ok(ws_l3_result?)
    }

    fn subscribe_l3_book(&mut self, cmd: &SubscribeBookDeltas) -> anyhow::Result<()> {
        let instrument_id = cmd.instrument_id;
        let symbol_ustr = instrument_id.symbol.inner();
        let depth = cmd.depth.map_or(1000, |d| d.get() as u32);

        if !matches!(depth, 10 | 100 | 1000) {
            anyhow::bail!("Invalid L3 depth {depth} for Kraken Spot, valid values: 10, 100, 1000");
        }

        if !self.config.has_api_credentials() {
            anyhow::bail!(
                "L3 order book requires API credentials; configure api_key and api_secret"
            );
        }

        let handler_finished = self
            .l3_handler_task
            .as_ref()
            .is_none_or(TaskRef::is_finished);

        if self.ws_l3.is_none() {
            let ws_l3 = KrakenSpotWebSocketClient::l3(
                self.config.clone(),
                self.cancellation_token.clone(),
                self.config

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Set the book subscription depth to 10, 100, or 1000
  2. Omit the depth to use the 1000-level default
  3. Aggregate/round your desired depth down to the nearest supported value

Example fix

// before
let cmd = SubscribeBookDeltas::new(instrument_id, Some(Quantity::from(50)));
// after
let cmd = SubscribeBookDeltas::new(instrument_id, Some(Quantity::from(100))); // one of 10 | 100 | 1000
Defensive patterns

Strategy: validation

Validate before calling

const KRAKEN_SPOT_L3_DEPTHS: [u32; 3] = [10, 100, 1000];
let depth = depth.unwrap_or(1000);
assert!(KRAKEN_SPOT_L3_DEPTHS.contains(&depth), "depth must be 10, 100, or 1000");

Type guard

fn is_valid_l3_depth(d: Option<Quantity>) -> bool {
    matches!(d.map(|q| q.get() as u32), None | Some(10) | Some(100) | Some(1000))
}

Prevention

When it happens

Trigger: Subscribing to L3 book deltas on Kraken Spot with `cmd.depth` set to a value other than 10/100/1000 (e.g. 1, 25, 500). depth=None defaults to 1000 and is valid.

Common situations: Requesting a custom book depth in a strategy config or via the data engine that does not align with Kraken's allowed snapshot sizes.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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