nautechsystems/nautilus_trader · error

Signed limit order share quantity {signed_base_qty} is inval

Error message

Signed limit order share quantity {signed_base_qty} is invalid at instrument size precision {}: {e}

What it means

Raised in `prepare_limit_order_submission` when converting the signed order's implied share quantity (`signed_base_qty`, derived from maker/taker amounts) into a `Quantity` at the instrument's size_precision fails — e.g. the decimal is malformed, negative, or has too many fractional digits. This is a post-signing consistency check ensuring the venue amounts decode to a valid quantity. Submission is aborted.

Source

Thrown at crates/adapters/polymarket/src/execution/submitter.rs:475

            )
        } else {
            self.order_builder.build_limit_order(
                &request.token_id,
                side,
                request.price.as_decimal(),
                request.quantity.as_decimal(),
                order_type,
                &expiration,
                request.neg_risk,
                request.tick_decimals,
            )
        }
        .map_err(|e| anyhow::anyhow!("{e}"))?;

        let signed_base_qty = signed_base_quantity(order.maker_amount, order.taker_amount, side);
        let expected_base_qty =
            Quantity::from_decimal_dp(signed_base_qty, request.size_precision).map_err(|e| {
                anyhow::anyhow!(
                    "Signed limit order share quantity {signed_base_qty} is invalid at instrument size precision {}: {e}",
                    request.size_precision,
                )
            })?;
        anyhow::ensure!(
            expected_base_qty.as_decimal() == signed_base_qty,
            "Signed limit order share quantity {signed_base_qty} cannot be represented exactly at instrument size precision {}",
            request.size_precision,
        );

        let expected_venue_order_id = self
            .order_builder
            .expected_order_id(&order, request.neg_risk)?;

        Ok(SignedLimitOrderSubmission {
            order,
            order_type,
            post_only: request.post_only,

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Match request.size_precision to the precision the order builder actually rounds to
  2. Verify instrument size_precision against current Polymarket market metadata
  3. Inspect the inner parse error for whether the quantity is invalid vs merely imprecise
Defensive patterns

Strategy: validation

Validate before calling

let dp = signed_base_qty.fract().scale();
if dp > request.size_precision {
    return Err(anyhow!("signed qty has {dp} dp > size_precision {}", request.size_precision));
}

Try / catch

match prepare_limit_order_submission(&req).await {
    Err(e) if e.to_string().contains("is invalid at instrument size precision") => {
        // correct instrument size_precision config and resubmit
    }
    other => other,
}

Prevention

When it happens

Trigger: Signed amounts whose ratio decodes to a share quantity that cannot be parsed at request.size_precision (e.g. more decimal places than the instrument allows, or an invalid decimal).

Common situations: Instruments configured with a size_precision smaller than what the builder's rounding produced; extreme prices causing long decimal expansions; misconfigured size_precision in the instrument definition.

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


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/bf42f8b81b235d67. Report an issue: GitHub.