order_margins api

zuser
Hi,
I am facing some issue with calling order_margins api. It's throwing the following error.
kiteconnect.exceptions.InputException: invalid json

API call code is as follow.
kite.order_margins({'order_id':XXXXX,'exchange':'NFO', 'tradingsymbol':'XXXXXXXX','transaction_type':'SELL','variety':'regular','product':'MIS','order_type':'MARKET','quantity':75,'price':0,'trigger_price':0})

Any example code here would help.
Thanks.
  • sujith
    You can print the exception message to know the exact error message. You can check out the exception structure here.
  • Alogji
    @zuser example code (Based on available margin, how many option lots of both PE and CE can be shorted/written)


  • zuser
    Thanks @Algoji.
    I am able to get the margin info. However the margin of all live trades aren't summing upto the total used margin! :(
  • Alogji
    Alogji edited May 2021
    It is dynamic, so it keeps changing. I have manually verified it when market hours got over. Then number you get using the code exactly matches with margin required for a basket.
  • rakeshr
    However the margin of all live trades aren't summing upto the total used margin!
    It is dynamic, so it keeps changing.
    Yes, that's correct. You can use margin APIs to get an idea of the approx margin required(unless there is huge volatility in the next second and it decreases or increases drastically).
  • akshay_thakker
    Hi everyone, is there a way to get the margin required for a future or option lot independent of the current position/ orderbook? The reason for this requirement is that I have a running tally of margin I have used for a particular setup and the margin that I have available. The code decides the number of new lots to trade by dividing the margin available with the margin per lot but sometimes because the margin queried is way low because of the existing positions or orderbook i get a reject order when I try to place an order. Thanks!
  • rakeshr
    Is there a way to get the margin required for a future or option lot independent of the current position/ orderbook?
    Yes, you can use basket margin API with consider_positions query param as False.
Sign In or Register to comment.