Description
Write code to simulate the BAPM and perform analysis as suggested. Notation and so forth
follows as given in Shreve, Stochastic Calculus for Finance vol. 1. Your simulation should
take r; d; u as given, and constant at all time steps. Building in error detection to ensure
these satisfy the no-arbitrage constraint is optional. Might as well take S0 = 1. We will
assume the coin toss distribution is constant over time, but the particular (p; q) values can
be variable. Two special cases are the ìactualî probabilities (p0; q0), and the risk-neutral
measure (~p; q~). Let Fn be the -algebra generated by the Örst n tosses, which covers the
time span f0 k ng. Let ~!n = (!1 !n) 2 fH; Tg
n
denote a particular ëpathíthrough
the Örst n tosses. Assume every stochastic process here, say Xn is adapted to this Öltration.
Your model should cover the time steps f0 n Ng. When you perform a Monte Carlo
simulation, M is the number of samples used (i.e., for purposes of Monte Carlo, you repeat
the experiment M times and average over those results).
There are two types of derivatives: one type has a payout VN = VN (SN ) that depends only
on the Önal value of the security; this is called ëpath independentí. Another type can depend
on the values of the security over the whole time span, i.e., VN = VN (S0; S1; ; SN ). Here
we will only build out simulation for the case of path-independent payouts, so feel free to
write your code assuming that condition holds. [A more complete BAPM simulation would
have to be able to handle the more general case.]
Finally, in what follows, for any stochastic process Xn, the discounted process is X~
n =
1
(1+r)
n Xn.
1. Distributions: Before you start coding: Assuming the coin-toss distribution (p; q),
Önd the distribution of Sn. That is, list all the possible values (there are n+1 of them),
and their probabilities. Also, if Rn = log (Sn=S0), show that Rn = cnYn + dn where
Yn binomial (n; p) (Önd the constants cn; dn). Note: In the continuous-time case,
something similar will occur: we will get Rt = log (St=S0) Gaussian (what else?),
and hence the distribution of St will be what is called lognormal.
2. Exact simulation: Assume we have code to compute the payout function V (SN ) for
a path-independent derivative.
(a) Write code to compute V0 = Ep~
V~N
using the known distribution for SN .
(b) Write code to generate one step of the replicating portfolio. If at time n there
are n shares of the stock, and wealth Xn, then the amount Mn = Xn nSn is
held in the money market. From n ! n + 1, the stock price changes from Sn to
Sn+1, and the amount in the money market grows to (1 + r) Mn. Thus, at time
n + 1, the wealth equation states:
Xn+1 = nSn+1 + (1 + r) (Xn nSn)
For this to be a replicating portfolio, Xn = Vn, the price of the derivative at time n,
where at n = N this should matchVN (SN ) exactly. Give ~!n, 0 n N 1, there
are two possibities for ~!n+1, namely (~!nH) and (~!nT). Assuming Vn+1 (~!nH),
Vn+1 (~!nT) are both known, and of course Sn+1 (~!nH); Sn+1 (~!nT); Sn (~!n) are
all known, with given r, the wealth equation yields two linear equations in the
unknowns n (~!n); Xn = Vn (~!n). By running this recursively backwards, you
should be able to derive fn (~!n)gall ~!n, for 0nN1
, and of course X0 = V0. Write
code to do this! Also as you do this, keep track of whether any n or Xn nSn
values are negative (the Örst is short selling the stock, the second is ìshort selling
the money marketî, i.e., borrowing money to buy stock).
(c) Now let us take a speciÖc example to test your code. Take r = 0:05, u = 1:1,
d = 1:01, N = 5, and the derivative a European call option with strike price
K = Ep~ (SN ) (you know the distribution of SN so should be able to Önd a simple
formula for this!) There are only 2
N = 32 paths so it should not be unreasonable
to compute and store the complete set of replicating portfolio values fn (~!n)g.
In any case, compute V0 using each of your two methods, and check that they
match! Question: Do you have to do any short selling the stock or borrowing
from the money market along the way?
3. Monte Carlo simulation: Next is to deal with the case N = 100. There are 2
100
paths, so rather than computing over all paths, we will use a Monte Carlo approach.
So let me Örst describe the code you should create. For Öxed m, and an adapted
stochastic process Xn, we want to compute Yn = Ep~ (Xn+mjFn). What this means
is Yn = Yn (~!n), a function of the path associated with the Örst n tosses. So assume
that is given. You will generate M random paths (!n+1 !n+m) according to the
distribution, compute Xn+m (~!n!n+1 !n+m) for each, and average over them to get
Yn. The details of computing Xn+m should be contained in a function that is called by
the Monte Carlo ìwrapperî. It is ok if you have to modify your wrapper code a little
bit in terms of the variables you pass to or receive back from this core function.
(a) As a Örst step, let us check the underlying behavior of your Monte Carlo code. Go
back to the previous case, with N = 5 and r; u; d as given. Taking M = 1; 5; 10; 32,
estimate S0 from SN , and V0 from VN . Note that you are not going through every
path systematically! You are generating paths independently, and so it is possible
(especially in the low order case) the same path will occur multiple times, so even
with M = 32 there is no guarantee you will get all paths! Hence your S0; V0
estimate will not be exact. The idea is to see how close your estimates are for
various M.
(b) Now take the case N = 100. In this case, we should change some of the parameters. Take r = 103
(so over 100 steps there is a total return of about 10%),
u = 1 + 5 103
, d = 1 + 104
. Take di§erent values of M, starting small so your
computer doesnít take too long to run, and increasing it somewhat. We want to
hopefully see an e§ect of increasing M, without forcing you to run simulations
overnight! First, as a check, we know we should get S0 = Ep~
S~N
and fortunately we know S0 = 1. See how this works for various M. Next, again let V (S
be a European call with K = Ep~ (SN ) [Note: Careful, this is not the discounted
value, since the strike price applies at tine N; also we are computing the expectation assuming p~; there is nothing formal here, this is just a SUGGESTION I am
making so you have a reasonable value K that lies somewhere between min SN
and max SN ] Compute V0 = Ep~
V~N
for the same M as before. Also compute
V10 assuming the Örst ten tosses are all heads, and again assuming all are tails.
Last thing to do: instead of using p~, take two cases for the ìactualîprobabilities:
p0 = 0:9~p, and p0 = 1:1~p. For each case, compute Ep0
S~N
, and compare with
S0, and Ep0
V~N
. In the latter case, if the answer with p0 is below V0 then
you should not have purchased the option (putting the cash into a money market
would have been better), if above V0 then purchasing the option gave you a higher
return than stashing you money in the money market 😀 So last question: even
if I told you that your expected return was better than putting it into a money
market, you may still have decided not to purchase this option. Why not? Hint:
Even if you know p0 (which in this case would lead to this result), we still donít
have an arbitrage here. What does that mean?
3