Span Calculator
The Span Calculator APIs enable you to calculate margin requirement for the portfolio before placing order.
POST: /apiV2/spanCalculators
https://connect.thefirstock.com/apiV2/spanCalculators
Request Details
Parameter | Description |
---|---|
userId | Logged in User Id |
exchange | NFO Exchange |
instname | FUTSTK, FUTIDX, OPTSTK, OPTIDX |
symbolName | ACC, ABB,NIFTY,BANKNIFTY Symbol Name |
expd | 29-OCT-2020 DD-MMM-YYYY format |
optt | CE,PE option type |
strike Price | 16000.00, 35500.00 Strike price |
buyQuantity | Buy Open Quantity |
sellQuantity | Sell Open Quantity |
netQuantity | Net traded quantity |
jKey | Token Received from Login API |
product | C / M / I C -> Cash and Carry, M -> F&O Normal, I -> Intraday |
Code
curl -X POST 'https://connect.thefirstock.com/apiV2/spanCalculators' \
-H 'Content-Type: application/json' \
-d '{
"userId": "",
"jKey": "",
"data": [
{
"exchange": "",
"instname": "",
"symbolName": "",
"expd": "",
"optt": "",
"strikePrice": "",
"netQuantity": ""
},
{
"exchange": "",
"instname": "",
"symbolName": "",
"expd": "",
"optt": "",
"strikePrice": "",
"netQuantity": ""
}
]
}'
from thefirstock import thefirstock
spanCalculator = thefirstock.firstock_SpanCalculator(
data=[
{
"exchange": "NFO",
"instname": "",
"symbolName": "NIFTY",
"expd": "27-OCT-2022",
"optt": "CE",
"strikePrice": "17000",
"netQuantity": "50"
},
{
"exchange": "NFO",
"instname": "",
"symbolName": "BANKNIFTY",
"expd": "27-OCT-2022",
"optt": "PE",
"strikePrice": "40000",
"netQuantity": "-25"
}
]
)
const Firstock = require('thefirstock');
const firstock = new Firstock();
firstock.spanCalculator(
[
{
exchange: "",
instname: "",
symbolName: "",
expd: "",
optt: "",
strikePrice: "",
netQuantity: "",
buyQuantity: "",
sellQuantity: "",
product: "",
},
],
, (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(
exchange: "NFO",
instname: "OPTIDX",
symbolName: "BANKNIFTY",
expd: "",
optt: "CE",
strikePrice: "",
netQuantity: "",
buyQuantity: "",
sellQuantity: "",
product: "M"
);
}
}
Response Success Details
Parameter | Description |
---|---|
status | Success |
data.status | Ok |
data.requestTime | Response received time |
data.span | |
data.expo | |
data.span_trade | |
data.expo_trade |
Sample Response
{
"Status": "Success",
"data": {
"marginList": [
{
"request_time": "",
"stat": "",
"span": "",
"expo": "",
"span_trade": "",
"expo_trade": ""
},
{
"request_time": "",
"stat": "",
"span": "",
"expo": "",
"span_trade": "",
"expo_trade": ""
}
],
"totalValue": {
"request_time": "",
"stat": "",
"span": "",
"expo": "",
"span_trade": "",
"expo_trade": ""
}
}
}
{
"Status": "Failed",
"data": "Error Occurred2 \"invalid input\""
}