{"record":{"id":"5dc6568cf75f222d","repo":"nautechsystems/nautilus_trader","slug":"cannot-include-emulated-or-local-orders-in-batch-m","errorCode":null,"errorMessage":"Cannot include emulated or local orders in batch modify","messagePattern":"Cannot include emulated or local orders in batch modify","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/trading/src/strategy/mod.rs","lineNumber":501,"sourceCode":"                        .try_order_owned(client_order_id)\n                        .map_err(|e| anyhow::anyhow!(\"Cannot modify order: {e}\"))\n                })\n                .collect::<Result<_, _>>()?\n        };\n\n        let instrument_id = orders[0].instrument_id();\n\n        for (order, (_, quantity, price, trigger_price)) in orders.iter().zip(updates.iter()) {\n            if order.instrument_id() != instrument_id {\n                anyhow::bail!(\n                    \"Cannot batch modify orders for different instruments: {} vs {}\",\n                    instrument_id,\n                    order.instrument_id()\n                );\n            }\n\n            if order.is_emulated() || order.is_active_local() {\n                anyhow::bail!(\"Cannot include emulated or local orders in batch modify\");\n            }\n\n            let mut updating = false;\n\n            if quantity.is_some_and(|q| q != order.quantity()) {\n                updating = true;\n            }\n\n            if let Some(price) = price {\n                if !LIMIT_ORDER_TYPES.contains(&order.order_type()) {\n                    anyhow::bail!(\"{} orders do not have a LIMIT price\", order.order_type());\n                }\n\n                if Some(*price) != order.price() {\n                    updating = true;\n                }\n            }\n","sourceCodeStart":483,"sourceCodeEnd":519,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/trading/src/strategy/mod.rs#L483-L519","documentation":"Batch modify only supports orders that are routed directly to the venue. Orders flagged as emulated (locally emulated contingent orders) or active-local are rejected because their lifecycle is managed by the risk engine/execution emulator, not a single venue command.","triggerScenarios":"Including an order where `order.is_emulated()` or `order.is_active_local()` is true in the batch passed to `modify_orders`.","commonSituations":"Using emulation for contingent/bracket orders on venues without native support, then attempting a batch amend; accidentally mixing emulated and direct orders in one batch; submitting a batch modify to a venue (e.g. Binance) that doesn't support batch amend for emulated positions.","solutions":["Exclude emulated and active-local orders from the batch and modify them individually via modify_order","Check `order.is_emulated() || order.is_active_local()` and route those orders through per-order handling","Reconsider emulation configuration if batch ops on emulated orders are required"],"exampleFix":"// before\nlet batch: Vec<&OrderAny> = open_orders.iter().collect();\nstrategy.modify_orders(&batch, &updates, None, None).await?;\n// after\nlet batch: Vec<&OrderAny> = open_orders.iter()\n    .filter(|o| !o.is_emulated() && !o.is_active_local())\n    .collect();\nfor o in open_orders.iter().filter(|o| o.is_emulated() || o.is_active_local()) {\n    strategy.modify_order(o, quantity, price, trigger_price, None).await?;\n}\nstrategy.modify_orders(&batch, &updates, None, None).await?;","handlingStrategy":"validation","validationCode":"let batch: Vec<_> = orders.iter()\n    .filter(|o| !o.is_emulated() && !o.is_active_local())\n    .collect();","typeGuard":"fn batch_modify_eligible(o: &OrderAny) -> bool { !o.is_emulated() && !o.is_active_local() }","tryCatchPattern":null,"preventionTips":["Check is_emulated()/is_active_local() when building batches","Handle emulated orders through per-order APIs","Know your emulation config and which orders it affects"],"tags":["validation","batch-orders","emulated-orders"],"backgroundTag":"unsupported-operation","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}