nautechsystems/nautilus_trader · error

Failed to build market order

Error message

Failed to build market order: {e}

What it means

Raised in `submit_market_order` after the order book fetch, when the order builder fails to construct and sign the FOK/FAK market order from price, signed_amount, neg_risk, and tick parameters. The underlying builder error (e.g. rounding to tick size failure, amount-to-lots conversion, signing error) is embedded in the message. Submission is aborted before any request is sent to the venue.

Solutions

  1. Read the inner builder error in the message for the exact cause
  2. Align the order price/amount to the instrument's current tick_size and size precision before submitting
  3. Refresh instrument metadata (tick size, neg_risk) rather than caching stale values
  4. Verify the signing key/wallet is configured correctly
Defensive patterns

Strategy: validation

Validate before calling

ensure!(price.as_decimal() % tick_size.as_decimal() == Decimal::ZERO, "price not on tick");
ensure!(neg_risk == market_neg_risk, "neg_risk mismatch");

Try / catch

if let Err(e) = submitter.submit_market_order(req).await {
    if e.to_string().contains("Failed to build market order") {
        // refresh tick size / neg_risk metadata and re-align price before retrying
    }
}

Prevention

When it happens

Trigger: Price not aligned to the market tick_size; signed_amount below minimum size; negative-risk market flags inconsistent; malformed book data leading to no valid executable level; EIP-712 signing failure (bad signing key).

Common situations: Using a price rounded to more decimals than tick_decimals; trading neg-risk markets without the correct neg_risk flag; tick size changed by the venue (0.01 -> 0.001) so cached tick parameters are stale.

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


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

Appendix: source

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

                price,
                ctx.fee_rate,
                ctx.fee_exponent,
                ctx.builder_taker_fee_rate,
            )?,
            _ => amount_dec,
        };

        let poly_order = self
            .order_builder
            .build_market_order(
                &token_id,
                poly_side,
                price,
                signed_amount,
                neg_risk,
                tick_decimals,
            )
            .map_err(|e| anyhow::anyhow!("Failed to build market order: {e}"))?;

        // Wire amounts are mantissas at USDC_DECIMALS (10^6) scale. The share-denominated leg is
        // the exact base quantity signed for the venue: takerAmount for BUY and makerAmount for
        // SELL. Market SELL signing truncates shares to two decimal places.
        let signed_base_qty =
            signed_base_quantity(poly_order.maker_amount, poly_order.taker_amount, poly_side);
        let expected_venue_order_id = self
            .order_builder
            .expected_order_id(&poly_order, neg_risk)?;

        let http_client = self.http_client.clone();
        let saw_unknown_outcome = Arc::new(AtomicBool::new(false));

        let response = match self
            .retry_manager
            .invocation(
                "submit_market_order",
                || {

View on GitHub (pinned to 18893faf8b)