How Volatility Affects a Stock’s Return: Tested with Python

Dane Brear
Analytics Vidhya
Published in
5 min readFeb 26, 2020

Finding an effective trading strategy is few and far between. There is a countless number of concepts, ratios, and jargon that is easy to get lost in. Today I am going to focus on one term: volatility.

Photo by Markus Spiske on Unsplash

Volatility is a statistical measure of the dispersion of returns for a given security or market index. -Investopedia

In English, volatility is how much and how often the price of a stock can be expected to increase or decrease over a period of time and is measured in standard deviations.

For example, if my stock’s price today is $100.00 and there is a standard deviation of $10.00 over the last 5 years’ closing prices, I can reasonably expect 68% of the next n number of closing prices to be between $90.00 and $110.00.

I recently read an article on Medium defining volatility and how it can be used in trading. The article does a great job explaining in depth what volatility is and covers a couple ideas and observations when it comes to trading. Here is the link to the article:

What I found most intriguing were the following ideas:

Low volatility now. If the order book is balanced, the price won’t change much as long as volume stays the same. Yet if there is a sudden increase in sellers or buyers, the price might change sharply;

High volatility now. Illiquid assets with little trading activity will typically have higher volatility as each large order changes the price;

Decreasing volatility. Low and decreasing volatility is common for bull runs when prices go up. If volatility continues to decline, this could be a bullish sign;

Increasing volatility. Volatility tends to revert to mean, with increases after periods of low volatility and decreases after periods of high volatility

As someone who is working on expanding my knowledge about the stock market and its trends, I wanted to find out if there is truth in the above ideas.

I used the last two years of stock data for over 500 stocks to make the following calculations and observations. I will include a link to my code at the end of the article.

High and Low Volatility vs. Return

I first wanted to map out a basic model which shows return against the volatility to find out if we could see any basic patterns. As the previously noted, we can likely expect higher volatility to yield more drastic changes in return.

Let’s use Apple Inc. for an example. If we use a timeframe of 30 days to calculate return and volatility, the outcome looks like this:

Line graph showing relationship between return and volatility over 30 days

And here is the same graph over a ten-day period:

Line graph showing relationship between return and volatility over 10 days

We can clearly see, regardless of the difference in time frame, how a larger spread of volatility affects the magnitude of a stock’s return. This is true for all stocks. This is may seem like common sense, however I thought it would be interesting to have a visual. Here comes the interesting part!

Rate of Volatility vs. Return

If there are consecutive days of decreasing volatility, does that actually signal a bullish future? How can I measure and test this?

Formulation

After some time thinking, I came up with the following solution for testing this hypothesis:

  1. I can measure decreasing volatility by finding the times the standard deviation decreases n days in a row
  2. After n days of consecutive decreasing volatility, record the prices for the next m days.
  3. Calculate the average return and percentage of times there is a positive return for each m days after n consecutive days of decreasing return.

As I previously mentioned, I used python to code an algorithm that fits these conditions. I used over 500 stocks with historical data from the last two years to test. I removed all stocks that did not have any periods of decreasing volatility so as not to affect the averages.

I tested with n = [3, 5, 7] and m = [10, 30].

Results

My first test was to find the average return:

Note: Multiplied each 10-day return by 3 to match 30-day time period

Trends worth pointing out:

  1. Mean returns consistently 1.45% or increasingly slowly for 30-day time periods while 10-day time periods increase at a faster rate when consecutive days of decreasing volatility rises.
  2. Maximum return of all stocks that I gathered data for was the highest with the longest period of consecutive days of decreasing volatility and the shortest period of closing prices collected afterwards. However, this is worth noting that there is a much larger standard deviation, indicating higher risk.
  3. The market return for the last two years was 14.23% via ycharts, which evaluates to 1.18% per month. This figure is eerily familiar to the average return, indicating that these positive returns may be due to overall market growth.

A second test I ran was to find the percentage of times there is a positive return following n consecutive days of decreasing volatility:

These figures are a bit more optimistic. Only 18% of the time (less than one standard deviation below the mean) you will be under a 50% likelihood of getting a positive return if you invest with the first three columns’ n and m.

The third column, 30 days after 5 consecutive, shows a very high 71% likelihood of a positive return.

However, it is worth noting that, as mentioned with the previous test results, this may be in part due to the natural market growth rather than investing using this strategy.

Conclusion

Volatility is an interesting concept when it comes to how a stock’s return might react to it. As we know, high volatility can lead to severe peaks and valleys while low volatility is much flatter.

When considering periods of decreasing and increasing volatility, there may be opportunity to consistently get positive returns. However, there will likely need to be more research done on whether or not this is a reflection of general market returns.

Other possibilities and future tests may include altering my formulation for these tests or changing the n and m to reflect a larger or smaller scope. I am also considering testing to see if volatility is mean regressing.

Thanks for reading! Hopefully you enjoyed and got something out of this article, as I have learned a lot while creating it.

--

--

Dane Brear
Analytics Vidhya

Mobile Application and Cloud Engineer | Purdue University Graduate