nautechsystems/nautilus_trader · error
Failed to fetch order book: {e}
Error message
Failed to fetch order book: {e} What it means
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.
Source
Thrown at crates/adapters/polymarket/src/execution/submitter.rs:168
token_id,
side,
amount,
time_in_force,
neg_risk,
tick_size,
tick_decimals,
fee_context,
} = request;
let poly_side = PolymarketOrderSide::from(side);
let order_type = PolymarketOrderType::from_market_time_in_force(time_in_force)
.map_err(|e| anyhow::anyhow!("{e}"))?;
let amount_dec = amount.as_decimal();
let book = self
.http_client
.get_book(&token_id)
.await
.map_err(|e| anyhow::anyhow!("Failed to fetch order book: {e}"))?;
let levels = match poly_side {
PolymarketOrderSide::Buy => &book.asks,
PolymarketOrderSide::Sell => &book.bids,
};
let result = calculate_market_price(levels, amount_dec, poly_side).map_err(|e| {
let message = format!("Market price calculation failed: {e}");
e.context(message)
})?;
let price = PolymarketOrderBuilder::normalize_market_price(
result.crossing_price,
tick_size,
tick_decimals,
)
.map_err(InvalidMarketPriceError)?;
// Fee-aware sizing applies to BUY only and only when a context isView on GitHub (pinned to 18893faf8b)
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
Defensive patterns
Strategy: retry
Validate before calling
// pre-check: token id is non-empty and market is live
if token_id.is_empty() { return Err(anyhow!("empty token_id")); } Try / catch
match book_result {
Err(e) if is_transient(&e) => backoff_retry(|| get_book(&token_id), 3).await,
Err(e) => return Err(anyhow!("book fetch failed permanently: {e}")),
Ok(book) => book,
} Prevention
- Validate token_id against market metadata before submitting
- Use retry-with-backoff for book fetches
- Monitor Polymarket API health during volatile periods
When it happens
Trigger: 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.
Common situations: Expired or wrong token_id after market resolution; corporate proxy/firewall blocking the endpoint; transient 5xx during high volatility; missing network in containers/CI.
Understand the failure class
Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.
Related errors
- Failed to probe market closure for {failed_chunks} of {total
- All {total} event slug requests failed
- Failed to fetch order status: {e}
- Polymarket only supports L2_MBP order book deltas, received
- Polymarket does not support OrderBookDepth10 subscriptions;
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/3712e9b04d4a7291.
Report an issue: GitHub.