Use Matlab to write a computer code which takes as inputs:
• The initial stock price S0
• The payoff function F (ST )
• The interest rate r
• The length of the period h
• The up and down factors u and d
• The number of periods T
and which calculates the European option price as well as the composition of the replicating portfolio at every node of the tree.
a. Apply your code to compute the initial value of a straddle with T = 4, r = 0.02,
h=0.25,u=exp(r*h+0.2*sqrt(h)),d=exp(r*h-0.2*sqrt(h)),S0 =100,and strike K=90.
b. Apply your code to compute the initial value of a straddle with T = 40, r = 0.02,
h=0.025,u=exp(r*h+0.2*sqrt(h)),d=exp(r*h-0.2*sqrt(h)),S0 =100,and strikeK=90.
c. Apply your code to compute the initial value of a binary call option with T = 4,
r=0.02,h=0.25,u=exp(r*h+0.2*sqrt(h)),d=exp(r*h-0.2*sqrt(h)),S0 =100,and strike K=90.