程序代写案例-CS 476/676-Assignment 3

欢迎使用51辅导,51作业君孵化低价透明的学长辅导平台,服务保持优质,平均费用压低50%以上! 51fudao.top
CS 476/676: Assignment 3
Winter 2021
Instructor: Yuying Li Office: DC3623 e-mail: [email protected]
TA: Chendi Ni [email protected] Online OH Mar 11, Thur, 11am-12pm Eastern
TA: Shenghao Yang [email protected] Online OH Mar 5,12, Fri, 10-11am Eastern
Online OH Mar 16, Tues, 10-11am Eastern
Lecture Times: Tues and Fri Online
OH Yuying Li: Wed 10 - 11 Online
My Web Site: http://www.uwaterloo.ca/˜yuying
Due 10 am Mar 17, 2021, Eastern Time
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+√ηudZ
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
dSt
St
= rtdt+ σtdZ
(0)
t
dσt = k1(σ¯ − σt)dt+ η1√σtdZ(1)t
drt = k2(r¯ − rt)dt+ η2√rtdZ(2)t
EQ(dZ
(0)
t dZ
(1)
t ) = ρ 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.
1
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) = φ(i)

dt and φ = [φ(0), φ(1), φ(2)]. What is the covariance matrix for φ?
Describe how to generate iid samples for φ(i), 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
Q
(
e−
∫ T
0
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
dSt
St
= µ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.
Specifically,
(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 Sn and delta δn as follows: When a simulated price in
S does not equal to any lattice price Sn, use linear interpolation from the adjacent nodes to
2
approximate the hedging position (you can use matlab function interp1). If an underlying price
exceeds the range of the price Sn, set the hedging position equal to that of the nearest binomial
price Sn. 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
frequency.
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 +δTST +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 + δTST + 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.
5
3
Table 2: Model Parameter Data
σ .20
r .05
Time to expiry 1 years
Strike Price $95
Initial asset price S0 $95
Payoff European put
µu 0.32
µd 0.3
pup 0.4
Intensity of Poisson Process λ .1
∆t 1/1000
5. (12 marks) (MC Pricing Under Jump Model)
Assume that Zt is a standard Brownian motion. Let qt denotes a Poisson counting process where the
change dqt is defined as
dqt =
{
0 with probability 1− λdt
1 with probability λdt,
where λ > 0 denotes the jump intensity. Consider the following risk neutral jump-diffusion-stochastic-
volatility process
dS(t)
S(t−)
= (r − λκ)dt+ σdZ + (J − 1)dqt (2)
where the value S(t−) is the price just before jump and κ = E[J − 1]. Note that, if dqt = 1, then after
the jump
S(t) = S(t−)J
Hence J corresponds to the random jump amplitude. In Merton’s jump model, log J has a normal
distribution, see §9, 9.1, 9.2, 9.4, 9.5 in the course notes for discussions on the Merton’s jump diffusion
model and its implementation.
Assume that, when jump occurs, the up-jump occurs with a probability pu and down-jump occurs with
a probability pdown = 1− pup.
The matlab function exprnd can be used to generate a random sample from an exponential distribution
in [0,+∞) with a probability density function
fX(x) =
{
1
µe
− xµ if x ∈ [0,+∞)
0 otherwise
(3)
where µ > 0 is a parameter.
(a) (2 mark) Suppose that, when a down-jump occurs, − log J has an exponential distribution (3)
with a parameter µd. Write down the probability density function for log J for the down-jump.
Assume further that, when the up-jump occurs, log J has an exponential distribution (3) with a
parameter µu. Determine κ = E(J − 1) under these assumptions.
(b) (6 marks) Assume that the model parameters are provided in Table 2.
Write a Matlab code to compute the fair value of a European call with strike K and expiry T
assuming the underlying follows a stochastic volatility jump diffusion process (2), using Monte
Carlo method with Euler time stepping. Using the data in Table 2, carry out a sequence of tests
with the number of (timesteps, simulations) = (800, 25000), (1600, 100000), (3200, 400000). Show
the results in a table.
4
(c) (4 marks) Use Matlab function blsimpv to plot the implied volatility of the call option price
computed under the jump model (2) with (timesteps, simulations) = (800, 25000) against the
strike, e.g., K=linspace(70, 120, 20) and T = 1. Discuss observed characteristics of the implied
volatility from the assumed jump model.
6 [(Graduate Student Question)] (10 marks)
Practitioner’s BS delta hedging consists of a portfolio Π(t) with the following components at t = tn:
an option position −Vn, δn shares at price Sn, and the dollar amount Bn in a risk-free bank account,
where
δn =
∂VBS
∂S
(Sn, tn; σ˘n)
and ∂VBS∂S (Sn, tn; σ˘n) is the BS delta at tn using the implied volatility σ˘n computed from the market
option price Vn at the rebalancing time tn. In [Hull and White(2017)]
1, the mean variance delta, δMV
is modeled in a quadratic form, see (5) in [Hull and White(2017)].
You are given the S&P 500 index option data, in the file RawData.mat, from 01-Jan-2009 to 31-Dec-
2010 as the training data set and the data from 01-Jan - 2011 to 31-Dec-2011 as the testing data set.
In RawData.mat, values of following additional variables are also provided for you to use for training
and testing:
• CSTrain: Daily change of the market index price for the training set.
• CVTrain: Daily change of the market index option price for the training set.
• CSTest: Daily change of the market index price for the testing set.
• CVTest: Daily change of the market option price for the testing set.
• DeltaTrain: BS delta δBS computed using implied volatility σimp for the training set.
• DeltaTest: BS delta δBS computed using implied volatility σimp for the testing set.
• VegaTrain: BS vega vegaBS computed using implied volatility σimp for the training set.
• VegaTest: BS vega vegaBS computed using implied volatility σimp for the testing set.
• STrain: market index price, S, for the training set.
• STest: market index price, S, for the testing set.
• TauTrain: time to expiry, τ , for the training set.
• TauTest: time to expiry, τ , for the testing set.
(a) Assume the hedging position function δ at time t has the following parametric form
δ = c0 + c1×S+ c2× τ + c3× δBS + c4× δ2BS + c5×vegaBS + c6×vega2BS + c7×vegaBS × δBS
where δBS denotes the BS delta and vegaBS denotes the BS vega. Learn this parametric function
for the δ position by minimizing the MV error defined in [Hull and White(2017)].
(b) Assess both training and testing hedging performance of the estimated model for the daily hedging
error ∆V − δ∆S, where ∆V = V (S(tn+1), tn+1) − V (S(tn), tn), ∆S = S(tn+1) − S(tn), δ is the
position of the underlying at tn, which is learned from (a). Plot the histogram of the hedging
error ∆V − δ∆S, tabulate its mean, standard deviation, 95% VaR and CVaR and compare these
performance measures with those from hedging with δ = δBS using the practitioner’s BS delta
hedging.
(c) Now learn the MV hedging model (5) in [Hull and White(2017)] from the provided option market
prices. Tabulate the same performance measures for the MV hedging model. Repeat computation
in (b) with the position in the underlying δ = δMV for the MV hedging model (5) in [Hull and
White(2017)] . Compare results from (c) with the parameterizations in (a). What does your
comparison imply about importance of choosing a parametric model in learning a hedging model?
You can use Matlab function blsprice, blsimpv, blsdelta.
1Optimal delta hedging for options, Journal of Banking and Finance, 82, 180-190, 2017.
5

欢迎咨询51作业君
51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468