I am using the following piece of code,
get_position_url = https://api.upstox.com/v2/portfolio/short-term-positions
headers = {
'Accept': 'application/json',
'Authorization': f'Bearer {live_access_token}'
}
try:
response = requests.get(get_position_url, headers=headers, data=payload)
response.raise_for_status()
json_data = response.json()
except Exception as e:
print(f" Error fetching positions: {e}")
return 0
but i am getting the output of json_data,
{‘status’: ‘success’, ‘data’: [{‘exchange’: ‘NFO’, ‘multiplier’: 0.0, ‘value’: 0.0, ‘pnl’: 0.0, ‘product’: ‘I’, ‘instrument_token’: ‘’, ‘average_price’: 0.0, ‘buy_value’: 0.0, ‘overnight_quantity’: 0, ‘day_buy_value’: 32471.25, ‘day_buy_price’: 0.0, ‘overnight_buy_amount’: 0.0, ‘overnight_buy_quantity’: 0, ‘day_buy_quantity’: 0, ‘day_sell_value’: 30465.0, ‘day_sell_price’: 0.0, ‘overnight_sell_amount’: 0.0, ‘overnight_sell_quantity’: 0, ‘day_sell_quantity’: 0, ‘quantity’: 0, ‘last_price’: 0.0, ‘unrealised’: 0.0, ‘realised’: 0.0, ‘sell_value’: 0.0, ‘tradingsymbol’: ‘’, ‘trading_symbol’: ‘’, ‘close_price’: 0.0, ‘buy_price’: 0.0, ‘sell_price’: 0.0}]}
NSE_FO|40476 not found in position data.
I am checking for the “NSE_FO|40476” instrument as i have executed this particular instrument.