Accurate Historical Testing for Stocks

An important part of systematic trading is the ability to see how a trading method performs under real historical market conditions. Trading Blox allows the user to do this, giving an accurate picture of how a strategy under consideration would have performed in different market environments. In order to produce “what-you-see-is-what-you-would-have-gotten” results when testing stocks, there are a couple of subtleties that must be taken into account. First, stocks sometimes split or reverse split, with price level and share amounts held changing drastically from one session to the next without the shareholder buying or selling anything. Secondly, stocks often pay dividends, where occasionally price decreases by some amount which is paid to shareholders in cash per share owned. Without accounting for dividends and splits it is not possible to accurately simulate the historical profit and loss of holding a stock position.

Fortunately, Trading Blox does account for dividends and splits and thus can accurately replicate the results of holding a stock or portfolio of stocks even if many stocks split and issue dividends. Here is what is needed to do this:

  1. Data that is adjusted for splits proportionally. That is, when a stock splits two-for-one (with price halving and shareholders recieving an additional share for each share owned) we want to see every price in the stock’s history halved. If the same stock splits again, all prices are halved again. As this process occurs, all prices are preserved with lots of decimal places (8) for full precision when prices are converted back to unadjusted levels.
  2. Data that includes the unadjusted close as a field. The unadjusted close is just what it sounds like: the actual closing price on each day, unadjusted for any splits.
  3. A separate file for each market that contains per share dividend distributions and the dates they occured. If the dividend file reports 10 cents on 08/20/2013, that means that a dividend of 10 cents per share was issued on that date.

With this data, Trading Blox is able to account for splits and dividends just as they happen in actual brokerage accounts. If a trader takes a position, the stock splits, and then a dividend occurs, there will be one profit or loss. However, if the dividend occurs before the split, the PnL will be different. Trading Blox is able to get this correct.

Not every data vendor provides the data to do this, but fortunately our recommended end-of-day data provider, CSI (www.csidata.com), does. Here is how you set Trading Blox up to expect data in the format explained above and direct the software to account for splits and dividends appropriately.

First, you ensure that the stock price and dividend data are available in the appropriate locations. In Data Folders and Options Preferences, you can let Trading Blox know the folder location of stock data files and dividend files. Note the “Build Dividends” button. It can be used to update the dividend files from a CSI Unfair Advantage installation.

Data and Divs prefs

Next, you set the Global Parameter Earn Dividends to “true”. Sometimes a stock split results in a fractional share amount, and we also set Sell Stock Split Remainder to “true” so that the remainder is liquidated to cash.

GP stock split and div

That’s it. Trading Blox now has all the information it needs to accurately test stocks regardless of the number of dividends and splits that have occured in the portfolio. See the Trading Blox User Guide (http://www.tradingblox.com/tblox/?page_id=252) for details on the method Blox uses to accurately represent split-adjusted PnLs.