Kite Connect API - Update

sujith
sujith edited September 15 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 2
    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
    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

    GMBREW
    1. API MIS JSON: 4.25
    2. Kite Website: 4.0

    GODREJCP
    1. API MIS JSON: 10.87
    2. Kite Website: 11.0

    GODREJPROP
    1. API MIS JSON: 5.0
    2. Kite Website: 8.0

    GSFC
    1. API MIS JSON: 9.8
    2. Kite Website: 10.0

    HAVELLS
    1. API MIS JSON: 10.63
    2. Kite Website: 11.0

    HCLTECH
    1. API MIS JSON: 10.44
    2. Kite Website: 10.0

    HDFC
    1. API MIS JSON: 7.73
    2. Kite Website: 8.0

    HDFCBANK
    1. API MIS JSON: 11.03
    2. Kite Website: 12.0

    HEROMOTOCO
    1. API MIS JSON: 9.37
    2. Kite Website: 10.0

    HINDALCO
    1. API MIS JSON: 7.5
    2. Kite Website: 7.0

    HINDPETRO
    1. API MIS JSON: 5.76
    2. Kite Website: 6.0

    HINDUNILVR
    1. API MIS JSON: 11.74
    2. Kite Website: 12.0

    IBULHSGFIN
    1. API MIS JSON: 3.99
    2. Kite Website: 4.0

    ICICIBANKN
    1. API MIS JSON: 11.48
    2. Kite Website: 12.0

    IDFCFIRSTB
    1. API MIS JSON: 4.25
    2. Kite Website: 4.0

    IGL
    1. API MIS JSON: 10.15
    2. Kite Website: 10.0

    IIFL
    1. API MIS JSON: 7.51
    2. Kite Website: 5.0

    INDIANB
    1. API MIS JSON: 4.59
    2. Kite Website: 5.0

    INDUSINDBK
    1. API MIS JSON: 3.86
    2. Kite Website: 4.0

    INFY
    1. API MIS JSON: 10.04
    2. Kite Website: 10.0

    IOC
    1. API MIS JSON: 10.79
    2. Kite Website: 11.0

    IRB
    1. API MIS JSON: 4.29
    2. Kite Website: 1.0

    IRCON
    1. API MIS JSON: 4.65
    2. Kite Website: 5.0

    IRCTC
    1. API MIS JSON: 10.4
    2. Kite Website: 11.0

    ISEC
    1. API MIS JSON: 4.63
    2. Kite Website: 5.0

    ITC
    1. API MIS JSON: 10.9
    2. Kite Website: 12.0

    JSWSTEEL
    1. API MIS JSON: 5.71
    2. Kite Website: 8.0

    JUBLFOOD
    1. API MIS JSON: 4.77
    2. Kite Website: 5.0

    JUSTDIAL
    1. API MIS JSON: 6.64
    2. Kite Website: 7.0

    KCP
    1. API MIS JSON: 4.35
    2. Kite Website: 4.0

    KIRLOSBROS
    1. API MIS JSON: 4.89
    2. Kite Website: 5.0

    KRBL
    1. API MIS JSON: 4.86
    2. Kite Website: 5.0

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

    LTI
    1. API MIS JSON: 4.65
    2. Kite Website: 5.0

    LUPIN
    1. API MIS JSON: 10.86
    2. Kite Website: 10.0

    M&M
    1. API MIS JSON: 6.62
    2. Kite Website: 7.0

    MARICO
    1. API MIS JSON: 14.83
    2. Kite Website: 16.0

    MARUTI
    1. API MIS JSON: 9.1
    2. Kite Website: 9.0

    MGL
    1. API MIS JSON: 8.16
    2. Kite Website: 8.0

    MRF
    1. API MIS JSON: 11.98
    2. Kite Website: 13.0

    NAUKRI
    1. API MIS JSON: 8.53
    2. Kite Website: 9.0

    NAVINFLUOR
    1. API MIS JSON: 5.0
    2. Kite Website: 1.0

    NAVKARCORP
    1. API MIS JSON: 4.63
    2. Kite Website: 5.0

    NBCC
    1. API MIS JSON: 4.72
    2. Kite Website: 5.0

    NCC
    1. API MIS JSON: 5.71
    2. Kite Website: 6.0

    NESTLEIND
    1. API MIS JSON: 11.61
    2. Kite Website: 12.0

    NIFTYBEES
    1. API MIS JSON: 14.04
    2. Kite Website: 15.0

    NLCINDIA
    1. API MIS JSON: 4.84
    2. Kite Website: 5.0

    NTPC
    1. API MIS JSON: 12.21
    2. Kite Website: 12.0

    ONGC
    1. API MIS JSON: 5.0
    2. Kite Website: 4.0

    PAGEIND
    1. API MIS JSON: 10.24
    2. Kite Website: 10.0

    PEL
    1. API MIS JSON: 4.04
    2. Kite Website: 4.0

    PETRONET
    1. API MIS JSON: 10.22
    2. Kite Website: 11.0

    PIDILITIND
    1. API MIS JSON: 11.15
    2. Kite Website: 12.0

    POLYCAB
    1. API MIS JSON: 4.4
    2. Kite Website: 4.0

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

    PRESTIGE
    1. API MIS JSON: 4.64
    2. Kite Website: 5.0

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

    RADICO
    1. API MIS JSON: 4.03
    2. Kite Website: 4.0

    RAMCOCEM
    1. API MIS JSON: 11.47
    2. Kite Website: 12.0

    RCF
    1. API MIS JSON: 4.35
    2. Kite Website: 4.0

    RECLTD
    1. API MIS JSON: 9.34
    2. Kite Website: 9.0

    RELIANCE
    1. API MIS JSON: 9.35
    2. Kite Website: 10.0

    ROSSARI
    1. API MIS JSON: 8.0
    2. Kite Website: 5.0

    SAIL
    1. API MIS JSON: 4.46
    2. Kite Website: 4.0

    SANDHAR
    1. API MIS JSON: 4.76
    2. Kite Website: 5.0

    SBILIFE
    1. API MIS JSON: 5.0
    2. Kite Website: 10.0

    SBIN
    1. API MIS JSON: 5.69
    2. Kite Website: 5.0

    SHREECEM
    1. API MIS JSON: 10.58
    2. Kite Website: 11.0

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

    SUDARSCHEM
    1. API MIS JSON: 4.87
    2. Kite Website: 5.0

    SUNPHARMA
    1. API MIS JSON: 10.63
    2. Kite Website: 11.0

    TATACHEM
    1. API MIS JSON: 11.12
    2. Kite Website: 5.0

    TATACOFFEE
    1. API MIS JSON: 4.62
    2. Kite Website: 5.0

    TATAPOWER
    1. API MIS JSON: 8.39
    2. Kite Website: 8.0

    TATASTEEL
    1. API MIS JSON: 8.73
    2. Kite Website: 9.0

    TCS
    1. API MIS JSON: 11.42
    2. Kite Website: 12.0

    TECHM
    1. API MIS JSON: 10.18
    2. Kite Website: 10.0

    THERMAX
    1. API MIS JSON: 4.09
    2. Kite Website: 4.0

    TITAN
    1. API MIS JSON: 9.73
    2. Kite Website: 10.0

    TORNTPHARM
    1. API MIS JSON: 10.5
    2. Kite Website: 10.0

    TORNTPOWER
    1. API MIS JSON: 11.61
    2. Kite Website: 12.0

    TVSMOTOR
    1. API MIS JSON: 9.54
    2. Kite Website: 10.0

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

    ULTRACEMCO
    1. API MIS JSON: 10.15
    2. Kite Website: 11.0

    VOLTAS
    1. API MIS JSON: 10.55
    2. Kite Website: 11.0

    WABCOINDIA
    1. API MIS JSON: 14.14
    2. Kite Website: 5.0

    WIPRO
    1. API MIS JSON: 10.3
    2. Kite Website: 11.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
Sign In or Register to comment.