Skip to main content
streamPositionUpdates(initial, priceStream?) takes a previously fetched getOpenPositions() response and emits an updated payload whenever relevant prices change.

Example

How it works

  • the SDK extracts the unique pairId values from initial.pairPositions
  • it subscribes only to those pairs
  • on each price tick, it recalculates price-sensitive fields and emits the full updated OpenPositionsResponse

Tracking a new position

The stream re-prices the set it was given; it does not discover new trades. After a fill or a close, fetch again and pass the result to refresh():
The new position starts being priced, a closed one stops, and the price subscription adjusts to match. A stream created for a trader with no open positions works the same way — it starts pricing when refresh() brings the first one in. A price stream you passed in stays yours: refresh() will not subscribe, unsubscribe or close it. For a stream that discovers trades on its own, use streamAccountUpdates().

Reusing an existing price stream

If your app already owns a price WebSocket, pass it as the second argument to avoid opening another connection:

Response schema