nautechsystems/nautilus_trader · error
invalid precision
Error message
invalid {field} precision: {e} What it means
Raised when converting a parsed decimal into a Price at the required precision fails via Price::from_decimal_dp — the value has more decimal places than the instrument's precision permits (or is otherwise not representable at that precision). The {field} placeholder names which order/quantity field (e.g. price, stopPrice) failed. It guards against constructing invalid domain prices from Futures order payloads.
Solutions
- Verify the precision passed to the parser matches the symbol's exchangeInfo tickSize for Futures.
- Refresh/rebuild instrument definitions so precision metadata is current.
- Truncate or round the incoming decimal to the instrument precision at the boundary before constructing Price, if lossy input is acceptable.
- Log the field name and raw value from the error to pinpoint which payload field needs adjustment.
Example fix
// before let precision = 4; // stale Price::from_decimal_dp(decimal, precision) // after let precision = instrument.price_precision; // from latest exchangeInfo Price::from_decimal_dp(decimal.round_dp(precision), precision)
Defensive patterns
Strategy: validation
Validate before calling
let d: Decimal = raw.parse()?;
if d.scale() > precision as u32 {
return Err(format!("{field} {} has {} dp, exceeds precision {precision}", raw, d.scale()));
} Try / catch
match parse_price_field(&raw, precision, "price") {
Ok(Some(price)) => use(price),
Ok(None) => {}, // absent/zero: optional field
Err(e) if e.to_string().contains("precision") => refresh_instrument_metadata(),
Err(e) => return Err(e.into()),
} Prevention
- Source precision from the latest exchangeInfo, not constants.
- Re-sync instrument definitions when Binance changes tick sizes.
- Round inputs to the instrument precision at system boundaries.
When it happens
Trigger: A Futures model field parsed as a decimal has fractional precision exceeding the configured precision — e.g. building order/position models from REST payloads where a price string like "0.123456789" is checked against a smaller precision; parse_optional_price helper in futures/http/models.rs:1768.
Common situations: Wrong precision constant for the symbol (spot vs futures tick size), newly listed symbols with unusual tick sizes, adapter metadata not refreshed after Binance precision 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
- Instrument not found in cache
- invalid Futures funding rate at
- invalid Futures kline
- invalid Futures kline
- invalid Futures kline
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/9eed19af5be93beb.
Report an issue: GitHub.
Appendix: source
Thrown at crates/adapters/binance/src/futures/http/models.rs:1768
raw.filter(|price| !price.is_empty())
.map(|price| parse_positive_price_at_precision(price, price_precision, "avg_price"))
.transpose()
.map(|price| price.flatten().map(|price| price.as_decimal()))
}
fn parse_positive_price_at_precision(
raw: &str,
precision: u8,
field: &str,
) -> anyhow::Result<Option<Price>> {
let decimal = parse_required_decimal(raw, field)?;
if decimal <= Decimal::ZERO {
return Ok(None);
}
Price::from_decimal_dp(decimal, precision)
.map(Some)
.map_err(|e| anyhow::anyhow!("invalid {field} precision: {e}"))
}
fn parse_callback_rate_basis_points(raw: &str) -> anyhow::Result<Option<Decimal>> {
let rate = parse_required_decimal(raw, "callback_rate")?;
if rate <= Decimal::ZERO {
return Ok(None);
}
rate.checked_mul(Decimal::from(100))
.map(Some)
.ok_or_else(|| anyhow::anyhow!("invalid callback_rate='{raw}': multiplication overflow"))
}
fn parse_working_type(working_type: Option<BinanceWorkingType>) -> TriggerType {
match working_type {
Some(BinanceWorkingType::ContractPrice) => TriggerType::LastPrice,
Some(BinanceWorkingType::MarkPrice) => TriggerType::MarkPrice,
Some(BinanceWorkingType::Unknown) | None => TriggerType::Default,View on GitHub (pinned to 18893faf8b)