source('utils.R') sigma = 0.2 S0 = 62 K = 60 delta_t = 1/12 r = 0.10 u = exp(sigma*sqrt(delta_t)) d = 1/u R = 1 + r/12 # total return over the next month q = (R - d)/(u - d) print(c(u, d, R, q)) n_months = 5 ## Build the stock lattice: ## SSpot = make_spot_table(S0, u, d, n_months) print('Spot lattice=') print(round(SSpot, 2)) ## Price the European call (this duplicates the numbers in Figure 12.7 in Example 12.3) ## C_European = evaluate_call_option(SSpot, K, q, R, type='European') print('European call option value=') print(round(C_European, 2)) C_American = evaluate_call_option(SSpot, K, q, R, type='American') print('American call option value=') print(round(C_American, 2)) ## Price the American put (this duplicates the numbers in Figure 12.8 in Example 12.4) ## P_American = evaluate_put_option(SSpot, K, q, R, type='American') print('American put option value=') print(round(P_American, 2))