Downloading Historical data

akabrboghani
akabrboghani edited August 2017 in Python client
Hi,

I have few queries on the historical data.
1) Is it possible to download last 2 year data in multiple time frames (15 min to 1 day)
2) Is commodity data available for download?
3) Finally, does zerodha provide any script for downloading the data?

Thank you for your help.

Regards
  • sujith
    Hi @akabrboghani,
    1) Is it possible to download last 2 year data in multiple time frames (15 min to 1 day)
    You can download 2 year data in 15 min to 1 day interval for equity segment.
    2) Is commodity data available for download?
    Kite Connect supports historical data fetch only based on instrument token. Exchange re-uses instrument token once it is expired. Hence as of now, you can't fetch historical data for expired contracts. We are planning to come up with a feasible solution for this in future.
    3) Finally, does zerodha provide any script for downloading the data?
    Fetching historical data is just one API call. You can check out example here.
  • Dileep
    Hi @sujith is it possible to fetch multiple tokens historical data at once.? if i use the below code "records= kite.historical_data(instrument_token, from_date, to_date, interval)" .I need to put time. sleep(1) to avoid rate limit error.(i.e. 3 hits per second) for fetching one more token.If i subscribed for 200 instruments in the kite ticker then i need to wait 200 seconds for fetching the historical data for a instrument token.How to avoid this? can you guide me the best possible solution
  • rakeshr
    rakeshr edited June 2018
    @Dileep
    It is not possible to fetch historical data for multiple instruments in a single request.Historical data is provided for backtesting purpose only and not suitable for live strategies.
    What possibly, you can do is, generate candles by using tick data from websocket and store it at your end for how much ever period you want. You can fetch it from your database and do any operations you want.
    Go through this thread to know, about forming candles at your end from websocket.
  • shivadasharathi
    Hi,
    I am trying to download the historical data for SBI. I have subscription for historicl data as well.

    I am using the below code to fetch the data. It says invalid token,
    please let me know if anything is wrong in the code.


    from_ = "2018-01-03 12:00:00"
    to_ = "2018-01-05 12:00:00"
    df = kite.historical_data("SBIN", from_, to_, '30minute', True)

    Thanks
  • sujith
    You need to send the instrument token and not the trading symbol.
    You can find the instrument token from the instrument master dump.
  • itjockey
    Hi Team, i just need to know how do i download Nifty 50 Stocks 1 min historical data in excel with one click as it is time-consuming to go one by one 50 symbols. i am not tech guy i am trader so please help me out.
  • sujith
    You can check out HowUTrade. This is a third-party developers team who have built a wrapper around the Kite Connect APIs.

    Maybe @HowUTrade can help you out here.
  • rehmankhans
    how to download 15 min candle stick data of NSE stocks for a period of last 1 year
  • sujith
    You can check out the documentation here.
  • vikassaini09
    Hi Sujit,
    I know it will be very basic thing and silly query, but i am not a techie and nned your help further. As i have seen in above posts that you have given some code to download the data from kite chart. but i do not know how to use this code in order to download the data from kite chart. It will be of great help if you may provide a step by step guide or youtube video how to use this code. It will be of great help to me and others too.

    Also just wish to confirm that is this still valid as over a period of time, software and sites do changes their things..
  • sujith
    This is a historical data API and Kite charts use the same API to populate data.
    One needs a live Kite Connect and historical data subscription to fetch the data. If you are not aware of the programming then I would suggest hiring one of the freelancers who often hangout here.
    We don't provide support or solutions for writing strategies, it is outside the scope of the forum.
  • Dileep
    Hi @sujith ,What is the minimum time interval that i can set for interval parameter? "kite.historical_data(instrument_token, from_date, to_date, interval)" can we mention seconds also? How to mention seconds here?
  • sujith
    You can check here to know more about the from and to date params. The finest resolution is minute, even if you send the seconds value, you might receive the latest candle only.
  • v_narang247
    Hi @sujith :smile:
    I am trying to download historic data for ZEEL from Zerodha. In the Dec 2002, ZEEL is shown trading at ~95 Rs and in the subsequent month i.e. Jan 2003, the chart is showing ZEEL trading at ~ 30 Rs.

    Please see the chart image attached. Seems the data for ZEEL is not correct on Zerodha kite.

    Is there any way to download correct pricing data?


  • rakeshr
    @v_narang247
    There was corporate action of name change from ZEETELE to ZEEL on 10-01-2007 and demerger on late 2006, check the details here.So, same corporate action rate has been adjusted here.
  • v_narang247
    Hi @rakeshr

    For the corporate action and demerger that happened in 2007, why has the adjustment happened in Dec 2003?

    If one wants to calculate the return for a simple Buy and Hold Strategy over the last 20 years for ZEEL- then this data is not suitable .

    Please let me know if I am missing something.
  • v_narang247
    Hi @rakeshr

    For the corporate action and demerger that happened in 2007, why has the adjustment happened in Dec 2003?

    If one wants to calculate the return for a simple Buy and Hold Strategy over the last 20 years for ZEEL- then this data is not suitable .

    Please let me know if I am missing something.
  • rakeshr
    @v_narang247
    We are looking to this.
  • v_narang247
    Hi, Do you have any update on this ?
  • MW5790
    when i try to use nodejs client API to access historic data , i get this error Insufficient permission for that call.
  • rakeshr
    @MW5790
    Make sure you have activated add-on subscriptions to use historical data API in the developer's dashboard.
  • vina
    Hi all,
    lets say, I need 90 days moving average for all scripts in nifty 50. This as you all know is a dynamic data which changes every day, ie. today's average is not tomorrow's.

    Two thing that is seriously hampering and not being supported by zerodha are:

    1. we are unable to take historical data of multiple scripts at one go ( they just say historical data is for back-testing.. which is not the case.
    2. hence there is no way for us to make this dynamic on a day-to-day basis which is so critical for strategies.

    does zerodha have any firm answer to it... or will just re-direct to some third party?

    Is there a solution?

    Best Wishes,
    Narayanan
  • sujith
    sujith edited December 2019
    Hi @vina,
    I would like to repeat our stance on this again as mentioned earlier. We provide historical data for backtesting purposes only. We don't recommend using the same for live strategies.
    If your strategy requires intra-day candles then you can build candles at your end using the live market data provided using the Websockets.

    As of now, we don't have any plans of providing an API for the bulk fetch of historical data.

    You may refer to this thread to get started.
  • vina
    hi Sujith... so what is real use of historical data subscription? and we did not ask for recommendation right... its up to us to develop strategies... is there a way to write to decision makers in you co., so that this is provided.
  • QY0510
    I am only able to get one minute data from 2015, is the data available only from 2015?
  • rakeshr
    Yes. You can go through Historical data FAQs here.
Sign In or Register to comment.