Worked Examples and Solutions for the Book:
Computational Finance Using C and C#
by George Levy
John L. Weatherwax"
May 8, 2009
Introduction
As a former applied mathematician, I found this book a very nice addition
to the computational finance literature. The mathematical formulation of
the problems discussed is clear without sacrificing rigor. Helpful but not
overly theoretical proofs are provided, and a nice summary appendix of useful
background mathematical results is given. One nice aspect of the book is that
it provides somewhat more advanced algorithms (and source code) than other
introductory books. This is beneficial in that this provides a more readable
introduction to the various papers one would need to read to understand
the same material. In these notes you ll find the solutions to the problems
for Chapter 2 and any additional mathematical derivations I performed as I
worked thought this book.
"
wax@alum.mit.edu
1
Chapter 2 (Introduction to Stochastic Processes)
Problem Solutions
k
Problem 1 (evaluating ²t = E[Wtk])
Part (a): As an explanation of the solution process we will take for this
problem we will derive a differential equation for Wtk which we will then solve.
Having solved this differential equation we will take the expectation of the
k
solution to derive a recursion relationship for the requested ²t = E[Wtk]. We
begin by defining the function Ć as Ć(Wt) = Wtk. Since Ć is only a function
of only a stochastic component Wt (and not time) from Ito s formula we have
for its differential the following
"Ć 1 "2Ć
dĆ = dWt + dt .
2
"W 2 "W
Thus for this specific Ć(Wt) we find
1
d(Wtk) = k(Wt)k-1dWt + k(k - 1)(Wt)k-2dt .
2
Integrating both sides of this last expression from 0 to t gives
t t t
1
k
d(Ws ) = k (Ws)k-1dWs + k(k - 1) (Ws)k-2ds ,
2
s=0 s=0 s=0
or
t t
1
k
Wtk - W0 = k (Ws)k-1dWs + k(k - 1) (Ws)k-2ds .
2
s=0 s=0
k
Since W0 = 0 we can take the expectation of the above to get
t t
1
k
²t = E[Wtk] = kE (Ws)k-1dWs + k(k - 1)E (Ws)k-2ds
2
s=0 s=0
t
Since E (Ws)k-1dWs = 0 then passing the second expectation into the
s=0
k
integral above gives the desired expression for ²t of
t
1
k k-2
²t = k(k - 1) ²s ds , (1)
2
s=0
the desired expression.
2
Part (b): From Equation 1 above we have that when k = 4 that
t
4
4 2
E[Wt4] = ²t = (3) ²s ds ,
2
s=0
2
which depends on ²s . When k = 2 Equation 1 gives
t
1
2
²t = (2) ds = t .
2
s=0
So with these two results we see that
t
t
E[Wt4] = 6 s2ds = 2s3 = 2t3 .
0
s=0
Part (c): In the same way as above we have when k = 6 that
t t
1
4
E[Wt6] = 6(5) ²s ds = 15 3s2ds = 15t3 .
2
s=0 s=0
Problem 2 (solving dXt = Xtdt + dWt)
From the given differential equation dXt = Xtdt + dWt we can write it
trivially but emphasizing that the random component Wt can be considered
like a forcing term to the linear system represented by the left hand side as
dXt - Xtdt = dWt .
This also suggest multiplying both sides by the integration factor of e-t to
get
dXte-t - Xte-tdt = e-tdWt .
In this expression the left hand side is equivalent to an exact differential and
our equation becomes
d(Xte-t) = e-tdWt .
Upon integrating both sides of this from t0 to t we obtain
t t
d(Xte-t) = e-tdWt ,
t0 t0
3
or performing the integration on the left hand side gives
t
0
Xte-t - Xt e-t = e-sdWs .
0
t0
Solving for Xt we finally find
t
0
Xt = Xt e-t +t + et-sdWs .
0
t0
Problem 3 (solving dXt = -Xtdt + e-tdWt)
Writing the given differential equation as
dXt + Xtdt = e-tdWt ,
we can simplify it by multiplying by an integrating factor of et to get
etdXt + etXtdt = dWt ,
or
d(etXt) = dWt .
When we integrate both sides from t0 to t we find
t
0
etXt - et Xt = dWs = Wt - Wt .
0 0
t0
Since Wt = 0 when we solve for Xt we find
0
0-t
Xt = et Xt + e-tWt .
0
2
Problem 4 (integrating Ws dWs)
Consider a function Ć defined as Ć = Wt3. Then Ito s formula in this case
since our stochastic variable, X, written in terms of W is so simple (X is
equal to W ) the general expression has a = 0, b = 1, and we find
"Ć 1 "2Ć "Ć
dĆ = + dt + dW
2
"t 2 "W "W
6
= 0 + Wt dt + 3Wt2dW
2
= 3Wtdt + 3Wt2dW ,
4
1
or expressing this in terms of Wt3 we find
3
1
d(Wt3) = Wtdt + Wt2dW .
3
On integrating both sides from t0 to t since Wt = 0 we see that
0
t t
1
2
Wt3 = Wsds + Ws dWs ,
3
s=0 s=0
which is the required identity.
Problem 5 (solving dYt = rdt + Ä…YtdWt)
To solve
dYt = rdt + Ä…YtdWt , (2)
Ä…2
t-
2
as a hint we are told to consider an integrating factor Ft = e-Ä…W t.
Note that there is a typo in the sign of the t term in the expression the books
provides for Ft. We begin by writing Equation 2 as
dYt - Ä…YtdWt = rdt .
We next multiply both sides by the suggested integrating factor Ft to obtain
FtdYt - Ä…YtFtdWt = rFtdt . (3)
Now with Ito s formula lets evaluate the differential of the integrating factor
Ft. We find
"F 1 "2F "F
dFt = + dt + dW where
2
"t 2 "W "W
"F Ä…2
= - F
"t 2
"F
= -Ä…F
"W
"2F
= Ä…2F .
2
"W
So we see that
Ä…2 1
dF = - + Ä…2 F dt - Ä…F dW = -Ä…F dW . (4)
2 2
5
Using Equation 4 we see that the differential of the product YtFt is
d(YtFt) = (dYt)Ft + Yt(dFt)
= Ft(dYt) + Yt(-Ä…2FtdWt)
= Ft(dYt) - Ä…Y F dWt .
Thus using this expression Equation 3 above becomes
Ä…2
t-
2
d(YtFt) = re-Ä…W tdt .
Integrating both sides from t0 to t gives
t
Ä…2
s-
2
YtFt - Yt Ft = re-Ä…W sds
0 0
t0
so that when we solve for Yt we find
t
Ä…2
s-
2
Yt = Ft-1Ft Yt + rFt-1 e-Ä…W sds
0 0
t0
t
Ä…2 Ä…2 Ä…2 Ä…2
t t0 2 t s-
2 2 2
= eÄ…W + te-Ä…W - t0Yt + reÄ…W + t e-Ä…W sds .
0
t0
Since Wt = 0 we get that
0
t
Ä…2 Ä…2
t t-Ws)+ (t-s)
2 2
Yt = Yt eÄ…W + (t-t0) + r eÄ…(W ds ,
0
s=t0
for the solution.
Problem 6 (solving the Ornstein-Uhlenbeck process)
For the mean reverting Ornstein-Uhlenbeck process given by
dXt = (m - Xt)dt + ÃdWt , (5)
we have by writing the random component on the right hand side
dXt + Xtdt = mdt + ÃdWt .
From this expression an integrating factor for this equation is given by F =
et and multiplying by this we find the left hand side becomes the perfect
differential
etdXt + etXtdt = d(etXt) .
6
Using this the above becomes
d(etXt) = metdt + ÃetdWt .
Integrating both sides over the limits t to t0 gives
t
0 0
etXt - et Xt = m(et - et ) + Ã esdWs ,
0
t0
or solving for Xt we obtain
t
0 0
Xt = e-(t-t )Xt + m(1 - e-(t-t )) + Ãe-t esdWs
0
t0
t
0
= m + (Xt - m)e-(t-t ) + Ãe-t esdWs . (6)
0
t0
Part (b): Taking the expectation of Equation 6 above we find
0
E[Xt] = m + (Xt - m)e-(t-t ) , (7)
0
t
Since E esdWs = 0 because dWs represents a draw from N(0, ds) which
t0
has an zero expectation. To compute the variance of Xt or Var[Xt] first
consider subtracting the mean from Xt to get
t
Xt - E[Xt] = Ãe-t esdWs ,
t0
then squaring this we find
t t
(Xt - E[Xt])2 = Ã2e-2t eu+vdWudWv .
u=t0 v=t0
Now the expectation of this (which is also the variance of Xt) then is
t t
E[(Xt - E[Xt])2] = Ã2e-2t eu+vE[dWudWv] .
u=t0 v=t0
2
Recalling that E[dWudWv] = E[dWu ]´(u - v) = du´(u - v), where ´(·) is the
Dirac delta function. Using this we obtain
Var[Xt] = E[(Xt - E[Xt])2]
t
= Ã2e-2t e2udu
u=t0
Ã2
0
= (1 - e-2(t-t )) . (8)
2
7
Problem 7 (time-dependent Brownian motion)
Part (a): For time-dependent geometric Brownian motion our asset price
St satisfies
dSt = µtStdt + ÃtStdWt , (9)
where now µ and à are functions of the time variable t. This is the general
stochastic differential of the variable St with at = µtSt and bt = ÃtSt. Now
define a function Ć such that Ć = log(St), so by Ito s formula we have
"Ć "Ć b2 "2Ć "Ć
dĆ = + a + dt + b dW
"t "S 2 "S2 "S
2 2
1 Ãt St 1 St
= µtSt + - dt + Ãt dW
2
St 2 St St
2
Ãt
= µt - dt + ÃtdWt .
2
Thus integrating both sides of this expression we have
t t
2
Ãs
log(St) - log(St ) = µs - ds + ÃsdWs , (10)
0
2
t0 t0
or solving for St we have
t t
2
Ãs
St = St exp µs - ds + ÃsdWs . (11)
0
2
t0 t0
Taking the expectation of Equation 10 we have
t
2
Ãs
E[log(St)] = log(St ) + µs - ds , (12)
0
2
t0
where we have used the fact that
t t
E ÃsdWs = ÃsE[dWs] = 0 .
t0 t0
Part (b): To compute the variance of log(St) consider its definition
Var[log(St)] = E (log(St) - E[log(St)])2
8
2
t t t
= E ÃsdWs = E ÃuÃvdWudWv
t0 u=t0 v=t0
t t t t
= ÃuÃvE[dWudWv] = ÃuÃv1´(u - v)du
u=t0 v=t0
0
u=t v=t0
t
2
= Ãudu ,
u=t0
the requested expression.
t
Problem 8 (the differential of etW )
This problem is a direct application of Ito s lemma where one knows the
stochastic differential equation followed by the process Xt and we want the
stochastic differential equation of a function of Xt and t. That is when we
know dXt = adt+bdWt, some values of a and b, then the function Ć = Ć(X, t)
has a differential given by
"Ć "Ć b2 "2Ć "Ć
dĆ = + a + dt + b dW . (13)
"t "X 2 "X2 "X
When the functional form form Ć is Ć(X, t) = etW we have that the stochastic
process followed by X is simply dX = dW and we find the partial derivatives
given by
"Ć
= W etW = W Ć
"t
"Ć "Ć
= = tetW = tĆ
"X "W
"2Ć "2Ć
= = t2etW = t2Ć .
2
"X2 "W
Using these in the above and recognizing that when X = W we have a = 0
and b = 1 we find dĆ given by
1
dĆ = ĆWt + t2Ć dt + tĆdWt
2
1
= Ć Wt + t2 dt + tĆdWt ,
2
as we were to show.
9
Problem 9 (the differential of Zt)
t
t
1 2
To evaluate the differential of the given Zt = exp ¸sdWs - ¸sds ,
s=0 2 s=0
observe that Zt can be considered a function of time only which is in tern a
function of only the variables ¸s and Ws. Thus to compute dZt we will use
the chain rule. Defining a function At as the argument of the exponential i.e.
t t
1
2
At = ¸sdWs - ¸sds ,
2
s=0 s=0
1 2
we have Zt = exp(At), and dAt = ¸tdWt - ¸t dt so At is stochastic with the
2
given differential. By Ito s lemma we have since Zt = exp(At) that
dZ 1 d2Z
dZt = dA + dA2
dA 2 dA2
1
= ZtdA + ZtdA2
2
1 1 1 1
2 2 3 4
= Zt ¸tdWt - ¸t dt + ¸t dWt2 - ¸t dWtdt + ¸t dt2
2 2 2 8
1 1
2 2
H" Zt ¸tdWt - ¸t dt + ¸t dt
2 2
= Zt¸tdWt .
2 2
Since the product ¸t dWt2 ¸t dt in expectation.
t
Problem 10 (the function St = S0eµt+ÃW )
Part (a): Given St = S0 exp(µt + ÃWt) with Wt <" N(0, t) then Ito s lemma
applied to the functional form
Ć = St = Ć(t, Wt) = S0 exp(µt + ÃWt) , (14)
Gives
"Ć "Ć 1 "2Ć
2
dĆ = dt + dW + dW
2
"t "W 2 "W
"Ć "Ć 1 "2Ć
= dt + dW + dt
2
"t "W 2 "W
1
t t t
= µS0eµt+ÃW + ÃS0eµt+ÃW dW + Ã2S0eµt+ÃW dt
2
1
= µÄ†dt + Ã2Ćdt + ÃĆdW .
2
10
So since Ć = St we see that
1
dSt = (µ + Ã2)Stdt + ÃStdWt , (15)
2
as we were to show.
Part (b): Integrating both sides of Equation 15 from t0 to t we find that
t
Ã2 t
St - St = µ + SÄ dÄ + Ã SÄ dWÄ .
0
2
t0 t0
Then taking expectations of the above we find
Ã2 t
E[St] - E[St ] = µ + E[SÄ]dÄ , (16)
0
2
t0
since the expectation of the second term is zero.
Part (c): Note that Equation 16 is an integral relation for E[St]. To solve
for E[St] we can convert this into a differential equation for E[St] that we
can then solve. Taking the derivative of Equation 16 with respect to time we
find
dE[St] Ã2
= µ + E[St] .
dt 2
The solution to this equation is
Ã2 Ã2
µ+ t µ+ t
2 2
E[St] = E[S0]e = S0e ,
as we were to show.
Problem 11 (an integration by parts identity)
This problem looks like Ito s product rule in two dimensions. Let Ć = XtYt
then from the product rule expression discussed in the book recall that dĆ is
given as
2 2
"Ć "Ć 1 "2Ć
dĆ = dX1 + dX2 + E dXidXj , (17)
"X1 "X2 2 "Xi"Xj
i=1 j=1
from which for when Ć = XtYt we obtain the result
d(XtYt) = XtdYt + YtdXt + E[dXtdYt] ,
11
Then integrating both sides of this expression from t to t0 gives
t t t
XtYt - Xt Yt = XsdYs + YsdXs + E[dXsdYs] ,
0 0
s=t0 s=t0 s=t0
which on rearranging gives the desired expression.
12
Wyszukiwarka
Podobne podstrony:
Gupta, Ardra, Gupta () Computer related illnesses and Facebook syndrome2002 03 Using and Setting Up JavaMary and?by Maryja z dzieciątkiemAnalysis of ADN, Its Precursor and Possible By Products Using Ion ChromatographyFound And Downloaded by AmigoFound And Downloaded by AmigoFound And Downloaded by AmigoAdvantages and disadvantages of computersFound And Downloaded by AmigoFound And Downloaded by AmigoFound And Downloaded by AmigoFound And Downloaded by AmigoFound And Downloaded by AmigoFound And Downloaded by Amigo22 The climate of Polish Lands as viewed by chroniclers, writers and scientistswięcej podobnych podstron