Trading
Portfolio
The positions stream and account funds/margin snapshot — both read-only, broker-driven.
positionsStreamer
Positions have no place/modify/cancel calls — your app pushes to positionsStreamer
whenever the broker reports a change, and the SDK never polls or writes back.
Stream<String> get positionsStreamer;Must be a broadcast stream — same requirement as ordersStreamer.
Emits a JSON list of position objects:
[
{
"symID": "RELIANCE",
"displayName": "Reliance Industries",
"netQty": 10,
"avgPrice": 2405.0,
"netOrgAvgPrice": 2405.0,
"realizedPnl": 0.0,
"realizedOrgPnl": 0.0,
"multiplier": 1.0,
"priceFactor": 1.0,
"productType": "intraday",
"symbol": { "id": "RELIANCE", "name": "Reliance Industries" }
}
]| Field | Type | Accepted values |
|---|---|---|
symID | String | required; the symbol this position is for — note the key is symID, not symbolId |
displayName | String | optional; display name, falls back to symID if omitted |
netQty | int | required; net quantity, sign carries long/short |
avgPrice | double | required; average entry price |
netOrgAvgPrice | double | required; average entry price before any partial exits |
realizedPnl | double | required; realized P&L |
realizedOrgPnl | double | required; realized P&L before any partial exits |
multiplier | double | required; contract multiplier, 1.0 if not applicable |
priceFactor | double | required; price scaling factor, 1.0 if not applicable |
productType | String | required; "normal" or "intraday" — the same symbol can have two simultaneous positions under different product types |
symbol | object | required; full symbolInfo shape |
These fields are derived by the SDK, never sent by the host:
| Field | Type | Derivation |
|---|---|---|
positionSide | "long" | "short" | null | sign of netQty — null when netQty is 0 |
positionTypes | "Open" | "Close" | "Close" when netQty is 0, "Open" otherwise |
orderAction | "Buy" | "Sell" | "Sell" when netQty is negative, "Buy" otherwise — mirrors positionSide's direction (the side that opened the position), not the exit side; the SDK's own exit-order UI inverts it (buy↔sell) to pre-fill the opposite-side exit order |
unrealizedPL | double | (dayClose - netOrgAvgPrice) * netQty * multiplier * priceFactor, recomputed on every market-data tick for the position's symbol; reads 0 until the first tick arrives |
pnl | double | unrealizedPL + realizedOrgPnl |
mtm | double | (dayClose - avgPrice) * netQty * multiplier * priceFactor + realizedPnl |
fundsData
A snapshot of the account's fund/margin details — fetched on demand each time the user opens the chart drawer's Funds panel, not cached at startup or polled.
Future<String> get fundsData;{
"availableMargin": 347500.0,
"usedMargin": 152500.0
}| Field | Type | Accepted values |
|---|---|---|
availableMargin | double | optional; margin available to trade with, defaults to 0 if omitted or not a number |
usedMargin | double | optional; margin already committed to open positions/orders, defaults to 0 if omitted or not a number |
totalBalance (derived, not sent): availableMargin + usedMargin, computed client-side —
there is no separate wire field for it.