{"record":{"id":"0b9a48f374a48fb1","repo":"nautechsystems/nautilus_trader","slug":"invalid-config-type-for-bitmexexecutionclientfacto","errorCode":null,"errorMessage":"Invalid config type for BitmexExecutionClientFactory. Expected BitmexExecutionClientConfig, was {config:?}","messagePattern":"Invalid config type for BitmexExecutionClientFactory\\. Expected BitmexExecutionClientConfig, was (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/bitmex/src/factories.rs","lineNumber":147,"sourceCode":"impl Default for BitmexExecutionClientFactory {\n    fn default() -> Self {\n        Self::new()\n    }\n}\n\nimpl ExecutionClientFactory for BitmexExecutionClientFactory {\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 mut bitmex_config = config\n            .as_any()\n            .downcast_ref::<BitmexExecutionClientConfig>()\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"Invalid config type for BitmexExecutionClientFactory. Expected BitmexExecutionClientConfig, was {config:?}\",\n                )\n            })?\n            .clone();\n\n        let account_id = bitmex_config\n            .account_id\n            .unwrap_or_else(|| AccountId::from(\"BITMEX-001\"));\n        bitmex_config.account_id = Some(account_id);\n\n        let core = ExecutionClientCore::new(\n            trader_id,\n            ClientId::from(name),\n            *BITMEX_VENUE,\n            OmsType::Netting,\n            account_id,\n            AccountType::Margin,\n            None, // base_currency","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bitmex/src/factories.rs#L129-L165","documentation":"BitmexExecutionClientFactory::create only accepts a config that downcasts to BitmexExecutionClientConfig. Any other config type produces this error naming the expected type and the actual config value.","triggerScenarios":"Calling create on BitmexExecutionClientFactory with a config that is not BitmexExecutionClientConfig — e.g. passing BitmexDataClientConfig, another venue's execution config, or a malformed generic config.","commonSituations":"Wiring the execution factory with the data client's config, swapping config sections in the node config, or config struct renames after an adapter upgrade.","solutions":["Pass a BitmexExecutionClientConfig instance to BitmexExecutionClientFactory::create.","Verify the config section in your node config is the execution-client section.","Deserialize the raw config into BitmexExecutionClientConfig before handing it to the factory.","Inspect the was {config:?} dump in the message to identify what was actually passed."],"exampleFix":"// before\nlet config = BitmexDataClientConfig { ... };\nlet client = BitmexExecutionClientFactory.create(name, config, cache, clock);\n// after\nlet config = BitmexExecutionClientConfig { api_key, api_secret, ... };\nlet client = BitmexExecutionClientFactory.create(name, config, cache, clock);","handlingStrategy":"type-guard","validationCode":"// Rust\nfn is_bitmex_exec_config(config: &dyn Any) -> bool {\n    config.downcast_ref::<BitmexExecutionClientConfig>().is_some()\n}","typeGuard":"// Rust\nfn as_bitmex_exec_config(config: &dyn Any) -> Option<&BitmexExecutionClientConfig> {\n    config.downcast_ref::<BitmexExecutionClientConfig>()\n}","tryCatchPattern":"// Rust\nlet cfg = config.as_any()\n    .downcast_ref::<BitmexExecutionClientConfig>()\n    .ok_or_else(|| anyhow::anyhow!(\"expected BitmexExecutionClientConfig, got {:?}\", config))?;","preventionTips":["Wire execution factories only with execution configs","Use serde to deserialize configs into the exact expected type","Review adapter wiring when upgrading versions"],"tags":["config","downcast","factory","bitmex"],"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"}