{"record":{"id":"3712e9b04d4a7291","repo":"nautechsystems/nautilus_trader","slug":"failed-to-fetch-order-book-e","errorCode":null,"errorMessage":"Failed to fetch order book: {e}","messagePattern":"Failed to fetch order book: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/execution/submitter.rs","lineNumber":168,"sourceCode":"            token_id,\n            side,\n            amount,\n            time_in_force,\n            neg_risk,\n            tick_size,\n            tick_decimals,\n            fee_context,\n        } = request;\n        let poly_side = PolymarketOrderSide::from(side);\n        let order_type = PolymarketOrderType::from_market_time_in_force(time_in_force)\n            .map_err(|e| anyhow::anyhow!(\"{e}\"))?;\n        let amount_dec = amount.as_decimal();\n\n        let book = self\n            .http_client\n            .get_book(&token_id)\n            .await\n            .map_err(|e| anyhow::anyhow!(\"Failed to fetch order book: {e}\"))?;\n\n        let levels = match poly_side {\n            PolymarketOrderSide::Buy => &book.asks,\n            PolymarketOrderSide::Sell => &book.bids,\n        };\n\n        let result = calculate_market_price(levels, amount_dec, poly_side).map_err(|e| {\n            let message = format!(\"Market price calculation failed: {e}\");\n            e.context(message)\n        })?;\n        let price = PolymarketOrderBuilder::normalize_market_price(\n            result.crossing_price,\n            tick_size,\n            tick_decimals,\n        )\n        .map_err(InvalidMarketPriceError)?;\n\n        // Fee-aware sizing applies to BUY only and only when a context is","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/execution/submitter.rs#L150-L186","documentation":"Raised in `submit_market_order` when the HTTP client's `get_book(&token_id)` call fails while fetching the order book needed to price/size the market order. The submitter needs live asks (for BUY) or bids (for SELL) to compute the signed order amounts, so a book-fetch failure aborts submission. The underlying transport/HTTP error is embedded in the message.","triggerScenarios":"Network outage or DNS failure to the Polymarket CLOB endpoint; invalid or unknown token_id (condition id not found); API returning 4xx/5xx; TLS or proxy misconfiguration; rate limiting during volatile markets.","commonSituations":"Expired or wrong token_id after market resolution; corporate proxy/firewall blocking the endpoint; transient 5xx during high volatility; missing network in containers/CI.","solutions":["Verify the token_id is a live, tradable asset id (market not resolved)","Check network connectivity/proxy settings to the Polymarket CLOB host","Retry with backoff — the HTTP client already classifies retryable errors; transient outages resolve on retry","Inspect the inner error in the message for status code/cause and fix accordingly"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// pre-check: token id is non-empty and market is live\nif token_id.is_empty() { return Err(anyhow!(\"empty token_id\")); }","typeGuard":null,"tryCatchPattern":"match book_result {\n    Err(e) if is_transient(&e) => backoff_retry(|| get_book(&token_id), 3).await,\n    Err(e) => return Err(anyhow!(\"book fetch failed permanently: {e}\")),\n    Ok(book) => book,\n}","preventionTips":["Validate token_id against market metadata before submitting","Use retry-with-backoff for book fetches","Monitor Polymarket API health during volatile periods"],"tags":["network","http","polymarket","order-book"],"backgroundTag":"http-request-failed","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"}