80 likes | 402 Views
Financial derivatives Numerical methods. The Black-Scholes equation. The value, f , of a derivative is: Dividing the possible values of t and S into a grid: t i =i D t and S j =j D S and using the explicit finite difference method, we write:. Numerical equation.
E N D
Financial derivativesNumerical methods Líkön og mælingar – Fjármálaafleiður
The Black-Scholes equation • The value, f, of a derivative is: • Dividing the possible values of t and S into a grid: ti=iDt and Sj=jDS and using the explicit finite difference method, we write: Líkön og mælingar – Fjármálaafleiður
Numerical equation • Inserting into the BS equation, and rewriting, we get: where: Líkön og mælingar – Fjármálaafleiður
Assignment 3 • Write programs that calculate and display the value of an European call option according to the Black-Scholes model. • Draw 3-D graphs for f as a function of t and S. • Use the exact solution and the boundary conditions. • Use K=40, r=0 and = 0, 0.5 and 1.0 (3 graphs). • Use 0 S 100 and 0 t* 1, (t*=T-t). • What is the effect of ? Líkön og mælingar – Fjármálaafleiður
Tips (1) Boundary conditions: • If S(t)=0 for all t, then f(0,t)=0 for all t (or t*). $f[$j=0]=0 for all t*=$i*$dt. • When S, then f(S,t). $f[$j=$jmax]=$jmax*$dS-$K where $jmax=$Smax/$Sdiv. • When t=T (t*=0), then f(S,T) = max(0,S-K) For (t*=0), we print out f(S,T) = max(0,S-K) We then use a temporary vector $f_next[$j]=&max(0,$j*$dS-$K); and calculate$f[$j] using $f_next and then set $f_next[$j]= $f[$j] for all $j to get a future value for $f. Líkön og mælingar – Fjármálaafleiður
Tips (2) • Warning: the terms in the parenthesis for the parameters a, b and c should not be negative. Choose the grid for S so that j does not become too large (and maybe different jmax for different ). • Outer loop for t*, inner loop for S. Líkön og mælingar – Fjármálaafleiður
Tips (3) Local PERL max function # Called by &max(a,b) sub max { $in1 = $_[0]; $in2 = $_[1]; if($in1 < $in2) {$tmp=$in2; } else { $tmp=$in1; } $res=$tmp } Líkön og mælingar – Fjármálaafleiður
Tips (4) 3D graphs in Gnuplot set terminal postscript enhanced "Times-Roman" 22set output "bs_3d.ps"set title "Value of an European call option"set xlabel "S (price/share)" 0,-1set ylabel "t* (years)"set zlabel "f (value/share)"set borderset parametricset dgrid3d 101,31,8set data style linesset hidden3dset contourset nokeyset zero 1e-10set view 75, 10splot "bs3d.dat" using 1:2:3 with lines lw 0.2 Líkön og mælingar – Fjármálaafleiður