Bug in historical API

chandrak
chandrak edited June 2019 in .Net API client
Guys,

There is a bug in Historical API. When you ask for daya for INTERVAL_DAY inbeween dates (From date to To Date) you will get perfect data including last day's data, but if you use same dates to get INTERVAL_5MINUTES, you are not geting last day's data. Even if you move To Date to even tomorrow's date, you still are not getting yesterday's data.

Zerodha should be giving simple functions to ask for standard SMA calculation in their APIs instead of giving option for date period.

Regards
  • sujith
    @chandrak,
    We will forward your concern to the data team.
    Zerodha should be giving simple functions to ask for standard SMA calculation in their APIs instead of giving option for date period.
    Kite Connect is purely an execution platform. We don't intend to provide any solution or assistance in building strategies.
  • chandrak
    Hi sujith.. please ignore this.

    Can you help me urgently as 8 clients are waiting for the software (they will subscribe to historic api too as my solution uses it).

    My problem :

    I am able to download 50 days data using INTERVAL_DAY and avg is coming perfect! Now using the same date period I am downloading data INTERVAL_5MINUTES and doing avg (dividing by 3750 i.e. 50 days 5 minute data) and now the avg comes far from the what it should be (as per zerodha kite platform). What could be the issue?
    First of all 5 minutes data should be coming (6.10 hrs * 50 days * 60 minutes ) / 5 = 3660 candles should come. Instead I am getting 1 day extra data i.e. total 3750 (please note that the same date period gives 50 candle data on daily basis ).

    Also is this logic correct to get 50 days 5 minute moving avg? this is where I am getting bad results.

    for (int count = 0; count < historical.Count; count++)
    closePrice += (double)historical[count].Close;
    double 50DMA= closePrice / historical.Count;

    (same code works for 50 DMA when interval is one day but not with 5 minutes data.

    Regards
  • rakeshr
    @chandrak
    Now using the same date period I am downloading data INTERVAL_5MINUTES and doing avg (dividing by 3750 i.e. 50 days 5 minute data) and now the avg comes far from the what it should be (as per zerodha kite platform). What could be the issue?
    It's might be because of the difference in the calculation formula on kite web chart and your's calculation.
    First of all 5 minutes data should be coming (6.10 hrs * 50 days * 60 minutes ) / 5 = 3660 candles should come. Instead I am getting 1 day extra data i.e. total 3750 (please note that the same date period gives 50 candle data on daily basis ).
    Total trading minutes in a day = 6hrs and 15minutes(you need to include last 5 minute candle as well) = 6.25 (not 6.10)
    So,(6.25*50*60)/5 = 3750
  • chandrak
    Yes sujith.. 3750 is correct. bbut then dividing total of closing prices by 3750 is not giving proper answer. Also I found an issue where if we ask for 50 day data using time dateXXX 23:59:59 and dateYYY 23:59:59, all ok for interval_day but for 5 mins interval we need to give dateXXX 9:15:00 to dateYYY 9:25:000 than only we are getting 3750 items for 50 days. But anyways..

    Stock : INFY

    From Date : 03-04-2019 09:15:00
    To Date : 18-06-2019 15:25:00

    total records coming 3750. Which is perfect
    now if I calculate average by..

    total of closing prices / total of count (here 3750)

    I am getting 733.14

    while 5 minute of 50 DMA is 749.40

    :'(

    Please help..
  • rakeshr
    rakeshr edited June 2019
    @chandrak
    Also I found an issue where if we ask for 50 day data using time dateXXX 23:59:59 and dateYYY 23:59:59, all ok for interval_day but for 5 mins interval we need to give dateXXX 9:15:00 to dateYYY 9:25:000 than only we are getting 3750 items for 50 days.
    Instead of dateXXX 23:59:59 as from_date, you need to give dateXXX 00:00:00 eg: from_date='2018-03-05 00:00:00', to_date='2018-05-27 23:59:59' or from_date='2018-03-05', to_date='2018-05-27'
    total of closing prices / total of count (here 3750) but I am getting 733.
    I am afraid, we can't assist you on writing the strategy,it's outside the scope of Kite Connect.
  • chandrak
    you can close this discussion. Thanks
This discussion has been closed.