未加星标

Trading with Python in Indian Markets

字体大小 | |
[开发(python) 所属分类 开发(python) | 发布者 店小二04 | 时间 2016 | 作者 红领巾 ] 0人收藏点击收藏

Trading with Python in Indian Markets

Algorithmic Trading in Indian Markets using python

We have told you why Python is one of the preferred languages to do algo trading inthis article. We have also told you how algorithmic trading in India . Since we are gearing up for our webinar on Trading in Indian Markets using Python (Not registered yet?Click here to register your seat), we ought to give you a prelude to the trading platform which will enable you to implement your algorithmic trading strategies in python.

To enable trading in Indian Markets using Python, we will utilize Kite Connect API, India’s first market API for retail clients. We will be covering this in detail in the webinar. We cover most of the trading platforms inEPAT, our highly sought after course on algorithmic trading and quantitative finance. We have also covered various libraries available in Python for algo trading in an earlier article, in this article we will also be talking about the official python client for communicating with Kite Connect API.

What is Kite Connect?

Kite Connect is a compilation of REST-like hypertext transfer protocol based APIs that ease numerous capabilities needed to build investment and trading platforms. It is built on top of Zerodha’s online trading platform. The users should be clients of Zerodha only and they will get programmatic access to all the information on the brokerage. You can also use Kite Connect API for:

Executing orders in real time managing portfolios streaming real time market data offsite order execution getting reliable updates on your orders of course, getting historical data

Now, if you remember, in our article on trading with Interactive Brokers, we had mentioned some of the advantages of using IB API for algorithmic trading . For Indian markets, Kite Connect is a great choice for implementing algorithmic trading strategies using Python, which will be further explained in ourwebinar.

Objectives of Kite Connect

Gone are the days when retail clients stayed away from capital markets because they did not have any option to access their trading accounts pragmatically. With aim to bring a revolutionary change in the way trading is done in India, Kite Connect promises to:

Cutting down costs involved to perform trading in India Going completely brokerage free in future Making the process more transparent Offer a better platform to do trading Keeping a client-first attitude. Supporting a wide array of programming languages including Python, Java, C#, Excel VBA, etc. You can also use the command line console on Kite Connect.

Besides placing and managing orders, Kite Connect promises to enable users to build:

Multi asset risk modelling systems Stock screeners Quant strategies Equity stock selection models Option greeks calculators Backtesting, machine learning Personal Kite or Pi.

One of the key advantages of Kite Connect is that you will own and control your trading account and the data associated with it, and you will not be restricted to the platform offered by your broker.

Python for Algorithmic Trading in Kite Connect

We have already told you why Python has sufficed as the best choice for algorithmic trading in our article titled: Why Python Algorithmic Trading is Preferred Choice Among Traders?

Kite Connect has client libraries in multiple programming languages includingphp, JS and of course, Python. The official library for Python is available here:

https://github.com/rainmattertech/pykiteconnect

Requirements

Zerodha is India’s first discount broker and all the trades in Kite Connect are executed through Zerodha. So, first thing that you need to do is to create a trading account on Zerodha so that you can access the APIs. Once you have that, next thing to do is to register for a developer account . That’s it! You can get started immediately. In our webinar, Nithin Kamat & Satyajit Sarangi will be explaining all this in a step-by-step manner.

Since Zerodha has already got all the necessary approvals for users of Kite Connect API, therefore you, as a Kite Connect user, do not have to acquire any other approvals.

Installation of Python client

After downloading the resources from the github repository you will have to install the files. To install the client, you will have to use the following command:

pipinstallkiteconnect API Usage

You can find the following code on the github repository as well. However, for convenience’ sake, we are giving it here:

<spanclass="pl-k">from</span> kiteconnect <spanclass="pl-k">import</span> KiteConnect kite <spanclass="pl-k">=</span> KiteConnect(<spanclass="pl-v">api_key</span><spanclass="pl-k">=</span><spanclass="pl-s"><spanclass="pl-pds">"</span>your_api_key<span class="pl-pds">"</span></span>) <spanclass="pl-c"># Redirect the user to the login url obtained</span> <spanclass="pl-c"># from kite.login_url(), and receive the request_token</span> <spanclass="pl-c"># from the registered redirect url after the login flow.</span> <spanclass="pl-c"># Once you have the request_token, obtain the access_token</span> <spanclass="pl-c"># as follows.</span> data <spanclass="pl-k">=</span> kite.request_access_token(<spanclass="pl-s"><spanclass="pl-pds">"</span>request_token_here<span class="pl-pds">"</span></span>, <spanclass="pl-v">secret</span><spanclass="pl-k">=</span><spanclass="pl-s"><spanclass="pl-pds">"</span>your_secret<span class="pl-pds">"</span></span>) kite.set_access_token(data[<spanclass="pl-s"><spanclass="pl-pds">"</span>access_token<span class="pl-pds">"</span></span>]) <spanclass="pl-c"># Place an order</span> <spanclass="pl-k">try</span>: order_id <spanclass="pl-k">=</span> kite.order_place(<spanclass="pl-v">tradingsymbol</span><spanclass="pl-k">=</span><spanclass="pl-s"><spanclass="pl-pds">"</span>INFY<span class="pl-pds">"</span></span>, <spanclass="pl-v">exchange</span><spanclass="pl-k">=</span><spanclass="pl-s"><spanclass="pl-pds">"</span>NSE<span class="pl-pds">"</span></span>, <spanclass="pl-v">transaction_type</span><spanclass="pl-k">=</span><spanclass="pl-s"><spanclass="pl-pds">"</span>BUY<span class="pl-pds">"</span></span>, <spanclass="pl-v">quantity</span><spanclass="pl-k">=</span><span

本文开发(python)相关术语:python基础教程 python多线程 web开发工程师 软件开发工程师 软件开发流程

主题: PythonPHPRESTC#JavaExcelEPA
分页:12
转载请注明
本文标题:Trading with Python in Indian Markets
本站链接:http://www.codesec.net/view/484269.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 开发(python) | 评论(0) | 阅读(45)