{"record":{"id":"2db668b7710d124f","repo":"nautechsystems/nautilus_trader","slug":"failed-to-send-order-rejected-event-e","errorCode":null,"errorMessage":"Failed to send order rejected event: {e}","messagePattern":"Failed to send order rejected event: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/interactive_brokers/src/execution/core_orders.rs","lineNumber":615,"sourceCode":"                );\n\n                let reason = format!(\"{failure_prefix}: {reason}\");\n                let event = OrderRejected::new(\n                    context.trader_id,\n                    context.strategy_id,\n                    context.instrument_id,\n                    context.client_order_id,\n                    account_id,\n                    Ustr::from(&reason),\n                    UUID4::new(),\n                    ts_event,\n                    clock.get_time_ns(),\n                    false,\n                    false,\n                );\n                exec_sender\n                    .send(ExecutionEvent::Order(OrderEventAny::Rejected(event)))\n                    .map_err(|e| anyhow::anyhow!(\"Failed to send order rejected event: {e}\"))?;\n                anyhow::bail!(reason);\n            }\n        }\n    }\n}\n\n#[cfg(test)]\nmod tests {\n    use nautilus_model::identifiers::Symbol;\n\n    use super::*;\n\n    fn modify_trigger_cmd() -> ModifyOrder {\n        ModifyOrder::new(\n            TraderId::from(\"TRADER-001\"),\n            Some(ClientId::from(\"CLIENT-001\")),\n            StrategyId::from(\"S-001\"),\n            InstrumentId::new(Symbol::from(\"AAPL\"), Venue::from(\"NASDAQ\")),","sourceCodeStart":597,"sourceCodeEnd":633,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/interactive_brokers/src/execution/core_orders.rs#L597-L633","documentation":"In handle_order_submit_failure, when the IB client submit fails with a condition that maps to a terminal rejection, the adapter emits an OrderRejected event via exec_sender. This error wraps a failure of that channel send; the adapter then bail!s with the rejection `reason`. Downstream will neither get the Rejected event nor a clean error about the original IB rejection unless the channel is fixed.","triggerScenarios":"client.submit_order returning an error classified as a hard rejection (e.g. invalid contract, insufficient permissions/funds, malformed order) while the exec event channel send fails (receiver dropped/closed).","commonSituations":"Submitting orders for contracts the IB account cannot trade (no market-data/subscriptions permissions); exceeding account buying power; engine shutdown racing a failed submission.","solutions":["Read the bail! `reason` for the underlying IB rejection and fix the order/contract/account issue.","Verify IB account permissions (trading permissions, subscriptions) for the instrument.","Check buying power/margin and order size against account limits.","Ensure the exec event channel/receiver is alive; restart the node if the channel was dropped."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-check account permissions and buying power for the contract\nensure!(account.allows_trading(&instrument_id), \"no trading permission for {}\", instrument_id);","typeGuard":null,"tryCatchPattern":"if let Err(e) = exec_client.submit_order(cmd).await {\n    if e.to_string().contains(\"Failed to send order rejected event\") {\n        // both the IB rejection and the event channel failed; halt and reconcile\n    }\n}","preventionTips":["Confirm IB account trading permissions and market-data subscriptions per instrument.","Check margin/buying power before sizing orders.","Keep the engine alive to receive rejection events."],"tags":["interactive-brokers","order-rejected","channel","rust"],"backgroundTag":"http-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"}