Using options for hedging
Suppose that you have an investment portfolio with one asset, IBM. You'll hedge the portfolio's risk using delta hedging with a European put option on IBM.
First, value the European put option using the Black-Scholes option pricing formula, with a strike X
of 80 and a time to maturity T
of 1/2 a year. The risk-free interest rate is 2% and the spot S
is initially 70.
Then create a delta hedge by computing the delta
of the option with the bs_delta()
function, and use it to hedge against a change in the stock price to 69.5. The result is a delta neutral portfolio of both the option and the stock.
Both of the functions black_scholes()
and bs_delta()
are available in your workspace.
You can find the source code of the black_scholes()
and bs_delta()
functions here.
This is a part of the course
“Quantitative Risk Management in Python”
Exercise instructions
- Compute the price of a European put option at the spot price 70.
- Find the
delta
of the option using the providedbs_delta()
function at the spot price 70. - Compute the
value_change
of the option when the spot price falls to 69.5. - Show that the sum of the spot price change and the
value_change
weighted by 1/delta
is (close to) zero.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Compute the annualized standard deviation of `IBM` returns
sigma = np.sqrt(252) * IBM_returns.std()
# Compute the Black-Scholes value at IBM spot price 70
value = black_scholes(S = ____, X = 80, T = 0.5, r = 0.02,
sigma = sigma, option_type = "put")
# Find the delta of the option at IBM spot price 70
delta = bs_delta(S = ____, X = 80, T = 0.5, r = 0.02,
sigma = sigma, option_type = "put")
# Find the option value change when the price of IBM falls to 69.5
value_change = ____(S = 69.5, X = 80, T = 0.5, r = 0.02,
sigma = sigma, option_type = "put") - ____
print( (69.5 - 70) + (1/delta) * ____ )
This exercise is part of the course
Quantitative Risk Management in Python
Learn about risk management, value at risk and more applied to the 2008 financial crisis using Python.
Now it’s time to expand your portfolio optimization toolkit with risk measures such as Value at Risk (VaR) and Conditional Value at Risk (CVaR). To do this you will use specialized Python libraries including pandas, scipy, and pypfopt. You’ll also learn how to mitigate risk exposure using the Black-Scholes model to hedge an options portfolio.
Exercise 1: Measuring RiskExercise 2: VaR for the Normal distributionExercise 3: Comparing CVaR and VaRExercise 4: Which risk measure is "better"?Exercise 5: Risk exposure and lossExercise 6: What's your risk appetite?Exercise 7: VaR and risk exposureExercise 8: CVaR and risk exposureExercise 9: Risk management using VaR & CVaRExercise 10: VaR from a fitted distributionExercise 11: Minimizing CVaRExercise 12: CVaR risk management and the crisisExercise 13: Portfolio hedging: offsetting riskExercise 14: Black-Scholes options pricingExercise 15: Options pricing and the underlying assetExercise 16: Using options for hedgingWhat is DataCamp?
Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.