Skip to content

Span Calculator

The Span Calculator APIs enable you to calculate margin requirement for the posrfolio before placing order.

POST: /api/spanCalculators

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

Request Details

Parameter Description
actid Account id - Post login screen
pos Array of json objects. (object fields given in below table)

Request Details: Json Fields of objects in values Array

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
actid Account id - Post login screen

Code

from thefirstock import thefirstock

SP = thefirstock.firstock_SpanCalculator(
    exchange="NFO",
    instname="OPTIDX",
    symbolName="BANKNIFTY",
    expd="2022-04-28",
    optt="CE",
    strikePrice="37000",
    netQuantity="-25",
    buyQuantity="",
    sellQuantity=""
)
  curl -X POST 'https://connect.thefirstock.com/api/spanCalculators' \
  -H 'Content-Type: application/json' \
  -d '{
    "userId": "",
    "actid": "",
    "exchange": "NFO",
    "instname": "OPTIDX",
    "symbolName": "BANKNIFTY",
    "expd": "",
    "optt": "CE",
    "strikePrice": "",
    "netQuantity": "",
    "buyQuantity": "",
    "sellQuantity": "",
    "jKey": "",
    "product": "M"
   }'
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");
}
}

Sample Response

{
"request_time": "18:57:05 31-05-2022",
"stat": "Ok",
"span": "117881.50",
"expo": "17743.70",
"span_trade": "117881.50",
"expo_trade": "17743.70"
}  
{
"stat": "Not_Ok",
"request_time": "20:40:01 19-05-2020",
"emsg": "Error Occurred : 2 \"invalid input\""
}