Instrument State Tracking: The state field is optional. Use ListInstruments to get and cache the initial state, then subscribe to the instrument state change subscription for real-time state updates.
if response.HasField('heartbeat'): passelif response.HasField('snapshot'): for order in response.snapshot.orders: print(f"Order: {order.id} - {order.symbol}")elif response.HasField('update'): for execution in response.update.executions: print(f"Execution: {execution.id}")
Name                                               Â
Value
Description
INSTRUMENT_STATE_PENDING
8
Initial state for a newly created instrument which has not yet begun trading.
INSTRUMENT_STATE_OPEN
1
In this state, the instrument is open for continuous order entry and matching.
INSTRUMENT_STATE_CLOSED
0
In this state, orders can not be entered, modified, or canceled, and no matching occurs. Any existing Day orders will be expired.
INSTRUMENT_STATE_EXPIRED
4
An instrument moves to this state when its Expiration Date/Time is reached. In this state, any resting orders are expired and no new orders can be entered.
INSTRUMENT_STATE_TERMINATED
5
When an instrument’s Termination Date is reached, the order book is removed from the matching engine, orders are canceled, and positions are closed. Historical data will still remain in Polymarket US ledgers.
Name                                               Â
Value
Description
INSTRUMENT_STATE_PREOPEN
2
Orders can be entered and modified, but no matching occurs. When the instrument transitions to an OPEN state, the orders entered during PREOPEN will match at a single opening price that is automatically determined by an algorithm that is designed to maximize the volume traded at the open.
INSTRUMENT_STATE_MATCH_AND_CLOSE_AUCTION
7
This state is similar to PREOPEN, with the exception that matching will occur upon the transition of this state to any other state. This state is useful if you want matching to occur at the end of the state, but you don’t want the instrument to be open after.