Kite Connect Connection

Download other SharpScripts
Post Reply
Admin
Site Admin
Posts: 71
Joined: Mon Mar 16, 2015 7:23 am

Kite Connect Connection

Post by Admin »

This source code is provided for educational purpose only and intended for users who want to build their own custom connection to connect to their preferred brokers/data-feed providers. This source code should only act as an example or guide for the above purpose.

We do not maintain the connection nor do we take enhancement request for this connection. As such if the API parameter changes the code may stop working.

The Kite Connect Connection connects to the Kite Connect API v3 as provided by Zerodha/Rainmatter. The Kite Connect Connection is part of our "External Connection" and the code is open-source. The source code can be found at at our github page. To know more about an external connection please click here.

Please make sure you meet the below requirements to connect to Kite Connect Once subscribed to the Kite Connect API please configure your the Kite Connect App as below
  • Login to your Kite Developers Account
  • Click on the Kite Connect app which have a valid subscription
  • Set the 'Redirect url' as http://127.0.0.1
  • Append your Zerodha client id in the 'Zerodha Cliend ID' field
  • Click on the save button
Once you have configured the Kite developers console take a note of the Kite API Key and the Kite API Secret which will further required while setting up the Kite Connect Connection in ArthaChitra.

Download the attached KiteConnectConnection.zip file and import it to ArthaChitra.
  • In Main View menu bar goto Settings > SharpScript > Import
  • In the file selector dialog view select the file you want to import
  • Click Open
  • Restart ArthaChitra
Please refer her to know more.

Once imported, please follow the below steps to configure the Kite Connect Connection:
  • In the "Main View" goto Connection > Add Edit Connection
  • In the Add Edit connection view click on the Add button
  • In the "New Connection View" select Kite Publisher as the Connection Type
  • Append a name in the Name textBox
  • Append your Kite API Key
  • Append your Kite API Secret
  • If 'Candles API' is subscribed then check the 'Is historical data subscribed' option. If 'Candles API' is not subscribed then uncheck it. If unchecked ArthaChita will not request historical data from the Kite API.
  • Click on the Close button and exit the Add Edit connection view
Now you will be able to connect to the newly created Kite connection from:
  • In Main View goto Connection > Available Connections > {name of the kite connection}
Note: Please register your copy of ArthaChitra before connecting to the Kite API. Please refer here to know how to register ArthaChitra

Upon connecting to the Kite Connect connection the Kite View will pop up. User has to login to his/her Zerodha account or for placing the orders etc. Once the user has logged in to his Zerodha account, the Kite View will display the actual orders, trades, positions and account/funds value. The values are essentially static though ArthaChitra may refresh the values from time to time as required. User can update the values anytime by clicking on the refresh button
  • In the Kite View menu bar goto Refresh > {value you want to refresh}
Before using the Kite Connection please refer to the below scenarios for a proper understanding on how ArthaChitra works with the Kite API. Please do note the below list is not exhaustive. There may be scenarios in addition to what listed below:
  • The Kite View displays the raw data fetched from the Kite API. ArthaChitra further parses the data as needed, and the parsed data is displayed in various views in ArthaChitra.
  • The Kite API has two types of positions, namely the 'day' position and the 'net' position. ArthaChitra takes into account (in both Kite View and the Main View) the 'net' position only
  • For FnO orders set the order quantity in terms of 'number of contracts' and NOT as 'lot size'. Thus if you want to place an order to buy 2 lots of Nifty futures then set the quantity as 2 (two) and NOT 150 (one hundred fifty), the lot size of Nifty futures being 75 (seventy five) while writing this documentation
  • For appending quotes ArthaChitra subscribes to the 'full' mode (Level2 quotes)
  • The Kite API changes the order state of a stop order from SL to Limit in case of stop limit orders and from SL-M to Market in case of Stop market order when the stop order gets filled. Thus if user re-connects to the Kite Connection, the order state will not reflect the original state.
  • The Kite Connect API does not sends the postbacks in a chronological order. While we do try filter out the stale/redundant postbacks wherever possible there might be scenarios where it is not filtered. For example while modifying a partially filled order the order might not reflect its actual scenario. As such user have to refresh the orders to reflect the actual position.
    • In the Kite View menu bar click on Refresh > Order to pull the order list.
  • The Kite Connect Connection does not supports automated trading as it is prohibited by the Kite Connect API TnC.
Updated version released on 18th July 2019 to accommodate the changes in the Kite API

ARTHACHITRA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. ARTHACHITRA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOURCE CODE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL ARTHACHITRA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE.
Attachments
KiteConnectConnection.zip
Kite Connect Connection
(115.46 KiB) Downloaded 1196 times
Post Reply