nautechsystems/nautilus_trader · error

Kraken Spot does not support the demo environment

Error message

Kraken Spot does not support the demo environment

What it means

Kraken's Spot product has no demo/testnet HTTP environment; only Kraken Futures offers a demo endpoint. get_kraken_http_base_url matches on (product_type, environment) and panics for the Spot+Demo combination since there is no URL to return. The panic fires during client construction (new/with_credentials) whenever that combination is configured.

Source

Thrown at crates/adapters/kraken/src/common/urls.rs:35

use super::{
    consts::{
        KRAKEN_FUTURES_DEMO_HTTP_URL, KRAKEN_FUTURES_DEMO_WS_URL, KRAKEN_FUTURES_HTTP_URL,
        KRAKEN_FUTURES_WS_URL, KRAKEN_SPOT_HTTP_URL, KRAKEN_SPOT_WS_PRIVATE_URL,
        KRAKEN_SPOT_WS_PUBLIC_URL,
    },
    enums::{KrakenEnvironment, KrakenProductType},
};

/// Returns the HTTP base URL for the given product type and environment.
pub fn get_kraken_http_base_url(
    product_type: KrakenProductType,
    environment: KrakenEnvironment,
) -> &'static str {
    match (product_type, environment) {
        (KrakenProductType::Spot, KrakenEnvironment::Live) => KRAKEN_SPOT_HTTP_URL,
        (KrakenProductType::Spot, KrakenEnvironment::Demo) => {
            panic!("Kraken Spot does not support the demo environment")
        }
        (KrakenProductType::Futures, KrakenEnvironment::Live) => KRAKEN_FUTURES_HTTP_URL,
        (KrakenProductType::Futures, KrakenEnvironment::Demo) => KRAKEN_FUTURES_DEMO_HTTP_URL,
    }
}

/// Returns the public WebSocket URL for the given product type and environment.
pub fn get_kraken_ws_public_url(
    product_type: KrakenProductType,
    environment: KrakenEnvironment,
) -> &'static str {
    match (product_type, environment) {
        (KrakenProductType::Spot, KrakenEnvironment::Live) => KRAKEN_SPOT_WS_PUBLIC_URL,
        (KrakenProductType::Spot, KrakenEnvironment::Demo) => {
            panic!("Kraken Spot does not support the demo environment")
        }
        (KrakenProductType::Futures, KrakenEnvironment::Live) => KRAKEN_FUTURES_WS_URL,
        (KrakenProductType::Futures, KrakenEnvironment::Demo) => KRAKEN_FUTURES_DEMO_WS_URL,

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Configure environment=Live for the Kraken Spot adapter
  2. Use the Kraken Futures adapter with Demo if you need a test environment
  3. Add a startup config validation that rejects Spot+Demo before client construction

Example fix

// before
environment = "demo"  # with product_type = "spot"
// after
environment = "live"  # Spot has no demo env; use Futures for demo
Defensive patterns

Strategy: validation

Validate before calling

fn validate_kraken_env(p: KrakenProductType, e: KrakenEnvironment) -> Result<(), String> {
    match (p, e) {
        (KrakenProductType::Spot, KrakenEnvironment::Demo) =>
            Err("Kraken Spot has no demo environment".into()),
        _ => Ok(()),
    }
}

Prevention

When it happens

Trigger: Creating a Kraken HTTP client (new or with_credentials) or calling http_base_url with product_type=Spot and environment=Demo.

Common situations: A single environment setting (demo) is applied across all adapters including Kraken Spot; developers assume Kraken Spot has a testnet like Futures do; config templates copy the Futures demo setup onto Spot credentials.

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


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