nautechsystems/nautilus_trader · error · anyhow::Error

Invalid config type for KrakenExecutionClientFactory. Expect

Error message

Invalid config type for KrakenExecutionClientFactory. Expected KrakenExecutionClientConfig, was {config:?}

What it means

The Kraken execution client factory only accepts a KrakenExecutionClientConfig; it downcasts the generic config passed by the adapter framework and fails with this error when the concrete type does not match. It indicates the factory was registered or invoked with the wrong config object (e.g. a spot config or a different venue's config).

Source

Thrown at crates/adapters/kraken/src/factories.rs:161

impl Default for KrakenExecutionClientFactory {
    fn default() -> Self {
        Self::new()
    }
}

impl ExecutionClientFactory for KrakenExecutionClientFactory {
    fn create(
        &self,
        trader_id: TraderId,
        name: &str,
        config: &dyn ClientConfig,
        cache: CacheView,
    ) -> anyhow::Result<Box<dyn ExecutionClient>> {
        let kraken_config = config
            .as_any()
            .downcast_ref::<KrakenExecutionClientConfig>()
            .ok_or_else(|| {
                anyhow::anyhow!(
                    "Invalid config type for KrakenExecutionClientFactory. Expected KrakenExecutionClientConfig, was {config:?}",
                )
            })?
            .clone();

        kraken_config.validate()?;

        let oms_type = OmsType::Netting;
        let account_type = match kraken_config.product_type {
            KrakenProductType::Spot => kraken_config.spot_account_type,
            KrakenProductType::Futures => AccountType::Margin,
        };

        let client_id = ClientId::from(name);
        let core = ExecutionClientCore::new(
            trader_id,
            client_id,
            *KRAKEN_VENUE,

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Pass a KrakenExecutionClientConfig (constructed via KrakenExecutionClientConfig::new) to the factory that creates KrakenExecutionClient.
  2. Check the client factory registration in your live node config: the factory and config pair must come from the same adapter module.
  3. If upgrading, verify the config type names in the current kraken adapter version and update your config construction.
  4. Run kraken_config.validate() yourself before create to surface config-field problems separately from type problems.

Example fix

// before
let factory = KrakenExecutionClientFactory::new();
let client = factory.create(ExecutionClientConfig::Spot(KrakenHttpClientConfig::default()))?;
// after
let config = KrakenExecutionClientConfig::new(
    trader_id, account_id, api_key, api_secret, None, instrument_provider_config, None,
)?;
let client = factory.create(config)?;
Defensive patterns

Strategy: type-guard

Validate before calling

if !config.is::<KrakenExecutionClientConfig>() {
    return Err(anyhow!("expected KrakenExecutionClientConfig for Kraken execution factory"));
}

Type guard

fn as_kraken_exec_config(config: &dyn ClientConfig) -> Option<&KrakenExecutionClientConfig> {
    config.as_any().downcast_ref::<KrakenExecutionClientConfig>()
}

Prevention

When it happens

Trigger: Calling KrakenExecutionClientFactory::create with a config whose as_any() downcast_ref::<KrakenExecutionClientConfig>() returns None — e.g. passing KrakenHttpClientConfig (spot), KrakenFuturesAuthConfig, or a config from another adapter.

Common situations: Wiring the spot data config into the futures/execution factory in a LiveNodeConfig; copy-pasted client factory registrations; renaming config types across adapter versions so an old config struct no longer matches.

Related errors


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