Kite Connect API - Update

sujith
sujith edited November 2020 in General
Hello developers,
We have two updates for you.

1. Margin computation APIs are now available on Kite Connect for all the users. This is still in beta, so you can expect there can be some changes.
You can check out the documentation to know more here. This will be rolled out in all the client libraries shortly.

2. There is an update to WebSocket subscriptions. There is an update that will be pushed on Sunday the 30th that will no longer accept `null` in place of numerical instrument tokens. Ideally, this should not affect your applications, but please check your code to ensure you are not sending `null`s in place of numerical values.

3. In addition, we are revising the 3000 subscription limit over maximum 3 WebSocket connections to 4000 instruments over 3 WebSocket connections. This change will be effective starting Sunday, 14th September 2020.

Thank you,
Team Zerodha
  • Anuj2343
    Hey. Good work, and this adds a lot of value to Kite Connect.

    Can you please tell me how to call for margins in Python?
  • sujith
    @Anuj2343
    It is not included in any of the client libraries yet. We will add it soon.
  • Anuj2343
    Alright. Can you still provide a tentative timeline as I'm building something and need to use this exact feature?
  • sujith
    We don't have any timeline yet. pykiteconnect is an open-source library, you can go ahead and add it.
  • rohitpoddar
    The margin calculation does not take into account securities unavailable for MIS. For instance, 20MICRON gets a 5X multiple for MIS order type.
    {'status': 'success', 'data': [{'total': 6.53, 'bo': 0, 'pnl': {'realised': 0, 'unrealised': 0}, 'cash': 0, 'tradingsymbol': '20MICRONS', 'additional': 0, 'exchange': 'NSE', 'exposure': 0, 'var': 6.53, 'type': 'equity', 'option_premium': 0, 'span': 0}]}
    Do we still need to refer to the manual data dump for MIS availability?
  • sujith
    20MICRONS is not allowed for MIS trading, I think RMS has not updated the data. You can start using this instead of that data API.
  • rohitpoddar
    Yes Sujith, the problem is that the new data api is sending the reduced margin for 20MICRON, even when it is not available for MIS, leading to incorrect order placement.
  • sujith
    Margin calculation API has no context of order placement or RMS policies. It will give you a 1x margin required but ounce is on the client application to check if the order placed is rejected or completed.
    As mentioned in the documentation, the margin calculation API does only the calculation part and nothing else.
  • rohitpoddar
    Got it. Thanks.
    So basically, there are two steps that the client application needs to perform.

    1. Check if the instrument is allowed for MIS on this link https://api.kite.trade/margins/equity
    2. Use the new API to get the margins required.

    It would be great if the new API can send back some sort of flag when the instrument queried is not available for the order type on that day (e.g. querying 20MICRON with MIS, should give an error response). This way we can completely do away with step-1.
  • nikhilR
    Hi @rohitpoddar ,

    As Sujith mentioned, the API currently doesn't have knowledge of the scrip level blocks put in the RMS. It provides leverages as per the product type (MIS in your case).

    For now you will have to query the list for all the scrips available for MIS and then proceed with your implementation. From a development perspective, it would be better to keep things separated instead of relying on a margins API for scrip level blocks.

    There are hundreds of blocks put in the RMS (across different products, exchanges, segments) according to our risk management and other policies and integrating the system into the margins API would be a complicated affair.

    We have this on our list of things to do, but this is not a priority feature for us and hence I won't be able to give you a timeline on this.
  • Gopikrishnan
    Gopikrishnan edited September 2020
    Margin computation API is a good addition. I saw this few back in the API docs but not able to see corresponding API wrappers in .NET library. Are you also going to update the library?
  • Gopikrishnan
    Also adding APIs for brokerage cost calculations will be very useful particularly for options trading. These are very complex otherwise https://zerodha.com/brokerage-calculator#tab-equities
  • sujith
    @Gopikrishnan,
    This is not yet added to client libraries. We will add it soon.
  • Gopikrishnan
    @sujith,
    When are we updating the client libraries(I am looking for .NET) with Margin computation APIs? I want to use them now
  • sujith
    @Gopikrishnan,
    It is on our list of things to do. I am afraid we can't give any timeline as of now. If you want to use it now then you can go ahead and fork the library, the client libraries are open source.
  • neel2323
    neel2323 edited October 2020
    I compared
    1) https://api.kite.trade/margins/equity
    2) https://zerodha.com/margin-calculator/Equity/

    Which one is the correct one as I need to incorporate these values for required fund calculation.

    There are following discrepancies for MIS Equity Intraday.

    ACC
    1. API MIS JSON: 11.57
    2. Kite Website: 12.0

    ACCELYA
    1. API MIS JSON: 12.33
    2. Kite Website: 14.0

    ADANIPOWER
    1. API MIS JSON: 6.7
    2. Kite Website: 7.0

    AMARAJABAT
    1. API MIS JSON: 9.91
    2. Kite Website: 10.0

    AMBUJACEM
    1. API MIS JSON: 10.3
    2. Kite Website: 10.0

    APLAPOLLO
    1. API MIS JSON: 4.21
    2. Kite Website: 4.0

    APOLLOTYRE
    1. API MIS JSON: 9.69
    2. Kite Website: 5.0

    ASIANPAINT
    1. API MIS JSON: 11.51
    2. Kite Website: 12.0

    AUROPHARMA
    1. API MIS JSON: 6.0
    2. Kite Website: 5.0

    BAJAJ-AUTO
    1. API MIS JSON: 10.58
    2. Kite Website: 11.0

    BALRAMCHIN
    1. API MIS JSON: 4.91
    2. Kite Website: 5.0

    BANDHANBNK
    1. API MIS JSON: 4.45
    2. Kite Website: 4.0

    BANKBEES
    1. API MIS JSON: 10.2
    2. Kite Website: 11.0

    BATAINDIA
    1. API MIS JSON: 10.08
    2. Kite Website: 5.0

    BERGEPAINT
    1. API MIS JSON: 10.44
    2. Kite Website: 11.0

    BHARTIARTL
    1. API MIS JSON: 9.95
    2. Kite Website: 5.0

    BHEL
    1. API MIS JSON: 4.6
    2. Kite Website: 5.0

    BIOCON
    1. API MIS JSON: 7.01
    2. Kite Website: 7.0

    BOSCHLTD
    1. API MIS JSON: 9.9
    2. Kite Website: 9.0

    BPCL
    1. API MIS JSON: 4.54
    2. Kite Website: 5.0

    BRITANNIA
    1. API MIS JSON: 9.87
    2. Kite Website: 10.0

    CADILAHC
    1. API MIS JSON: 11.03
    2. Kite Website: 11.0

    CENTURYTEX
    1. API MIS JSON: 5.0
    2. Kite Website: 7.0

    CESC
    1. API MIS JSON: 10.36
    2. Kite Website: 10.0

    CIPLA
    1. API MIS JSON: 11.25
    2. Kite Website: 11.0

    COALINDIA
    1. API MIS JSON: 10.62
    2. Kite Website: 11.0

    COLPAL
    1. API MIS JSON: 11.2
    2. Kite Website: 12.0

    CUMMINSIND
    1. API MIS JSON: 9.65
    2. Kite Website: 10.0

    DABUR
    1. API MIS JSON: 12.81
    2. Kite Website: 14.0

    DBCORP
    1. API MIS JSON: 4.01
    2. Kite Website: 4.0

    DCMSHRIRAM
    1. API MIS JSON: 4.5
    2. Kite Website: 5.0

    DIVISLAB
    1. API MIS JSON: 11.36
    2. Kite Website: 11.0

    DMART
    1. API MIS JSON: 10.33
    2. Kite Website: 11.0

    DRREDDY
    1. API MIS JSON: 11.89
    2. Kite Website: 12.0

    EICHERMOT
    1. API MIS JSON: 8.99
    2. Kite Website: 9.0

    EQUITAS
    1. API MIS JSON: 5.0
    2. Kite Website: 6.0

    EXIDEIND
    1. API MIS JSON: 11.04
    2. Kite Website: 11.0

    FACT
    1. API MIS JSON: 4.27
    2. Kite Website: 4.0

    GAIL
    1. API MIS JSON: 9.56
    2. Kite Website: 10.0
  • rakeshr
    @neel2323
    1) https://api.kite.trade/margins/equity
    2) https://zerodha.com/margin-calculator/Equity/
    API MIS Margin https://api.kite.trade/margins/equity is updated by RMS team at regular interval. Seems like they might have missed to update the same, so the difference.
    Zerodha Margin Calculator(https://zerodha.com/margin-calculator/Equity/), is updated BOD(Beginning of the day) on every trading day, this remains correct.
    Instead of depending on API MIS Margin JSON dump, you can start using above Margin computation APIs.
  • neel2323
    @rakeshr thank you for the clarification.

    I am actually looking for determining the max quantity I can buy/sell for X amount. I want to place orders accordingly. Example Company X has a MIS Margin of 20% or Multiplier of 5 and a share price of Rs. 1.
    I want to to place an order for a max quantity for Rs. 100 i.e 500 shares in this case such that my Rs. 100 will be fully utilised.

    Will the margin computation api help with determining the mis multipliers that I see on (https://zerodha.com/margin-calculator/Equity/)?

    Is there a python documentation for the Margin computation APIs? I couldn't find the same. Unfortunately, I am a self taught coder and python is the only language I am able to understand the API's in.
  • rakeshr
    @neel2323
    Will the margin computation api help with determining the mis multipliers that I see on (https://zerodha.com/margin-calculator/Equity/)?
    Yes, you can know the total margin required for 1 quantity of required symbol, and then you can perform the computation of placing_quantity = Margin_available(funds) / margin required for 1 Quantity .
    You can check an example here for the above explanation with required request and response detail for 1 quantity.
    Is there a python documentation for the Margin computation APIs? I couldn't find the same.
    Above margin computation end-point is not added on python client for now. Maybe you can fork and add the same at your end.
  • neel2323
    Thanks for being prompt! Please update on this thread once the python client is available
  • neel2323
    @rakeshr

    On the website margins fluctuate greatly after a few refreshes to the tune of 70% for a same limit buy price. Could you please look into this asap?

    The steps I followed to get this error:
    Entered Qty/Price -> Hit Refresh -> Got margin requirement in the range of 60,000.

    After hitting refresh a few times, it jumps to 104387 :/





    1.jpg 57.5K
    2.jpg 56.7K
  • sujith
    @neel2323,
    This forum is dedicated only to Kite Connect related queries, you can write to support here.
This discussion has been closed.