nautechsystems/nautilus_trader · error
Failed to parse `lot_sz` '{}' for {}: {e}
Error message
Failed to parse `lot_sz` '{}' for {}: {e} What it means
Venue-data parse failure in parse_spread_instrument: OKX's lot_sz (lot size / size increment) string for the spread instrument cannot be parsed into a Quantity; the message includes the raw string and instrument id.
Source
Thrown at crates/adapters/okx/src/common/parse.rs:1681
.map(parse_millisecond_timestamp)
.ok_or_else(|| anyhow::anyhow!("`list_time` is required for {}", definition.sprd_id))?;
let expiration_ns = definition
.exp_time
.map(parse_millisecond_timestamp)
.unwrap_or_default();
let ts_event = definition
.u_time
.map_or(ts_init, parse_millisecond_timestamp);
let price_increment = Price::from_str(&definition.tick_sz).map_err(|e| {
anyhow::anyhow!(
"Failed to parse `tick_sz` '{}' for {}: {e}",
definition.tick_sz,
definition.sprd_id
)
})?;
let size_increment = Quantity::from_str(&definition.lot_sz).map_err(|e| {
anyhow::anyhow!(
"Failed to parse `lot_sz` '{}' for {}: {e}",
definition.lot_sz,
definition.sprd_id
)
})?;
let min_quantity = if definition.min_sz.is_empty() {
None
} else {
Some(Quantity::from_str(&definition.min_sz).map_err(|e| {
anyhow::anyhow!(
"Failed to parse `min_sz` '{}' for {}: {e}",
definition.min_sz,
definition.sprd_id
)
})?)
};
let info = Some(build_spread_info(definition));View on GitHub (pinned to 18893faf8b)
Solutions
- Verify lot_sz in the failing payload is a valid non-empty decimal string
- Re-fetch spread instrument definitions from the live OKX endpoint
- Fix field-name/casing mismatches (lotSz -> lot_sz with serde rename)
- Default empty lot_sz to a known-safe increment if the instrument is still tradeable
Defensive patterns
Strategy: validation
Validate before calling
fn lot_sz_valid(def: &OKXSpreadInstrument) -> bool {
!def.lot_sz.is_empty() && def.lot_sz.parse::<rust_decimal::Decimal>().is_ok()
} Try / catch
let size_increment = match parse_spread_instrument(&definition, ts_init) {
Ok(inst) => inst,
Err(e) => { tracing::error!("lot_sz parse failed for {}: {e:#}", definition.sprd_id); return; }
}; Prevention
- Validate lot_sz at ingestion time, before caching
- Watch for OKX schema changes in /sprd/instruments
- Trim/normalize numeric strings before parsing
When it happens
Trigger: Calling parse_spread_instrument when definition.lot_sz is empty or not a valid decimal string (e.g. '0.001 BTC' or missing after a schema change).
Common situations: Bad fixtures or cached definitions; serde deserialization leaving lot_sz empty when OKX omits the field; copy/paste mistakes in stored instrument metadata.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Failed to parse fallback quantity for ord_id={}, sz='{}': {e
- Failed to convert quote-to-base quantity for ord_id={}, sz={
- Failed to parse filled quantity for ord_id={}, acc_fill_sz='
- Failed to parse base quantity for ord_id={}, sz='{}': {e}
- Failed to parse `min_sz` '{}' for {}: {e}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/178cfd916a89d1c7.
Report an issue: GitHub.