{"record":{"id":"d161407c7ab024de","repo":"nautechsystems/nautilus_trader","slug":"interactive-brokers-execution-client-id-must-not-b","errorCode":null,"errorMessage":"Interactive Brokers execution client_id must not be a multiple of 1000 because order ID partitioning uses client_id % 1000; got {}","messagePattern":"Interactive Brokers execution client_id must not be a multiple of 1000 because order ID partitioning uses client_id % 1000; got (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/interactive_brokers/src/execution/core.rs","lineNumber":257,"sourceCode":"\nimpl InteractiveBrokersExecutionClient {\n    /// Creates a new [`InteractiveBrokersExecutionClient`].\n    ///\n    /// # Arguments\n    ///\n    /// * `core` - Core execution client functionality\n    /// * `config` - Configuration for the client\n    /// * `instrument_provider` - Instrument provider\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if client creation fails.\n    pub fn new(\n        mut core: ExecutionClientCore,\n        config: InteractiveBrokersExecutionClientConfig,\n        instrument_provider: Arc<InteractiveBrokersInstrumentProvider>,\n    ) -> anyhow::Result<Self> {\n        anyhow::ensure!(\n            !config.client_id.unsigned_abs().is_multiple_of(1000),\n            \"Interactive Brokers execution client_id must not be a multiple of 1000 because order ID partitioning uses client_id % 1000; got {}\",\n            config.client_id\n        );\n\n        // If account_id is provided in config, use it\n        if let Some(account_id) = &config.account_id {\n            core.account_id = AccountId::from(account_id.clone());\n        }\n\n        let pending_tasks = TaskGroup::new();\n        let session_tasks = TaskGroup::new();\n\n        Ok(Self {\n            core,\n            config,\n            instrument_provider,\n            is_connected: AtomicBool::new(false),","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/interactive_brokers/src/execution/core.rs#L239-L275","documentation":"The InteractiveBrokersExecutionClient constructor enforces that the configured execution client_id is not a multiple of 1000, because the adapter partitions order IDs using client_id % 1000 and a multiple of 1000 would collide with other clients' ID ranges. The ensure! fails fast at client construction with this message including the offending client_id.","triggerScenarios":"Constructing the execution client with an InteractiveBrokersExecutionClientConfig whose client_id is 0, 1000, 2000, 7000, etc. — i.e. any unsigned value where client_id % 1000 == 0.","commonSituations":"Config defaults or copied example configs using client_id values like 0 or 1000; multiple gateway sessions where a user picked a round-number client ID; automations that derive client IDs by multiplying or scaling other numbers.","solutions":["Change client_id in the InteractiveBrokers execution client config to a non-multiple of 1000 (e.g. 1–999 modulo 1000, like 5 or 1001).","If multiple clients run against one gateway, assign each a distinct client_id that is not a multiple of 1000 to avoid ID partition overlap.","Check for generated or templated configs that compute client_id and ensure the generator avoids round multiples of 1000."],"exampleFix":"// before\n[execution]\nclient_id = 1000\n// after\n[execution]\nclient_id = 1001","handlingStrategy":"validation","validationCode":"fn client_id_is_valid(client_id: i64) -> bool {\n    client_id.unsigned_abs() % 1000 != 0\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick client IDs in 1..=999 (mod 1000) per gateway session.","Never use round defaults like 0 or 1000 in configs.","Validate config at load time with the same modulo check the client enforces."],"tags":["configuration","interactive-brokers","order-ids","validation"],"backgroundTag":"invalid-config-value","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"}