{"record":{"id":"145af814d7a49e51","repo":"nautechsystems/nautilus_trader","slug":"derived-market-price-widened-rounds-to-0-ticks","errorCode":null,"errorMessage":"derived market price `{widened}` rounds to 0 ticks at precision {price_precision} (slippage_bps={slippage_bps}); reduce slippage or increase price precision","messagePattern":"derived market price `(.+?)` rounds to 0 ticks at precision (.+?) \\(slippage_bps=(.+?)\\); reduce slippage or increase price precision","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/lighter/src/websocket/dispatch.rs","lineNumber":2166,"sourceCode":"    let widened = if is_buy {\n        base * (Decimal::ONE + slippage)\n    } else {\n        base * (Decimal::ONE - slippage)\n    };\n\n    let scale = Decimal::from(10_i64.pow(u32::from(price_precision)));\n    let scaled = widened * scale;\n    let rounded = if is_buy {\n        scaled.ceil()\n    } else {\n        scaled.floor()\n    };\n    let value = decimal_trunc_to_i64(rounded).with_context(|| {\n        format!(\"derived market price `{widened}` overflows i64 at precision {price_precision}\",)\n    })?;\n\n    // Lighter rejects `price = 0` as `21702 invalid price`.\n    anyhow::ensure!(\n        value > 0,\n        \"derived market price `{widened}` rounds to 0 ticks at precision {price_precision} (slippage_bps={slippage_bps}); reduce slippage or increase price precision\",\n    );\n    u32::try_from(value).with_context(|| {\n        format!(\"derived market price `{widened}` overflows u32 at precision {price_precision}\",)\n    })\n}\n\n#[cfg(test)]\nmod tests {\n    use std::str::FromStr;\n\n    use nautilus_core::UUID4;\n    use nautilus_model::{\n        enums::{AccountType, LiquiditySide, OrderSide, OrderStatus, OrderType, PositionSide},\n        identifiers::{AccountId, StrategyId, TradeId},\n        orders::Order,\n        reports::FillReport,","sourceCodeStart":2148,"sourceCodeEnd":2184,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/lighter/src/websocket/dispatch.rs#L2148-L2184","documentation":"For MARKET/STOP_MARKET/MARKET_IF_TOUCHED orders the adapter derives a worst-acceptable price from a base price widened by slippage_bps, rounded at the instrument's price_precision. Lighter rejects price=0 (venue error 21702), so if the derived price rounds down to 0 ticks this error is raised to prevent the submit.","triggerScenarios":"A very small base price (low-priced asset) with a price_precision that makes one tick larger than the widened price — e.g. price 0.0000001 with price_precision 2 and any positive slippage widening direction rounding to 0.","commonSituations":"Trading micro-cap tokens whose price is below one tick at the configured precision; misconfigured instrument precision; excessive slippage_bps applied to sells pushing price toward zero then rounding to 0.","solutions":["Increase the instrument's price_precision configuration so the price has at least 1 tick","Reduce slippage_bps for sell-side widening","Verify the base price is correct; a near-zero price may indicate a bad data feed"],"exampleFix":"// before\n// price_precision = 2, price = 0.0000004 -> derived price rounds to 0\n// after: configure instrument with higher price precision\nlet price_precision = 8; // 0.0000004 -> 0 ticks at 2dp, valid at 8dp","handlingStrategy":"validation","validationCode":"let widened = derive_worst_price(base, slippage_bps, side);\nlet ticks = (widened * Decimal::from(10u32.pow(price_precision))).trunc();\nanyhow::ensure!(ticks > Decimal::ZERO, \"derived price rounds to 0 ticks\");","typeGuard":null,"tryCatchPattern":"match derive_market_price(...) {\n    Err(e) if e.to_string().contains(\"rounds to 0 ticks\") => {\n        // raise price_precision or reject the market order\n    }\n    r => r?,\n}","preventionTips":["Configure price_precision from venue metadata, not guesses","For very low-priced assets, ensure price_precision puts price above 1 tick","Check base price sanity before deriving market prices"],"tags":["rust","market-order","precision","validation"],"backgroundTag":"invalid-argument-value","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"}