How to get started - trading via Python

pytrader edited May 2016 in General
Can someone please guide to the exact process to start trading using Python language? I have a zerodha account. How do I get the API key and other stuff. What all is required on my part?
  • Kailash
    Signup here to get your keys --

    Use the Kite Connect Python client in your Python app --

    Read the Kite Connect documentation to get the complete picture --
  • pytrader
    Few more questions : 1) What should I choose in the Type option while creating an App? 2) Redirect URL - What is this for and how do I create a https url for myself?
  • Kailash
    1) If you want to use the complete APIs, choose Kite Connect. Publisher is only for embedding buttons on webpages.

    2) After the login prompt (like Facebook or Gmail logins), the API will redirect to this url you register. You'll have to have a domain name where you are running your Python web app.

    "how do I create a https url for myself" -- I am afraid this question falls outside the scope of the API. Please look into Python web development and installing SSL certificates (https) on your apps.
  • pytrader
    I have Spyder 3.5 installed on my laptop where I have my strategies coded. How will I use it to fire orders using this API and http URL?
  • Kailash
    Ah, if that's the case, you can set the redirect url to `` (your localhost). When the login is done and the redirect happens, you can copy the request_token from the redirect url.

    Then, you'll use the pykiteconnect library in your Python code to get the access token and place orders. Please refer to the documentation --
  • pytrader
    Thanks for your quick replies Kailash. Appreciate. Is there a way to automate the copying of the request_token from the redirect url straight into the pykiteconnect? and can the trades be place automatically without any manual intervention? And how will my fund from the account be debited when I place the trades? will it be through the api_key and the access_token?
  • Kailash
    1) Yes. You can setup a standalone Python webserver on to which the redirect happens. This app can capture token_request from the URL parameters and pass to your app.

    2) Trades can be placed completely programmatically.

    3) Funds are debited just as they would be if you were trading using the trading terminal at Zerodha. You login to the API using a Zerodha client id, and everything happens under this client it.
  • hanzo
    hanzo edited May 2016
This discussion has been closed.