Knowing More About How To Exploit Market Volatility Will Improve Your Trading Confidence

By akohad Oct30,2022

[ad_1]

AI image by Simplified

High and rising volatility is both a risk and an opportunity across every asset class.

Knowing where or how to get the important volatility metrics for your asset class, how to interpret these metrics, and finally how to apply them in your everyday trading will help you determine whether volatility is a risk to be managed or an opportunity to be exploited.

We will cover all these things.

What is volatility?

Rather than the academic definition of dispersion from the mean, think of volatility as the quantification of how far, how fast, and how often.

A stock that goes up just a little bit almost every month, year after year, will have low volatility but will still be a great investment for your retirement account or your grandchildren’s’ trust. However, that great investment will not be of much interest to you if you are an active trader who built his trading plan around fast moving tickers and short holding periods.

Volatility is a tool that you can use to avoid heartburn or to pump adrenaline. It’s up to you.

Where can I get volatility data?

You may want to use a single reading of volatility of an individual stock or ETF to project a range of possible future stock prices over a specific holding period, like I covered in this recent article: How You Can Use Volatility To Anticipate The Future Price Of Your Ticker Before You Make The Trade.

OpenBB Terminal is a good source for a single reading of annual volatility for stocks and ETFs. It’s free and easy to use. You can also get crypto annual volatility. FOREX volatility is buried a little deeper in OpenBB Terminal but also doable.

If your ticker has options you can get implied volatility on Yahoo Finance for the expiration date that best approximates your anticipated holding period. Implied volatility tends to be higher than historical volatility.

The self-reliant way to get historical volatility for any ticker

You can get any lookback period of historical volatility, when you want it, for any exchange traded ticker you may ever want to trade, if you do it yourself. At the bottom of this article there is a complete Python script you can copy and paste into VS Code or a new Jupyter Notebook to calculate historical volatility and the other volatility metrics you need to get the most out of this unique tool.

What are these other volatility metrics I need to know?

Volatility Rank tells you if today’s volatility is high or low for a specific ticker compared against that ticker’s volatility for all the other days in the lookback period. It’s expressed as a percentage. For example if the maximum volatility over the lookback period was 70 and the minimum was 20 then today’s reading of 60 would give you a Volatility Rank of 80%. That means that today’s volatility is higher than 80% of every other day’s volatility over the lookback period.

Volatility Percentile tells you for how many days in the lookback period this ticker’s volatility was below today’s volatility. For example, if Volatility Percentile is 20% that means that only 20% of the days in the lookback period had lower volatility and 80% had higher volatility than today.

Correlation tells you if your ticker moves in the same direction, or in the opposite direction, of volatility and how strongly these separate movements are tied together. Correlation is always between 0% and 100% and -100%. Positive correlation means both variables move in the same direction. Negative correlation means they move opposite each other.

Mean tells you the most typical value for volatility for all the days in the lookback period. The Mean is what volatility heads back toward after it has been too high or too low.

How do I use this?

Volatility Rank tells you if today’s volatility for a particular ticker is very high or very low. Use the 80/20 rule. If Volatility rank is more than 80% then it is very high and when it stops going higher, it will almost certainly start to revert back toward the mean. Unfortunately there are no clues about when that mean reversion may start to happen.

Volatility Percentile is information similar to what you can get from Volatility Rank. If a very high percentage of days in the past had lower volatility then today’s volatility is very high.

You can marry the correlation information with what you get from these metrics to develop a potential outlook for your ticker.

For example, if correlation is -80% or less and today’s Volatility Rank is 80% or more then you can anticipate that the Black Swan is lurking around somewhere in the shadows waiting for the catalyst to come swooping in and whup the unprepared around the head.

#!pip install pandas_datareader
#!pip install datetime
#!pip install scipy
import pandas as pd
import pandas_datareader as pdr
from datetime import datetime, timedelta, date
from dateutil.relativedelta import relativedelta
import matplotlib.pyplot as plt
import numpy as np
end_date = date.today()
start_date = end_date-relativedelta(days=1000)
ticker = 'SPY'
df = pdr.DataReader(name= ticker, data_source='yahoo', start=start_date, end=end_date)
# lookback is in trading days. For annual volatility use 252 trading days in a calendar year
lookback = 252
retval = np.log(df['Adj Close'] / df['Adj Close'].shift(1))
retval.fillna(0, inplace=True)
all_volatility = retval.rolling(window=lookback).std()*np.sqrt(lookback)
historical_volatility = all_volatility.tail(lookback)
fig = plt.figure(figsize=(12, 5))
ax1 = fig.add_subplot(1, 1, 1)
all_volatility.plot(ax=ax1)
ax1.set_ylabel('Historical Volatility')
ax1.set_title(ticker + ' Historical Volatility ' + str(lookback) + ' Periods')
plt.grid()
plt.show()
today_vol = (historical_volatility.tail(1)).item()
max_vol = historical_volatility.max()
min_vol = historical_volatility.min()
print("Today's Volatility: ", "{:.2f}".format(today_vol))
print("Today's Volatility as a Percentage: {:.0%}". format(today_vol));
from scipy import stats
mean = stats.tmean(historical_volatility, axis=0)
lookback_mean = mean.item()
print("The Mean is: ", "{:.2f}".format(lookback_mean))
print('The Mean as a Percentage is: {:.0%}'.format(lookback_mean))
vol_rank = (today_vol - min_vol) / (max_vol - min_vol)
print("Volatility Rank: {:.0%}".format(vol_rank))
n = 0
for i in historical_volatility:
if i < today_vol:
n = n + 1
percentile = n / lookback
print("Volatility Percentile: {:.0%}". format(percentile))
price_lookback = df["Adj Close"].tail(lookback)
correlation_lookback = stats.pearsonr(price_lookback, historical_volatility)
(c, w) = correlation_lookback #unpack the tuple
print("Correlation: {:.0%}". format(c));
VS Code Output

Resources:

Python in Visual Studio Code

New to trading? Try crypto trading bots or copy trading

[ad_2]

Source link

By akohad

Related Post

Leave a Reply

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