Skip to main content

Span calculator

The Span Calculator API provides you with the capability to determine the margin requirement for your portfolio prior to executing any trades.

Method: POST

https://connect.thefirstock.com/api/V3/spanCalculators

Request details

ParameterDescriptionData typeExample
userIdLogged in User IdString"AA1999"
exchangeNFO ExchangeString"NFO"
instnameFUTSTK, FUTIDX, OPTSTK, OPTIDXString"OPTIDX"
symbolNameACC, ABB,NIFTY,BANKNIFTY Symbol NameString"BANKNIFTY"
expireDate29-OCT-2020 DD-MMM-YY formatString"12JAN23"
optionTypeCE,PE option typeString"CE"
strikePrice16000.00, 35500.00 Strike priceString"16000.00"
netQuantityNet traded quantityString"1700"
jKeyToken Received from Login APIString"d4180daa72ea70885ab0d
0fb38f0fa5796352b57de0
641d4442294b87f2b7315"
curl --location 'https://connect-dev.thefirstock.com/api/V3/spanCalculator'
--header 'Content-Type: application/json'
--data '{
"userId": "AA123",
"data": [
{
"exchange": "NFO",
"instrumentName": "OPTIDX",
"symbolName": "NIFTY",
"expireDate": "23-FEB-2023",
"optionType": "CE",
"strikePrice": "17000",
"netQuantity": "50"
},
{
"exchange": "NFO",
"instrumentName": "OPTIDX",
"symbolName": "NIFTY",
"expireDate": "23-FEB-2023",
"optionType": "CE",
"strikePrice": "40000",
"netQuantity": "-25"
}
],
"jKey": "e6a211bea63adff386578988e1cf4a9521c4744e6a39ad63174c8797e2af8c38"
}'

Success response details

ParameterDescriptionData typesExamples
statusSuccessString"Success"
data.statusOkString"ok"
data.requestTimeResponse received timeString"17:38:33 17-02-2023"
data.spanSpan marginString"83866.00"
data.expoExposure marginString"17954.10"
data.span_tradeSpan margin after tradeString"83866.00"
data.expo_tradeExposure margin after tradeString"17954.10"

Failure response details

ParameterDescriptionData TypeExample
statusFailedString"Failed"
codeHTTP CodeString"401"
nameType of errorString"SESSION_EXPIRED"
error.fieldError fieldString"jKey"
error.messageError messageString"Session key has been expired, please login in again"

Sample response

{
"status": "Success",
"data": {
"marginList": [
{
"requestTime": "17:38:33 17-02-2023",
"span": "83866.00",
"expo": "17954.10",
"span_trade": "83866.00",
"expo_trade": "17954.10"
},
{
"requestTime": "17:38:34 17-02-2023",
"span": "115909.00",
"expo": "20602.53",
"span_trade": "115909.00",
"expo_trade": "20602.53"
}
],
"totalValue": {
"requestTime": "17:38:34 17-02-2023",
"span": "199775.00",
"expo": "38556.62",
"span_trade": "199775.00",
"expo_trade": "38556.62"
}
}
}