{"record":{"id":"5eca2440008a03fe","repo":"nautechsystems/nautilus_trader","slug":"modify-order-rejected-reason","errorCode":null,"errorMessage":"modify order rejected: {reason}","messagePattern":"modify order rejected: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bybit/src/execution.rs","lineNumber":1858,"sourceCode":"                        venue_order_id,\n                        quantity,\n                        price,\n                    )\n                    .await;\n\n                if let Err(e) = result {\n                    match classify_modify_http_failure(&e) {\n                        CommandFailure::VenueRejected(reason) => {\n                            let ts_event = clock.get_time_ns();\n                            emitter.emit_order_modify_rejected_event(\n                                strategy_id,\n                                instrument_id,\n                                client_order_id,\n                                venue_order_id,\n                                &format!(\"modify-order-error: {reason}\"),\n                                ts_event,\n                            );\n                            anyhow::bail!(\"modify order rejected: {reason}\");\n                        }\n                        CommandFailure::NotSent(reason) => {\n                            log::warn!(\n                                \"HTTP modify command failed local validation for {client_order_id}: {reason}\"\n                            );\n                        }\n                        CommandFailure::Ambiguous(reason) => {\n                            log::warn!(\n                                \"Ambiguous HTTP modify failure for {client_order_id}, awaiting reconciliation: {reason}\"\n                            );\n                        }\n                    }\n                }\n\n                Ok(())\n            });\n\n            return Ok(());","sourceCodeStart":1840,"sourceCodeEnd":1876,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bybit/src/execution.rs#L1840-L1876","documentation":"Raised when a modify-order request is rejected by Bybit (or fails with a confirmed reason) during modify_order. The adapter emits an OrderModifyRejected event carrying 'modify-order-error: {reason}' and then bails with the venue reason.","triggerScenarios":"Calling modify_order when Bybit rejects the amend — e.g. order already filled or cancelled, quantity/price violating filters, unknown order ID, or modifying an order in a non-amendable state.","commonSituations":"Race conditions where the order fills while the modify is in flight; amend requests exceeding symbol limits; stale client/venue order IDs after reconciliation gaps.","solutions":["Check the order is still open (not filled/cancelled) before modifying","Validate new price/qty against the instrument's tick size and lot size before calling","Handle the rejection reason and fall back to cancel+replace if modify is not possible","Refresh order state via reconciliation if venue order IDs are stale"],"exampleFix":"// before\nclient.modify_order(&order, Some(new_price), Some(new_qty))?; // may bail if order filled\n// after\nif let Some(order) = cache.order(client_order_id) && order.is_open() {\n    client.modify_order(&order, Some(new_price), Some(new_qty))?;\n} else {\n    log::warn!(\"skipping modify, order not open\");\n}","handlingStrategy":"try-catch","validationCode":"if let Some(o) = cache.order(&venue_order_id_or_client_id) {\n    if !o.is_open() { return Err(anyhow!(\"cannot modify non-open order\")); }\n}\nassert!(new_qty >= instrument.min_quantity().unwrap());\nassert!(new_price % instrument.tick_size() == 0.0);","typeGuard":null,"tryCatchPattern":"match exec_client.modify_order(&order, new_price, new_qty) {\n    Err(e) if e.to_string().starts_with(\"modify order rejected:\") => {\n        // fall back to cancel + replace\n        exec_client.cancel_order(&order).ok();\n        exec_client.submit_order(order_factory.limit(...))?;\n    }\n    r => r?,\n}","preventionTips":["Confirm the order is still open before amending (fills/cancels race)","Prefer cancel+replace for large state changes or when modify is uncertain","Validate amended values against tick/lot size filters","Reconcile venue order state before batch modifies"],"tags":["bybit","order-rejected","modify-order","venue-rejection"],"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"}