Skip to Content
API ReferenceMargin CalculatorMulti-order Margin Calculator

Multi-order Margin Calculator

This API allows you to calculate the approximate margin required for proposed equity and derivative orders, including commodity derivatives, and returns the available account margin.

USE CASE

Check the funding requirement of an order basket before you submit it, using the intended order sequence and product types.

Note

  • A maximum of 50 orders is allowed per request.
  • Order sequence and product types can affect the margin requirement.
  • The calculator works through the orders in the sequence you send them. After the orders are placed, the margin blocked on your account is based on your combined positions, so it does not depend on the order in which they were placed.
  • margin_total is calculated after your existing positions, so it is not a standalone figure for the basket. For a figure that ignores your account, use the SPAN Margin Calculator.
  • For hedged strategies, passing hedge BUY orders before SELL orders can reduce the required margin.
  • Using different product types for hedge and main legs can increase the margin requirement.
  • A hedge with an existing position gets the margin benefit only when it has the same product type.

Details

  • Pass the orders inside a data array in the intended execution sequence.
  • Margin fields are returned inside data.
  • To check whether the orders can be funded, compare margin_total with margin_avail. margin_avail already excludes the margin in use.
  • limitPrice, stopPrice, stopLoss and takeProfit can be omitted. If any order has an invalid symbol, the whole request is rejected.
  • Rate limits differ between the Standard and Prime plans. See Plans & rate limits.

Request Attributes

AttributeData TypeRequiredDescription
symbolstringYesInstrument symbol in FYERS symbology format.
qtyintYesQuantity. For NSE and BSE derivatives, in units, as a multiple of the lot size. For MCX, the number of lots.
sideintYes1 = Buy; -1 = Sell.
typeintYes
  • 1 = Limit
  • 2 = Market (MPP: Market Price Protection )
  • 3 = Stop-market (SL-M, MPP: Market Price Protection )
  • 4 = Stop-limit (SL-L)
productTypestringYesCNC, INTRADAY, MARGIN or MTF, in uppercase. The calculator does not check whether the instrument is eligible for the product type.
limitPricefloatNoPositive limit price (at least 0.0025) for limit and stop-limit orders. Must be 0.0 for market and stop-market orders. For a stop-limit sell order it must be below the trigger price.
stopPricefloatNoPositive trigger price (at least 0.0025) for stop-market and stop-limit orders. Use 0.0 otherwise.
stopLossfloatNoReserved. Must be 0.0.
takeProfitfloatNoReserved. Must be 0.0.

Response Attributes

AttributeData TypeDescription
sstringok / error.
codeintAPI response code. 200 on success; -50 for invalid input; -16 for authentication errors.
messagestringResponse or error message. Empty on success.
dataobjectObject that holds the margin values below.
margin_totalfloatApproximate additional margin required for the submitted orders, after considering your existing positions. It equals the margin for the orders alone only when prevMargin is 0.
margin_new_orderfloatApproximate total margin in use after the submitted orders are placed. It equals margin_total + prevMargin.
margin_availfloatAvailable margin in your account, the same as Available Balance in the Funds API. It already excludes the margin in use (prevMargin).
prevMarginfloatMargin already in use on your account when the request is made, the same as Utilized Amount in the Funds API. It covers existing positions and open orders, and also includes the brokerage and realised result of trades you have closed today.

Errors

CodeDescription
-50Invalid input. For example: qty: Must be greater than or equal to 1, The input symbol is invalid.:SYMBOL or Maximum Items number limit reached.
-16Authentication failed.
Last updated on