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
Parameter | Description | Data type | Example |
---|---|---|---|
userId | Logged in User Id | String | "AA1999" |
exchange | NFO Exchange | String | "NFO" |
instname | FUTSTK, FUTIDX, OPTSTK, OPTIDX | String | "OPTIDX" |
symbolName | ACC, ABB,NIFTY,BANKNIFTY Symbol Name | String | "BANKNIFTY" |
expireDate | 29-OCT-2020 DD-MMM-YY format | String | "12JAN23" |
optionType | CE,PE option type | String | "CE" |
strikePrice | 16000.00, 35500.00 Strike price | String | "16000.00" |
netQuantity | Net traded quantity | String | "1700" |
jKey | Token Received from Login API | String | "d4180daa72ea70885ab0d 0fb38f0fa5796352b57de0 641d4442294b87f2b7315" |
- cURL
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"
}'
from thefirstock import thefirstock
spanCalculator = thefirstock.firstock_SpanCalculator(
dataList=[
{
"exchange": "NFO",
"instrumentName": "",
"symbolName": "NIFTY",
"expireDate": "23-FEB-2023",
"optionType": "CE",
"strikePrice": "17000",
"netQuantity": "50"
},
{
"exchange": "NFO",
"instrumentName": "",
"symbolName": "BANKNIFTY",
"expireDate": "23-FEB-2023",
"optionType": "PE",
"strikePrice": "40000",
"netQuantity": "-25"
}
]
)
const Firstock = require("thefirstock");
const firstock = new Firstock();
firstock.spanCalculator(
[
{
exchange: "NFO",
instrumentName: "",
symbolName: "NIFTY",
expireDate: "23-FEB-2023",
optionType: "CE",
strikePrice: "17000",
netQuantity: "50",
},
{
exchange: "NFO",
instrumentName: "",
symbolName: "BANKNIFTY",
expireDate: "23-FEB-2023",
optionType: "PE",
strikePrice: "40000",
netQuantity: "-25",
},
],
(err, result) => {
console.log("Error, ", err);
console.log("Result: ", result);
}
);
using thefirstock;
class Program
{
public static void Main()
{
Firstock firstock = new Firstock();
var result = firstock.spanCalculator(list: new List<spanCalculatorObject>() {
new spanCalculatorObject{
exchange="NFO",
instrumentName="OPTIDX",
symbolName="NIFTY",
expireDate="02-MAR-2023",
optionType="CE",
strikePrice="17000",
netQuantity="50"
}
}
);
}
}
Success response details
Parameter | Description | Data types | Examples |
---|---|---|---|
status | Success | String | "Success" |
data.status | Ok | String | "ok" |
data.requestTime | Response received time | String | "17:38:33 17-02-2023" |
data.span | Span margin | String | "83866.00" |
data.expo | Exposure margin | String | "17954.10" |
data.span_trade | Span margin after trade | String | "83866.00" |
data.expo_trade | Exposure margin after trade | String | "17954.10" |
Failure response details
Parameter | Description | Data Type | Example |
---|---|---|---|
status | Failed | String | "Failed" |
code | HTTP Code | String | "401" |
name | Type of error | String | "SESSION_EXPIRED" |
error.field | Error field | String | "jKey" |
error.message | Error message | String | "Session key has been expired, please login in again" |
Sample response
- Success response
- Failure 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"
}
}
}
{
"status": "Failed",
"code": "401",
"name": "SESSION_EXPIRED",
"error": {
"field": "jKey",
"message": "Session key has been expired, please login in again"
}
}