Value American options with the influential Heston Model
![](https://cdn.prod.website-files.com/6606adcab6ed6464b674ad71/667c1809362554dad04cd5ea_pyquant-newsletter-98.png)
Value American options with the influential Heston Model
Accurately pricing options is not easy. But failing to do so can lead to trading losses. The Black-Scholes model assumes a constant level of volatility, which does not happen in the markets.
This is where the Heston Volatility Model shines.
The Heston Model accounts for changing volatility which reflects actual market conditions. Models like Black Scholes assume constant volatility which leads to inaccurate pricing.
Best of all? Python makes it easy.
When I was a quant, I spent years working on improving volatility inputs into models. All to better reflect reality. The team I was on usually used the Heston Model.
By reading today’s newsletter, you’ll be able to implement the Heston Volatility Model with Python to price options more accurately.
Let’s go!
Value American options with the influential Heston Model
The Heston Volatility Model enhances the Black-Scholes model by incorporating stochastic volatility, making it more realistic for option pricing. Introduced by Steven L. Heston in 1993, it captures volatility clustering and the leverage effect through a stochastic process.
This model is more flexible and adapts to varying market conditions.
In practice, the Heston Model uses stochastic differential equations to account for asset price dynamics and mean-reverting variance. Implementing the model often involves Monte Carlo simulations, Fourier transform techniques, or finite difference methods. These approaches help solve the complex equations to determine option prices.
QuantLib does all the hard work for us.
Professionals use the Heston Model to price exotic options and manage risk in derivative portfolios. Its ability to handle stochastic volatility makes it a preferred choice for traders dealing with complex derivatives. This helps in hedging positions more effectively and mitigating potential losses.
Let’s see how it works with Python.
Import necessary QuantLib functions and set up our parameters
We start by importing the necessary functions from the QuantLib library and setting up our initial parameters for the Heston model.
import QuantLib as ql
evaluation_date = ql.Date(30, 5, 2024)
ql.Settings.instance().evaluationDate = evaluation_date
expiry_date = ql.Date(20, 9, 2024)
strike_price = 190
option_type = ql.Option.Call
spot_price = 191.62
dividend_rate = 0.0053
risk_free_rate = 0.05
volatility = 0.2361
First, we set the evaluation date, which is the date we are pricing the option. Next, we define the option parameters, such as the expiry date, strike price, and option type. We’ll use a call option on Apple with a $190 strike price expiring in September.
We also set the market data, including the spot price, dividend rate, risk-free rate, and volatility.
Set up the Heston process and model
Next, we will set up the Heston process and model using the parameters defined earlier.
dividend_ts = ql.YieldTermStructureHandle(
ql.FlatForward(
evaluation_date,
dividend_rate,
ql.Actual360()
)
)
risk_free_ts = ql.YieldTermStructureHandle(
ql.FlatForward(
evaluation_date,
risk_free_rate,
ql.Actual360()
)
)
v0 = volatility * volatility
kappa = 2.0
theta = volatility * volatility
sigma = 0.1
rho = 0.0
heston_process = ql.HestonProcess(
risk_free_ts,
dividend_ts,
ql.QuoteHandle(
ql.SimpleQuote(spot_price)
),
v0,
kappa,
theta,
sigma,
rho
)
heston_model = ql.HestonModel(heston_process)
We construct the yield curves for the dividend and risk-free rates using the FlatForward function. The Heston process requires several parameters: initial variance (v0), mean reversion rate (kappa), long-run variance (theta), volatility of volatility (sigma), and correlation between the spot and variance (rho).
We then create the Heston process and model using these parameters.
Use QuantLib to price our option
Now we will use the Heston model to price our option.
payoff = ql.PlainVanillaPayoff(option_type, strike_price)
exercise = ql.AmericanExercise(evaluation_date, expiry_date)
american_option = ql.VanillaOption(payoff, exercise)
heston_fd_engine = ql.FdHestonVanillaEngine(heston_model)
american_option.setPricingEngine(heston_fd_engine)
option_price = american_option.NPV()
print(f"Option Price: {option_price:.2f}")
We define the payoff and exercise type for the option. The PlainVanillaPayoff function takes the option type and strike price as arguments. We then create the American option using the payoff and exercise.
We set up the pricing engine using the FdHestonVanillaEngine and the Heston model. Finally, we calculate and print the option price using the NPV (Net Present Value) function.
Your next steps
Try changing different parameters in the code, such as the strike price, expiry date, or volatility, to see how they affect the option price. This will help you understand the sensitivity of option prices to various factors.
Experiment with different market data to gain a deeper insight into the Heston model.
![Man with glasses and a wristwatch, wearing a white shirt, looking thoughtfully at a laptop with a data screen in the background.](https://cdn.prod.website-files.com/6604815bfffc39e4941bd158/66070439083cb3ca5c1d1c34_cta%20image.webp)