100
STAT 906: Comp Intensive Methods In Finance •Instructor: Don McLeish office: MC6138 email:[email protected] •Text: available at http://www.stats.uwaterloo.ca/~dlmcleis/s906/

STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

STAT 906: Comp Intensive Methods In Finance

•Instructor: Don McLeish office: MC6138email:[email protected]

•Text: available at

http://www.stats.uwaterloo.ca/~dlmcleis/s906/

Page 2: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Other References• The Mathematics of Financial Derivatives• (Wilmott, Howison, Dewynne) (bookstore)• Monte Carlo: Concepts, Algorithms and Applications.

George Fishman QA298.F57(one day reserve)• Arbitrage Theory in Continuous Time. Tomas Bjork• Mathematics of Financial Markets. R.J. Elliott and P.E.

Kopp (Springer) HG4515.3.E37(one day reserve)• Glasserman, P. (2003) Monte Carlo Methods in

Financial Engineering (Applications of Mathematics, 53) Springer, New York

• Jaeckel, P. (2003) Monte Carlo Methods in Finance, Wiley, New York

Page 3: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Marking

•Marks DISTRIBUTION

– Midterm Test: 20– Project&presentation 40 – Class presentations 40

•Tentative Calendar: Week of

– Sept 15: McLeish=M– Sep 22 : M,A,B– Sep 29 : M,C,D– Oct. 6: M,E,F– Oct 13: M,G,H– Oct 20: M,I,J– Oct 27: M,A,B– Nov 3 : C,D,midterm– Nov 10 : M,E,F– Nov 17: M,C,D– Nov 24: M,A,B– Dec 1: projects

Page 4: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Contents •A general discussion of simulation.•Example: 2 person game. •Some basic theory of finance (Chapter 2)•How to generate random numbers (Uniform and non-uniform)(Chapter 3)

•Variance Reduction•Quasi Monte Carlo•Simulation and Option valuation•Estimation and Calibration•Sensitivity Analysis•Numerical solutions to PDE’s•..\book\contents.pdf

Page 5: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Course Prerequisites

• Knowledge of (or tolerance of) Stochastic Calculus.

• Some finance knowledge/interest• Computing: Some computer language

(e.g. MATLAB, R, C++)• “Tolerance of”= have taken or willing to

study on side

Page 6: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Simulation: Monte Carlo Methods

•Simulation: Imitation of a real-world process or system. •Model: set of assumptions concerning the operation of the system•Monte Carlo:simulation of random phenomena

•Parameters: numerical values associated with the model•Why use simulation? •Permits changing model and parameters, examining interactions, changes to system,

Page 7: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Option

• Gives the holder the right (no obligation) to buy or sell an asset at a prescribed price,time determined by the contract.

• e.g. a (European) call option on IBM stock. exercise price $120. expiry date Oct 20, 2003. If S=stock price on Oct 20 the value of option on expiry is max(S-120,0)

Page 8: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Uses of financial derivatives

• Speculate on a rise (call option) or fall (put option) in asset price.

• Hedge a portfolio already held-e.g. a promise to deliver IBM stock at point in future. Insurance against disadvantageous moves in asset prices, currency exchange rates, interest rates, credit changes, weather, electricity demand, …...

Page 9: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Asset prices as random variables

• Random models often applied to complex systems which are essentially causal with many factors influencing result in a complex way. e.g. Brownian motion, toss of coin, currency exchange rates, …

• What are the constants---- a dollar and if so whose…..? Choice of “numeraire”.

Page 10: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Why use simulation?

•Permits experimenting with the controllable system parameters to identify optimal settings•Permits examining effect of environmental or exogenous changes.

•Identify which of several systems is most efficient•Determine which variables are most important.•Verify and check robustness of analytic solutions.

Page 11: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Advantages of Simulation

•investigate effects of changes, new designs, new models, etc. without costly implementation.•Stress testing: test systems under different scenarios (e.g. higher interest rates, different exchange rates)

•“What if” questions.•NON-FINANCIAL •Identify bottlenecks in systems and rectify•Increase experience with complex system at lower cost.

Page 12: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Disadvantages

•Two models for same process may differ. •Simulation output is random so hard to interpret results. •Building models and running simulation is time consuming

•ANALYTIC SOLUTIONS, IF AVAILABLE, SHOULD BE USED! (analytic solutions to a similar (simpler) model can be used to improve a simulation)

Page 13: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Non Finance Applications

•Manufacturing systems: e.g. material handling, inventory, assembly plants, scheduling, •Public Systems: health care- hospital management, emergency room, Military

•Natural resource management, transportation, traffic systems, airport (e.g. Motorway)•Construction systems: project planning, scheduling, •entertainment: restaurants, movies etc.

Page 14: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Types of Systems

•State variables: determine the state of the system in order to simulate future events.•Discrete: state variables change only at discrete time points. (discrete event simulation)

•Continuous: state variables change continuously over time •Stochastic, deterministic

Page 15: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Example (Discrete): Bank queue

•Interested in required number of tellers.•State variables: number of tellers available, number of customers in bank, (possibly also the time in service of customers being served)

Page 16: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

EXAMPLE: QUEUE

•Calling population•queue (waiting line)•server(s)

Page 17: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

One-server queue

Page 18: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Examples of queueing systems

•Repair facility(garage, mechanics, etc.)•hospital, airport,production line, job shop, computer, telephone, ticket office, grocery store, taxi, mass transit, warehouse

•Identify the customers and the server(s) in each.

Page 19: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Example (continuous-time model):TSE300 index.

•X(t) = TSE300 index at time t. Changes (almost) continuously in time•On what present values does the future depend? (state variables) : Current value of index

•possibly other factors depending on model (e.g. interest rates, exchange rates, balance of trade, agricultural prices, forest product prices, kitchen sink …)

Page 20: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Steps in contructing a simulation

•Formulate Problem (why do a simulation?)•Set objectives•suggest candidate models.•Collect real data-identify most appropriate model

•Computer implementation of model (code or program)•Verify model (i.e. debug)•validate model (i.e. accurately represents system?)

Page 21: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Designing Simulation

•Design the simulation-what alternatives are to be simulated? How long a run- what data is collected etc.•Run simulation and analyse output.

•More runs? •Change model? •Change parameters? •Document•report on results Conclusion

Page 22: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Prisoner’s dilemna• non-zero-sum game called the "Prisoner's Dilemma" (Axelrod, 1984). The two players choose between two

moves, either "cooperate" or "defect". The idea is that each player gains when both cooperate, but if only one of them cooperates, the other one, who defects, will gain more. If both defect, both lose (or gain very little) but not as much as the "cheated" cooperator whose cooperation is not returned. The whole game situation and its different outcomes can be summarized below. Points=payoff to A

• The game got its name from the following hypothetical situation: imagine two criminals arrested under the suspicion of having committed a crime together. However, the police does not have sufficient proof in order to have them convicted. The two prisoners are isolated from each other, and the police visit each of them and offer a deal: the one who offers evidence against the other one will be freed. If none of them accepts the offer, they are in fact cooperating against the police, and both of them will get only a small punishment because of lack of proof. They both gain. However, if one of them betrays the other one, by confessing to the police, the defector will gain more, since he is freed; the one who remained silent, on the other hand, will receive the full punishment, since he did not help the police, and there is sufficient proof. If both betray, both will be punished, but less severely than if they had refused to talk. The dilemma resides in the fact that each prisoner has a choice between only two options, but cannot make a good decision without knowing what the other one will do.

Page 23: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Example: Simulate the Prisoner’s Dilemma.

•Payoff matrix•Prisoners Alf and Butch either confess or not. Payoffs taken from table: A chooses row (don’t confess/ confess) •B chooses column (don’t confess/confess)

•Payoff (to Alf)•cooperate: 5 -10•Defect 10 0•(to B)•cooperate defect• 5 10•-10 0

Page 24: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Summary of game& simulation results.

[p,q,val]=nonzerosum(A,B,100)A =

5 -1010 0

B =5 10

-10 0

>> [p,q,val]=nonzerosum(A,B,100)p = 0 1q = 0

1val = 0 0

Page 25: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

TWO PERSON GAME-MATLAB CODE

• [p,q]=nonzerosum(A,B,nsim)• n=size(A); p=ones(1,n(1)); % q=ones(n(2),1);

• for i=1:nsim• [m,s]=max(A*q); p(s)=p(s)+1;• [m,s]=max(p*B); q(s)=q(s)+1;• end• p=p-ones(1,n(1)); p=p/sum(p);• q=q-ones(n(2),1); q=q/sum(q);

Page 26: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Another two-person game.

•Payoff matrix•Two companies A and B each choose bid . Payoffs taken from table:

•Payoff to A•A’s Bid Payoffs•12 3 2 -2•13 1 -4 4•14 0 -5 6•Payoff to B•B’s bid B1 B2 B3• -1 -2 3• 0 4 -6• 0 5 -5

Page 27: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

OUTPUT

• [p,q]=nonzerosum(A,B,50000)• p = 0.6667 0 0.3333• q = 0 0.53334 0.46666

• and the value of the game• 0 to A and 0.3333 to B.

Page 28: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Generating random bid

• Generate a uniform [0,1] random variable.• If U<2/3, then bid $12,• otherwise bid $14.

Page 29: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Random Numbers

•Almost all random numbers are generated from uniform [0,1] random numbers•Uniform [0,1] random numbers X are generated from discrete uniform{0,1,….m-1} random numbers, m large.

•We then convert discrete uniform to continuous U[0,1] using (U=X+0.5)/m

Page 30: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Example: Monte Carlo Integration

•Notice that

4/13/1

1

0

)1()(

ref(x)dx whe

xxxf

Find

−=

∫.t independenfor )(

n1

averagerun longnExpectatio1].uniform[0, is

)]([)(

1

1

0

i

n

ii UUf

Uwhere

UfEdxxf

=

=

=

Page 31: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Graph of function

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.1

0.2

0.3

0.4

0.5

0.6

0.7

Page 32: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

One-Dimensional Monte-Carlo Integral-Variance of error

nUf

UUfn

UUfEduuf

i

n

ii

))(var( variancehasIt

estimator. unbiasedan is This

. variablesrandom 1]uniform[0,t independen are where)(1 isestimator theCarlo, Monte crude Using

variable.random 1]uniform[0,

a with )]([)(

form theof integralan estimatingConsider

1

1

^

1

0

=

=

=

θ

Page 33: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Monte Carlo integration in Excel

• Put =RAND() in cell A1• Copy to cells A2:A20• put =A1^(1/3)*(1-A1)^(1/4) in cell B1• copy to cells B2:B20• in any cell you wish put

=AVERAGE(B1:B20) for mean of values in column B.

• Similarly =STDEV(B1:B20)• and =STDEV(B1:B20)/SQRT(20)

Page 34: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Worksheet for integral0.727331 0.64986 0.587992 0.103846 0.0232210.332666 0.6262610.325482 0.6233860.766509 0.636170.097599 0.4487440.735855 0.6472290.038771 0.3351270.982999 0.3590330.246993 0.5844690.931513 0.499610.603536 0.6705820.54235 0.670749

0.627847 0.6688030.293298 0.609180.688517 0.6596750.132834 0.4923740.77347 0.63328

0.460555 0.6618310.323538 0.6225910.682537 0.660894

Page 35: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Matlab Code for integral

• u=rand(1,1000000);• mean(u.^(1/3).*(1-u).^(1/4))• (Answer=.57325, se=.00011) • true value approx .57326)• How much error is there? • Can we decrease the error? • script2

Page 36: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Standard Error of Estimator

• The standard error is the square root of the variance of the estimator

• se=sqrt(var(fn(U))/length(U));• This gives standard error of estimator. • An approximate 95% confidence interval is estimate +-2

se

))((n

1Error Standard

))((1))(1(1

i

n

iii

UfVar

UfVarn

Ufn

Var

=

=∑=

Page 37: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Changing Variables to obtain integral over [0,1]

U[0,1].is where

]1)11([1)11(

becomes integral above The

1,11, 1

1Let e.g.- variablesChange

[0,1].over integralan it toconvert toneed we variable,random 1]uniform[0, a using valueexpectedan toconvertingby

)(

integrate wish to weIf

2

1

02

2

0

UUU

fEduuu

f

duu

dxu

xx

u

dxxf

−=−

−=−=+

=

∫∞

Page 38: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Example: A double integral

dww

dydzz

dx

yw

xz

yxyxg

g(x,y)dxdy

22

33

0 0

1 and 11

1 and 1

1Put

11),(

where

2.1362)approx value(true :Evaluate

−=−=

+=

+=

++=

∫ ∫∞ ∞

Page 39: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Integral as an expected value

]1,0[t independen are ,)1()1(

),(

where)),(()1()1(

111111

333333

1

0

1

0333333

1

022

1

00 0

UWZwzwzwz

zwwzh

WZhE

dzdwwzwzwz

zw

dzdw wz

)w

,z

g( g(x,y)dxdy

−+−+=

=

−+−+=

−−=

∫ ∫

∫∫∫ ∫∞ ∞

Page 40: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Matlab Code for integral

• w=rand(1,1000000);• z=rand(1,1000000);• f=(z.*w)./(w.^3.*z.^3+w.^3.*(1-z).^3+(1-w).^3.*z.^3);• mean(f)• sqrt(var(f)/1000000)• (gives 2.1399 and SE=.0019)

Page 41: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Example: estimating pi

• Estimate pi by randomly generating points in square and counting how many fall in unit circle.

• Matlab code:• u=rand(1000000,2);• 4*mean(u(:,1).^2+u(:,2).^2 <1)

4]1P[U

then U[-1,1]indep are , If

22

2 1

21

π=<+U

UU

Page 42: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Estimating Pi (picture)

-1 -0.8 -0.6 -0.4 -0.2 0 0.2 0.4 0.6 0.8 1-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

Page 43: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Example: 3 Monte Carlo estimators of pi.

Page 44: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Stat 906 Class Random Number Generator

• Write down five digits “randomly selected” from {0,1,2,…,9}.

• e.g. 12345

Page 45: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Some elementary tests:

•N=number of digits equal to 7 is binomial(5n,1/10) where n=number in class. •

•Probability at least one digit repeated=1-probability all different =

nSD

n

n

209

209)

1011)(

101(5n)(Variance

2n1)

101)(5( valueExpected

=

=−=

== 6976.010

6*7*8*9*101 5 =−

Page 46: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Basic Theory of Finance: The No Arbitrage Principle

• Can I Make money with positive probability with net investment of $0??( this is called an arbitrage)

Page 47: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

One stock, One bond, one period

• Assume stock presently worth $s will be worth su or sd after one month where d<1<u.

• A bond, presently worth $1 goes to $(1+r)over the next month

• Buy x bonds and y shares of stock.• Value in 1 month =x(1+r)+ysu• or x(1+r)+ysd depending on whether

stock goes up or down.

Page 48: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Possible stock movements.

Page 49: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Find an arbitrage

• Can you find values of (x,y) so that the net cost is $0 (e.g. sell short bonds and buy stocks) so that you are certain you will not lose money and you make a positiveamount with positive prob. i.e. both x(1+r)+ysu>=0 and

• x(1+r)+ysd >=0 with one >0.• For net investment =0, need sy=-x.

Page 50: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Condition for no arbitrage

• Arbitrage IS possible UNLESS• d<1+r<u• i.e. $1 in stock either returns more (u) or

less (d) than bond. In this case, the bond return is a CONVEX linear combination of the stock returns.

• THAT IS 1+r=qu+(1-q)d for some 0<q<1.

Page 51: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

RISK NEUTRAL MEASURE

• Solve for q: • q=(1+r-d)/(u-d)• The distribution which assigns probability

q to the stock rising to su and probability • 1-q to the stock falling to sd is the risk

neutral measure, denoted Q.

Page 52: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Expected value of stock price under Q

If there is to be no arbitrage, there exists a probability measureQ such that the expected price of future value of the stock S1 discountedto the present using the return from a risk-free bond is exactly the present valueof the stock.

Denote by Q the probability distribution which puts probabilities q and 1 − qon these points su, sd.

Page 53: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Risk neutral measure

• consensus investors' attitude to risk avoidance. It is not necessarily true that the expected value of S1 under the actual probability distribution P describing the future probabilities of the stock is equal to s, only the expected value under Q.

Page 54: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

DerivativesDerivatives are investments which derive their value from that of a corresponding asset, such as a stock. A European call option is an option which permits you (but does not compel you) to purchase the stock at a fixed future date ( the maturity date) or for a given predetermined price, the exercise price of the option). For example a call option with exercise price $10 on a stock whose future value is denoted S1, is worth on expiry S1 − 10 if S1 > 10 but nothing at all if S1 < 10. The difference S1 − 10 between the value of the stock on expiry and the exercise price of the option is your profit if you exercises the option, purchasing the stock for $10 and sell it on the open market at $S1.However, if S1 < 10, there is no point in exercising your option as you are not compelled to do so and your return is $0. In

Page 55: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Replicating a Contingent ClaimA function of the stock price V (S1) which may represent the return from aportfolio of stocks and derivatives is called a contingent claim. V (S1) represents the payoff to an investor from a certain financial instrument or derivative when the stock price at the end of the period is S1.In a complete market, there is an investment solely in the stock and bond which reproduces these values V (su) and V (sd) exactly.

Page 56: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Discounted Expected value under Q

Page 57: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Recap

• Under the Q measure, the expected discounted-to-present value of any marketed asset (stock or option) is its present price.

• The Q measure is uniquely determined by this property in a complete market.

Page 58: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Multiperiod Models

• When an asset price evolves over time, decisions about an investment are made at various periods during the life of investment.

• Decisions made with the benefit of information including the price of the asset and any related assets at all previous time periods, beginning at some time t=0 when we started observing the process.

Page 59: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

The “history” sequence. • When an asset price evolves over time, the investor normally makes

decisions about the investment at various periods during its life. Such decisions are made with the benefit of current information, and this information, whether used or not, includes the price of the asset and any related assets at all previous time periods, beginning at some time t = 0 when we began observation of the process. We denote this information available for use at time t as Ht. Ht is what is called a sigma-field generated by the past. There are two fundamental properties of this sigma-field

1. the sigma-fields increase over time. In other words, our informationabout this and related processes increases over time because we have

observed more of the relevant history. In the mathematical model, we do not “forget” relevant information

• Ht includes the value of the asset price Sτ , τ · t at all times τ · t. In measure-theoretic language, St is adapted to or measurable with respect to Ht.

Page 60: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

In general, under Q, the discounted stock price is a

martingale

Page 61: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Martingales

Page 62: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Recap II

• Prices of derivatives (in a complete market) determined, not by actual distribution of stock, but by risk neutral measure Q.

• Under Q, the discounted price of any marketed security (stocks and options) are martingales.

• This martingale measure Q is unique in a complete market.

Page 63: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Determining Q from derivative prices.

Page 64: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Possible stock movements

Page 65: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

• At each node, assume probability stock

• so discounted price is a martingale.• Leaves us 4 parameters, the probability it

moves up at each of four nodes.

.11

wheredown movesy probabilit and is up moves

duc

cpp ii

−−=

=

Page 66: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Equating option prices with discounted expectation

Page 67: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

• In this case we can solve for all four unknowns ( the p’s)

• What if there are only two options sold on this stock--say the first two?

• This is an incomplete market since market prices do not uniquely determine Q

• Can use principle of maximum entropy(minimum cross-entropy)

Page 68: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Entropy

• For a discrete distribution, such that P[X = x] = p(x), the entropy may be defined to be

Page 69: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Discrete analogue to Normal

Page 70: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Sum of values on two dice compared with max entropy

distribution

Page 71: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Monte Carlo Price

Page 72: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc
Page 73: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Generating S from a discrete uniform

Page 74: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Congruence modulo mReduction Modulo m

For positive integers a and m, the value a (mod m) is the remainder (between 0 and m-1) obtained when a is divided by m.

So 7( mod 3)=1 .

Page 75: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

A Linear congruential pseudo-random number generator

• Start with seed• and certain constants a,c,m• Repeat• Note that

0x

0,1,...n ),mod()(1 =+=+ mcaxx nn

}1,...,2,1,0{ −∈ mxn

Page 76: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Example.Example: Linear (or mixed) congruential generator

Page 77: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Matlab Code for linear congruentialgenerator (m small)

• function x=lcg(x0,a,c,m,)• y=x0; x=[]; • for i=1:n • y=rem(a*y+c,m); x=[x y];• end

Page 78: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Better linear congruentialgenerators

• Period =length of sequence before it repeats• =8 for the last generator ( in which m=8).

• Better to choose m large, near word-length e.g.

• Want period large and random-looking behaviour

machine.bit 32 afor 12 31 −

Page 79: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Example (script3)

• Consider (x0,a,c,m,n)=(1,33,1,m,2^10).

• Plot the values of x(i-1) versus x(i) for m=50,500,1100. Do they appear random? What if c=113 or a=113?

• x=lcg(1,33,1,m,2^10);• n=length(x);• plot(x(1:n-1)),x(2:n),’.’);

Page 80: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Multiplicative CongruentialGenerators

script3b

Page 81: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

example

• Consider (x0,a,c,m,n)=(1,33,1,m,2^10).

• Plot the values of x(i-1) versus x(i) for m=50,500,1100. Do they appear random? What if c=113 or a=113?

• x=lcg(1,33,1,m,2^10);• n=length(x);• plot(x(1:n-1)),x(2:n),’.’);

Page 82: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

More random if we use only a fraction of the period.

• For example a=397, m=1024, c=1 if we plot only the first 200 or so, they look more or less randomly placed.

Page 83: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Full period Linear CongruentialGenerators (script3b)

.1 divides alsoit divides 4 If )(1 divides also offactor primeEach (b)

prime relatively are and (a) ifonly and

if period thishasIt . period possible maximum has) )(mod(

generator alcongruentilinear The .

1

−−

+=+

amcam

mc

mmcaxx

THEOREM

nn

Page 84: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Various linear congruentialgenerators

Page 85: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Recent Generators: MersenneTwister

From Matsumoto and Nishimura (1998). A twisted Generalized Feedback Shift Register with period 2^19937 - 1 and equidistribution in 623 consecutive dimensions (over the whole period). The "seed" is a 624-dimensional set of 32-bit integers plus a current position in that set.

This is the default in R although there are other options.

See their web page:math.keio.ac.jp/~matumoto/emt.html

Page 86: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Recent Generators: Marsaglia-Multicarry

• A multiply-with-carry RNG recommended by George Marsaglia. It has a period of more than 2^60 and has passed all tests (according to Marsaglia). The seed is two integers (all values allowed).

Page 87: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Testing uniform generators: runs(up) test

Page 88: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Runs Test...

t!significan So

14,13.118

53)(

14nfor ,93

12)(

normalely approximat is R largen For

==−

=

==−

=

nnRSD

nRE

Page 89: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Runs test on Mersenne Twister

• u<-runif(100000)• n<-length(u)• v<-u[1:n-1]<u[2:n]• r<-sum(v[1:99998]!=v[2:99999])• er<-(2*n-1)/3• s<-sqrt((3*n-5)/18)• z=(r-er)/s

Page 90: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

The chi-squared Test.

Page 91: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Chi-squared test. Example.

Page 92: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Example (cont)

•N1=7, N2=5, N3=2, N4=2•All P(Ai)=1/4

Page 93: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

The poker test.

•E.g. .123 .112 .344 .977 .882 .234 .788 .835 .854 .444•Are there too many repeated digits?????•Probability all digits different=

Page 94: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Poker test (cont)

Page 95: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Tests for serial correlation

•Estimate the autocorrelations for the sequence e.g. cor(x(i),x(i+m))•These theoretical values all 0. Determines whether observed values significantly non-zero.

Page 96: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Tests of lattice structure:e.g. a=23,c=0,m=97.

Page 97: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Spectral test.

•e1 is shortest distance between two distinct points on lattice•e2 is shortest vector not spanned by e1. Try to ensure that relative size e2/e1 not too great. Since all generators with common period have common

•area in parallelogram spanned by e1 and e2, we can look at the length of the vector e1 (spectral test statistic). Repeat in 3,4,5,6,7 dimensions (i.e. 3-7 spanning vectors ei)

Page 98: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

In 3 dim. e.g. a=383,c=263,m=10,000

Page 99: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

RANDU in three dimensions

MATLAB.

x=lcg(17,65539,0,2^(31),10000);

plot3(x(1:9998),x(2:9999),x(3:10000),'.')

0,65539,231 === cam

Page 100: STAT 906: Comp Intensive Methods In Financesas.uwaterloo.ca/~dlmcleis/s906/slides1-100.pdf · 2004-09-22 · project planning, scheduling, •entertainment: restaurants, movies etc

Spectral Test results

1. toclose allwith generator Chooses)hyperplane parallelbetween distancemax /()(StatisticTest mck=