{"record":{"id":"319e2e33408b5555","repo":"nautechsystems/nautilus_trader","slug":"failed-to-build-market-order-e","errorCode":null,"errorMessage":"Failed to build market order: {e}","messagePattern":"Failed to build market order: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/execution/submitter.rs","lineNumber":211,"sourceCode":"                price,\n                ctx.fee_rate,\n                ctx.fee_exponent,\n                ctx.builder_taker_fee_rate,\n            )?,\n            _ => amount_dec,\n        };\n\n        let poly_order = self\n            .order_builder\n            .build_market_order(\n                &token_id,\n                poly_side,\n                price,\n                signed_amount,\n                neg_risk,\n                tick_decimals,\n            )\n            .map_err(|e| anyhow::anyhow!(\"Failed to build market order: {e}\"))?;\n\n        // Wire amounts are mantissas at USDC_DECIMALS (10^6) scale. The share-denominated leg is\n        // the exact base quantity signed for the venue: takerAmount for BUY and makerAmount for\n        // SELL. Market SELL signing truncates shares to two decimal places.\n        let signed_base_qty =\n            signed_base_quantity(poly_order.maker_amount, poly_order.taker_amount, poly_side);\n        let expected_venue_order_id = self\n            .order_builder\n            .expected_order_id(&poly_order, neg_risk)?;\n\n        let http_client = self.http_client.clone();\n        let saw_unknown_outcome = Arc::new(AtomicBool::new(false));\n\n        let response = match self\n            .retry_manager\n            .invocation(\n                \"submit_market_order\",\n                || {","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/execution/submitter.rs#L193-L229","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Read the inner builder error in the message for the exact cause","Align the order price/amount to the instrument's current tick_size and size precision before submitting","Refresh instrument metadata (tick size, neg_risk) rather than caching stale values","Verify the signing key/wallet is configured correctly"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"ensure!(price.as_decimal() % tick_size.as_decimal() == Decimal::ZERO, \"price not on tick\");\nensure!(neg_risk == market_neg_risk, \"neg_risk mismatch\");","typeGuard":null,"tryCatchPattern":"if let Err(e) = submitter.submit_market_order(req).await {\n    if e.to_string().contains(\"Failed to build market order\") {\n        // refresh tick size / neg_risk metadata and re-align price before retrying\n    }\n}","preventionTips":["Always round price/size to current tick_size and size precision","Refresh instrument metadata instead of caching it","Validate neg_risk flag against the market definition"],"tags":["polymarket","order-builder","tick-size","signing"],"backgroundTag":"invalid-argument-value","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}