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
pairIdvalues frominitial.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 torefresh():
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().