kite.basket_order_margins() giving wrong results in high vix

akhilesh_singla
Today I lost 50k+ just because kite.basket_order_margins(basket) said margin is enough but when order was placed, I got margin errors for as little as 10K. I had even reduced 2 lots margin (~4L) from my original margin.

How to manage margin?
Assume I have 10L. basket_order_margins() returns 9L margin is required for my basket. Should I rely on 9L? Because apparently, it's highly unreliable API.
  • akhilesh_singla
    @sujith Could you please help?

    I follow below steps to handle margin:
    1. Fetch available margin using kite.margins()
    2. Use 90% of available margin
    3. Create basket and check basket margin using kite.basket_order_margins()
    4. Execute only if basket margin <= 90% of available margin
  • Arockiya_r
    @akhilesh_singla, you are considering "initial" margin or "final" margin. The initial margin is required while placing a basket order. If you compare the initial margin with the available margin and see the issue, please share the order details that you added to the basket to assist further.
  • akhilesh_singla
    akhilesh_singla edited May 12
    @Arockiya_r I'm using final margin as below:
    def check_required_margin(basket):
    margin = kite.basket_order_margins(basket)
    return margin["final"]["total"]
    Do you suggest using margin["initial"]["total"] ? After taking a trade, can required margin spike to increase more than the initial margin?
  • Arockiya_r
    Do you suggest using margin["initial"]["total"]
    yes.

    Please refer to the kite connect documentation, the basket margin section.
    The final margin is the total margin with the spread benefit.
  • akhilesh_singla
    Thanks. I have modified my code accordingly. You may close this thread.
This discussion has been closed.