# Upstox

Upstox API v2: portfolio, market data, orders, P&L (Indian F&O)

- Repository: https://github.com/taracodlabs/aiden (868 stars)
- Category: Engineering
- License: Apache-2.0
- Last updated: 2026-10-19
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add taracodlabs/aiden --skill upstox -g -a claude-code -y`
Codex: `npx skills add taracodlabs/aiden --skill upstox -g -a codex -y`
Cursor: `npx skills add taracodlabs/aiden --skill upstox -g -a cursor -y`
Gemini CLI: `npx skills add taracodlabs/aiden --skill upstox -g -a gemini-cli -y`

## Description

Upstox API v2: portfolio, market data, orders, P&L (Indian F&O)

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Upstox

Access your Upstox brokerage account via the Upstox API v2, live quotes, holdings, positions, order placement, and margin data. Requires Upstox API credentials.

## When to Use

- User wants to check Upstox portfolio holdings or positions
- User asks for live market quotes on NSE/BSE instruments
- User wants to place, modify, or cancel an Upstox order
- User asks about today's P&L, order book, or trade history
- User wants margin or funds information

## How to Use

### Set up credentials
```powershell
$env:UPSTOX_TOKEN = "your_access_token"   # Bearer token from OAuth flow
$baseUrl = "https://api.upstox.com/v2"
$headers = @{
  "Authorization" = "Bearer $env:UPSTOX_TOKEN"
  "Accept"        = "application/json"
}
```

### Get holdings
```powershell
$resp = Invoke-RestMethod -Uri "$baseUrl/portfolio/long-term-holdings" -Headers $headers
$resp.data | Select-Object tradingsymbol, quantity, average_price, last_price,
  @{N='PnL';E={[math]::Round(($_.last_price - $_.average_price)*$_.quantity,2)}}
```

### Get short-term positions (intraday / F&O)
```powershell
$resp = Invoke-RestMethod -Uri "$baseUrl/portfolio/short-term-positions" -Headers $headers
$resp.data | Select-Object tradingsymbol, quantity, average_price, last_price, pnl, product
```

### Get live market quote
```powershell
$instrument = "NSE_EQ|INE009A01021"   # INFOSYS ISIN-based instrument key
$resp = Invoke-RestMethod -Uri "$baseUrl/market-quote/quotes?instrument_key=$instrument" -Headers $headers
$resp.data | Select-Object last_price, net_change, volume, ohlc
```

### Get funds and margin
```powershell
$resp = Invoke-RestMethod -Uri "$baseUrl/user/get-funds-and-margin" -Headers $headers
$resp.data | Select-Object equity
```

The rest: https://github.com/taracodlabs/aiden/blob/HEAD/skills/upstox/SKILL.md
