{"record":{"id":"e2913a8a171483f1","repo":"nautechsystems/nautilus_trader","slug":"order-rejected-reason","errorCode":null,"errorMessage":"Order rejected: {reason}","messagePattern":"Order rejected: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/bitmex/src/http/client.rs","lineNumber":1777,"sourceCode":"\n        if !exec_inst.is_empty() {\n            params.exec_inst(exec_inst);\n        }\n\n        if let Some(contingency_type) = contingency_type {\n            let bitmex_contingency = BitmexContingencyType::try_from(contingency_type)?;\n            params.contingency_type(bitmex_contingency);\n        }\n\n        let params = params.build().map_err(|e| anyhow::anyhow!(e))?;\n\n        let order: BitmexOrder = self.inner.place_order_response(params).await?;\n\n        if order.ord_status == Some(BitmexOrderStatus::Rejected) {\n            let reason = order\n                .ord_rej_reason\n                .map_or_else(|| \"No reason provided\".to_string(), |r| r.to_string());\n            anyhow::bail!(\"Order rejected: {reason}\");\n        }\n\n        // Cache order type for future lookups (e.g., cancel responses missing ord_type)\n        self.order_type_cache.insert(client_order_id, order_type);\n\n        let instrument = self.instrument_from_cache(instrument_id.symbol.inner())?;\n        let ts_init = self.generate_ts_init();\n\n        parse_order_status_report(&order, &instrument, &self.order_type_cache, ts_init)\n    }\n\n    /// Cancel an order.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if:\n    /// - Credentials are missing.\n    /// - The request fails.","sourceCodeStart":1759,"sourceCodeEnd":1795,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bitmex/src/http/client.rs#L1759-L1795","documentation":"After placing an order, submit_order checks the returned BitMEX order's ord_status; if it is Rejected, the call bails with the venue's ord_rej_reason (or 'No reason provided'). This surfaces a BitMEX-side rejection synchronously to the caller.","triggerScenarios":"place_order_response returns an order with ord_status=Some(Rejected) — e.g. invalid price/quantity, insufficient balance, market closed, testnet/live mismatch, or a rejected pegged/trailing parameter combination.","commonSituations":"Submitting below-minimum notional quantities; using stale instrument specs after BitMEX contract updates; trading while the API key lacks order permission; price outside the venue's limits.","solutions":["Read the reason embedded in the message and fix the offending order parameters","Validate price/quantity against the instrument's size/price increments before submitting","Confirm API key permissions and that the contract is active","Check account balance/margin for the symbol"],"exampleFix":"// before\nclient.submit_order(... quantity: Quantity::from(0.00001) ...)\n// after\nclient.submit_order(... quantity: instrument.min_quantity() ...)","handlingStrategy":"try-catch","validationCode":"if let Some(instrument) = instrument_opt {\n    if qty < instrument.min_quantity() || price < instrument.min_price() {\n        return Err(anyhow::anyhow!(\"order violates instrument limits\"));\n    }\n}","typeGuard":null,"tryCatchPattern":"match client.submit_order(params).await {\n    Ok(o) => o,\n    Err(e) if e.to_string().starts_with(\"Order rejected:\") => {\n        let reason = e.to_string();\n        log::error!(\"BitMEX rejected order: {reason}\");\n        // generate an OrderRejected event / halt strategy\n        return Err(e);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Validate price/quantity against instrument precision and limits before submit","Ensure API keys have trade permission for the account","Keep instrument definitions in sync with BitMEX contract updates","Check available balance/margin before submitting"],"tags":["rust","bitmex","order-rejected","api"],"backgroundTag":"api-error-response","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"}