General Socket - Position Events
This WebSocket allows you to receive live updates on your positions as your trades execute.
USE CASE
Track your net quantity, average prices and realised P&L live as trades execute.
Details
- Subscribe with the
positionsaction on the raw socket, orOnPositionsin the Python SDK (callbackon_positions). Nothing is delivered until you subscribe. idis unique for each position, for exampleNSE:IDEA-EQ-INTRADAY.slNois used to sort positions.netQtyis the net quantity andqtyis its absolute value. A squared-off position is sent withnetQty0, as in the sample response.dayBuyQtyanddaySellQtyare today's quantities.cfBuyQtyandcfSellQtyare carry-forward quantities.- For cross-currency positions (
crossCurrencyis Y), userbiRefRateto calculate P&L. For commodity positions, useqtyMulti_com. - The raw socket message uses different key names. The SDK renames them, for example
pl_realizedtorealized_profit,tran_sidetoside,pl_totaltoplandpl_unrealizedtounrealized_profit.
Response Attributes - For position updates
| Attribute | Data Type | Description |
|---|---|---|
symbol | string | Eg: NSE:SBIN-EQ |
id | string | The unique value for each position |
buyAvg | float | Average buy price |
buyQty | int | Total buy qty |
sellAvg | float | Average sell price |
sellQty | int | Total sell qty |
netAvg | float | netAvg |
netQty | int | Net qty |
side | int |
|
qty | int | Absolute value of net qty |
productType | string |
|
realized_profit | float | The realized p&l of the position |
crossCurrency | string |
|
rbiRefRate | float | Incase of cross currency position, the rbi reference rate will be required to calculate the p&l |
qtyMulti_com | float | Incase of commodity positions, this multiplier is required for p&l calculation |
segment | int |
|
exchange | int |
|
slNo | int | This is used for sorting of positions |
fytoken | string |
|
cfBuyQty | int | Carry forward buy quantity |
cfSellQty | int | Carry forward sell quantity |
dayBuyQty | int | Day forward buy quantity |
daySellQty | int | Day forward sell quantity |
exchange | int |
|
buyVal | float | Total buy value of the position. |
sellVal | float | Total sell value of the position. |
Last updated on