{"record":{"id":"126a4226514029d6","repo":"nautechsystems/nautilus_trader","slug":"invalid-name-quantity-e","errorCode":null,"errorMessage":"invalid {name} quantity: {e}","messagePattern":"invalid (.+?) quantity: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/spot/http/client.rs","lineNumber":3085,"sourceCode":"                             side: OrderSide,\n                             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        }","sourceCodeStart":3067,"sourceCodeEnd":3103,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/spot/http/client.rs#L3067-L3103","documentation":"Thrown when a level's quantity mantissa (with the snapshot's `qty_exponent`) cannot be converted into a Nautilus `Quantity` at the instrument's `size_precision`. The `name` is \"bid\" or \"ask\", identifying the failing side.","triggerScenarios":"Calling `request_book_snapshot` when `Quantity::from_mantissa_exponent_checked` fails for a level — a quantity not representable at `instrument.size_precision()`, typically from an instrument-definition/cache mismatch with the snapshot's `qty_exponent`.","commonSituations":"Stale cached instrument definitions whose size precision no longer matches exchange LOT_SIZE filters; corrupted depth payloads; exchange precision changes after an instrument update.","solutions":["Refresh the instruments cache so `size_precision` matches current LOT_SIZE filters.","Re-fetch the snapshot to rule out a transient malformed payload.","Check the inner `{e}` message for the exact Quantity conversion failure.","Update the adapter if Binance changed the qty-exponent encoding."],"exampleFix":"// before\nlet book = client.request_book_snapshot(instrument_id, depth).await?;\n// after: ensure instrument definitions are fresh first\nclient.reload_instruments().await?;\nlet book = client.request_book_snapshot(instrument_id, depth).await?;","handlingStrategy":"validation","validationCode":"fn qty_fits_precision(qty: i64, exponent: i32, precision: u8) -> bool {\n    exponent >= -(precision as i32) || qty % 10 == 0\n}","typeGuard":"fn valid_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(\"invalid bid quantity\") || e.to_string().contains(\"invalid ask quantity\") => {\n        reload_instruments_and_retry(id, depth).await?\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Keep the instruments cache refreshed so size_precision matches current LOT_SIZE filters.","Reload instruments after exchange lot-size updates.","Capture raw responses on failure for support requests."],"tags":["orderbook","binance","quantity","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-14T05:17:10.506Z"}