{"record":{"id":"ba49463fe765aaa2","repo":"nautechsystems/nautilus_trader","slug":"invalid-config-type-for-deribitexecutionclientfact","errorCode":null,"errorMessage":"Invalid config type for DeribitExecutionClientFactory. Expected DeribitExecutionClientConfig, was {config:?}","messagePattern":"Invalid config type for DeribitExecutionClientFactory\\. Expected DeribitExecutionClientConfig, was (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/deribit/src/factories.rs","lineNumber":147,"sourceCode":"impl Default for DeribitExecutionClientFactory {\n    fn default() -> Self {\n        Self::new()\n    }\n}\n\nimpl ExecutionClientFactory for DeribitExecutionClientFactory {\n    fn create(\n        &self,\n        trader_id: TraderId,\n        name: &str,\n        config: &dyn ClientConfig,\n        cache: CacheView,\n    ) -> anyhow::Result<Box<dyn ExecutionClient>> {\n        let deribit_config = config\n            .as_any()\n            .downcast_ref::<DeribitExecutionClientConfig>()\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"Invalid config type for DeribitExecutionClientFactory. Expected DeribitExecutionClientConfig, was {config:?}\",\n                )\n            })?\n            .clone();\n\n        // Deribit uses netting (derivatives only, no hedging)\n        let oms_type = OmsType::Netting;\n        let account_type = AccountType::Margin;\n\n        let client_id = ClientId::from(name);\n        let core = ExecutionClientCore::new(\n            trader_id,\n            client_id,\n            *DERIBIT_VENUE,\n            oms_type,\n            deribit_config.account_id,\n            account_type,\n            None, // base_currency","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/deribit/src/factories.rs#L129-L165","documentation":"DeribitExecutionClientFactory::create requires the config to be a DeribitExecutionClientConfig. It downcasts the type-erased ClientConfig; if the concrete type differs the downcast fails and this error is raised with the actual config's Debug output. It exists to catch wiring a non-execution (e.g. data-client) config into the execution factory.","triggerScenarios":"Calling DeribitExecutionClientFactory::create(name, config, cache, ...) with any config other than DeribitExecutionClientConfig — most commonly a DeribitDataClientConfig or another venue's config.","commonSituations":"Duplicating data-client wiring for the execution client without changing the config type; bootstrapping all Deribit clients from one shared config; typos in generic bootstrap code that pass the wrong Rc'd config to the wrong factory.","solutions":["Pass a DeribitExecutionClientConfig to this factory; inspect the printed Debug type name in the message to confirm what was actually passed.","Build the execution config explicitly (DeribitExecutionClientConfig::new(instrument_provider_config, ...)) and wire it only into DeribitExecutionClientFactory.","In generic bootstrap code, match the config concrete type to the corresponding factory instead of passing every config to every factory."],"exampleFix":"// before\nlet config = DeribitDataClientConfig::new(provider_config);\nlet exec = DeribitExecutionClientFactory.create(name, Rc::new(config), cache, clock)?;\n// after\nlet config = DeribitExecutionClientConfig::new(provider_config);\nlet exec = DeribitExecutionClientFactory.create(name, Rc::new(config), cache, clock)?;","handlingStrategy":"type-guard","validationCode":"let Some(cfg) = config.as_any().downcast_ref::<DeribitExecutionClientConfig>() else {\n    return Err(anyhow::anyhow!(\"expected DeribitExecutionClientConfig, got {config:?}\"));\n};","typeGuard":"fn is_deribit_execution_config(config: &dyn ClientConfig) -> bool {\n    config.as_any().is::<DeribitExecutionClientConfig>()\n}","tryCatchPattern":"match factory.create(name, config, cache, clock) {\n    Ok(client) => client,\n    Err(e) => { eprintln!(\"deribit execution client init failed: {e:#}\"); return Err(e); }\n}","preventionTips":["Use distinct variable names for data and execution configs to avoid swapping them.","Assert the concrete config type in bootstrap tests before wiring clients.","Never reuse one shared 'deribit config' for both factories; construct each explicitly."],"tags":["rust","config","downcast","deribit","factory"],"backgroundTag":"config-type-mismatch","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}