Simple price models

advertisement
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
Líkön og mælingar – Fjármálaafleiður
1.3
Simple stock price
models
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.
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.
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.
Líkön og mælingar – Fjármálaafleiður
1.7
The normal distribution
• Standardized form:
1  x2 / 2
 (0,1) 
e
2
• 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.
Líkön og mælingar – Fjármálaafleiður
1.8
Basic Wiener processes
S(t) - Wiener processes
1,500000
1,000000
Value
0,500000
0,000000
-0,500000
0
0,2
0,4
0,6
0,8
1
-1,000000
-1,500000
Time (years)
• Advantage: Allows fluctuations with time.
• Limitation: Doesn’t show an average drift with time.
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
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):
N
S(t)  S(t 0 )  μT  σ Δt  εi
i 1
• The change in S after a period T is normally
distributed, has a mean =T and a variance =2 T.
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
2,5
2,0
Value
1,5
Wiener
1,0
Linear
0,5
Gen. Wiener
0,0
-0,5 0
0,2
0,4
0,6
0,8
1
-1,0
Time (years)
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
Líkön og mælingar – Fjármálaafleiður
1.13
More realistic considerations
• In model 2,
N
S(t)  S(t 0 )  μT  σ Δt  εi
i 1
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
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:

2
d( ln S)   μ' dt  σε dt
2 

• The change in ln(S) after a period T is
normally distributed, has a mean =(’-2/2)T
and a variance =2 T.
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
ν  S(t 0 )e μ 'T
η  S (t 0 )e
2
2 μ 'T
(e
σ 2T
1 )
• How to calculate S:
(μ '  σ 2 / 2 )t σε t
Si  Si 1e
• Note: ’=/S(t0 ) gives a higher change than wished
for. A better result is gotten with ’=ln(/S(t0 ))
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-1eui.
• An estimate of the variance of the ui ‘s (one interval)
2
N
N
N
is:
1
1
1


2
2
est 
  ui 
 (ui  u ) 
 ui 
N  1 i 1
N  1 i 1
N ( N  1)  i 1

• The variance (one interval) is =2t, so an estimate
of the volatility for a period T=Nt is:
 est 
est
t

Nest
 Nest
T
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.
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
a
xy  x y
x  x
2
2
b  y a x
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
y1   2 ln x1 cos( 2πx2 )
y2   2 ln x1 sin( 2πx2 )
• In model 3, the rise/fall tends to be
overestimated if we use the obtained from
linear fitting.
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 filename
open (INFILE,$file_in);
#Relate INFILE with filename
@ALL = <INFILE>;
#Read all the data into a vector
close (INFILE);
#Close the infile
open (OUTFILE,">" . $file_out);
#Open for output
for($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 time
print (OUTFILE "$day_norm\t$price\n"); #Output data
}
close (OUTFILE);
#Close the outfile
--To debug code, type: perl –wc program.pl
To run code, type: ./program.pl infile.dat
Líkön og mælingar – Fjármálaafleiður
1.21
Gnuplot
set terminal postscript landscape "Times-Roman" 22
set output “plot.ps“
set title “Title“
set ylabel "Value (kr/share)“
set xlabel "Time (years)"
0,-1
#set data style linespoints
set 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+b
fit f(x) ‘data.dat’ via a,b
Líkön og mælingar – Fjármálaafleiður
Download