nautechsystems/nautilus_trader · error
Failed to build amend order params: {e}
Error message
Failed to build amend order params: {e} What it means
The amend-order flow builds a Kraken `AmendOrderParams` via a builder with validation. If the combination of fields (order id, quantity, price, trigger price, etc.) is invalid per the builder's checks, `build()` fails and the adapter wraps it in this anyhow error before any HTTP call is made.
Source
Thrown at crates/adapters/kraken/src/http/spot/client.rs:2909
} else if let Some(ref id) = cl_ord_id {
builder.cl_ord_id(id.clone());
}
if let Some(qty) = quantity {
builder.order_qty(qty.to_string());
}
if let Some(p) = price {
builder.limit_price(p.to_string());
}
if let Some(tp) = trigger_price {
builder.trigger_price(tp.to_string());
}
let params = builder
.build()
.map_err(|e| anyhow::anyhow!("Failed to build amend order params: {e}"))?;
let _response = self.inner.amend_order(¶ms).await?;
// AmendOrder modifies in-place, so the order keeps its original ID
let order_id = venue_order_id.ok_or(KrakenModifyOrderError::MissingOrderId)?;
Ok(order_id)
}
/// Cancels an order on the Kraken Spot exchange.
///
/// # Errors
///
/// Returns an error if:
/// - Credentials are missing.
/// - Neither client_order_id nor venue_order_id is provided.
/// - The request fails.
/// - The order cancellation is rejected.View on GitHub (pinned to 18893faf8b)
Solutions
- Read the inner `{e}` message; it names the exact builder validation that failed.
- Ensure exactly one valid order identifier is supplied and it is non-empty.
- Validate quantity/price/trigger-price values are positive and correctly formatted before calling amend.
- Use values sourced from the original order report (precision-correct Price/Quantity types converted with `to_string()`).
Example fix
// before
builder.quantity("0"); // invalid qty
// after
builder.quantity(order.quantity().to_string()); Defensive patterns
Strategy: validation
Validate before calling
fn validate_amend(venue_order_id: Option<&str>, qty: Option<Decimal>, price: Option<Decimal>) -> Result<(), String> {
if venue_order_id.map_or(true, |s| s.is_empty()) {
return Err("amend requires non-empty venue order id".into());
}
if qty.map_or(false, |q| q <= Decimal::ZERO) { return Err("amend qty must be positive".into()); }
if price.map_or(false, |p| p <= Decimal::ZERO) { return Err("amend price must be positive".into()); }
Ok(())
} Try / catch
match client.amend_order(req).await {
Ok(r) => r,
Err(e) if e.to_string().contains("Failed to build amend order params") => {
log::error!("invalid amend request {:?}: {e}", req);
return Err(e);
}
Err(e) => return Err(e),
} Prevention
- Source amend values from the original order report to guarantee valid formats
- Never amend orders that lack a venue order id
- Validate quantities/prices are positive and precision-correct before calling amend
When it happens
Trigger: Calling amend-order with an invalid parameter combination: e.g. both a modify quantity and price that violate builder invariants, empty required identifiers, malformed price/quantity strings, or mutually exclusive fields set together.
Common situations: Strategy code amending an order with a computed price that formats to an invalid string (NaN/zero precision); passing both `venue_order_id` and client order id in a way the builder rejects; amend requests constructed from partially-filled order state with invalid sizes.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Failed to build cancel params: {e}
- Failed to build order params: {e}
- limit_price is required for batch order type {order_type:?}
- Conditional order type {order_type:?} requires trigger_price
- Leverage {n}:1 not supported for {raw_symbol} on {side_label
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/25b08809ffc5e25e.
Report an issue: GitHub.