Real-Time Position Updates
Subscribe to position changes for live portfolio tracking.
Subscription Structureβ
subscription WatchPositions(
$cursor: [positions_stream_cursor_input]!
$accountId: String
$batchSize: Int!
) {
positions_stream(
cursor: $cursor
batch_size: $batchSize
where: {
account_id: { _eq: $accountId }
shares: { _gt: "0" }
}
) {
id
shares
vault {
term_id
current_share_price
}
}
}
Best Practicesβ
- Filter by account for user-specific updates
- Filter shares > 0 for active positions only
- Update UI state with new data
- Resume from last cursor after disconnection