Ahead of the competition with Implied Volatility - All you need to know about Implied Volatility (with Python example!)
Implied Volatility overview with Python example
If you are observing current scene of traders and market makers you will notice that they are more concerned with volatility than premium itself because they know perfectly well that the latter is a consequence of the former.
Therefore, being able to tell what the implied volatility and implement it to your analysis will definitely give you an edge over those who use classical volatility indicators. This article will provide you with purpose of iv, available tools and theory behind them. I will also equip you in ready IV calculator using one of the most popular, accurate and efficient method: Newton-Raphson model.
Why consider implied volatility? The historical volatility limitations
Today’s market has been affected by number of critical events madly affecting fluctuations on the stock market, Lock Down, War on Ukraine, Costs of Living Crisis, sky-high inflation, food crisis etc. All those event have impacted volatility in huge extent. And here’s the problem, in lots of models market risk is measured in historical volatility that is measured based on Standard deviation from the mean in change of price of an asset. Time that volatility is being measured cannot be too long, to provide us with relevant outlook but also cannot be too short to obtain full view of the situation. Depending on the need, time to measure volatility usually lies between 1 and 3 years. Here comes troubles, for example at a time of writing this article (28th April 2023), a little bit more than 3 years ago multinational lockdown has started causing short but firm confusion on the market. Since that time interest rates in the US and UK has managed to get lower up until all time lows, and sky-high onto 6%. In this circumstances, historical volatility would point us to the assumption that the markets will remain that volatile in the future, making the view far less likely than in the times of stable growth. We are not expecting new global pandemic to hit in the time of next 2-3 years as probability is rather low. Therefore, why would we tell our model to assume that stock market will repeat that scenario?
Going more theoretically, as I mentioned in the article about Black and Scholes model (which you can visit here). One of the biggest flaws of this model is its static volatility. In the reverse situation, if the market remained relatively static, however there are multiple factors that suggest a change in that trend, Black and Scholes will not take that into account which may lead to false view on the fair price of an option as it not includes all risks involved.
In order to combat that inaccuracy, we can the star of today’s article, implied volatility. Implied volatility (IV) is a metric derived from the market prices of options, which reflects the market's expectation of the future volatility of the underlying asset, such as a stock or an index. It indicates how much traders expect the asset's price to move over the life of the option. Higher implied volatility implies that market participants anticipate larger price fluctuations, whereas lower implied volatility suggests smaller price movements.
Applications of Implied Volatility
As mentioned above, in solid number of situation we can substitute our standard deviation based volatility by implied volatility. Hence, this indicator can give us reliable insights on market sentiment, elevated implied volatility often signals increased uncertainty or fear in the market, while lower implied volatility suggests a more stable and confident market environment.
But IV goes way farther than just market sentiment. Many option traders use implied volatility to adjust trading strategy based on upcoming fluctuations getting the edge over traditional volatility practitioners. In practice, when implied volatility is relatively high, option sellers might benefit from selling options (e.g., writing covered calls or selling cash-secured puts) to take advantage of the higher premiums, while option buyers might find it more expensive to purchase options due to higher premiums.
Implied volatility may also affect hedging strategy. Investors can use implied volatility to gauge the cost of hedging their portfolios with options. When implied volatility is low, it might be more cost-effective to purchase protective puts or implement other hedging strategies to protect the portfolio against potential market downturns.
What difference between historical and implied volatility tells us?
A high difference between historical and implied volatility suggests that market participants anticipate a change in the asset's price behavior. If implied volatility is higher than historical volatility, it may indicate heightened uncertainty or potential upcoming events that could lead to increased price fluctuations. In this scenario, you might seek to hedge their positions or capitalize on the expected increase in volatility through appropriate trading strategies.
Conversely, when implied volatility is lower than historical volatility, it signals that market participants expect a relatively stable price environment. This perception of reduced risk may present opportunities to implement strategies that capitalize on the anticipated lower volatility, such as selling options or establishing more conservative investment positions.
How to calculate Implied Volatility?
There are couple of models available, starting from less accurate but also not requiring a lot of computational power and straightforward to implement to slightly more advanced algorithms which I shall present in the following part.
When it comes to IV, there are 3 models you should remember:
Bisection Method
This model is easy to implement, and, unlike the Newton-Raphson approach, does not need numerical derivatives in its calculation.
All calculations here are focused on setting the starting range where we know IV lies then tightening those ranges. We start from setting up our function that takes our old good Black and Scholes model (if you are not familiar I highly encourage you to read more about it here):
f(v) = Black_and_Scholes_Call(st,k,r,v) Price
Essentially we need to know volatility for which f(v) = 0
In order to do that we need to set up Upper and Lower band where we are sure volatility lies, the do not need to be overly accurate but you rather do not want the to be to broad as it will make the process longer or increase computational power required if you are programming function for it.
Once we have out f(Lower) and f(Upper) we need to find the mid-point i between those i.e. volMid=(VolUpper + volLower)/2. By this step we should obtain assumed function that looks like that:
Next step is tightening those bands based on the sign of volMid and VolLower, if they are they are opposite, then root(our implied volatility) lies between volLower and volMid, and if the signs are the same, root is between volMid and volUpper. you repeat this step in accordance to our condition as long as volUpper-volLower will be equal 0 or set tolerance.
For more about bisection method please read excellent article where author covers the method in more detailed way as well as provides VBA code for its calculation. Check it out here.
Here are some pros and cons of using this method:
Pros:
Simplicity: The bisection method is easy to understand and implement, making it accessible to a wide range of users.
Reliability: Provided that the function is continuous and the initial interval contains a root, the bisection method is guaranteed to converge to a solution.
Robustness: This method is less sensitive to the choice of initial interval and is not affected by extreme values or multiple roots.
Cons:
Slower Convergence: The bisection method generally converges more slowly compared to other methods like Newton-Raphson, which could lead to increased computation time.
Linear Convergence Rate: This method exhibits a linear convergence rate, meaning that the error is reduced by a constant factor in each iteration, which might not be as efficient as other methods with faster convergence rates.
Brenner and Subrahmanyam approximation - for quick, computationally light approximation of implied volatility
The Brenner and Subrahmanyam approximation uses only a few inputs, such as the option's price, the underlying asset's price, the time to expiration, and the risk-free interest rate. The main idea behind the approximation is to eliminate the need to solve the Black-Scholes model iteratively (which can be computationally expensive) to find the implied volatility.
The approximation is particularly useful when you need a quick estimate of implied volatility, as it provides a faster and less complex way to calculate this value. However, it is important to note that the approximation may not be as accurate as other more complex methods. It is best used in situations where speed is more important than extreme precision.
Formula goes as follows:
Implied Volatility (σ) ≈ √(2π/T) * (C/S)
T = Time to expiration of the option (in years)
C = Price of the option (either a call or a put)
S = Current price of the underlying asset
Note that there is slight difference in price and put formula, as you will see in code below:
def brenner_subrahmanyam_approximation(spot_price, strike_price, time, risk_free_rate, market_price, option_type):
if option_type == 'C':
forward_price = spot_price * m.exp(risk_free_rate * time)
d1 = (m.log(forward_price / strike_price)) / m.sqrt(time)
return m.sqrt(2 * m.pi / time) * (market_price / strike_price)
elif option_type == 'P':
forward_price = strike_price * m.exp(-risk_free_rate * time)
d1 = (m.log(forward_price / spot_price)) / m.sqrt(time)
return m.sqrt(2 * m.pi / time) * (market_price / strike_price)
Newton-Raphson
And our final method is Newton-Raphson which can be more advanced than previous ones but it makes up for it in accuracy and efficiency (at least for European options)
In the context of implied volatility estimation, the Newton-Raphson method is applied to find the root of the Black-Scholes equation, a widely used option pricing model. Like in bisection method, the root represents the implied volatility that, when plugged into the Black-Scholes formula, produces a theoretical option price equal to the observed market price.
NR takes black and Scholes’ fair price, initial guess about volatility .. and Vega. Vega is the BSM derivate widely used to measure option sensitivity on change in implied volatility (you can read more about so called Greeks like Vega here). More precisely, Vega indicates volatility risk, that is, approximately how much an option price will increase or decrease in the change in implied volatility. NR model is designed to evaluate initial guess adjusting difference between Black Scholes price of initial guess and actual market price of an option with relation to Vega. If the difference between BSM price and market price is equal to 0 (or pre-designated tolerance), NR returns implied volatility, if not new volatility is set as initial guess and iterated again.
It will get clearer with the formula:
Where:
Where
if (i=0) is the initial guess for the implied volatility,
is the option price derived from the initial guess,
is the market price of the option,
is the Vega in terms of the initial guess, and finally
would be the updated implied volatility. While the absolute value of
falls into a desired degree,
By incorporating Vega in the NR method, we ensure that the iterative process takes into account how the option price changes with respect to the implied volatility. This allows the algorithm to converge more rapidly and accurately to the correct implied volatility value that matches the observed market option price
However, according to some deeper researches the Newton–Raphson method becomes very inaccurate when the strike of the option is more than 20% Away-From-The-Money (AFTM)
NR is quite mathematically heavier than the pervious methods and rather accurate initial guess to aggregate properly (in relation to Bisection method). However, it makes up in the result. As the summary of this method I wush to present to you code for calculating Implied Volatility using NR metheod … and Brenner and Subrahmanyam approximation as quite accurate initial guess (you can also find this and more codes on my GitHub, here):
Newton-Raphson method for calculating implied volatility:
#import packages
import math as m
from scipy.stats import norm
#Black and Scholes calculator
def black_scholes(spot_price,strike_price,risk_free_rate,volatility,time, option_type='C'):
d1 = (m.log(spot_price/strike_price) + (risk_free_rate+(volatility**2/2))*time)/(volatility*m.sqrt(time))
d2 = d1 - volatility*m.sqrt(time)
try:
if option_type == "C":
price = norm.cdf(d1,0,1)*spot_price - norm.cdf(d2,0,1)*strike_price*m.exp(-risk_free_rate*time)
elif option_type == "P":
price = -spot_price*norm.cdf(-d1,0,1) + norm.cdf(-d2,0,1)*strike_price*m.exp(-risk_free_rate*time)
except:
return -2
return price
#vega calculator
def vega(spot_price, strike_price, time, risk_free_rate, volatility):
d1 = (m.log(spot_price / strike_price) + (risk_free_rate + 0.5 * volatility ** 2) * time) / (volatility * m.sqrt(time))
return spot_price * norm.pdf(d1) * m.sqrt(time)
#Brenner-Subrahmanyam approximation
def brenner_subrahmanyam_approximation(spot_price, strike_price, time, risk_free_rate, market_price, option_type):
if option_type == 'C':
forward_price = spot_price * m.exp(risk_free_rate * time)
d1 = (m.log(forward_price / strike_price)) / m.sqrt(time)
return m.sqrt(2 * m.pi / time) * (market_price / strike_price)
elif option_type == 'P':
forward_price = strike_price * m.exp(-risk_free_rate * time)
d1 = (m.log(forward_price / spot_price)) / m.sqrt(time)
return m.sqrt(2 * m.pi / time) * (market_price / strike_price)
#implied volatility calculator
def implied_volatility(spot_price, strike_price, time, risk_free_rate, market_price, option_type='C'):
MAX_ITERATIONS = 500
tolerance = 1e-4
volatility = brenner_subrahmanyam_approximation(spot_price, strike_price, time, risk_free_rate, market_price, option_type) #set starting volatility
for i in range(MAX_ITERATIONS):
bs_price = black_scholes(spot_price,strike_price,risk_free_rate,volatility,time,option_type)
bs_vega = vega(spot_price, strike_price, time, risk_free_rate, volatility)
diff = bs_price - market_price
if abs(diff) < tolerance:
return volatility
else:
volatility = volatility - diff/(bs_vega + 1e-8)
return -1
#Test/usable area
if __name__ == '__main__':
spot_price = 275.00
strike_price = 310.00
time = 184 / 365
risk_free_rate = 0.0341
market_price = 1.937
implied_volatility(spot_price, strike_price, time, risk_free_rate, market_price, option_type='C')
So there you have it, implied volatility and how to calculate it, don’t forget to subscribe for weekly dosage of tools and news from the world of modern finance!
Thanks,
Tomasz