Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

Matlab代写 | CS 476/676: Assignment 3

Matlab代写 | CS 476/676: Assignment 3


CS 476/676: Assignment 3

Programming Questions
IMPORTANT: In this and in future assignments, most of the marks for programming questions are
allocated for explanations of algorithms (e.g. pseudo-code) and discussion of results. If all you hand in is
the listing of the “Raw Code” or “Raw Output” by itself, you will get poor marks. All coding should be
done in Matlab. All the plots should be appropriately labeled. You should submit all Matlab code used in
your assignment. Be sure to document (i.e. add liberal comments) your code. The TA will take off marks
for poor documentation.
1 [(10 marks) ] (Numerical Scheme for SDE)
The variance in the stochastic volatility of the Heston model
du = −λ(u − u¯)dt +

is a mean reverting Cox-Ingersoll-Ross (CIR) process, where λ, η, u¯ are positive constants.
Let the time step ∆t be given. Assume that the variance un at time tn is given.
(a) Write down the Euler-Maruyama formula for computing the variance value un+1 at tn+1. Assume
un = ¯u. Write down the condition on the standard normal sample which leads to un+1 < 0.
(b) Given un, write down the Milstein method for computing un+1. Assume un = 0. Provide a
condition which guarantees that un+1 is always positive. Hint: the condition is an inequality
using parameters λ, u, η ¯ .
2 [( 15 marks)] (MC Methods)
A long term European option on a risky asset St has the payoff P(ST ) at the expiry T. Assume that
the underlying price process St, under the risk neutral probability, and the interest rate rt process
satisfy equations below
= rtdt + σtdZ(0)
dσt = k1(¯σ − σt)dt + η1

drt = k2(¯r − rt)dt + η2

t dZ(1)
) = ρ dt
where k1, k2, r, ¯ σ, η ¯ 1, η2, ρ are given positive constants. In addition the initial price S0 > 0, interest
rate r0 > 0, and volatility σ0 > 0 are given. Furthermore, dZ(0) and dZ(2) are independent and dZ(1)
and dZ(2) are independent.
Table 1: Data for Hedging Simulations Using a Binomial Lattice
σ .23
r .02
µ 0.18
Time to expiry 1.0 years
Strike Price K $100
Initial asset price S(t0) $100
N 250
(a) (5 marks) Let dZ(i) = φ

dt and φ = [φ
(0), φ(1), φ(2)]. What is the covariance matrix for φ?
Describe how to generate iid samples for φ
, i = 0, 1, 2, assuming that you are given a function
randn which generates independent samples from the standard normal.
(b) (5 marks) Let tn = n∆t, n = 0, 1, · · · , N, where N∆t = T. Assuming that r(tn), σ(tn), S(tn) are
given, describe how to compute r(tn+1), σ(tn+1), S(tn+1) using the Euler’s formulae?
(c) (5 marks) The fair value V0 of this European option can be computed based on the risk neutral
valuation, i.e.,
V0 = E


r(t)dtP(ST )

Write a pseudo code, using M Monte Carlo simulations and N time steps, N∆t = T, to determine
the fair value of the option at t = 0 based on (a) and (b). You can ignore handling of potential
negative rates and prices.
3 [(20 marks) ](Compute Delta from a Binomial Lattice)
Assume that the (no dividend) underlying price follows
= µdt + σdZt (1)
where Zt is a standard Brownian, µ and σ are constants.
Consider the European power call option on this underlying which has the payoff
[max(S − K, 0)]m
where m is a specified positive integer.
You are to conduct hedging effectiveness analysis for this power option using MC simulations of (1)
for the underlying price so that there is no time discretization error in the simulated price.
In addition, you will compute hedging positions by modifying your code for option pricing under a
binomial lattice in Assignment 2.
Assume that the initial option price is computed from your binomial model.
(a). Write a Matlab function [V0, S, δ] = binomialDeltaPowerCall(S0, r, σ, T, N, m) which returns,
the initial option value V0, S and δ, representing the underlying price and delta hedging positions
on the binomial lattice nodes over equally spaced N time periods in [0, T]. The interest rate r
and volatility σ are constants.
(b). Now consider a vector of (simulated) underlying price S (not necessarily equal to any binomial
lattice price), using linear interpolation to determine the corresponding hedging positions δ(S)
from the binomial lattice price vector S
n and delta δ
n as follows: When a simulated price in
S does not equal to any lattice price S
n, use linear interpolation from the adjacent nodes to
approximate the hedging position (you can use matlab function interp1). If an underlying price
exceeds the range of the price S
n, set the hedging position equal to that of the nearest binomial
price S
n. Write a Matlab function δ=interpDelta(δ
n, Sn, S) to implement this interpolation.
(c). Using the data in Table 1, binomialDeltaPowerCall, and interpDelta, write a matlab script
to compute hedging positions at time t = T /2 for a European power call with m = 1 (which
becomes a standard call) and S = linspace(80, 140, 100) and plot the computed hedge position δ
against S. Compare it with the delta from the Black-scholes blsdelta.
(d) Using the parameter values given in Table 1, determine the hedging error using discrete delta
hedging for the quadratic power call, i.e., m = 2. Plot the histogram of the relative hedging
error P&L, for no hedging, hedging position rebalanced at n = 0 (once), n = 1 : 1 : N (daily),
n = 5 : 5 : N (weekly), n = 20 : 20 : N (monthly) respectively, assuming hedging positions are
computed using binomialDeltaPowerCall and interpDelta,. The Matlab functions histc, bar
might prove useful. Use at least 50 bins in your histogram. Comment on your observations.
(e) Write a Matlab function [var,cvar]=dVaRCVaR(P&L, β) which returns VaR and CVaR for a
discrete P&L distribution with M independent samples using the procedure described. In Matlab,
ordering can be done using sort. For the power call with m = 2, compute and report in a
table, mean, standard deviation, VAR (95%), CVAR (95%), of P&L for no hedging, rebalancing
monthly, weekly, and daily. Discuss how hedging performance changes with the rebalancing
4 [(10 marks)]. (Trading simulation)
Assume that it is possible to trade continuously in time. Suppose that a writer has sold one European
call option with strike K and expiry T.
Assume that the writer implements the following simple hypothetic hedging strategy: As soon as
St > K, the writer borrows from cash account and buys the stock at t. As soon as St < K, the writer
sells the stock at t.
Let δtSt + Bt denote the value of the hedging portfolio of the underlying and bond and Ct denote the
call option value at t. At t = 0, the cash account is set such that −C0 + δ0S0 + B0 = 0.
Assume that the interest r = 0.
Assume that S0 < K, i.e. the initial asset price is less than K.
(a) What is the value of B0? Write down a mathematical expression for the writer’s trading strategy
δt, 0 ≤ t < T.
(b) Under the above continuous trading assumption, the value of hedging portfolio δtSt + Bt is either
St − K + C0 or C0 for any 0 < t < T. When does the value δtSt + Bt equals to St − K + C0?
When does the value δtSt + Bt equals to C0? Explain your answers.
(c) What is the relative P&L for the writer (−CT +δT ST +BT )/C0? What are the mean and variance
of this relative P&L?
(d) The answers to the above questions seem to suggest the existence of an arbitrage. Perform the
following computation to investigate whether this is true. Assume that the underlying follows
the following Black-Scholes model. Simulate writer’s strategy above, assuming S0 = 95, K = 105
and other parameters in Table 1. Compute the relative P&L (−CT + δT ST + BT )/C0 by MC
simulations. Assume C0 equals the initial call value computed by Black-Scholes formula. Use
about 80, 000 simulations. Use 100, 200, 400, 800 rebalancing times. Show a table of results (mean,
standard deviation, 95% VAR and CVAR) versus number of rebalancing times. Generate plot of
the probability density of the relative P&L for the case of 800 rebalancing times.
What do you observe about the mean and variance of the hedging error?
(e) Bonus. Explain the discrepancy in the variance hedging error between the theoretical value under
the continuous hedging assumption and the computed values using MC simulations.