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.
Diese Übung ist Teil des Kurses
Quantitative Risk Management in Python
Anleitung zur Übung
- Compute the price of a European put option at the spot price 70.
 - Find the 
deltaof the option using the providedbs_delta()function at the spot price 70. - Compute the 
value_changeof the option when the spot price falls to 69.5. - Show that the sum of the spot price change and the 
value_changeweighted by 1/deltais (close to) zero. 
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# 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) * ____ )