Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs

    getMarginApi Api returns wrong margin for Nifty futures ? [Urgent]

    Python SDK
    0
    1
    20
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      coolankurmahe last edited by coolankurmahe

      getMarginApi returns following normally response for June Nifty Futures:
      {'status': True, 'message': 'SUCCESS', 'errorcode': '', 'data': {'totalMarginRequired': 65482.09, 'marginComponents': {'netPremium': 182130.0, 'spanMargin': 400425.5, 'marginBenefit': 84922.0, 'deliveryMargin': 0.0, 'nonNFOMargin': 0.0, 'totOptionsPremium': 0.0}, 'marginBreakup': [{'exchange': 'NFO', 'productType': 'CARRYFORWARD', 'totalMarginRequired': 65482.09}], 'optionsBuy': {'totOptionsPremium': 0.0, 'optionDetails': []}}}

      So as can be seen 65482.09 is the margin for 1 lot (25 quantity).

      Today at 10:45 AM when this Api gets called , my code had also placed order for Nifty Call option as well and when checking margin using getMarginApi got following response:
      {'status': True, 'message': 'SUCCESS', 'errorcode': '', 'data': {'totalMarginRequired': 11554.58, 'marginComponents': {'netPremium': 182130.0, 'spanMargin': 0.0, 'marginBenefit': 53927.5, 'deliveryMargin': 0.0, 'nonNFOMargin': 0.0, 'totOptionsPremium': 0.0}, 'marginBreakup': [{'exchange': 'NFO', 'productType': 'CARRYFORWARD', 'totalMarginRequired': 11554.58}], 'optionsBuy': {'totOptionsPremium': 0.0, 'optionDetails': []}}}

      I had kept the capital for futures to be 1 Lakh
      Since the margin using above Api came out to be 11554.58, I calculate the actual future quantity to be placed for order as below:
      actualFutureQuantity = (int)(capital/oneLotMargin)*futureLostSize
      which in this case is (int)(100000/11554.58)*25 = 8

      So 8 lots(200 quantity) order was placed for Nifty futures.
      But the problem is I can see 4.3 lakhs have been deducted from my account rather than anything near to 1 lakh.

      Below is Nifty future order response:
      orderResponse : {'status': True, 'message': 'SUCCESS', 'errorcode': '', 'data': {'variety': 'NORMAL', 'ordertype': 'MARKET', 'producttype': 'CARRYFORWARD', 'duration': 'DAY', 'price': 0.0, 'triggerprice': 0.0, 'quantity': '200', 'disclosedquantity': '0', 'squareoff': 0.0, 'stoploss': 0.0, 'trailingstoploss': 0.0, 'tradingsymbol': 'NIFTY27JUN24FUT', 'transactiontype': 'BUY', 'exchange': 'NFO', 'symboltoken': '35004', 'instrumenttype': 'FUTIDX', 'strikeprice': -1.0, 'optiontype': 'XX', 'expirydate': '27JUN2024', 'lotsize': '25', 'cancelsize': '0', 'averageprice': 23152.78, 'filledshares': '200', 'unfilledshares': '0', 'orderid': '240527000529143', 'text': '', 'status': 'complete', 'orderstatus': 'complete', 'updatetime': '27-May-2024 10:45:03', 'exchtime': '27-May-2024 10:45:03', 'exchorderupdatetime': '27-May-2024 10:45:03', 'fillid': '', 'filltime': '', 'parentorderid': '', 'ordertag': '', 'uniqueorderid': 'c5acc46f-9919-4d3c-bd55-34afdf75cb5c'}}

      Please let me know the problem here ? Also, how should the margin just for futures should be calculated ? Why there is difference in one response to another of getMarginApi - 11554.58 rather than 65482.09 for one lot(25 qty).
      Also, if 11554.58 is the right margin, it didn't deduct 1 lakh but 4.3 lakh from my account.

      Please let me know as it urgent.

      1 Reply Last reply Reply Quote 0
      • First post
        Last post