Man vs. The Stock Market: One of Us Must be Crazy

Ian Macleod
7 min readJun 10, 2020

--

Me trying to explain the erratic behavior of the markets in terms of largely inapplicable historical trends.

The stock market is amoral. That sentence has echoed across the nation in the past week, along with Black Lives Matter protests and the spread of coronavirus. We’ve seen stock market indices approach record highs come at a time when America is grappling with the horrific lows of police brutality and systemic racism as well as the consistent undercurrent that is the ongoing pandemic. Frankly, amorality wouldn’t be enough to justify an almost complete recovery. The macroeconomic factors that are often tied to the stock market now appear to have no tie at all with our current reality. The adjusted unemployment rate for May was 14.8%. Yet the stock market is trading close to pre-recession highs, when the unemployment rate was a shockingly-low 3.5%. How can these two statistics be rationalized? What macroeconomic factors are driving the sudden recovery we’re seeing today? Worst of all, am I crazy?

In order to answer these questions (and try to save my own sanity), I’m going heed the advice of all the “experts” and “gurus” floating around on morning talk shows and try to take an amoral stance. In my case, that means just looking at the data (While it’s important to note that data can also be biased, for the sake of simplicity I’ll assume that my data is immoral and unbiased). For this project, I’m going to use the Spyder S&P 500 index, which is an exchange-traded fund that serves as an (at least adequate) proxy for performance of the overall stock market. I’m also going to be using the Yahoo Finance API in order to pull historical time data to perform my (admittedly simple) analysis.

Importing all required packages and creating a new spy object to get historical data for SPY index.

After creating a new object for the Yahoo Finance API, I’m going to send a request to pull data for the close price of each trading day from the beginning of 2019 to present day (at the time of writing, June 10th, 2020). I’m going to add 50- and 200-day simple moving averages in order to look at some basic trendlines as well. I’m also going to repeat this process for the Great Recession of 2008 (the most recent major economic downturn in the United States), which will act as a sort of historical control that we can measure the recovery pattern of 2020 against.

Pulling data from API and adding columns for moving averages.

Now that I have my data for the 2008 and 2020 recessions, I can begin to actually try and figure out what’s going on. The first thing I’m going to do is generate a simple plot of 2008 recession patterns using PyPlot from MatPlotLib (an amazing tool for making simple, easy to follow graphs). I’m also going to repeat this process for the 2020 recession data that I have so that we can try and draw some initial comparisons.

Here’s the 2008 recovery chart.
And here’s the 2020 recovery chart.

Can you see the difference yet? It might not be immediately obvious. In fact, when you first look at the two charts, they are more or less similar. We see a large dip followed by a recovery over time, indicating the classical definition of a recession. From this, we can confidently say that the 2020 recession was as great (if not greater) than the 2008 recession. Beyond this obvious similarity, however, the two recessions have almost nothing in common. One way to see this is to examine the timeframes for our graphs. In the 2008 recession graph, the date range selected in order to show the “full” recovery (where the SPY approached its pre-recession highs) are shown from 2007 to 2012. In the 2020 recession, however, the results were shown on a timeframe of months rather than years. In fact, it appears that the SPY index has crashed far faster than in 2008. Moreover, it has recovered far faster, demonstrating the full cycle of a recession from fall to bounce in just over 3 months from March to June. This is sort of pattern is historically unimaginable. I might not be crazy.

To further illustrate the shocking difference between the two stock market crashes, lets look at their 200-day simple moving averages shown by the dotted red line. In the graph of the Great Recession of 2008, the 200-day simple moving average tracked with the economic fall and recovery, showing a clear dip and bounce. In the coronavirus-induced recession of 2020, however, the 200-day simple moving average barely fluctuates, showing an almost imperceptible dip. If you were to look at a plot of the 200-day simple moving average absent any other information, you would hardly be able to tell that a recession had occurred at all; instead, it would merely appear to be a natural (even potentially overdue) market correction.

In order to dig even further into the differences between the two recessions, I decided to create a third graph that overlays the patterns of the SPY in 2008 and 2020. To do so, I found the pre-recession high for both dataframes and then tracked the time it took to present a “full” recovery. Since the 2020 recession is still ongoing, I decided to use the timeframe from the value of the high to present day.

The corresponding Python code that gave me the pre-recession high values and their dates.

Although it may feel like centuries have elapsed since quarantine began and the stock market began to fall, the data reveals that it has only been a short 112 calendar days since the SPY index was at its pre-recession, all-time high. After eliminating holidays and weekends when the stock market was closed, we find that it has been less than 80 actual trading days since the stock market began to fall. Armed with this information, I created a new dataframe that had SPY data from 2008 and 2020 over the 112 day time band.

Creating a new overlay dataframe and converting all values into percentages on a 0 to 1 scale.

Finally, I graphed my results.

Aha! We’ve got it! I’m not the crazy one. It must be the stock market.

This last figure really illustrates the ideas I’ve been hinting at by looking at simple moving averages. In short, we can see that the 2008 recession was only just beginning to decline over the same 80-day period where the SPY fell by almost 40% and then bounced back. In short, this is a recession unlike we’ve ever seen before followed by a recovery unlike we’ve ever seen before. I’m not crazy! I hate to use this word as it feels almost banal in our current environment, but this chart really is unprecedented. Moreover, the macroeconomic factors that I’m most interested in looking at––namely, the unemployment rate in America––are completely inconsistent with the recovery shown by the stock market today. In fact, the graph below from the Saint Louis Federal Reserve shows that the unemployment rate today should historically be correlated with the largest recession we’ve seen in the past 70 years.

So what, exactly, is driving the rise in the stock market? In order to understand why the stock market is rising so quickly, I’m going to invert my original hypothesis. I’m not crazy, everyone else is! What do I mean by this? At it’s core, the stock market is not driven by present-day economic performance, but by expectations of future performance. Normally, these two factors would be closely correlated (so correlated, in fact, that people often bandy around the terms interchangeably as though they are one and the same). In today’s economy, however, the distinction between the two factors is incredibly important. Yes, the economy is currently at recession levels unlike we’ve seen in the past 70 years. From an amoral, data-driven perspective, things are incredibly bleak. However, from an optimistic, forward looking perspective, things are looking up. States across the nation have begun to reopen, signalling what will hopefully be the beginning of the end of the coronavirus pandemic.

So, in short, the stock market isn’t amoral. At least not to me. Because it has departed so drastically from underlying macroeconomic data like the unemployment rate, I have no choice but to conclude that the stock market is not data-driven, but sentiment-oriented. Which, in my mind, makes a lot of sense. The stock market is based on the actions of men, and, at the end of the day, we’re all a little crazy. We hate to see our balances dwindle and feel like we’re losing money. We also hate to see the stock market rise when we’re not invested and feel like we’re missing out. Our emotions get the better of us, and we often act based on how we’re feeling rather than acting amorally or being unbiased. In 2020, I think that these two results combined to create a drastic fall unlike any we’ve ever seen before followed by a sharp recovery (read: erratic behavior). Overall, I posit that the stock market is crazy precisely because we’re all crazy.

--

--

Ian Macleod

Student interested in economics, data science and computer programming.