{"record":{"id":"ad2164a5c06a012e","repo":"nautechsystems/nautilus_trader","slug":"bitmex-execution-client-requires-api-key-and-secre","errorCode":null,"errorMessage":"BitMEX execution client requires API key and secret","messagePattern":"BitMEX execution client requires API key and secret","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/bitmex/src/execution.rs","lineNumber":129,"sourceCode":"            LogLevel::Warning => log::warn!(\"{message}\"),\n            LogLevel::Error => log::error!(\"{message}\"),\n        }\n    }\n\n    /// Creates a new [`BitmexExecutionClient`].\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the broadcaster pool sizes are invalid, API credentials are unavailable,\n    /// or either the HTTP or WebSocket client fails to construct.\n    pub fn new(\n        mut core: ExecutionClientCore,\n        config: BitmexExecutionClientConfig,\n    ) -> anyhow::Result<Self> {\n        config.validate_broadcaster_pool_sizes()?;\n\n        if !config.has_api_credentials() {\n            anyhow::bail!(\"BitMEX execution client requires API key and secret\");\n        }\n\n        if let Some(account_id) = config.account_id {\n            core.set_account_id(account_id);\n        }\n\n        let trader_id = core.trader_id;\n        let account_id = core.account_id;\n        let clock = get_atomic_clock_realtime();\n        let emitter =\n            ExecutionEventEmitter::new(clock, trader_id, account_id, AccountType::Margin, None);\n        let api_key = config\n            .api_key\n            .as_ref()\n            .map(|value| value.expose_secret().to_owned());\n        let api_secret = config\n            .api_secret\n            .as_ref()","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bitmex/src/execution.rs#L111-L147","documentation":"The BitMEX execution client constructor requires API credentials; BitmexExecutionClientConfig::has_api_credentials must be true. If the API key and/or secret is absent, new() bails rather than constructing a client that cannot authenticate.","triggerScenarios":"Constructing BitmexExecutionClient::new() with a config where api_key or api_secret is None/empty (has_api_credentials() returns false).","commonSituations":"Missing or mistyped env vars/config fields for the API key and secret, live config accidentally built from the sandbox/testnet template with credentials stripped, or secrets not loaded from the secrets store.","solutions":["Provide both api_key and api_secret in BitmexExecutionClientConfig","Verify the env vars or secrets file backing the config are set in the runtime environment","Validate the config (keys non-empty, correct key permissions for trading) before constructing the client"],"exampleFix":"// before\nlet config = BitmexExecutionClientConfig { api_key: None, api_secret: None, ... };\n// after\nlet config = BitmexExecutionClientConfig {\n    api_key: Some(std::env::var(\"BITMEX_API_KEY\")?),\n    api_secret: Some(std::env::var(\"BITMEX_API_SECRET\")?),\n    ...,\n};","handlingStrategy":"validation","validationCode":"// Python-style guard before building client\nassert api_key and api_secret, \"BitMEX execution client requires API key and secret\"","typeGuard":"fn has_credentials(cfg: &BitmexExecutionClientConfig) -> bool {\n    cfg.api_key.as_deref().map_or(false, |k| !k.is_empty())\n        && cfg.api_secret.as_deref().map_or(false, |s| !s.is_empty())\n}","tryCatchPattern":"let client = BitmexExecutionClient::new(core, config)\n    .map_err(|e| { log::error!(\"exec client init: {e}\"); ConfigError })?;","preventionTips":["Load credentials from env/secrets store at startup and fail fast if absent","Run a config validation pass before constructing clients","Keep testnet and live credential config separate and checked"],"tags":["bitmex","credentials","config"],"backgroundTag":"missing-credentials","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"}