Test investment strategies with Dow Jones data in C#


[investment strategies]

Important Note: I am not a tax or investment professional so you need use your own judgement when evaluating these investment strategies. I don’t even pretend to understand this stuff. This is a very simple tool for playing with numbers that doesn’t even compound continuously, and I don’t vouch for its correctness. It should in no way be taken for investment advice. What, are you crazy???

That said…

This example explores different investment strategies and test them on historical Dow Jones Industrial Average data. For each strategy, it assumes that you start with $4,000 and then follows the strategy for moving the money into the stock market. It uses the historical Dow Jones data to model your stock portfolio’s performance. It also assumes that you get a small amount of interest (1% in this example) on any money not yet invested. You can tweak this and other values in the code to study other effects.)

The strategies examined here are:

  • All In (257.88%) – All $4,000 goes into the market at the beginning. This strategy follows the market exactly.
  • 5% interest (165.33%) – All $4,000 goes into CDs or some other interest-bearing account and stays there earning 5% annually. This is the gray stair-stepped curve. This strategy generally underperforms the other investment strategies. In the picture shown above, it sometimes beats a few strategies (and briefly beats all of them in 2009) due to the chaotic ups and downs during the time period shown here. If you use data that extends farther into the past, every other strategy beats this one.
  • $100 per period (247.88%) – Every investment period (each weekday in this example), you move $100 into the market. This is a popular strategy with personal finance managers. The idea is that you don’t dump everything in at the start so you don’t get penalized if the market moves down right after you enter the market. Conversely you don’t reap the benefits if the market jumps right after you enter. The idea is to even out the bumps. Try experimenting with the amount you move in during each period. If you use a small value like $1, the money moves in too slowly so you don’t get the full benefit of being in the market over a long time. If you move too quickly, the method doesn’t even out the bumps so, for this example data, you get hit a bit in the beginning.
  • $100 per 3 down periods (198.97%) – You move $100 into the market if the market is down 3 times in a row. The idea is that if the market is down, you should put more money in so you get the benefit when it recovers.
  • $10 when down by 0.1% (145.93%) – You move $10 if the market drops 0.1% in one period. The idea is that if the market is down, you should put more money in so you get the benefit when it recovers. Larger values for the percentage don’t occur very often so you don’t get the money in fast enough.
  • $100 when down by $10 (238.00%) – You move $100 into the market if the market is down by $10 in one period. Again the idea is that if the market is down, you should put more money in so you get the benefit when it recovers. Large values for the amount that the market should be down don’t let you move money in too often so you don’t get the money in fast enough. Very small values (i.e. you move money whenever the market is down) work fairly well.
  • $100 per 3 up periods (226.17%) – You move $100 into the market if the market is up 3 periods in a row. The idea is that the upward trend will hopefully continue and you want to ride the wave.
  • $100 if increase > 1% (210.82%) – This is a “perfect guess” strategy where you know ahead of time what the market will do. If the market will be up by more than the base interest rate (1% in this example), you move $100 into the market. This provides a reasonable upper bound for performance, although if you were really omniscient and could buy and sell without paying commissions you could do even better by moving all of the money in and out of the market at will.

The results of all of these investment strategies are fairly similar. In particular, investing a fixed amount per period as favored by personal finance managers works pretty well. Who would have thought?

Several of the investment strategies even beat the “perfect guess” strategy. The reason is (I think) because that strategy doesn’t move the money in quickly enough. For example, if you have three periods in a row where the market is up by 0.9%, the strategy doesn’t move any money into the market even though it probably should.

Keep in mind that this example is just for playing with the numbers. Many of these investment strategies are sensitive to the particular behavior of the market so the results may vary widely depending on what the market is doing when you run the simulation. If you change the dates used for the historical data, or if you change the parameters (such as interest rate, amount to move into the market, and movement threshold values), you may get very different results.

The only conclusions that really seem to make sense are:

  • Staying out of the market and only collecting interest is a losing strategy in the long run. Unless you can guess extremely well what the market will do, you’ll earn more in the market.
  • Some people panic and get out of the market right after a big drop. This is a HUGE mistake. Even with the big drops around 2003 and 2009, the market recovered its lost value within the next two to four years. Unless you need the money immediately for something really important, you’re better off waiting a bit before you get out.
  • Strategies such as “it’s been up 3 days in a row so it must continue up” and “it’s been down 3 days in a row so it must go back up” don’t really work very well. Unless you can guess specific ups and downs, those investment strategies are too simplistic.

For information about how the program loads the data and displays the graphs, see the earlier post Graph historical Dow Jones Industrial Average values in C#.


Download Example   Follow me on Twitter   RSS feed   Donate




This entry was posted in algorithms, finance, graphics, mathematics and tagged , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *