nautechsystems/nautilus_trader · error

{e}

Error message

{e}

What it means

request_book_snapshot fetches the CLOB order book via get_book and wraps any transport/HTTP error from that call into an anyhow::Error with this message. It indicates the order-book snapshot could not be retrieved from the Polymarket CLOB API, so no OrderBook is built.

Source

Thrown at crates/adapters/polymarket/src/http/clob.rs:739

            .request_with_params(Method::GET, url, None::<&()>, None, None, None, None)
            .await
            .map_err(Error::from_http_client)?;

        decode_response(&response)
    }

    /// Requests an order book snapshot and builds an [`OrderBook`].
    pub async fn request_book_snapshot(
        &self,
        instrument_id: InstrumentId,
        token_id: &str,
        price_precision: u8,
        size_precision: u8,
    ) -> anyhow::Result<OrderBook> {
        let resp = self
            .get_book(token_id)
            .await
            .map_err(|e| anyhow::anyhow!(e))?;

        let mut book = OrderBook::new(instrument_id, BookType::L2_MBP);

        for (i, level) in resp.bids.iter().enumerate() {
            let price = parse_price(&level.price, price_precision)?;
            let size = parse_quantity(&level.size, size_precision)?;
            let order = BookOrder::new(OrderSide::Buy, price, size, i as u64);
            book.add(order, 0, i as u64, Default::default());
        }

        let bids_len = resp.bids.len();
        for (i, level) in resp.asks.iter().enumerate() {
            let price = parse_price(&level.price, price_precision)?;
            let size = parse_quantity(&level.size, size_precision)?;
            let order = BookOrder::new(OrderSide::Sell, price, size, (bids_len + i) as u64);
            book.add(order, 0, (bids_len + i) as u64, Default::default());
        }

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Inspect the inner error message ({e}) to distinguish transport vs HTTP status causes.
  2. Verify the token_id is a valid, active CLOB token id.
  3. Retry with backoff for transient transport errors; check Polymarket status if 5xx persists.
Defensive patterns

Strategy: retry

Validate before calling

if token_id.is_empty() { bail!("token_id required for book snapshot"); }

Try / catch

match client.request_book_snapshot(instrument_id, token_id, pp, sp).await {
    Ok(book) => book,
    Err(e) => { warn!("book snapshot failed: {e}"); backoff_retry(|| client.request_book_snapshot(...), 3).await? }
}

Prevention

When it happens

Trigger: Calling request_book_snapshot while the CLOB /book endpoint returns a network error, non-2xx response, timeout, or the token_id is rejected by the server.

Common situations: Invalid or delisted token_id, CLOB API outage or rate limiting, DNS/proxy failures, or running against a stale/incorrect CLOB host.

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


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