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_totalis 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
dataarray in the intended execution sequence. - Margin fields are returned inside
data. - To check whether the orders can be funded, compare
margin_totalwithmargin_avail.margin_availalready excludes the margin in use. limitPrice,stopPrice,stopLossandtakeProfitcan 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
| Attribute | Data Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Instrument symbol in FYERS symbology format. |
qty | int | Yes | Quantity. For NSE and BSE derivatives, in units, as a multiple of the lot size. For MCX, the number of lots. |
side | int | Yes | 1 = Buy; -1 = Sell. |
type | int | Yes | |
productType | string | Yes | CNC, INTRADAY, MARGIN or MTF, in uppercase. The calculator does not check whether the instrument is eligible for the product type. |
limitPrice | float | No | Positive 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. |
stopPrice | float | No | Positive trigger price (at least 0.0025) for stop-market and stop-limit orders. Use 0.0 otherwise. |
stopLoss | float | No | Reserved. Must be 0.0. |
takeProfit | float | No | Reserved. Must be 0.0. |
Response Attributes
| Attribute | Data Type | Description |
|---|---|---|
s | string | ok / error. |
code | int | API response code. 200 on success; -50 for invalid input; -16 for authentication errors. |
message | string | Response or error message. Empty on success. |
data | object | Object that holds the margin values below. |
margin_total | float | Approximate 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_order | float | Approximate total margin in use after the submitted orders are placed. It equals margin_total + prevMargin. |
margin_avail | float | Available margin in your account, the same as Available Balance in the Funds API. It already excludes the margin in use (prevMargin). |
prevMargin | float | Margin 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
| Code | Description |
|---|---|
-50 | Invalid input. For example: qty: Must be greater than or equal to 1, The input symbol is invalid.:SYMBOL or Maximum Items number limit reached. |
-16 | Authentication failed. |
Last updated on