líkön og mælingar – fjármálaafleiður 1.1 aðalbjörn Þórólfsson [email protected]

21
Líkön og mælingar – Fjármálaafleiður 1.1 Aðalbjörn Þórólfsson [email protected]

Post on 21-Dec-2015

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Líkön og mælingar – Fjármálaafleiður 1.1 Aðalbjörn Þórólfsson ath@alit.is

Líkön og mælingar – Fjármálaafleiður

1.1

Aðalbjörn Þóró[email protected]

Page 2: Líkön og mælingar – Fjármálaafleiður 1.1 Aðalbjörn Þórólfsson ath@alit.is

Líkön og mælingar – Fjármálaafleiður

1.2

Financial derivatives• Stock price models and parameters (hlutabréfalíkön

og kennistærðir)– Approx. 2 weeks– Simple models– Stochastic behavior (slembiferli)

• Financial derivatives (fjármálaafleiður)– Approx. 2 weeks – Introduction– The Black-Scholes model

• Bank visit and other material– Approx. 1 week

Page 3: Líkön og mælingar – Fjármálaafleiður 1.1 Aðalbjörn Þórólfsson ath@alit.is

Líkön og mælingar – Fjármálaafleiður

1.3

Simple stock price models

Page 4: Líkön og mælingar – Fjármálaafleiður 1.1 Aðalbjörn Þórólfsson ath@alit.is

Líkön og mælingar – Fjármálaafleiður

1.4

Price model 1

• The value of a stock at a given time t [t0,T] is supposed to be a continuous real function:

S : [t0,T] R

• The value of S(t0) is known.

• The change in value with time is constant:

dS = dt

or

S(t) = S(t0) + (t- t0)

• Limitation: Doesn’t allow fluctuations with time.

Page 5: Líkön og mælingar – Fjármálaafleiður 1.1 Aðalbjörn Þórólfsson ath@alit.is

Líkön og mælingar – Fjármálaafleiður

1.5

Stochastic processes

• A variable whose value changes over time in an uncertain way is said to follow a stochastic process (slembiferli).

• In a Markov process, future movements of a variable depend only on where we are, not the history of how we got there.

• Stock prices are usually assumed to follow Markov processes.

Page 6: Líkön og mælingar – Fjármálaafleiður 1.1 Aðalbjörn Þórólfsson ath@alit.is

Líkön og mælingar – Fjármálaafleiður

1.6

Basic Wiener process• A variable Z follows a basic Wiener process

if it has the following two properties:

• The change Z during a small time period t is

Z = t

where is a random drawing from a standardized normal distribution (0,1).

• The values of Z for any two different short intervals of time t are independent.

Page 7: Líkön og mælingar – Fjármálaafleiður 1.1 Aðalbjörn Þórólfsson ath@alit.is

Líkön og mælingar – Fjármálaafleiður

1.7

The normal distribution• Standardized form:

• Mean: = 0. Variance = 1.

• Why the normal distribution?

If X is the mean of N independent measurements of the same phenomena, then the distribution of X becomes normal as N (central limit theorem).

• Examples:– Independent measurements of your height.– Stock price with no drift in the mean with time.

2/2e2

1)1,0( x

Page 8: Líkön og mælingar – Fjármálaafleiður 1.1 Aðalbjörn Þórólfsson ath@alit.is

Líkön og mælingar – Fjármálaafleiður

1.8

Basic Wiener processesS(t) - Wiener processes

-1,500000

-1,000000

-0,500000

0,000000

0,500000

1,000000

1,500000

0 0,2 0,4 0,6 0,8 1

Time (years)

Val

ue

• Advantage: Allows fluctuations with time.

• Limitation: Doesn’t show an average drift with time.

Page 9: Líkön og mælingar – Fjármálaafleiður 1.1 Aðalbjörn Þórólfsson ath@alit.is

Líkön og mælingar – Fjármálaafleiður

1.9

Generalized Wiener process• A generalized Wiener process for a variable S is

defined by:

dS = a dt + b dZ

where dZ (= dt) is defined as before.

• The discrete form is:

S = a t + b t

where is a random drawing from a standardized normal distribution (0,1).

• A special case is b = 0, and we find model 1 for stock price: S = a t

Page 10: Líkön og mælingar – Fjármálaafleiður 1.1 Aðalbjörn Þórólfsson ath@alit.is

Líkön og mælingar – Fjármálaafleiður

1.10

Price model 2• The change in value with time is based on the general

Wiener process:

dS = dt + dZ

or, in a discrete form:

S = t + t

where is defined as before.

• Solution (T=t-t0, N=T/t):

• The change in S after a period T is normally distributed, has a mean =T and a variance =2 T.

N

iiεΔtσμT)S(tS(t)

10

Page 11: Líkön og mælingar – Fjármálaafleiður 1.1 Aðalbjörn Þórólfsson ath@alit.is

Líkön og mælingar – Fjármálaafleiður

1.11

Model comparisons• Model 1 - Linear: S(t) = 1.0 * t

• Basic Wiener (no average drift with time): S(t) = t

• Model 2 - General Wiener: S(t) = 1.0 * t + 1.0 * t

Linear, Wiener and general Wiener behavior

-1,0

-0,5

0,0

0,5

1,0

1,5

2,0

2,5

0 0,2 0,4 0,6 0,8 1

Time (years)

Val

ue

Wiener

Linear

Gen. Wiener

Page 12: Líkön og mælingar – Fjármálaafleiður 1.1 Aðalbjörn Þórólfsson ath@alit.is

Líkön og mælingar – Fjármálaafleiður

1.12

The factor • The factor describes the amplitude of the stochastic

behavior of stocks (volatility (flökt)), and thus how high the associated investment risk is:

dS = dt + dZ

• The factor actually depends on time, but can be taken as a constant when considering relatively short periods.

• The volatility can be estimated by:– The naked eye– Calculating the standard deviation of past data (see later)

sdev = = T

Page 13: Líkön og mælingar – Fjármálaafleiður 1.1 Aðalbjörn Þórólfsson ath@alit.is

Líkön og mælingar – Fjármálaafleiður

1.13

More realistic considerations• In model 2,

the drift and variability terms are independent of S(t).

• However, investors require a certain percentage return:

dS ~ S’ dt or S(t)=S(t0)e’T with ’= /S(t0).

• Also, the volatility term is, to a good appoximation, a percentage of the price:

dS ~ S dt

N

iiεΔtσμT)S(tS(t)

10

Page 14: Líkön og mælingar – Fjármálaafleiður 1.1 Aðalbjörn Þórólfsson ath@alit.is

Líkön og mælingar – Fjármálaafleiður

1.14

Price model 3 (1)

• The change in value is proportional the value:

dS = S’ dt + S dZ

• Result of Ito’s lemma:

• The change in ln(S) after a period T is normally distributed, has a mean =(’-2/2)T and a variance =2 T.

dtσεdtμS)d(

2

'ln2

Page 15: Líkön og mælingar – Fjármálaafleiður 1.1 Aðalbjörn Þórólfsson ath@alit.is

Líkön og mælingar – Fjármálaafleiður

1.15

Price model 3 (2)• S is log-normally distributed, with a mean

and a variance

• How to calculate S:

• Note: ’=/S(t0 ) gives a higher change than wished for. A better result is gotten with ’=ln(/S(t0 ))

tσεt)/σ(μii S S 2'1

2

e

)(e)e(tSη TσTμ 12'2

02

Tμ)eS(tν '0

Page 16: Líkön og mælingar – Fjármálaafleiður 1.1 Aðalbjörn Þórólfsson ath@alit.is

Líkön og mælingar – Fjármálaafleiður

1.16

Historic volatility

• Let ui=ln(Si /Si-1), i=0,1,...,N. This is the daily return in interval i, since Si=Si-1e

ui.

• An estimate of the variance of the ui ‘s (one interval) is:

• The variance (one interval) is =2t, so an estimate of the volatility for a period T=Nt is:

N

i

N

iii

N

ii u

NNu

Nuu

N 1

2

1

2

1

2est )1(

1

1

1)(

1

1

estestest

est NT

N

t

Page 17: Líkön og mælingar – Fjármálaafleiður 1.1 Aðalbjörn Þórólfsson ath@alit.is

Líkön og mælingar – Fjármálaafleiður

1.17

Assignment 1• Write programs that calculate and display the values of

S(t) according to stock price models 1, 2 and 3.

• Get real one-year data from the web and determine S(t0) and (linear fit). Try to determine by the naked eye and then by using the variance formula. Note that calculated is only comparable to real data in model 3.

• Compare the values /S(t0), and the return/risk ratio: (S(t)-S(t0))/(S(t0)) for two different companies. Are the /S(t0) and the returns comparable?

• Write and return a short report, including graphics and code.

Page 18: Líkön og mælingar – Fjármálaafleiður 1.1 Aðalbjörn Þórólfsson ath@alit.is

Líkön og mælingar – Fjármálaafleiður

1.18

Tips (1)

• Data on bi.is or financialweb.com

• Use for example Excel, Perl and Gnuplot

• One year = 1.

• Linear fit: y = ax + b

xayb

xx

yxxya

22

Page 19: Líkön og mælingar – Fjármálaafleiður 1.1 Aðalbjörn Þórólfsson ath@alit.is

Líkön og mælingar – Fjármálaafleiður

1.19

Tips (2)

• Standardized normal distribution:– If x1 and x2 are random variables between 0 and 1,

then y1 and y2 are standardized and normally distributed if

• In model 3, the rise/fall tends to be overestimated if we use the obtained from linear fitting.

)π2sin(ln2

)π2cos(ln2

212

211

xxy

xxy

Page 20: Líkön og mælingar – Fjármálaafleiður 1.1 Aðalbjörn Þórólfsson ath@alit.is

Líkön og mælingar – Fjármálaafleiður

1.20

Perl#!/usr/bin/perl #Launches the PERL compilator$file_in=$ARGV[0]; #The first argument passed to the program$file_out = "data.dat"; #Assign a filenameopen (INFILE,$file_in); #Relate INFILE with filename@ALL = <INFILE>; #Read all the data into a vectorclose (INFILE); #Close the infileopen (OUTFILE,">" . $file_out); #Open for outputfor($k=1;$k<=$#ALL;$k++) #Loop over vector content{

($date,$day,$price,@rest) = split(/\s/,$ALL[$k]);#Split the fields on spaces

$price =~ s/,/./;#Substitute . for ,$day_norm = $day/365; #Normalize the timeprint (OUTFILE "$day_norm\t$price\n"); #Output data

}close (OUTFILE); #Close the outfile

---To debug code, type: perl –wc program.plTo run code, type: ./program.pl infile.dat

Page 21: Líkön og mælingar – Fjármálaafleiður 1.1 Aðalbjörn Þórólfsson ath@alit.is

Líkön og mælingar – Fjármálaafleiður

1.21

Gnuplotset terminal postscript landscape "Times-Roman" 22set output “plot.ps“set title “Title“set ylabel "Value (kr/share)“set xlabel "Time (years)" 0,-1#set data style linespointsset data style lines#set nokey#set yrange [100:102.3]#set xrange [100:102.3]plot "data.dat“ using 1:2, 4.15 + 0.17*x

---To make a fit, start gnuplot, then type:f(x)=a*x+bfit f(x) ‘data.dat’ via a,b