
Upstox
Upstox API v2: portfolio, market data, orders, P&L (Indian F&O)
Install
npx skills add taracodlabs/aiden --skill upstox -g -a claude-code -y- Repository
- taracodlabs/aiden868
- Category
- Engineering
- Updated
- 16d ago
- License
- Apache-2.0
- Context cost
- Lightabout 869 tokens
- Runs scripts
- No, instructions only
What it does
Upstox API v2: portfolio, market data, orders, P&L (Indian F&O)
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
$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
$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)
$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
$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
$resp = Invoke-RestMethod -Uri "$baseUrl/user/get-funds-and-margin" -Headers $headers
$resp.data | Select-Object equity
