Skip to content

Margin calculation

Margin calculation APIs lets you calculate span, exposure, option premium, additional, bo, cash, var, pnl values for a list of orders.

type endpoint  
POST /margins/orders Calculates margins for each order considering the existing positions and open orders
POST /margins/basket Calculates margins for spread orders

Note

Requests to the above endpoints are JSON POST and it needs application/json header.

Order margins

Request order structure
Response margin structure

curl https://api.kite.trade/margins/orders \
    -H 'X-Kite-Version: 3' \
    -H 'Authorization: token api_key:access_token' \
    -H 'Content-Type: application/json' \
    -d '[
    {
        "exchange": "NSE",
        "tradingsymbol": "INFY",
        "transaction_type": "BUY",
        "variety": "regular",
        "product": "CNC",
        "order_type": "MARKET",
        "quantity": 1,
        "price": 0,
        "trigger_price": 0
    }
]'

Query parameters are as follows.

parameter  
mode compact - Compact mode will only give the total margins
{
  "status": "success",
  "data": [
    {
      "type": "equity",
      "tradingsymbol": "INFY",
      "exchange": "NSE",
      "span": 0,
      "exposure": 0,
      "option_premium": 0,
      "additional": 0,
      "bo": 0,
      "cash": 0,
      "var": 1498,
      "pnl": {
        "realised": 0,
        "unrealised": 0
      },
      "leverage": 1,
      "charges": {
        "transaction_tax": 1.498,
        "transaction_tax_type": "stt",
        "exchange_turnover_charge": 0.051681,
        "sebi_turnover_charge": 0.001498,
        "brokerage": 0.01,
        "stamp_duty": 0.22,
        "gst": {
          "igst": 0.011372219999999999,
          "cgst": 0,
          "sgst": 0,
          "total": 0.011372219999999999
        },
        "total": 1.79255122
      },
      "total": 1498
    }
  ]
}

Order structure

parameter  
exchange Name of the exchange
transaction_type BUY/SELL
variety Order variety (regular, amo, co etc.)
product Margin product to use for the order (margins are blocked based on this) ?
order_type Order type (MARKET, LIMIT etc.)
quantity Quantity of the order
price Price at which the order is going to be placed (LIMIT orders)
trigger_price Trigger price (for SL, SL-M, CO orders)

Margin structure

parameter  
type equity/commodity
tradingsymbol Trading symbol of the instrument
exchange Name of the exchange
span SPAN margins
exposure Exposure margins
option_premium Option premium
additional Additional margins
bo BO margins
cash Cash credit
var VAR
pnl Realised and unrealised profit and loss
leverage Margin leverage allowed for the trade
charges The breakdown of the various charges that will be applied to an order
total Total margin block

Charges structure

Field Definition
total Total charges
transaction_tax Tax levied for each transaction on the exchanges
transaction_tax_type Type of transaction tax
exchange_turnover_charge Charge levied by the exchange on the total turnover of the day
sebi_turnover_charge Charge levied by SEBI on the total turnover of the day
brokerage The brokerage charge for a particular trade
stamp_duty Duty levied on the transaction value by Government of India
gst.igst Integrated Goods and Services Tax levied by the government
gst.cgst Central Goods and Services Tax levied by the government
gst.sgst State Goods and Services Tax levied by the government
gst.total Total GST

Basket margins

curl https://api.kite.trade/margins/basket?consider_positions=true \
    -H 'X-Kite-Version: 3' \
    -H 'Authorization: token api_key:access_token' \
    -H 'Content-Type: application/json' \
    -d '[
    {
        "exchange": "NFO",
        "tradingsymbol": "NIFTY20JUL10600CE",
        "transaction_type": "SELL",
        "variety": "regular",
        "product": "NRML",
        "order_type": "MARKET",
        "quantity": 75,
        "price": 0,
        "trigger_price": 0
    },
    {
        "exchange": "NFO",
        "tradingsymbol": "NIFTY20JUL10700CE",
        "transaction_type": "BUY",
        "variety": "regular",
        "product": "NRML",
        "order_type": "MARKET",
        "quantity": 75,
        "price": 0,
        "trigger_price": 0
    }
]'

Query parameters are as follows.

parameter  
consider_positions Boolean to consider users positions
mode compact - Compact mode will only give the total margins
{
  "status": "success",
  "data": {
    "initial": {
      "type": "",
      "tradingsymbol": "",
      "exchange": "",
      "span": 132257.58,
      "exposure": 56597.19,
      "option_premium": 0,
      "additional": 0,
      "bo": 0,
      "cash": 0,
      "var": 0,
      "pnl": {
        "realised": 0,
        "unrealised": 0
      },
      "leverage": 0,
      "charges": {
        "transaction_tax": 0,
        "transaction_tax_type": "",
        "exchange_turnover_charge": 0,
        "sebi_turnover_charge": 0,
        "brokerage": 0,
        "stamp_duty": 0,
        "gst": {
          "igst": 0,
          "cgst": 0,
          "sgst": 0,
          "total": 0
        },
        "total": 0
      },
      "total": 188854.77
    },
    "final": {
      "type": "",
      "tradingsymbol": "",
      "exchange": "",
      "span": 26000.519999999986,
      "exposure": 9452.689999999999,
      "option_premium": 0,
      "additional": 0,
      "bo": 0,
      "cash": 0,
      "var": 0,
      "pnl": {
        "realised": 0,
        "unrealised": 0
      },
      "leverage": 0,
      "charges": {
        "transaction_tax": 0,
        "transaction_tax_type": "",
        "exchange_turnover_charge": 0,
        "sebi_turnover_charge": 0,
        "brokerage": 0,
        "stamp_duty": 0,
        "gst": {
          "igst": 0,
          "cgst": 0,
          "sgst": 0,
          "total": 0
        },
        "total": 0
      },
      "total": 35453.209999999985
    },
    "orders": [
      {
        "type": "equity",
        "tradingsymbol": "NIFTY23JANFUT",
        "exchange": "NFO",
        "span": 132257.58,
        "exposure": 28239.120000000003,
        "option_premium": 0,
        "additional": 0,
        "bo": 0,
        "cash": 0,
        "var": 0,
        "pnl": {
          "realised": 0,
          "unrealised": 0
        },
        "leverage": 1,
        "charges": {
          "transaction_tax": 0,
          "transaction_tax_type": "",
          "exchange_turnover_charge": 0,
          "sebi_turnover_charge": 0,
          "brokerage": 0,
          "stamp_duty": 0,
          "gst": {
            "igst": 0,
            "cgst": 0,
            "sgst": 0,
            "total": 0
          },
          "total": 0
        },
        "total": 160496.69999999998
      },
      {
        "type": "equity",
        "tradingsymbol": "NIFTY23FEBFUT",
        "exchange": "NFO",
        "span": 0,
        "exposure": 28358.07,
        "option_premium": 0,
        "additional": 0,
        "bo": 0,
        "cash": 0,
        "var": 0,
        "pnl": {
          "realised": 0,
          "unrealised": 0
        },
        "leverage": 1,
        "charges": {
          "transaction_tax": 0,
          "transaction_tax_type": "",
          "exchange_turnover_charge": 0,
          "sebi_turnover_charge": 0,
          "brokerage": 0,
          "stamp_duty": 0,
          "gst": {
            "igst": 0,
            "cgst": 0,
            "sgst": 0,
            "total": 0
          },
          "total": 0
        },
        "total": 28358.07
      }
    ]
  }
}

Response structure is as follows.

parameter  
initial Total margins required to execute the orders
final Total margins with the spread benefit
orders Individual margins per order