nautechsystems/nautilus_trader · error · anyhow::Error
Failed to create quantity from orig_sz: {e}
Error message
Failed to create quantity from orig_sz: {e} What it means
parse_order_status_report_from_basic() converts the exchange-reported original size (order.orig_sz) into a domain Quantity rounded to the instrument's size_precision; it fails when the value cannot be represented at that precision (e.g. too many decimal digits or out of range for Quantity).
Source
Thrown at crates/adapters/hyperliquid/src/http/parse.rs:967
_ => OrderType::Limit,
}
} else {
OrderType::Limit
};
let time_in_force = order
.tif
.map_or(TimeInForce::Gtc, hyperliquid_time_in_force_to_nautilus);
let order_status = OrderStatus::from(*status);
let price_precision = instrument.price_precision();
let size_precision = instrument.size_precision();
let orig_sz = order.orig_sz;
let current_sz = order.sz;
let quantity = Quantity::from_decimal_dp(orig_sz.abs(), size_precision)
.map_err(|e| anyhow::anyhow!("Failed to create quantity from orig_sz: {e}"))?;
let filled_sz = orig_sz.abs() - current_sz.abs();
let filled_qty = Quantity::from_decimal_dp(filled_sz, size_precision)
.map_err(|e| anyhow::anyhow!("Failed to create quantity from filled_sz: {e}"))?;
let ts_accepted = UnixNanos::from(order.timestamp * 1_000_000);
let ts_last = ts_accepted;
let report_id = UUID4::new();
let mut report = OrderStatusReport::new(
account_id,
instrument_id,
None, // client_order_id - will be set if present
venue_order_id,
order_side.into(),
order_type,
time_in_force,
order_status,
quantity,View on GitHub (pinned to 18893faf8b)
Solutions
- Reload/refresh instrument definitions so size_precision matches the venue's current tick/size rules for that symbol
- Check orig_sz in the raw payload ({e} details) for unexpected magnitude or precision
- Update the adapter/instrument parsing if a new market type (HIP-3) reports sizes incompatible with current precision handling
- Re-fetch instruments at connect time rather than relying on cached definitions
Example fix
null
Defensive patterns
Strategy: validation
Validate before calling
// before parsing, confirm instrument precision accommodates the venue size
let dp = orig_sz.abs().fract().to_string().split('.').nth(1).map(|f| f.len()).unwrap_or(0);
if dp > instrument.size_precision() as usize { refresh_instrument_definition(); } Try / catch
match parse_order_status_report_from_basic(instrument, order, ...) { Err(e) if e.to_string().contains("Failed to create quantity from orig_sz") => { refresh_instruments(); reparse(); }, other => other } Prevention
- Refresh instrument definitions at connect time; never cache across sessions with stale precision
- Verify size_precision matches Hyperliquid's market metadata for the symbol
- Watch for HIP-3 builder-deployed markets with unusual size decimals
- Compare raw orig_sz values in logs when the error appears to detect precision drift
When it happens
Trigger: Parsing an order status report (HTTP or WS) whose orig_sz has more decimal places than the configured instrument size_precision, or a value outside the Quantity representable range (e.g. a builder-deployed market whose instrument metadata mismatches the sizes reported).
Common situations: Stale or wrong instrument definitions where size_precision is smaller than what Hyperliquid returns for that market; HIP-3 builder-deployed markets with unusual size decimals; instrument definition changed on the venue while cached definitions are outdated.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- quantity size={} cannot be represented with precision={}
- Failed to parse '{field_name}' value '{value}' into Quantity
- size precision {precision} exceeds maximum {MAX_DECIMALS}
- Failed to convert quote-to-base quantity for ord_id={}, sz={
- Order quantity {quantity} is not exactly representable in {d
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/04e63fd81777d636.
Report an issue: GitHub.