The Stock Market: Beautiful One Day, Perfect The Next

This planet has – or rather had – a problem, which was this: most of the people living on it were unhappy for pretty much most of the time.  Many solutions were suggested for this problem, but most of these were largely concerned with the movements of small green pieces of paper, which is odd because on the whole it wasn’t the small green pieces of paper that were unhappy. – The Hitchhikers Guide to the Galaxy

By all reports we’re at the edge of a precipice, staring forebodingly down into a pit of total economic ruin.  Banks are falling (or frozen with fear), credit has dried up and the world’s financial markets lurch up and down wildly from one day the next.  It will be interesting to look back on this post in a year and reflect on how it all turned out.  Or maybe by then there will be no blogs for humanity to turn to… we’ll have abandoned civilisation and returned to the trees.  In fact you could argue that the The Hitchhiker’s Guide to the Galaxy had it right: even moving to the trees was a mistake.  We should never have left the oceans.

Regardless, money troubles are weighing on our minds at present.  So let’s take a break and have a light hearted look at the Stock Market from a statistical point of view.  The question I’ll pose is: based on historical data what would an optimal investment strategy be? Of course far better brains than mine have trained their thoughts on this topic before.  I won’t be breaking any new economic theory.  But the analysis below is simple and fun.  Importantly, I must stress that it is NOT financial advice (which I am not qualified to give).  It is for academic interest only.

But first we need some data.

The Wren Investment Advisors website has made long term time series data on various financial market indicators available for download.  Among those is the monthly average Australian Stock Exchange All Ordinaries Index (AORD) commencing from January 1875.  The history of the AORD over the last 133 years looks a little bit like this (plotted on a log scale):

ASX All Ordinaries, Monthly Averages, 1875 to 2008

ASX All Ords Monthly Avg Jan 1875 to Jul 2008

Between February 1875 and July 2008 there were 1,602 months, of which 930, or 58.1%, recorded an increase over the preceding month.  (I had to leave January 1875 out as I don’t know if it was up, down or sideways compared to December 1874).  So you could argue that it doesn’t matter when you invest.  You have better than even odds that the next month will be better.  Of more interest, perhaps, is when we look at a month’s average AORD index to its preceding month, and then the preceding month’s index compared to the month that came before that.  If we define:

Event A: Monthly average AORD index moved higher over the preceding month (e.g. December 2005 was higher than November 2005).

Event B: Preceding monthly average AORD index moved higher over the month that came before that (e.g. November 2005 was higher than October 2005).

Similarly A’=Not A (went down or sideways) and B’=Not B.

The possible outcomes can be expressed as a 3×3 contingency table:

month n UP month n DOWN total
month (n-1) UP A∩B A’∩B B
month (n-1) DOWN A∩B’ A’∩B’ B’
A A’ Σ

For example the monthly average AORD index for December 2005 was higher than November 2005 which in turn was higher than October 2005.  This is an Event A∩B (A “intersection” B).  I counted 602 of these events in the 1,601 months between March 1875 (this time a minimum of three months of data is needed to start) and July 2008.  Similarly, November 2007 was lower than October 2007 but which was higher than September 2007.  This is an Event A’∩B.  I counted 328 of these events.

If I got everything right then the completed contingency table of counts looks like this:

month n UP month n DOWN total
month (n-1) UP 602 328 930
month (n-1) DOWN 328 343 671
930 671 1,601

Or, in terms of frequencies:

month n UP month n DOWN total
month (n-1) UP 0.376 0.205 0.581
month (n-1) DOWN 0.205 0.214 0.419
0.581 0.419 1.000

Which leads back to the original question: based on historical data what would an optimal investment strategy be?  One possible strategy would be to base our investment decision on the market’s average performance last month.  Looking at the available data, the chances that the stock market (as measured by the monthly average AORD index) will be up this month, GIVEN that it was up last month, is derived using the law of conditional probability:

P(stock market moves up this month, given that it moved up last month)

= P(A|B) = P(A∩B) / P(B) = 0.376 / 0.581

= 0.647 (i.e. just under 65%)

Interesting.  It seems the stock market is a bit like the weather.  A sunny day today means a high likelihood of a sunny day tomorrow.  Beautiful one day, perfect the next.

Going back to the remaining conditional probabilities:

P(A’|B) = 0.205/0.581 = 0.353 (down next month, given up this month)

P(A|B’) = 0.205/0.419 = 0.489 (up next month, given down this month)

P(A’|B’) = 0.214/0.419 = 0.511 (down next month, given down this month)

One optimal investment strategy therefore appears to be to put your money into the market only if the last month was up.  If the prior month was down then keep/take your money out.  Lather.  Rinse.  Repeat.  In theory this strategy should work about 65% of the time.  If, on the other hand, you put your money into the market when the previous month was down (or sideways) you’ll have just 49% chance of making a profit.

Of course things are a lot more complicated in the real world.  For a start, history is no guarantee of future performance.  Also, the success of this strategy assumes that you don’t have to pay any brokerage fees.  And I didn’t consider magnitude of movements in this analysis, only direction.  One fall of 50% is clearly going to wipe out 5 gains of 1%, for example.

But I think an interesting result nonetheless.  Did I get my analysis right?  You can download my raw calculations here.

Please feel free to send me feedback.  I hope to expand on this theme further in future blog entries.




5 Responses

  1. Nice writing. You are on my RSS reader now so I can read more from you down the road.

    Allen Taylor

    • Thanks for the feedback! I’ve only been blogging for a few months but am really enjoying it. I’m aiming to post about once a week.

  2. Hi Stanley, thanks for the post. I’m having some difficulty accessing the Google Docs link – are you able to re-up?


    • Hi Scott, The Google Docs file seems to have disappeared, but luckily I still had a local copy in Excel format which I’ve uploaded to this blog. The link should now work.

      • Great! Many thanks, Stanley.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: