{"record":{"id":"29961e3d85c3ee14","repo":"nautechsystems/nautilus_trader","slug":"invalid-non-positive-name-quantity","errorCode":null,"errorMessage":"invalid non-positive {name} quantity","messagePattern":"invalid non-positive (.+?) quantity","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/spot/http/client.rs","lineNumber":3086,"sourceCode":"                             order_id: usize,\n                             name: &str|\n         -> anyhow::Result<()> {\n            let price = Price::from_mantissa_exponent_checked(\n                level.price_mantissa,\n                snapshot.price_exponent,\n                instrument.price_precision(),\n            )\n            .map_err(|e| anyhow::anyhow!(\"invalid {name} price: {e}\"))?;\n            anyhow::ensure!(price.is_positive(), \"invalid non-positive {name} price\");\n            let qty_mantissa = u64::try_from(level.qty_mantissa)\n                .map_err(|_| anyhow::anyhow!(\"invalid negative {name} quantity\"))?;\n            let quantity = Quantity::from_mantissa_exponent_checked(\n                qty_mantissa,\n                snapshot.qty_exponent,\n                instrument.size_precision(),\n            )\n            .map_err(|e| anyhow::anyhow!(\"invalid {name} quantity: {e}\"))?;\n            anyhow::ensure!(\n                quantity.is_positive(),\n                \"invalid non-positive {name} quantity\"\n            );\n            let order = BookOrder::new(\n                side,\n                price,\n                quantity,\n                u64::try_from(order_id)\n                    .map_err(|_| anyhow::anyhow!(\"order-book level index overflow\"))?,\n            );\n            book.add(order, 0, sequence, ts_event);\n            Ok(())\n        };\n\n        for (index, level) in snapshot.bids.iter().enumerate() {\n            add_level(level, OrderSide::Buy, index, \"bid\")?;\n        }\n        let bid_count = snapshot.bids.len();","sourceCodeStart":3068,"sourceCodeEnd":3104,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/spot/http/client.rs#L3068-L3104","documentation":"Sanity guard when parsing Binance order-book snapshot levels: after decoding, each level's quantity must be a positive value; a zero or negative quantity indicates malformed venue data and is rejected (with the level name in the message).","triggerScenarios":"Calling `request_book_snapshot` when any depth level decodes to a zero quantity — e.g. a level that rounds to zero at the instrument's `size_precision`, or a malformed payload with 0 quantity.","commonSituations":"Very small quantities rounded to zero at coarse size precision (stale instrument definitions); mock/fixture data with zero quantities; corrupted upstream responses.","solutions":["Refresh the instruments cache so `size_precision` matches the current LOT_SIZE step (a too-coarse precision can round tiny quantities to zero).","Re-fetch the snapshot to rule out transient data issues.","Inspect raw JSON levels to find the zero-quantity level.","Report to maintainers if genuine exchange data triggers this."],"exampleFix":"// before\nlet book = client.request_book_snapshot(instrument_id, depth).await?;\n// after: refresh instrument precision first\nclient.reload_instruments().await?;\nlet book = client.request_book_snapshot(instrument_id, depth).await?;","handlingStrategy":"validation","validationCode":"fn quantities_positive(snapshot: &BinanceDepth, precision: u8) -> bool {\n    snapshot.bids.iter().chain(snapshot.asks.iter()).all(|l| {\n        l.qty_mantissa as f64 * 10f64.powi(l.qty_mantissa.to_string().len() as i32) > 0.0 || l.qty_mantissa > 0\n    })\n}","typeGuard":"fn positive_qty_level(l: &BinancePriceLevel) -> bool { l.qty_mantissa > 0 }","tryCatchPattern":"match client.request_book_snapshot(id, depth).await {\n    Ok(book) => book,\n    Err(e) if e.to_string().contains(\"non-positive\") && e.to_string().contains(\"quantity\") => {\n        reload_instruments_and_retry(id, depth).await?\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Ensure instrument size_precision is not coarser than the exchange step, or dust quantities round to zero.","Refresh instrument definitions before large snapshot requests.","Filter zero-quantity levels in any custom pre-processing."],"tags":["orderbook","binance","quantity","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"}