Skip to content

/get_order_book and /book endpoint returns stale data (0.99/0.01), while get_price is accurate #180

@chienb

Description

@chienb

I have encountered a critical discrepancy between the data returned by get_order_book() (and get_order_books()) versus get_price().

For active, liquid markets, get_order_book() consistently returns a "ghost market" state with a Best Bid of 0.01 and Best Ask of 0.99, regardless of the actual trading activity. Meanwhile, calling get_price() (which presumably hits the /price endpoint or utilizes the internal get_midpoint logic) returns the correct, fresh market price.

This makes it impossible to assess market depth or implement strategies requiring order book visibility (like market making) using the standard client methods.

Environment

  • Library: py-clob-client v0.28.0
  • Python: 3.11
  • OS: macOS (Darwin)

Reproduction Steps

Run the following script with a valid Token ID for an active market.

from py_clob_client.client import ClobClient

client = ClobClient("https://clob.polymarket.com")

# Example Token ID (Active Market)
token_id = "66165572830542895638033723077931657501549172243920223554030255390751841276554"

print(f"Testing Token: {token_id}")

# 1. Check Price (Correct)
buy_price = client.get_price(token_id, side="BUY")
sell_price = client.get_price(token_id, side="SELL")
print(f"get_price(BUY): {buy_price}")   # Returns actual market price (e.g. 0.40)
print(f"get_price(SELL): {sell_price}") # Returns actual market price (e.g. 0.41)

# 2. Check Order Book (Incorrect)
book = client.get_order_book(token_id)
print(f"get_order_book():")
if book.bids and book.asks:
    print(f"  Best Bid: {book.bids[0].price}") # Returns 0.01
    print(f"  Best Ask: {book.asks[0].price}") # Returns 0.99

Actual Output

Testing Token: 66165572830542895638033723077931657501549172243920223554030255390751841276554

get_price(BUY): {'price': '0.4'}
get_price(SELL): {'price': '0.41'}

get_order_book():
  Best Bid: 0.01
  Best Ask: 0.99

Expected Output

get_order_book() should return a Best Bid of ~0.40 and Best Ask of ~0.41, matching the data from get_price() and the Polymarket UI.

Additional Context

  • The issue persists across both get_order_book (single) and get_order_books (batch).
  • get_midpoint() also returns the correct value.
  • This appears to be an issue with the /book endpoint serving stale or disconnected snapshots, while /price is serving live data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions