Historical Exact date and time data for backtesting

rahuljain
Hello,

How can I get exact historical data of exact date and time for any backtesting strategy? Whenever i try to backtest, Date i am able to select , but time it always starts at 9:15
  • MAG
    The market opens for trade at 9:15. And the tradeable candles are from 9:15(:00) to 15:29(:59).
    So what is the query again?
  • rahuljain
    So if I want data of any time like 09:48:30 AM , i can get the data of this exact time with price and all other details?
  • rahuljain
    @MAG So if I want data of any time like 09:48:30 AM , i can get the data of this exact time with price and all other details?
  • MAG
    Your comments seem to indicate you are confused about historical api and what it offers.

    In historical data the smallest unit of time is minute. So your query is invalid as there is no data for 09:48:30.
    You will get either one minute OHLCV candle data for 9:48 or 9:49.

    And this "with price and all other details" comment is ambigious. You will get OHLC data with volume. Thats it.
    If by "other details" you mean market depth etc, thats not available in historical api.

    If you want lower granularity than one minute, the only possible way is to get live tickdata via the websocket api and then save and process this data to get any timeframe you want down to second level. And if your websocket subscription mode is set to full, you will get the market depth and other information fields as specified in the kite ticker documentation.

    All this is in the documentaion - all you need to do is RTFM.
  • rahuljain
    @MAG oh okay , sorry I guess my question was not direct .

    although got the partial answer.

    Like in historical data , minute wise.. can we also scan like pricing ?
    Like I am planning a buy and sell, where buy is at specific time let say 10:17AM , but sell I set as 5% profit from Buy price..? Like i need to check for the backtest results so
  • MAG
    MAG edited November 2023
    Your query is still pretty vague and unclear. What is "can we also scan like pricing".

    I am assuming you mean you want to know when the price hits your 5% target between 10:17:00 and 10:17:59.
    You cant do that from historical data.
    Unless you store the tick data and backtest on tick data what you want is not possible.

    You could do a backtest where the signal indicates a buy signal for some stock for 100 rupees at 10:17.
    The historical data candle might show something like
    T: 10:17 O:100 H:110 L:90 C:102 V:10K
    And lets assume your target is 105 and stoploss is 95.

    This will tell you that the high was above your target of 5% but your L was also below your stoploss of say 5%. Now there are two possibilities.
    1. It went low below 95 first, you got stopped out and ended up with a loss and then it bounced and went up to 110.
    2. It went high first to 100, hit target and booked profit and then went low below 95.

    There is no way to determine whether 1 or 2 happened.
    Another reason why backtest on OHLC data is not a very reliable method of testing strategies.

    Now I am assuming stuff. If you cant articulate your query properly, no one will be able to help you properly.
Sign In or Register to comment.