unable to backtest a strategy on historical data

sreeni_28
hi,i have bought historical data on which i am trying to implement backtest on 1minute interval. i am not able to get buy or sell orders.but when the market is live the strategy automatically executing trades...pl help me on this regard...


thank u
  • rahulchitale
    @sreeni_28 Assume you mean historical data sourced from Candles API here. Historical data contains the last trade price (usually) expressed in terms of OHLC. What do you mean here by 'not able to get buy or sell orders' ?
  • sreeni_28
    THE code is running successfully but it shows gross profit '0'.no buy/sell orders.and it is directly buying live instead of bactesting....
  • sujith
    Hi @sreeni_28,
    We don't have sandbox environment for now. We are working on it.
    For pnl being 0, I would suggest you to check your code.
  • sujith
    For backtesting as of now, I would suggest you do it after market hours. Just make sure not to place AMO
  • sreeni_28
    @sujith I am performing the strategy after market hours only.. still not able to get trades.i have replicated a MACD strategy shown by one of your developers in a webinar on kite. trade .in that the transaction_type = transaction_type ; when i executed the code it says "InputException: Required parameter 'transaction_type' is missing"...but the same got worked in the webinar...pl help me on this regard..
  • sujith
    @sreeni_28 you cannot see any trades after market hours as order is not executed. You can only see order which will be rejected in orderbook.
    Transaction type can be either "BUY" or "SELL".
  • sreeni_28
    @sujith ,I want to backtest on historical data produce trades see whats the gross profit/loss of a particular stock. ..what does it got to do with live market data?... i earlier worked on tradestation and multicharts platforms using csv files of historical data... Is such facility not available on kite.trade apps... pl, help me on this regard
  • nithin
    Hopefully I am getting your query right,

    You will never be able to backtest live trades completely using historical data. Also your code to backtest vs live trading has to be different. Let me tell you why,

    During live markets, you get a tick every second with a LTP (last traded price) to it. I am guessing your strategy is firing orders based on this LTP.

    Historical data comes only as OHLCV (Open high low close volume) for a particular minute. You don't have a LTP. To backtest, you will have to use either of OHLC to trigger your strategy buy/sell. Most people would be using the close of candle price.

    So if your strategy is to buy above a moving average price. To backtest, you will have to track when either OHLC crosses the moving average upwards. Capture this price of either O, H, L, C. Use all such entry and exit to calculate the profitability of the strategy.
Sign In or Register to comment.