Skip to content

Portfolio

This API lets you retrieve holdings and positions in your portfolio.

GET /holdings Retrieve list of holdings in demat account
GET /positions Retrieve open positions
POST /positions/convert Convert intraday position to delivery or delivery to intraday

Holdings

Users can retrieve all holdings bought/sold in previous trading sessions. All T1 and delivered quantities can be fetched.

curl --request GET \
--url https://api.dhan.co/holdings \
--header 'Content-Type: application/json' \
--header 'access-token: JWT'


Request Structure

No Body


Response Structure

[
    {
    "exchange": "ALL",
    "tradingSymbol": "HDFC",
    "securityId": "1330",
    "isin": "INE001A01036",
    "totalQty": 1000,
    "dpQty": 1000,
    "t1Qty": 0,
    "availableQty": 1000,
    "collateralQty": 0,
    "avgCostPrice": 2655.0
    } 
]


Parameters

Field Type Description
exchange enum string Exchange
tradingSymbol string Refer Trading Symbol at Page No
securityId string Exchange standard id for each scrip. Refer here
isin string Universal standard id for each scrip
totalQty int Total quantities
dpQty int Quantities in delivered in demat account
t1Qty int Quantities not delivered in demat account
availableQty int Quantities available for transactions
collateralQty int Quantities placed as collateral with broker
avgCostPrice float Average Buy Price of total quantities

Positions

Users can retrieve a list of all open positions for the day. This includes all F&O carryforward positions as well.

curl --request GET \
--url https://api.dhan.co/positions \
--header 'Content-Type: application/json' \
--header 'access-token: JWT'


Request Structure

No Body


Response Structure

[
    {
    "dhanClientId": "1000000009",    
    "tradingSymbol": "TCS",
    "securityId": "11536",
    "positionType": "LONG",
    "exchangeSegment": "NSE_EQ", 
    "productType": "CNC",
    "buyAvg": 3345.8,
    "buyQty": 40,
    "sellAvg": 0.0,
    "sellQty": 0,
    "netQty": 40,
    "realizedProfit": 0.0,
    "unrealizedProfit": 6122.0,
    "rbiReferenceRate": 1.0,
    "multiplier": 1,
    "carryForwardBuyQty": 0,
    "carryForwardSellQty": 0,
    "carryForwardBuyValue": 0.0,
    "carryForwardSellValue": 0.0,
    "dayBuyQty": 40,
    "daySellQty": 0,
    "dayBuyValue": 133832.0,
    "daySellValue": 0.0,
    "drvExpiryDate": "0001-01-01",
    "drvOptionType": null,
    "drvStrikePrice": 0.0.
    "crossCurrency": false
    } 
]


Parameters

Field Type Description
dhanClientId string User specific identification generated by Dhan
tradingSymbol string Refer Trading Symbol in Tables
securityId string Exchange standard id for each scrip. Refer here
positionType enum string Position Type
LONG SHORT CLOSED
exchangeSegment enum string Exchange & Segment
NSE_EQ  NSE_FNO   NSE_CURRENCY  BSE_EQ  MCX_COMM
productType enum string Product type
CNC  INTRADAY  MARGIN  CO BO
buyAvg float Average buy price
buyQty int Total quantity bought
sellAvg float Average sell price
sellQty int Total quantities sold
netQty int buyQty - sellQty = netQty
realizedProfit float Profit or loss booked
unrealizedProfit float Profit or loss standing for open position
rbiReferenceRate float RBI mandated reference rate for forex
multiplier int Multiplying factor for currency F&O
carryForwardBuyQty int Carry forward F&O long quantities
carryForwardSellQty int Carry forward F&O short quantities
carryForwardBuyValue float Carry forward F&O long value
carryForwardSellValue float Carry forward F&O short value
dayBuyQty int Quantities bought today
daySellQty int Quantities sold today
dayBuyValue float Value of quantities bought today
daySellValue float Value of quantities sold today
drvExpiryDate int For F&O, expiry date of contract
drvOptionType enum string Type of Option
CALL PUT
drvStrikePrice float For Options, Strike Price
crossCurrency boolean Check for non INR currency pair

Convert Position

Users can convert their open position from intraday to delivery or delivery to intraday.

curl --request POST \
--url https://api.dhan.co/positions/convert \
--header 'Content-Type: application/json' \
--header 'access-token: JWT' \
--data '{}'


Request Structure

{
    "dhanClientId": "1000000009",
    "fromProductType":"INTRADAY",  
    "exchangeSegment":"NSE_EQ",
    "positionType":"LONG",
    "securityId":"11536",  
    "tradingSymbol":"",
    "convertQty":"40",
    "toProductType":"CNC"
}


Parameters

Field Type Description
dhanClientId string User specific identification generated by Dhan
fromProductType enum string Refer Trading Symbol in Tables
CNC INTRADAY MARGIN CO BO
exchangeSegment enum string Exchange standard id for each scrip
NSE_EQ  NSE_FNO   NSE_CURRENCY  BSE_EQ  MCX_COMM
positionType enum string Position Type
LONG SHORT CLOSED
securityId string Exchange standard id for each scrip. Refer here
tradingSymbol string Refer Trading Symbol in Tables
convertQty int No of shares modification is desired
toProductType enum string Desired product type
CNC  INTRADAY  MARGIN  CO BO


Response Structure

202 Accepted


Note: For description of enum values, refer Annexure