Events
Each subscription stream has a corresponding event that will be broadcasted over websocket.
Order Update
Update speed: real-time
Example Scenarios:
Let's assume your initial order amount is 100 units and each match occurs for an amount of 10 units.
Note: The following events only include amount
and reason
for simplicity.
Scenario 1: Limit Order Partially Fills and Gets Placed
Your limit order matches against existing orders in the book.
You will receive the following events over websocket, each with the same timestamp but in sequential order:
Event 1:
(90, "filled")
โ 10 units of your order are filled.Event 2:
(80, "filled")
โ Another 10 units are filled.Event 3:
(80, "placed")
โ The remaining 80 units are placed on the book.
Scenario 2: Immediate-Or-Cancel (IOC) Order Partially Fills
Your IOC order matches against existing orders but is not completely filled.
The events you will receive are as follows:
Event 1:
(90, "filled")
โ 10 units are filled.Event 2:
(80, "filled")
โ Another 10 units are filled.Event 3:
(0, "cancelled")
โ The remaining order is cancelled. Note: If your IOC order is fully filled, the last event you will receive is(0, "filled")
.
Scenario 3: Resting Limit Order Gets Matched
Your existing, or "resting," limit order matches against an incoming order.
You will receive the following event: (90, "filled")
โ 10 units of your resting limit order are filled.
Scenario 4: Resting Limit Order Gets Cancelled
Your resting limit order could be cancelled for various reasons, such as manual cancellation, expiration, failing health checks, or self-trade prevention.
In any of these cases, you will receive: (0, "cancelled")
Scenario 5: IOC order doesn't cross the book or FOK order fails to be entirely filled
In any of these cases, you will receive: (0, "cancelled")
Trade
Update speed: real-time
Best Bid Offer
Update speed: real-time
Fill
Update speed: real-time
Position Change
Update speed: real-time
Note: that it is possible that back to back position_change
events have the same fields except for timestamp
. Additionally, position_change
events are not sent on interest and funding payments, and also are not sent on actions done through slow mode (except deposits). The full list of actions that will trigger a PositionChange
event are:
Minting or burning LP tokens
Liquidating a subaccount
Matching orders
Depositing or withdrawing spot
Settling PNL
Book Depth
Update speed: once every 50ms
Note: To keep an updated local orderbook, do the following:
Subscribe to the
book_depth
stream and queue up events.Get a market data snapshot by calling MarketLiquidity. The snapshot contains a
timestamp
in the response.Apply events with
max_timestamp
> snapshottimestamp
.When you receive an event where its
last_max_timestamp
is not equal to the last event you've received, it means some events were lost and you should repeat 1-3 again.
Last updated