{"record":{"id":"f8ecd81fa9286d33","repo":"nautechsystems/nautilus_trader","slug":"quantity-new-qty-rounds-to-0-ticks-at-size-pre","errorCode":null,"errorMessage":"quantity `{new_qty}` rounds to 0 ticks at size_precision {}","messagePattern":"quantity `(.+?)` rounds to 0 ticks at size_precision (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/lighter/src/execution.rs","lineNumber":1980,"sourceCode":"\n                derive_market_order_price_ticks(\n                    trigger.as_decimal(),\n                    is_buy,\n                    price_precision,\n                    slippage_bps,\n                )?\n            }\n            _ => {\n                let new_price = cmd.price.or(order.price()).ok_or_else(|| {\n                    anyhow::anyhow!(\"modify_order requires a price (none on order or command)\")\n                })?;\n\n                price_to_ticks(&new_price, price_precision)?\n            }\n        };\n\n        let base_amount = quantity_to_ticks(&new_qty, instrument.size_precision())?;\n        anyhow::ensure!(\n            base_amount > 0,\n            \"quantity `{new_qty}` rounds to 0 ticks at size_precision {}\",\n            instrument.size_precision(),\n        );\n        let trigger_price_ticks = match new_trigger {\n            Some(trigger) if trigger.raw != 0 => price_to_ticks(&trigger, price_precision)?,\n            _ => 0,\n        };\n\n        if matches!(\n            order.order_type(),\n            OrderType::StopMarket\n                | OrderType::StopLimit\n                | OrderType::MarketIfTouched\n                | OrderType::LimitIfTouched\n        ) {\n            anyhow::ensure!(\n                trigger_price_ticks > 0,","sourceCodeStart":1962,"sourceCodeEnd":1998,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/lighter/src/execution.rs#L1962-L1998","documentation":"The modify's new quantity is converted to integer base-amount ticks at the instrument's size_precision. If the resulting tick value is 0 (quantity too small or below rounding granularity) the order would be invalid on Lighter, so the adapter rejects it up front.","triggerScenarios":"prepare_signed_modify_order computes quantity_to_ticks(&new_qty, instrument.size_precision()) == 0 — the new quantity from cmd.quantity (or the order) rounds down to zero ticks, e.g. 0.0004 BTC at size_precision 2.","commonSituations":"Configured size_precision smaller than the quantity's decimals; very small reduce-only adjustments; position sizing computed in a different instrument's units; truncation from float-to-Decimal conversion losing precision.","solutions":["Increase the new quantity so it is at least one tick at the instrument's size_precision.","Check the instrument definition's size_precision and size_increment; align strategy quantities to whole ticks.","If the intent is to fully close, cancel the order instead of modifying quantity to ~0."],"exampleFix":"// before\nlet new_qty = Quantity::from(0.0004); // rounds to 0 ticks at precision 2\n// after\nlet new_qty = Quantity::new(Decimal::new(1, 2), 2); // 0.01 = 1 tick","handlingStrategy":"validation","validationCode":"let ticks = (new_qty.as_decimal() * Decimal::from(10u64.pow(instrument.size_precision() as u32)))\n    .round()\n    .to_u64().unwrap_or(0);\nif ticks == 0 { return Err(\"quantity below one tick\".into()); }","typeGuard":null,"tryCatchPattern":"match client.modify_order(&cmd).await {\n    Err(e) if e.to_string().contains(\"rounds to 0 ticks\") => cancel_order(&cmd.client_order_id).await?,\n    r => r?,\n}","preventionTips":["Quantize all quantities to the instrument's size_increment before ordering.","Reject reduce amounts smaller than one tick; cancel instead.","Avoid f64 for quantity math — use Decimal."],"tags":["quantity","size-precision","tick-rounding","lighter"],"backgroundTag":"value-out-of-range","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"}