Handling splits in intraday backtesting

Discussion in 'Automated Trading' started by jabowery, Nov 25, 2019.

  1. jabowery

    jabowery

    I recently ran into an intraday backtest showing ridiculously high profits that turned out to be due to a reverse split causing a jump in the price.

    How is this kind of error usually avoided in backtesting? Must the datafeed provide an out-of-band feed with all of the historic splits? Is there a standard database providing all of these events somewhere one can incorporate into one's backtesting algorithm?
     
  2. trend2009

    trend2009

    i just kick out price jumps comparing today's open price vs yesterday close price, say at least 25% difference.
     
  3. fan27

    fan27

    Who is your data provider? Whatever the case, splits need to be accounted for, either from your data source provider of by you, the backtester. What platform are you backtesting in?
     
  4. jabowery

    jabowery

    AlgoTerminal backtesting platform with DTN's IQFeed which adjusts their day-aggregation but not their minute aggregation or tick events (at least that's as I understand it). Since IQFeed provides the last 2 split events per stock in their Fundamentals feed, I can incorporate that into my AlgoTerminal code. In the interim, I simply close out all my positions at the end of the day, which prevents them from being fulfilled on a limit or stop loss at an out-of-whack price/quantity upon resumption of trading at the start of the next session after a split.
     
  5. fan27

    fan27

    That is news to me but then again I am not actively trading stocks. Can you give me an example of a stock where the split is not accounted for in the IQ Feed minute data.
     
  6. Metamega

    Metamega

    They all are. I remember the same when I had IQFeed hooked up to Amibroker. I use to just adjust the data using Amibrokers tools based of EOD prices. Amibroker also had tools to detect splits/recommend possible splits. Wasn't the easiest process.

    Googling and looking at IQFeed's forums, they seemed to say that the majority of their users wanted the raw data as is. It'd be fine if there was a way to call all the split data but then most data plugins for trading software usually lack any features for IQFeed fundamental data requests.

    I always figured it was a bad idea if you had an automated algo that didn't realize a split was coming up. All of a sudden your seeing a 50% move on a 2:1 split which could throw your logic way off. You'd almost have to stay on top of the news for upcoming splits or somehow logic in your algo to compare daily data to intraday data. But then the other issue is does your software request updated backfill past last received data or just fill in from left off. I know with Amibroker, their data plugin just updated from your last data point, which makes perfect sense since requesting a bunch of historic data you already have over and over is a huge waste of resources.

    I always thought it was a weird way to tackle intraday data but their are nuances to both ways.

    Even their EOD data they didn't adjust volume for splits. Yahoo for instance if theirs a 2:1 split in price, they adjust the volume so you can still use a dollar/volume metric for perhaps calculating liquidity filter.

    Just part of the game I guess, data can be a nightmare to go through. Glad I don't touch futures, that's another ball game of what type of backadjusting/sewing contracts together.
     
    Ninja likes this.
  7. jabowery

    jabowery

    It's more a combination of the way AlgoTerminal simulates order fulfillment and the way IQFeed presents data to AlgoTerminal:

    I place a market-buy order with limit and stop loss figures. EOD hits in the data feed without the limit or stop loss triggering a sell. A split occurs over night. The next day, AlgoTerminal's backtesting simulator detects a sell condition and sells. Illusory gain or loss results.
     
  8. fan27

    fan27

    Gotcha...but what about doing a fresh import of data into AlgoTerminal via IQFeed? Can you see the split in the minute data as it exists in the database?
     
  9. jabowery

    jabowery

    What do you mean "see the split"?
     
  10. WealthSignals

    WealthSignals Sponsor

    It depends. Some data feeds just don't throw split/dividend information in their intraday data (but provide it in EOD data). Having an external feed can surely help. -Eugene
     
    #10     Nov 26, 2019