Positions¶
Use positions() to fetch current positions for the account with explicit buy, sell, and net quantities.
LLM guidance
Use this page for fetched portfolio-position state, not for placing or modifying orders. Positions are snapshots of account state after trades and can be used for monitoring, reconciliation, and risk views.
Walkthrough Video¶
If the embedded video does not load, watch it on YouTube: Positions Walkthrough
Basic Usage¶
from nubra_python_sdk.portfolio.portfolio_data import NubraPortfolio
from nubra_python_sdk.start_sdk import InitNubraSdk, NubraEnv
nubra = InitNubraSdk(NubraEnv.UAT, env_creds=True)
portfolio = NubraPortfolio(nubra)
result = portfolio.positions()
positions() returns the Trading API V3 positions snapshot with the response fields documented below.
Accessing Data¶
print(result.portfolio.client_code)
print(result.portfolio.position_stats.total_pnl)
print(result.portfolio.position_stats.total_pnl_chg)
if result.portfolio.positions:
first_position = result.portfolio.positions[0]
print(first_position.symbol)
print(first_position.buy_quantity)
print(first_position.sell_quantity)
print(first_position.net_quantity)
print(first_position.pnl)
Request Contract¶
| Input | Meaning |
|---|---|
NubraPortfolio(nubra).positions() |
fetch Trading API V3 positions with buy, sell, and net quantity fields |
Response Contract¶
| Field | Type | Meaning |
|---|---|---|
message |
str |
response message |
portfolio.client_code |
str |
trading account client code |
portfolio.position_stats.total_pnl |
int |
total PnL |
portfolio.position_stats.total_pnl_chg |
float |
total PnL percentage change |
portfolio.positions |
list[PositionStruct] |
flattened position list |
Response Meaning¶
Important position-level fields include:
| Field | Meaning |
|---|---|
ref_id |
instrument reference ID |
symbol |
tradable symbol |
exchange |
exchange such as NSE or BSE |
asset or asset_type |
instrument asset classification |
product or delivery_type |
product or delivery bucket |
order_side |
direction associated with the position |
quantity or net_quantity |
net position quantity |
buy_quantity |
total buy quantity |
sell_quantity |
total sell quantity |
last_traded_price |
latest price field used for live position valuation |
avg_price, avg_buy_price, avg_sell_price |
average trade prices |
pnl |
current position profit or loss |
pnl_chg |
percentage change in PnL |
Important Rules¶
Important Rules
- Use
NubraPortfolio(nubra).positions()for Trading API V3 positions. - Position price and PnL fields are typically returned in exchange-native integer units such as paise for NSE instruments.
- Positions are account-state snapshots. The response does not auto-update after it is returned.
- Use realtime order or market-data streams when you need continuously updating values instead of a fetched portfolio snapshot.
- Use environment-correct login and account context. UAT and PROD portfolios are separate.