nautechsystems/nautilus_trader · error
invalid non-positive {name} price
Error message
invalid non-positive {name} price What it means
Thrown when a parsed bid or ask level price is zero or negative. A valid order-book level must have a strictly positive price; `anyhow::ensure!(price.is_positive(), ...)` rejects anything else before the level is added to the book.
Source
Thrown at crates/adapters/binance/src/spot/http/client.rs:3077
instrument: &InstrumentAny,
snapshot: &BinanceDepth,
ts_event: UnixNanos,
) -> anyhow::Result<OrderBook> {
let sequence = u64::try_from(snapshot.last_update_id)
.map_err(|_| anyhow::anyhow!("invalid negative order-book update ID"))?;
let mut book = OrderBook::new(instrument_id, BookType::L2_MBP);
let mut add_level = |level: &super::models::BinancePriceLevel,
side: OrderSide,
order_id: usize,
name: &str|
-> anyhow::Result<()> {
let price = Price::from_mantissa_exponent_checked(
level.price_mantissa,
snapshot.price_exponent,
instrument.price_precision(),
)
.map_err(|e| anyhow::anyhow!("invalid {name} price: {e}"))?;
anyhow::ensure!(price.is_positive(), "invalid non-positive {name} price");
let qty_mantissa = u64::try_from(level.qty_mantissa)
.map_err(|_| anyhow::anyhow!("invalid negative {name} quantity"))?;
let quantity = Quantity::from_mantissa_exponent_checked(
qty_mantissa,
snapshot.qty_exponent,
instrument.size_precision(),
)
.map_err(|e| anyhow::anyhow!("invalid {name} quantity: {e}"))?;
anyhow::ensure!(
quantity.is_positive(),
"invalid non-positive {name} quantity"
);
let order = BookOrder::new(
side,
price,
quantity,
u64::try_from(order_id)
.map_err(|_| anyhow::anyhow!("order-book level index overflow"))?,View on GitHub (pinned to 18893faf8b)
Solutions
- Re-fetch the snapshot; a single bad response is typically transient.
- Inspect the raw JSON levels to find the offending zero/negative price.
- Fix any proxy/mock fixtures to return realistic positive prices.
- Report to the adapter maintainers if a genuine Binance response violates this.
Defensive patterns
Strategy: validation
Validate before calling
fn prices_positive(snapshot: &BinanceDepth) -> bool {
snapshot.bids.iter().chain(snapshot.asks.iter()).all(|l| l.price_mantissa > 0)
} Type guard
fn positive_level(l: &BinancePriceLevel) -> bool { l.price_mantissa > 0 } Try / catch
match client.request_book_snapshot(id, depth).await {
Ok(book) => book,
Err(e) if e.to_string().contains("non-positive") => fetch_fresh_snapshot(id, depth).await?,
Err(e) => return Err(e),
} Prevention
- Re-fetch the snapshot on transient malformed data.
- Sanity-check payloads from proxies/mocks for zero-priced levels.
- Report genuine exchange responses that trigger this to maintainers.
When it happens
Trigger: Calling `request_book_snapshot` when any depth level decodes to a non-positive price — a malformed or synthetic depth response containing 0 or negative price mantissas.
Common situations: Mock servers or fixtures emitting zero-priced levels; corrupted responses from proxies; upstream API anomalies or schema changes.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- invalid {name} price: {e}
- Binance Spot order-book depth must be between 1 and 5000
- Binance Spot L1_MBP supports depth 1 only
- invalid negative order-book update ID
- invalid negative {name} quantity
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/0a0804451b274ff9.
Report an issue: GitHub.