-
Option Payoffs 4
-
Lecture1.1
-
Lecture1.2
-
Lecture1.3
-
Lecture1.4
-
-
Binomial Model 8
-
Lecture2.1
-
Lecture2.2
-
Lecture2.3
-
Lecture2.4
-
Lecture2.5
-
Lecture2.6
-
Lecture2.7
-
Lecture2.8
-
-
Black-Scholes 6
-
Lecture3.1
-
Lecture3.2
-
Lecture3.3
-
Lecture3.4
-
Lecture3.5
-
Lecture3.6
-
-
Monte Carlo Simulations 3
-
Lecture4.1
-
Lecture4.2
-
Lecture4.3
-
Binomial Trees 4
We have focused on call options until this point, but we have more options than just that! Let’s change the functions so that backward_induction takes a function for conversion to an option’s value.
#Add in an ability to change the option valuation
def call_value(level, strike_price):
level = np.where(level-strike_price < 0, 0, level-strike_price).round(2)
return level
def backward_induction(node_levels, strike_price, sigma, rf, T_increment, option_valuation_function):
opt_values = []
level = node_levels[-1]
level = np.array(level)
level = option_valuation_function(level, strike_price)
opt_values.append(level)
for level in node_levels[::-1][1:]:
opt_values.append(backward_induction_node_level(opt_values[-1], sigma, rf, T_increment))
opt_values = opt_values[::-1]
return opt_values
node_levels = create_nodes(price0, T, sigma, T_increment)
opt_values = backward_induction(node_levels, strike_price, sigma, rf, T_increment, call_value)
print(opt_values)
This can also be changed to use put options instead now!
#And this let's us switch the function to value put options
def put_value(level, strike_price):
level = np.where(strike_price - level < 0, 0, strike_price- level).round(2)
return level
opt_values = backward_induction(node_levels, strike_price, sigma, rf, T_increment, put_value)
print(opt_values)
Draw both options and the stock price binomial tree.
node_levels = create_nodes(price0, T, sigma, T_increment)
call_opt_values = backward_induction(node_levels, 100, sigma, rf, T_increment, call_value)
put_opt_values = backward_induction(node_levels, 100, sigma, rf, T_increment, put_value)
node_levels = convert_nodes_to_labels(node_levels)
call_opt_labels = convert_nodes_to_labels(call_opt_values)
put_opt_labels = convert_nodes_to_labels(put_opt_values)
pos_dictionary = create_node_positions(node_levels)
print("Stock Values")
draw_binary_tree(node_levels, pos_dictionary,node_levels)
print("Call Option Values")
draw_binary_tree(node_levels, pos_dictionary,call_opt_labels)
print("Put Option Values")
draw_binary_tree(node_levels, pos_dictionary,put_opt_labels)
sigma = .08
rf = .04
T_increment = 1/4
T = 4
strike_price = 100
price0 = 100
node_levels = create_nodes(price0, T, sigma, T_increment)
call_opt_values = backward_induction(node_levels, 100, sigma, rf, T_increment, call_value)
put_opt_values = backward_induction(node_levels, 100, sigma, rf, T_increment, put_value)
node_levels = convert_nodes_to_labels(node_levels)
call_opt_labels = convert_nodes_to_labels(call_opt_values)
put_opt_labels = convert_nodes_to_labels(put_opt_values)
pos_dictionary = create_node_positions(node_levels)
print("Stock Values")
draw_binary_tree(node_levels, pos_dictionary,node_levels)
print("Call Option Values")
draw_binary_tree(node_levels, pos_dictionary,call_opt_labels)
print("Put Option Values")
draw_binary_tree(node_levels, pos_dictionary,put_opt_labels)
WHat about a straddle?
def straddle_value(level, strike_price):
level = abs(strike_price - level)
return level
sigma = .08
rf = .04
T_increment = 1/4
T = 4
strike_price = 100
price0 = 100
node_levels = create_nodes(price0, T, sigma, T_increment)
call_opt_values = backward_induction(node_levels, 100, sigma, rf, T_increment, call_value)
put_opt_values = backward_induction(node_levels, 100, sigma, rf, T_increment, put_value)
straddle_opt_values = backward_induction(node_levels, 100, sigma, rf, T_increment, straddle_value)
node_levels = convert_nodes_to_labels(node_levels)
call_opt_labels = convert_nodes_to_labels(call_opt_values)
put_opt_labels = convert_nodes_to_labels(put_opt_values)
straddle_opt_labels = convert_nodes_to_labels(straddle_opt_values)
pos_dictionary = create_node_positions(node_levels)
print("Stock Values")
draw_binary_tree(node_levels, pos_dictionary,node_levels)
print("Call Option Values")
draw_binary_tree(node_levels, pos_dictionary,call_opt_labels)
print("Put Option Values")
draw_binary_tree(node_levels, pos_dictionary,put_opt_labels)
print("Straddle Values")
draw_binary_tree(node_levels, pos_dictionary,straddle_opt_labels)
You can confirm that the price of a put and call is the same as the price of a straddle based on the binomial model (assuming some rounding error).
for i in range(len(straddle_opt_values)):
print(straddle_opt_values[i] - (call_opt_values[i] + put_opt_values[i]))
This was a very long lesson but we did not yet introduce valuation for american options, or what happens when we have dividends for stocks. These lead to different valuations but in this first part of the course we won't cover them to keep it at a reasonable length.
Prev
Binomial Trees 3