Historical data api problem

kanvi915
Hello Team,

Historical data api is not working properly.

Operation time out happens every time. can you please ch
eck out and provide me a proper solution.

Consider the following screenshot

Here is the used code.

public static List Get_1_Day_HistoricalCandle_ByDate(DateTime FromDate, DateTime ToDate, string instrumentToken)
{
List historical = kite.GetHistoricalData(
InstrumentToken: instrumentToken,
FromDate: new DateTime(FromDate.Date.Year, FromDate.Date.Month, FromDate.Date.Day),
ToDate: new DateTime(ToDate.Date.Year, ToDate.Date.Month, ToDate.Date.Day),
Interval: Constants.INTERVAL_DAY,
Continuous: false
);
return historical;
}


Thanks.
  • sujith
    Can you share the debug logs here?
    Make sure to remove the app and user specific tokens.
  • kanvi915
    here is the debug logs

    Exception thrown: 'System.Net.WebException' in KiteConnect.dll
    Exception thrown: 'System.Net.WebException' in KiteConnect.dll
    The thread 0x1f90 has exited with code 0 (0x0).
    Exception thrown: 'System.Net.WebException' in KiteConnect.dll
  • sujith
    Can you create a Kite Connect object with debug logs flag true and paste the complete stack trace here?
  • kanvi915
    kanvi915 edited November 2020
    DEBUG: GET https://api.kite.trade/instruments/historical/6401/5minute?from=2016-12-30+09:15:00&to=2016-12-30+15:30:00&continuous=0
    DEBUG: User-Agent: KiteConnect.Net/1.0.0.0
    DEBUG: X-Kite-Version: 3
    DEBUG: Authorization: token avk4op5fui5ft6uh:ytTVGcG1mPYKK7unaFAuFlJ22c9PRamY
    DEBUG: 200 {"status": "success", "data": { "candles":[["2016-12-30T09:15:00+0530",73.4,73.5,73.1,73.25,54262],["2016-12-30T09:20:00+0530",73.25,73.4,73.1,73.1,19281],["2016-12-30T09:25:00+0530",73.1,73.25,73,73.05,32064],["2016-12-30T09:30:00+0530",73.05,73.1,72.65,72.7,41961],["2016-12-30T09:35:00+0530",72.65,73.1,72.65,72.75,44247],["2016-12-30T09:40:00+0530",72.85,73.3,72.75,73.05,62009],["2016-12-30T09:45:00+0530",73.05,73.25,73,73.2,17847],["2016-12-30T09:50:00+0530",73.2,73.9,73.2,73.7,110778],["2016-12-30T09:55:00+0530",73.8,74,73.65,73.95,44122],["2016-12-30T10:00:00+0530",73.95,75,73.95,74.7,239811],["2016-12-30T10:05:00+0530",74.65,75.15,74.3,74.9,214488],["2016-12-30T10:10:00+0530",74.9,75.75,74.85,75.45,299239],["2016-12-30T10:15:00+0530",75.45,75.5,75.1,75.25,47030],["2016-12-30T10:20:00+0530",75.15,75.2,74.9,75.05,32813],["2016-12-30T10:25:00+0530",75.05,75.2,74.9,75.15,43311],["2016-12-30T10:30:00+0530",75.15,75.7,75.05,75.2,93757],["2016-12-30T10:35:00+0530",75.2,75.25,75.1,75.25,21561],["2016-12-30T10:40:00+0530",75.25,75.4,75.15,75.3,20837],["2016-12-30T10:45:00+0530",75.3,75.35,74.85,75.05,43824],["2016-12-30T10:50:00+0530",75.1,75.25,75.05,75.15,22638],["2016-12-30T10:55:00+0530",75.15,75.25,75,75.15,30217],["2016-12-30T11:00:00+0530",75.15,75.25,75.05,75.15,18006],["2016-12-30T11:05:00+0530",75.15,75.25,75,75.15,21886],["2016-12-30T11:10:00+0530",75.15,75.2,75,75,17047],["2016-12-30T11:15:00+0530",74.85,75.15,74.75,75,117401],["2016-12-30T11:20:00+0530",75,75.15,74.95,75,18432],["2016-12-30T11:25:00+0530",75,75.35,75,75.35,40174],["2016-12-30T11:30:00+0530",75.35,75.6,75.35,75.4,73056],["2016-12-30T11:35:00+0530",75.4,75.5,75.3,75.5,16341],["2016-12-30T11:40:00+0530",75.5,75.5,75.35,75.4,17547],["2016-12-30T11:45:00+0530",75.4,75.55,75.25,75.25,28434],["2016-12-30T11:50:00+0530",75.25,75.95,75.25,75.8,157457],["2016-12-30T11:55:00+0530",75.8,76.3,75.5,76.15,177944],["2016-12-30T12:00:00+0530",76.2,76.7,75.9,76.2,526510],["2016-12-30T12:05:00+0530",76.2,76.25,76.05,76.05,56976],["2016-12-30T12:10:00+0530",76.15,76.2,76.05,76.15,34192],["2016-12-30T12:15:00+0530",76.15,76.3,76.05,76.25,33655],["2016-12-30T12:20:00+0530",76.25,76.3,76,76,43383],["2016-12-30T12:25:00+0530",76,76.05,75.9,75.95,35904],["2016-12-30T12:30:00+0530",75.95,76.15,75.95,76,47482],["2016-12-30T12:35:00+0530",76,76.4,75.9,76.25,35290],["2016-12-30T12:40:00+0530",76.25,76.35,76.15,76.35,21901],["2016-12-30T12:45:00+0530",76.35,76.35,76.1,76.25,21805],["2016-12-30T12:50:00+0530",76.25,76.3,76.05,76.1,36817],["2016-12-30T12:55:00+0530",76.05,76.15,75.9,75.9,43550],["2016-12-30T13:00:00+0530",75.9,76,75.9,75.9,15410],["2016-12-30T13:05:00+0530",75.9,76,75.7,75.9,50786],["2016-12-30T13:10:00+0530",75.9,76.05,75.85,75.95,8104],["2016-12-30T13:15:00+0530",75.95,76.1,75.95,76,18094],["2016-12-30T13:20:00+0530",76,76.05,75.95,76,33257],["2016-12-30T13:25:00+0530",76,76.15,75.7,75.75,34472],["2016-12-30T13:30:00+0530",75.75,75.9,75.7,75.85,23848],["2016-12-30T13:35:00+0530",75.85,76,75.85,75.95,21202],["2016-12-30T13:40:00+0530",75.95,76,75.9,75.95,11016],["2016-12-30T13:45:00+0530",75.95,76.25,75.95,76,37316],["2016-12-30T13:50:00+0530",76,76.1,76,76.05,7240],["2016-12-30T13:55:00+0530",76.05,76.2,76.05,76.15,11763],["2016-12-30T14:00:00+0530",76.15,76.25,76.05,76.1,35834],["2016-12-30T14:05:00+0530",76.2,76.2,76.1,76.15,7389],["2016-12-30T14:10:00+0530",76.15,76.2,76,76.1,15761],["2016-12-30T14:15:00+0530",76.1,76.15,75.9,75.9,14115],["2016-12-30T14:20:00+0530",75.7,75.95,75.4,75.6,128341],["2016-12-30T14:25:00+0530",75.6,75.8,75.45,75.75,79598],["2016-12-30T14:30:00+0530",75.75,76.1,75.7,76,44252],["2016-12-30T14:35:00+0530",76,76.85,75.95,76.85,161188],["2016-12-30T14:40:00+0530",76.8,77.15,76.6,76.65,275248],["2016-12-30T14:45:00+0530",76.65,76.85,76.55,76.6,103641],["2016-12-30T14:50:00+0530",76.6,76.8,76.3,76.65,68007],["2016-12-30T14:55:00+0530",76.55,76.6,76.3,76.3,52108],["2016-12-30T15:00:00+0530",76.3,76.45,76.1,76.25,53080],["2016-12-30T15:05:00+0530",76.25,76.8,76.25,76.75,77429],["2016-12-30T15:10:00+0530",76.75,76.75,76.35,76.4,96549],["2016-12-30T15:15:00+0530",76.5,76.65,76.4,76.55,102977],["2016-12-30T15:20:00+0530",76.55,76.6,76.35,76.5,114533],["2016-12-30T15:25:00+0530",76.55,76.9,76.55,76.75,180629]]}}

    DEBUG: GET https://api.kite.trade/instruments/historical/6401/day?from=2017-01-01+00:00:00&to=2017-12-31+00:00:00&continuous=0
    DEBUG: User-Agent: KiteConnect.Net/1.0.0.0
    DEBUG: X-Kite-Version: 3
    DEBUG: Authorization: token avk4op5fui5ft6uh:ytTVGcG1mPYKK7unaFAuFlJ22c9PRamY
    Exception thrown: 'System.Net.WebException' in KiteConnect.dll
  • kanvi915
    kanvi915 edited November 2020
    DEBUG: GET https://api.kite.trade/instruments/historical/6401/day?from=2017-01-01+00:00:00&to=2017-12-31+00:00:00&continuous=0
    DEBUG: User-Agent: KiteConnect.Net/1.0.0.0
    DEBUG: X-Kite-Version: 3
    DEBUG: Authorization: token avk4op5fui5ft6uh:ytTVGcG1mPYKK7unaFAuFlJ22c9PRamY
    Exception thrown: 'System.Net.WebException' in KiteConnect.dll
    The thread 0x1f1c has exited with code 0 (0x0).
    The thread 0x192c has exited with code 0 (0x0).
    DEBUG: GET https://api.kite.trade/instruments/historical/6401/day?from=2017-01-01+00:00:00&to=2017-12-31+00:00:00&continuous=0
    DEBUG: User-Agent: KiteConnect.Net/1.0.0.0
    DEBUG: X-Kite-Version: 3
    DEBUG: Authorization: token avk4op5fui5ft6uh:ytTVGcG1mPYKK7unaFAuFlJ22c9PRamY
    Exception thrown: 'System.Net.WebException' in KiteConnect.dll
    DEBUG: GET https://api.kite.trade/instruments/historical/6401/day?from=2017-01-01+00:00:00&to=2017-12-31+00:00:00&continuous=0
    DEBUG: User-Agent: KiteConnect.Net/1.0.0.0
    DEBUG: X-Kite-Version: 3
    DEBUG: Authorization: token avk4op5fui5ft6uh:ytTVGcG1mPYKK7unaFAuFlJ22c9PRamY
    Exception thrown: 'System.Net.WebException' in KiteConnect.dll
    DEBUG: GET https://api.kite.trade/instruments/historical/6401/day?from=2017-01-01+00:00:00&to=2017-12-31+00:00:00&continuous=0
    DEBUG: User-Agent: KiteConnect.Net/1.0.0.0
    DEBUG: X-Kite-Version: 3
    DEBUG: Authorization: token avk4op5fui5ft6uh:ytTVGcG1mPYKK7unaFAuFlJ22c9PRamY
    Exception thrown: 'System.Net.WebException' in KiteConnect.dll
  • rakeshr
    @kanvi915
    You seem to be using the old version. You need to update your .Net client using Nuget or dll from github releases. If still facing exception, you need to catch exception and let us us the error message and status code.
  • kanvi915
    i think this is from your side a server time out error.
  • kanvi915
    and i think you have added some new features in the old dll but the old must be working properly .
  • sujith
    @kanvi915,
    Make sure to remove the app and client-specific tokens while posting on public threads.
  • kanvi915
    oops. how to remove those things now ?
  • kanvi915
    if you are able than please remove because it is by mistake posted some creds.
  • sujith
    We have edited it.
  • kanvi915
    thanks sujith but i think this is not dll old version problem. i placed 10 request 5 times it provides me data and 5 times it happens operation time out. so i there any operation time limit in historical data some thing like that?
  • sujith
    You can check out the historical data section in the FAQs thread.
  • sujith
    You can also refer to the rate limits mentioned here.
  • kanvi915
    hello team i have used new dll but still the same problem remains
  • kanvi915
    DEBUG: Content-Type: application/x-www-form-urlencoded
    DEBUG: User-Agent: KiteConnect.Net/3.0.7.0
    DEBUG: X-Kite-Version: 3
    DEBUG: Authorization: token ****
    Exception thrown: 'System.Net.WebException' in System.dll
    The operation has timed out
    The thread 0x226c has exited with code 0 (0x0).
  • kanvi915
    i really cant understand what is going on.
  • kanvi915
    should i regenerate the old api key to new api key is there a problem like this ?
  • kanvi915
    it is providing me data and verification but not consistence. when i try 10times it gives me access for 1 time rest of the 9 times it providing me time out error.
  • sujith
    @kanvi915,
    If you are fetching data continuously then add some delay and check.
    If you are getting too many timeouts after adding delays then try on some other network.
  • kanvi915
    it is not like that when i m trying to verify access token operation time out occurs. so i think some crucial issue is there because to verify access token we need not to call it again and again.

    and i have already changed the internet service provider but still the same issue remains.
  • sujith
    One doesn't need to verify if the access token is valid or not for every call, it is valid for one whole day. You just need to re-generate the session only when the server throws 403.
  • tonystark
    @kanvi915 "The operation has timed out" is a client side error. This can happen due to multiple reasons. First of all it can be a network issue. Kite APIs usually respond in milliseconds. If it is timing out, that means the request has been stalled for seconds. Try using Kite in your browser and see if that is slower than usual.

    If it is fine in your browser then the issue is present in your code. Make sure your application is not issuing many requests back to back. This will result in your application becoming unresponsive and unavailable to process the response or will get rate limited by our firewalls. The solution is to avoid such polling mechanisms to fetch data and use the websocket/postback mechanisms to trigger fetching calls.

    If your application is doing a lot of processing on the data or does processing on lot of data(orders, positions etc.) then it is likely that your application is unable to keep up. To solve this you can either offload Kite API calls to a different thread or optimise your application using async operations.
  • kanvi915
    i m waking up morning. going to my office. the very first time opening my computer. open my software and the very first time trying to verify access token. very first time i m telling you. the only first request of the whole day from my pc. and i m not using any another pc to use zerodha connection. do you under stand the meaning of very first time call. the first call of all the day. and it is giving me time out. i used different networks. my internet speed is 50mbps. not tell me where i m hitting the multiple calls?

    i appreciate your point of view guys but i m facing this issue at my very first call. multiple calls are the secondary things. i hope you under stand the meaning of very first time call to the server.
  • kanvi915
    and if it is client side code error than it must not give me result of any calls. it gives me results from server some times and most of the time server time out error. I hope I can worth the 4000 rs every month by purchasing your api.
  • kanvi915
    problem is not only for the historical data even i m suffering to verify access toke at very first time. the fresh first call from my code.
  • sujith
    @kanvi915,
    There are more than 600 production Kite Connect apps running and it includes our in-house applications and client-facing applications which are used by more than 4 lakh clients at any point in time. Everything is working without any issues, if there were so many timeouts then not only this forum will be full of chaos but also we will be trending on Twitter.

    Everyone is trying to help you out, we are not support guys here, we are all developers like you who work on their projects and take some time out to help out fellow Kite Connect community members. The error logs you provided has no context, it just says timeout. If the timeout is thrown from Kite Connect then it would be in this format. How do you expect us to help you out without complete information? There is no point losing patience, we are all helping you out to figure out the issue. Kite Connect is not a ready-made product to provide support, if you are writing scripts then you need to spend time on debugging, no one else will do it. If you are out of time then outsource it to someone who can do it for you, there are a lot of freelancers on the forum who would be happy to help you out.
Sign In or Register to comment.