{"record":{"id":"871cb4f8029b65e9","repo":"nautechsystems/nautilus_trader","slug":"cannot-modify-order-in-place-status-is-status","errorCode":null,"errorMessage":"Cannot modify order in place: status is {status:?}, expected INITIALIZED or RELEASED","messagePattern":"Cannot modify order in place: status is (.+?), expected INITIALIZED or RELEASED","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/trading/src/algorithm/mod.rs","lineNumber":1017,"sourceCode":"    ///\n    /// # Errors\n    ///\n    /// Returns an error if the order status is not INITIALIZED or RELEASED,\n    /// or if no parameters would change.\n    fn modify_order_in_place(\n        &mut self,\n        order: &mut OrderAny,\n        quantity: Option<Quantity>,\n        price: Option<Price>,\n        trigger_price: Option<Price>,\n    ) -> anyhow::Result<()>\n    where\n        Self: ExecutionAlgorithmNative,\n    {\n        // Validate order status\n        let status = order.status();\n        if status != OrderStatus::Initialized && status != OrderStatus::Released {\n            anyhow::bail!(\n                \"Cannot modify order in place: status is {status:?}, expected INITIALIZED or RELEASED\"\n            );\n        }\n\n        // Validate order type compatibility\n        if price.is_some() && order.price().is_none() {\n            anyhow::bail!(\n                \"Cannot modify order in place: {} orders do not have a LIMIT price\",\n                order.order_type()\n            );\n        }\n\n        if trigger_price.is_some() && order.trigger_price().is_none() {\n            anyhow::bail!(\n                \"Cannot modify order in place: {} orders do not have a STOP trigger price\",\n                order.order_type()\n            );\n        }","sourceCodeStart":999,"sourceCodeEnd":1035,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/trading/src/algorithm/mod.rs#L999-L1035","documentation":"modify_order_in_place only accepts orders in INITIALIZED or RELEASED status because in-place modification is only meaningful before the order has been submitted to or acted on by the venue. Orders in any other status (SUBMITTED, ACCEPTED, FILLED, DENIED, etc.) are rejected.","triggerScenarios":"Calling modify_order_in_place on an order already SUBMITTED/ACCEPTED at the venue, after it filled, or after it was canceled/denied.","commonSituations":"Race between an execution algorithm's modification logic and order submission; retrying a modification after the order state advanced; using modify-in-place where a venue-level order modify (OrderModify) is required instead.","solutions":["Check order.status() is Initialized or Released before calling modify_order_in_place","Use the venue-level order modify request (generate_order_modify / OrderModify) for live orders","Guard against concurrent state changes by performing the check and modification in the same handler scope","Log order status on failure to diagnose races with submission"],"exampleFix":"// before\nalgo.modify_order_in_place(&mut order, Some(new_qty), None, None)?;\n// after\nif matches!(order.status(), OrderStatus::Initialized | OrderStatus::Released) {\n    algo.modify_order_in_place(&mut order, Some(new_qty), None, None)?;\n}","handlingStrategy":"validation","validationCode":"if !matches!(order.status(), OrderStatus::Initialized | OrderStatus::Released) { return Err(anyhow!(\"order not modifiable in place: {:?}\", order.status())); }","typeGuard":"fn modifiable_in_place(o: &OrderAny) -> bool { matches!(o.status(), OrderStatus::Initialized | OrderStatus::Released) }","tryCatchPattern":"match algo.modify_order_in_place(&mut order, q, p, t) { Err(e) if e.to_string().contains(\"status is\") => { /* fall back to venue modify */ }, r => r?, }","preventionTips":["Check status before in-place modification","Use venue-level OrderModify for submitted/accepted orders"],"tags":["rust","orders","execution-algorithm"],"backgroundTag":"invalid-state-transition","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"}