Skip to main content

Get Order Margin Info

This API calculates the approximate margin required for a new or modified order before it is placed. Supports single-leg and multi-leg strategies.

🔑Header Parameters

HeaderTypeRequiredDescriptionExample/ENUM
AuthorizationstringYesBearer token for authenticationBearer access_token
x-api-keystringYesAPI key for access controlx-api-key
Content-TypestringYesFormat of the request bodyapplication/json

📦Request Body Schema

📑 Request Body Parameters

FieldTypeRequiredDescriptionExample / Enum
NoOfLegsintegerYesNumber of legs in the order1, 2
ModestringYesCalculation mode: "N" = New order, "M" = Modify order"N", "M"
FETraceIdstringNoOptional trace ID echoed back in the response for tracking"DEMO31_Sa212022190445"
MessageTypestringYesRequest type: "FUND_UTIL_CALC_REQ" for span margin, "FUND_BASKET_UTIL_REQ" for basket/order cart"FUND_UTIL_CALC_REQ"
LegDetailsarrayYesArray of leg detail objectsRefer below

🗂️Leg Details object Fields

FieldTypeRequiredDescriptionExample/ENUM
LegNointegerYesLeg number (positive integer)1, 2
BuyOrSellintegerYesTransaction type: 1 = Buy, 2 = Sell1
MarketSegmentstringYesExchange segments"NSE_EQ"
TokenintegerYesScrip token ID as per exchange master file (positive integer)12345
QuantityintegerYesOrder quantity (positive integer)100
PriceintegerYesPrice in paise (1 INR = 100 paise), e.g. 100.05 INR = 10005 paise10005
MktFlagintegerNoMarket order flag Possible values: 0 = No, 1 = Yes0
OldPriceintegerNoPrevious price in paise (before modification)9500
OldQuantityintegerNoPrevious quantity (before modification)50
ProductTypestringYesProduct type of the order"M"
LegIndicatorintegerNoCustom indicator per leg1
Response Formats
  • Standard Margin Response – Returns a single-token margin result.
  • SpanMargin Response – Returns multi-leg margin details with a LegDetails breakdown.

🟢Success Response - 200 Ok

FieldTypeDescriptionExample/ENUM
statusstringStatus of the API call"success"
codestringResponse code"s-101"
messagestringSuccess message"Success"
dataobjectContains margin response detailsSee details below

📦 data Object Fields

FieldTypeDescriptionExample
statusintegerInternal status code: 200 = success200
resultobjectMargin calculation resultRefer below

📘 Result Object Fields (Standard Response)

FieldTypeDescriptionExample
StatusintegerInternal status: 1 = success1
ClientIdstringUCC of the client"APITEST"
ClientCodestringInternal client code"NWSYF"
TokenstringCombined token (format: "100002885" = 10000 prefix + token)"100002885"
MarketSegmentIdstringMarket segment ID as string"521"
ApproxMarginstringApproximate margin required in rupees"385.78"
AvailableMarginstringAvailable margin balance in rupees"10000000000.00"
RequestTraceIdstringEcho-back of FETraceId or system-generated trace ID"NWSYF1929281000"
ProductTypestringProduct type code"1"
ShortFallstringMargin shortfall (rupees); "0.00" if no shortfall"0.00"
BrokeragestringEstimated brokerage in rupees"0.00"

📘 Result Object Fields (SpanMargin / Multi-leg Response)

All standard fields plus:

FieldTypeDescriptionExample
SPAN/VARstringSPAN or VAR margin component"0.56"
ExposureMarginstringExposure margin component"0.00"
Total Premium PayablestringPremium payable for options legs"0.00"
Total Premium ReceivablestringPremium receivable for options legs"0.00"
TotalMarginstringCombined total margin required"0.56"
BenefitstringHedge benefit applied"0.00"
LegDetailsarrayPer-leg margin breakdownRefer below

📘 LegDetails Array in Response

FieldTypeDescriptionExample
TokenstringScrip token for this leg"2885"
MarketSegmentIdstringMarket segment ID"1"
InitialMarginstringInitial margin for this leg"0.28"
ExposureMarginstringExposure margin for this leg"0.00"
PremiumPayablestringOptions premium payable"0.00"
PremiumReceivablestringOptions premium receivable"0.00"
TotalMarginstringTotal margin for this leg"0.28"