Write a program to price a Bermudan up-and-out call option, exercisable only at dates in exercise_dates with payoff max(S - X, 0) if the option has not knocked out, on a dividend-paying stock using an n-step recombinant trinomial tree over maturity T (Δt = T / n). The stock has initial price S0, continuous dividend yield q, risk-free rate r, and volatility σ. At each time step k in { 0, 1, ..., n }, i.e. tk = kΔt, a node knocks out and becomes worthless if the stock price satisfies S ≥ H. Use the trinomial tree describe in lecture slide p. 749 and find the smallest λ defined in slide p. 747. Any other tree, such as a binomial tree, a binomial-trinomial tree, or other variations, does not meet the requirements and will receive a grade of zero.
Inputs:
S0: initial stock price at t = 0, a float;
X: strike price of the call option, a float;
r: annualized continuously compounded risk-free interest rate, a float;
q: annualized continuous dividend yield, a float;
σ: annualized volatility of stock returns, a float;
T: time to maturity in years, a float;
H: up-and-out barrier level, a float;
n: total number of time steps in the trinomial tree, an integer;
exercise_dates: comma-separated annual dates allowing early exercise, a string;
Output the price of this option. For example, if S0 = 100, X = 100, r = 0.03, q = 0.01, σ = 0.25, T = 1.0, H = 120, n = 200, exercise_dates = "[0.25, 0.5, 0.75, 1.0]", the output is 3.7541. Input Format (for Python codes, replace the student ID with uppercase): "python3 D13922016_HW_3.py 100 100 0.03 0.01 0.25 1.0 120 200 "[0.25, 0.5, 0.75, 1.0]"". Output Format: "3.7541". Please submit your source (and executable) code and a brief explanation text file (if the code is not written in Python, describe how to compile and run it) via Gradescope in NTU COOL before08:00 AM (GMT+8) 2026 Nov 26. No late submissions will be accepted. Compress all files into a single zip file named ID_HW_i.zip, where ID is your student ID in uppercase and i is the homework number (e.g., D13922016_HW_3.zip). If the code is not written in Python, you may be asked to demonstrate your code to the TA.
我網頁剛好沒刷新笑死