c++lanquage for financial engineering
TRANSCRIPT
-
8/18/2019 C++lanquage for financial engineering
1/113
Financial Numerical Recipes in C++
CCC++++++ !!!"""###$$$%%% &&&'''((( )))***+++,,,---...
6080
100
120140KOSPI200
0.2
0.4
0.6
0.8!"#
0
20
40
60
$%&'
6080
100
120140KOSPI200
0.2
0.4
0.6
0.8!"#
Bernt Arne degaard
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/
-
8/18/2019 C++lanquage for financial engineering
2/113
2004-9-20
1 2004, !"#
/ Contents
• $%
• &
• '()*(cash flow)
'+ ,-
./ #01(IRR)
23 4563 78
• 9:;8 ?@; 2(2@2)
o AB
o 4CD E> F LM NOPGHI- JK 2@
§
-
8/18/2019 C++lanquage for financial engineering
3/113
2004-9-20
2 2004, !"#
§ xy
§ xyg z\ qr3 4CD
-
8/18/2019 C++lanquage for financial engineering
4/113
2004-9-20
3 2004, !"#
o N/3 ,Q •u
o N/
-
8/18/2019 C++lanquage for financial engineering
5/113
2004-9-20
4 2004, !"#
o &0; ef6(stochastic volatility)
• JK ?r ?@
o &
o JK ?r LMNcO
o ELP(short sales)3 Cl BQ
• 9R AB3 abcd
o 9R AB3 0r
o STU 9R AB3 gV
§ ND tR
§ #043 ND tR
§ NP(c3 ND tR
o 9R AB3 &u
§ Nelson Siegel W#D (1987)
§ Bliss R~ (1989)
§ 3 % X%8
o 9RAB RD(Term structure models)
§ Vasicek R~
§ Cox Ingersoll Ross R~
§ Y813 0r
§ ^_̀ X!"
§ CIR R~k 3l &u
§ Y81
• bu #0 R~Z(BQ/ [AP\ ]^WX)
o Black Scholes RDk 3l bond pricing.
§^_ ̀ X!"
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/
-
8/18/2019 C++lanquage for financial engineering
6/113
2004-9-20
5 2004, !"#
o Rendleman Bartter R~
§ _X ̀ ab\ c2&
o Vasicek R~
• ud ?L3 ij-
o .efX
• C++k Sl gMh p, ij
o p, ij3 k#
o %glmc
o ( CnnX!opq cl Cnn2•
o #a 9r
§ [#W#
§ s?t ?
o xu3 f; u3
o for XvgMwM3 &F
o #include 3 AB
o xoX3 Ay
o z{ |Dk zD&3 abcd A'(implementation)
o .efX
• j)
• VD ;8
• }b ~•
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/
-
8/18/2019 C++lanquage for financial engineering
7/113
2004-9-20
6 2004, !"#
/ Introduction
+! "3q Y # q$ %~&\ .Vg $D' #-q 0r2$\ EFk G2 () %~\ &\z.*CX D+,
0r-\[q q.3 /WX 78-\ 0) LT ]B-z. g ~&k&\, (1k jV2\ 3A3 abcdk G2
*CX D+, 0r2\[q •4-5b ,P-b zz.!cb !0\ ^_`3 &l67WX& abcd\ A'2 t8z.
*C X!o9 |D\ D:0WX *;2 tWY, *Cabcd\ ,?2 9 #, >W@ 3V, >D,
Aq\C++X!o9\ NOBz. Aq\ Y # z\ l AC |Dk 3D-[ E, abcd\ FV;WX(generic )
9G-5b gHB[}, 3A3 abcdk G2&\ _X ̀ C++3 STL (The Standard Template Library )q gVY
AB, zIz.!mY, s;JP, KJ (c3 9R ABk Sl abcd) LM-, FV;8 9G) Y # >\ 0\
a8z.() (1 abcdk&\ 9R ABq ND O) '+ ,-q gV-b zz.~C\ 9RABq
0r/&u/R~2Y Img =yJ (g D+-\0gz.Aq\ g ~Cq PQ-9 c2& xoXq u32 9R AB3
9G\ &=2 BR 0gz.}S xoXq LM-, 9G-5b -@ LT T ,Rg UV 0g W 0gz.xoXk Sl
~&\ Aq3 XYg[X/ ̀ k#Y # z, 2D zz.TN abcd\ 9:-b Y&,!0\ *;2t\ ijq ;b
zz.!mY g0Z) "3q cl q[g\, abcd3 u76k S2&\ ts -9 ]Z^X $3 2$,_
`az.bl, t,@ ac[} g ~&\ +i L6U 0g &\
-
8/18/2019 C++lanquage for financial engineering
8/113
2004-9-20
7 2004, !"#
b g 0r3 C++p, ij\
-
8/18/2019 C++lanquage for financial engineering
9/113
2004-9-20
8 2004, !"#
double cash_flow_pv_discrete( vector& cflow_times,
vector& cflow_amounts,
double r){double PV=0.0;
for (unsigned int t=0; t
-
8/18/2019 C++lanquage for financial engineering
10/113
2004-9-20
9 2004, !"#
double x1=0. 0;
double x2 = 0.2;
// create an initial bracket, with a root somewhere between bot, top
double f1 = cash_flow_pv(cflow_times, cflow_amounts, x1);
double f2 = cash_flow_pv(cflow_times, cflow_amounts, x2);
int i;
for (i=0;i
-
8/18/2019 C++lanquage for financial engineering
11/113
2004-9-20
10 2004, !"#
// author Bernt A Oedegaard
#include #include
inline int sgn(double& r){ if (r>=0) {return 1;} else {return - 1;}; };
bool cash_flow_unique_irr(vector& cflow_times, vector& cflow_amounts) {
// check whether the cash flow has a unique irr.
int sign_changes=0; // first check Descartes rule
for (unsigned t=1;t,[X ?;Y # zz. gr,R RD3 |l) g0\ vA-7Y, *k& jVY # o?l #a\ jV-[ E\z\ lgz. z{ lU, vw,R RD) 4 o?l #c; [F\ BAlz.
vw,R RDk zD V?IuF\ gV-2 AY # >\ ST #-2@9m(numerical method ) y, gr,R RDWX 2q P@Y
# zz. vw,R RD\ G]-\ RDWX\ Black- Scholes(1973)RDg zb, gr,R RD\ G]-\ RD) Cox, Ross, and
Rubinstein(1979) RDg zz. *C;WX gr,R RDWX 0rU
-
8/18/2019 C++lanquage for financial engineering
12/113
2004-9-20
11 2004, !"#
• AB
• 4CDE> F F
-
8/18/2019 C++lanquage for financial engineering
13/113
2004-9-20
12 2004, !"#
o " (Gamma)
o #(Theta)
o $ (Vega)
o % (Rho)
o Black Scholes UV? abcdA'
• .+ef6(Implied volatility)
o ghijk 3l abcd A'
o Newton- Raphson m abcd A'
0?@
AB
C
89DEF
- GH
.>
E(b\ F)
-
8/18/2019 C++lanquage for financial engineering
14/113
2004-9-20
13 2004, !"#
g0Z) UV? IuF(PDE )3
k Gl S0BQWX u329 #~k, g PDE q J@ p-\
-
8/18/2019 C++lanquage for financial engineering
15/113
2004-9-20
14 2004, !"#
#include // mathematical library
#include "normdist.h" // this defines the normal distribution
double option_price_call_black_scholes( double S, // spot price
double X, // Strike (exercise) price,
double r, // interest rate
double sigma,
double time)
{
double time_sqrt = sqrt(time);
double d1 = (log(S/X) +r*time)/(sigma*time_sqrt) + 0.5*sigma*time_sqrt;
double d2 = d1- (sigma*time_sqrt);
double c = S * N(d1) - X * exp(- r*time) * N(d2);
return c;
};
LM=NO
P"Q
':
RP
-
8/18/2019 C++lanquage for financial engineering
16/113
2004-9-20
15 2004, !"#
// author: Bernt A Oedegaard
// The delta of the Black - Scholes formula
#include
#include "normdist.h"
double option_price_delta_call_black_scholes(double S, // spot price
double X, // Strike (exercise) price,
double r, // interest rate
double sigma, // volatility
double time){ // time to maturity
double time_sqrt = sqrt(time);
double d1 = (log(S/X) +r*time)/(sigma*time_sqrt) + 0.5*sigma*time_sqrt;
double delta = N(d1);
return delta;
};
z{ []\ PQR jV2[ E[}, !0Z) &X S0, zz.
UV(#
, Gamma)5
-
8/18/2019 C++lanquage for financial engineering
17/113
2004-9-20
16 2004, !"#
X'( , Vega)
ef6(volatility )k Gl UV?\ Dlz. y, ef6(volatility )3 e2k G2&
-
8/18/2019 C++lanquage for financial engineering
18/113
2004-9-20
17 2004, !"#
double time, // time to maturity
double& Delta, // partial wrt S
double& Gamma, // second prt wrt Sdouble& Theta, // partial wrt time
double& Vega, // partial wrt sigma
double& Rho){ // partial wrt r
double time_sqrt = sqrt(time);
double d1 = (log(S/X) +r*time)/(sigma*time_sqrt) + 0.5*sigma*time_sqrt;
double d2 = d1- (sigma*time_sqrt);
Delta = N(d1);
Gamma = n(d1)/(S*sigma*time_sqrt);
Theta =- (S*sigma*n(d1)) / (2*time_sqrt) - r*X*exp( - r*time) *N(d2);
Vega = S * time_sqrt * n(d1);
Rho = X * time * exp(- r * time) * N(d2);
};
)&`a2
(implied volatility)
\ e#\ 9/qr ,Q3 ]9
U%Ygz.E13 ~C\, $D' ST-X/ ̀ ef6(volatility )\ 0r-\ 0gz .8q Z@ ,|k& 7o2b z\
E;gz. ,| 67l Im) ghijX ^;2 Y,\ Imgz.
6 s;`O~z {AYN @| `O~( N_}~- gh •BZi YB. NZRm,`O~I!(volatility smile)- g2 "#p hBZi 2
@.$%-&'(M-R A)+`O~* NO( *+Z_O, eLY@t [email protected] }LCM(-V./, /~wB)g2 s;`O~ m
p WXhBB./~wB- g2 0"1 CNO( e .2+,i @| 8)6F( NO- g2 s; Ò~* [email protected]_q, }[i
s;`O~* d 8)6F@@ @| 34p BNCt ?@. ._2 :U- gh j5Z_O, @62 "#. [Z9t ?@. 26y Z7Wj2-,im NO Q'Bm 4y CM( A)+ `O~B@ 89* ^5LBV 6yt ?@m-.@.}LZ3( 3:+; LBV .M
YN g.* 8 L|2# I~. ?@.`O~ I!m ._2 ?6+; @{p ?rYm-e' [email protected]_, `O~ I!
mZ\BX( 'T2Jh6 LAJh6 6z RBC D9JhV 6yZ IE.@. (F uv(: ( .hG , ch 9. `O~ WXz -=, HI
', pp 102~103, unpublished manuscript )
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/
-
8/18/2019 C++lanquage for financial engineering
19/113
2004-9-20
18 2004, !"#
)&`a2(IV)/ YZ[ \]^_ (binomial search) / b=c(bisection method)
// file black_scholes_imp_vol_bisect.cc// author: Bernt A Oedegaard
// calculate implied volatility of Black Scholes formula
#include "fin_algoritms.h"
#include
double option_price_implied_volatility_call_black_scholes_bisections(
double S, double X, double r, double time, double option_price)
{ // check for arbitrage violations:// if price at almost zero volatility greater than price, return 0
double sigma_low=0.0001;
double price = option_price_call_black_scholes(S, X, r, sigma_low, time);
if (price>option_price) return 0.0;
// simple binomial search for the implied volatility.
// relies on the value of the option increasing in volatility
const double ACCURACY = 1.0e- 5; // make this smaller for higher accuracy
const int MAX_ITERATIONS = 100;
const double HIGH_VALUE = 1e10;
const double ERROR = - 1e40;
// want to bracket sigma. first find a maximum sigma by finding a sigma
// with a estimated price higher than the actual price.
double sigma_high=0.3;
price = option_price_call_black_scholes(S, X, r, sigma_high, time);
while (price HIGH_VALUE) return ERROR; // panic, something wrong.
};
for (int i=0;i
-
8/18/2019 C++lanquage for financial engineering
20/113
2004-9-20
19 2004, !"#
else { sigma_high = sigma; }
};
return ERROR;};
Newton- Raphsonc
ghijk 3l ^;Im G.k, *C g_3 Img 0r=3 wP, `% jV W# zz.65 e#3 IuF3 2
q mq-\r ab- cd(Newton - Raphson )m\ jVY# zz.
\ Tc, JDs Y IuFgz. TN /9- q e&,
g W #([ o-2 0r-@ Uz.
29&, \ u763 hVPgz. pz.
29&, \ ,|k& STU p) >oF\
0r-@ Uz.
ab- cd(Newton- Raphson )m\ jV-9c2&\ p) EF3 ,Q+uk Gl UV?
(greeks )) 0r-\ 0g }[E
-
8/18/2019 C++lanquage for financial engineering
21/113
2004-9-20
20 2004, !"#
)&`a2(IV)/ YZ[ \]^_ / de- fg hc(Newton steps)
// file black_scholes_imp_vol_newt.cc// author: Bernt A Oedegaard
// calculate implied volatility of Black Scholes formula using newton steps
#include "fin_algoritms.h"
#include "normdist.h"
#include
double option_price_implied_volatility_call_black_scholes_newton(
double S, double X, double r, double time, double option_price){
// check for arbitrage violations:
// if price at almost zero volatility greater than price, return 0
double sigma_low = 1e- 5;
double price = option_price_call_black_scholes(S, X, r, sigma_low, time);
if (price >option_price) return 0.0;
const int MAX_ITERATIONS = 100;
const double ACCURACY = 1.0e- 4;
double t_sqrt = sqrt(time);
double sigma = (option_price/S)/(0.398*t_sqrt); // find initial value
for (int i=0;i
-
8/18/2019 C++lanquage for financial engineering
22/113
2004-9-20
21 2004, !"#
3.35i jk'(l mQ no/ p F3 ,Q) g-3 Fk&
$D'z.(Hull, 1997, pg 263 q }BY 0.)
z},
WX lz. b abcd3 A') zI> pz.
// file: black_scholes_price_payout_call.cc
// author: Bernt A Oedegaard
// Calculation of the Black Scholes option price formula,
// special case where the underlying is paying out a yield of q.
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/
-
8/18/2019 C++lanquage for financial engineering
23/113
2004-9-20
22 2004, !"#
#include // mathematical library
#include "normdist.h" // this defines the normal distribution
double option_price_european_call_payout( double S, // spot price
double X, // Strike (exercise) price,
double r, // interest rate
double q, // yield on underlying
double sigma, // volatility
double time) { // time to maturity
double sigma_sqr = pow(sigma, 2);
double time_sqrt = sqrt(time);
double d1 = (log(S/X) + (r- q + 0.5*sigma_sqr) *time)/(sigma*time_sqrt);
double d2 = d1- (sigma*time_sqrt);
double call_price = S * exp(- q*time)* N(d1) - X * exp(- r*time) * N(d2);
return call_price;
};
3.3.2no
:p; qr,-k3 [sg xy8 KCl ST, zz.}S xyWX [sUz@, ,-, `pD qc9 #~k 0r
EF) #u2[ EW@ r Uz. vwxy3 ST\ mng R6-z.g0) [(([ s t 0 p) vw [s3 STh
Gulz.~C\ () xyg gr;WX [sUzb -\ lk zz.
nob st uvl mQ 0?@ 89
9D3 xy3 4CD
-
8/18/2019 C++lanquage for financial engineering
24/113
2004-9-20
23 2004, !"#
vector& dividend_times,
vector& dividend_amounts )
// reduce the current stock price by the amount of dividends.{
for (int i=0;i
-
8/18/2019 C++lanquage for financial engineering
25/113
2004-9-20
24 2004, !"#
• :xy [s5
• :
-
8/18/2019 C++lanquage for financial engineering
26/113
2004-9-20
25 2004, !"#
g # -
Uz.
Roll- Geske- Whaley call89 |v \]^_ }"(RGW)
// file anal_price_am_call_div.cc
// author: Bernt A Oedegaard
// calculate dividend adjusted formula for american call option.
#include
#include "normdist.h" // define the normal distribution functions
#include "fin_algoritms.h" // the regular black sholes formula
double option_price_american_call_dividend(double S,
double X,
double r,
double sigma,
double tau,
double D1,
double tau1)
{
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/
-
8/18/2019 C++lanquage for financial engineering
27/113
2004-9-20
26 2004, !"#
if (D1 0. 0)
&& (S_high1e10) { // early exercise never optimal, find BS value
return option_price_call_black_scholes(S- D1*exp(- r*tau1), X, r, sigma, tau);
};
S_bar = 0.5 * S_high; // now find S_bar that solves c=S_bar- D+X
c = option_price_call_black_scholes(S_bar, X, r, sigma, tau- tau1);
test = c- S_bar- D1+X;
while ( (fabs(test) >ACCURACY)
&& ((S_high- S_low) >ACCURACY) ) {
if (test
-
8/18/2019 C++lanquage for financial engineering
28/113
2004-9-20
27 2004, !"#
/ (sigma*tau1_sqrt);
double b2 = b1 - sigma * tau1_sqrt;
double C = (S- D1*exp(- r*tau1)) * N(b1)+ (S- D1*exp(- r*tau1)) * N(a1, - b1, rho)
- (X*exp(- r*tau)) *N(a2, - b2, rho)
- (X- D1) *exp(- r*tau1) *N(b2);
return C;
};
Chapter4. b~I@l /Q 89 ': ;
-
8/18/2019 C++lanquage for financial engineering
29/113
2004-9-20
28 2004, !"#
4.1
gh ?imWX
-
8/18/2019 C++lanquage for financial engineering
30/113
2004-9-20
29 2004, !"#
3 W#X+ E
-
8/18/2019 C++lanquage for financial engineering
31/113
2004-9-20
30 2004, !"#
4.20?@ 89
4CD
-
8/18/2019 C++lanquage for financial engineering
32/113
2004-9-20
31 2004, !"#
for (int step=steps- 1; step>=0; - - step) {
for (int i=0; i
-
8/18/2019 C++lanquage for financial engineering
33/113
2004-9-20
32 2004, !"#
for (int i=1; i
-
8/18/2019 C++lanquage for financial engineering
34/113
2004-9-20
33 2004, !"#
vectorprices (no_steps+1);
vectorcall_values (no_steps+1);
double R = exp(r*(t/no_steps));double Rinv = 1.0/R;
double u = exp(sigma*sqrt(t/no_steps));
double d = 1.0/u;
double uu= u*u;
double pUp = (R- d)/(u- d);
double pDown = 1.0 - pUp;
prices[0] = S*pow(d, no_steps);
int i;
for (i=1; i
-
8/18/2019 C++lanquage for financial engineering
35/113
2004-9-20
34 2004, !"#
double& gamma, // second prt wrt S
double& theta, // partial wrt time
double& vega, // partial wrt sigmadouble& rho) // partial wrt r
{
vectorprices(no_steps+1);
vectorcall_values(no_steps+1);
double delta_t =(time/no_steps);
double R = exp(r*delta_t);
double Rinv = 1.0/R;
double u = exp(sigma*sqrt(delta_t));
double d = 1.0/u;
double uu= u*u;
double pUp = (R- d)/(u- d);
double pDown = 1.0 - pUp;
prices[0] = S*pow(d, no_steps);
for (int i=1; i
-
8/18/2019 C++lanquage for financial engineering
36/113
2004-9-20
35 2004, !"#
double f00 = call_values[0];
delta = (f11- f10)/(S*u- S*d);double h = 0.5 * S * ( uu - d*d);
gamma = ( (f22- f21)/(S*(uu- 1)) - (f21- f20)/(S*(1- d*d)) ) / h;
theta = (f21- f00) / (2*delta_t);
double diff = 0.02;
double tmp_sigma = sigma+diff;
double tmp_prices
= option_price_call_american_binomial(S, X, r, tmp_sigma, time, no_steps);
vega = (tmp_prices- f00) /diff;
diff = 0.05;
double tmp_r = r+diff;
tmp_prices = option_price_call_american_binomial(S, X, tmp_r, sigma, time, no_steps);
rho = (tmp_prices- f00) /diff;
};
Subsections
• () xy
• gr xy
o ghRDk 3l gr xy */3 ,Q •u3 ^_̀ X!"
4.5b~I@l /Q #
-
8/18/2019 C++lanquage for financial engineering
37/113
-
8/18/2019 C++lanquage for financial engineering
38/113
-
8/18/2019 C++lanquage for financial engineering
39/113
2004-9-20
38 2004, !"#
// start a new tree at each ex- dividend date.
// do this recursively, at each ex dividend date, at each step, call the
// binomial formula starting at that point to calculate the value of the live// option, and compare that to the value of exercising now.
{
int no_dividends = dividend_times.size();
if (no_dividends == 0) // just take the regular binomial
return option_price_call_american_binomial(S, X, r, sigma, t, steps);
int steps_before_dividend = (int)(dividend_times[0]/t*steps);
double R = exp(r*(t/steps));
double Rinv = 1.0/R;
double u = exp(sigma*sqrt(t/steps));
double uu= u*u;
double d = 1.0/u;
double pUp = (R- d)/(u- d);
double pDown = 1.0 - pUp;
double dividend_amount = dividend_amounts[0];
vectortmp_dividend_times(no_dividends- 1); // temporaries with
vectortmp_dividend_amounts(no_dividends- 1); // one less dividend
for (int i=0;i
-
8/18/2019 C++lanquage for financial engineering
40/113
2004-9-20
39 2004, !"#
// less the dividend.
call_values[i] = max(value_alive, (prices[i]- X)); // compare to exercising now
};for (int step=steps_before_dividend- 1; step>=0; - - step) {
for (int i=0; i
-
8/18/2019 C++lanquage for financial engineering
41/113
2004-9-20
40 2004, !"#
4CD [}, (e3 $;WX D+, 0rg g6D[\[q YZ.9
c2& •4lz.
+,7 0Q*=c (implicit finite differences)
g-3 UX\ Hull (1993, P.354) 3 g\ i7X -b zz.g abcd 672 -9 c2 NDG#(linear algebra )q
jV-Lz.
#include
#include "newmat.h" // definitions for newmat matrix library
#include // standard STL vector template
#include
double option_price_put_european_finite_diff_implicit(
double S, double X, double r, double sigma, double time,
int no_S_steps, int no_t_steps)
{
double sigma_sqr = sigma*sigma;
// need no_S_steps to be even:
int M; if ((no_S_steps%2)==1) { M=no_S_steps+1; } else { M=no_S_steps; };
double delta_S = 2.0*S/M;
vectorS_values(M+1);
for (int m=0;m
-
8/18/2019 C++lanquage for financial engineering
42/113
2004-9-20
41 2004, !"#
};
return F.element(M/2);
};
-.7 0Q*=c(explicit finite differences)
;j,
#A2[ E\z\ ~Clg zz.g-3 UX\ Hull (1993, P.356) \ i7X -b zz.
// findiff_exp_eur_put.cc
// author: Bernt A Oedegaard
#include
#include
#include
double option_price_put_european_finite_diff_explicit(double S,
double X,
double r,
double sigma,
double time,
int no_S_steps,
int no_t_steps) {
double sigma_sqr = sigma*sigma;
unsigned int M; // need M = no_S_steps to be even:
if ((no_S_steps%2)==1) { M=no_S_steps+1; } else { M=no_S_steps; };
double delta_S = 2.0*S/M;
vectorS_values(M+1);
for (unsigned m=0;m
-
8/18/2019 C++lanquage for financial engineering
43/113
2004-9-20
42 2004, !"#
b[j] = r1*(1.0- sigma_sqr*j*j*delta_t);
c[j] = r2*0.5*j*(r+sigma_sqr*j);
};vectorf_next(M+1);
for (unsigned m=0;m=0;- - t) {
f[0]=X;
for (unsigned m=1;m
-
8/18/2019 C++lanquage for financial engineering
44/113
2004-9-20
43 2004, !"#
// need no_S_steps to be even:
int M; if ((no_S_steps%2)==1) { M=no_S_steps+1; } else { M=no_S_steps; };
double delta_S = 2.0*S/M;double S_values[M+1];
for (int m=0;m
-
8/18/2019 C++lanquage for financial engineering
45/113
2004-9-20
44 2004, !"#
double r,
double sigma,
double time,int no_S_steps,
int no_t_steps) {
double sigma_sqr = sigma*sigma;
int M; // need M = no_S_steps to be even:
if ((no_S_steps%2)==1) { M=no_S_steps+1; } else { M=no_S_steps; };
double delta_S = 2.0*S/M;
vectorS_values(M+1);
for (int m=0;m
-
8/18/2019 C++lanquage for financial engineering
46/113
2004-9-20
45 2004, !"#
/O0 123 4.
Brennan and Schwartz (1978) \ 4l %?m3 (1! ?sk3 f/3 ;V8gz. Hull (1993) 3 >= 14.7 k\
4l %?mk3 ?) UA/?g zz.Wilmott et al. (1994) k\ V? IuFk 3l
-
8/18/2019 C++lanquage for financial engineering
47/113
2004-9-20
46 2004, !"#
l% ̀ `f )(dB k i7l 9R\ ,-.g= -9c2&, l% ̀ `f3 KCg D: 4lU3 _gk Gl s?g
JK 0, ?rg s q ,' ud?L%\ 0\ 9DY AB, zz. ?rg s g^X, ]9 U%\ s gz.n%&
}5t
ε , JK 0, ?r 1 3 ud ?Lk n{z@, u(discrete process ) gV2 ,-.g= -\
0g ,F-z.
b\,
g F\ gV-@ &@U ]:3 RQ , tUWk n% l% ̀ `f >u3 ]:SXq ij,E# z\ 5j3
]:SXq n6Y #, zz.11
!mY, g gr2 Im(discretization )) *C jV\ c2 &k Y # >z. 29&
Tc\ 9/qr ,Q3 G#, l% ̀ `fk n{z\ 0\ b52 9# zW\, g\ g-3 F> pg YZF# zz.
11 XYZVi ^W\.O : Z\BX. e; `a XYZVi ^W\.O* Rx( Z\BX- g2 NO,i f# |5 P ' ?@.
t t S S S t ∆+∆−=∆+
,11
2
11111 )
2
1exp[( ασσµ
t t S S S t ∆+∆−=∆+
,22
2
221222 )
2
1exp[( ασσµ
Rx( Z\BX_( U{{Wm @`z g. "LP ' ?@.
t t ,1,1 εα =
2
,2,1,2 1 ρερεα −+= t t t
NZR, t ,1ε ] t ,2ε m L1LAJhifB ?>2 hi+; j'.@. Rx( U{{W6 ?m BX- g2 gfJ( NO* JN+;
Kw.q, 3kl .JFB.1p Kh 8m nu+,i WXW ' ?@. Z\BX. e; `a( XYZVi ^W\.O( 2 -i, 0"
1 6^, NO( European asian spread option)( 6FpL- .Kw. 0MY# )MP ' ?@. .-* jZ- R6y BX( XoQ^_(
k.- ST3n6 (+Ym NO.@. .-- {2 sMz VBA Codem F The Complete Guide To Option Pricing FormulasG , Espen Gaarder
Haug, 1998, p142 V pnY$ U@. (ABC)
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/
-
8/18/2019 C++lanquage for financial engineering
48/113
2004-9-20
47 2004, !"#
g0) @0AB, 9R MHq 1l qr3 MAk 3D-\ ST3 gr2 Im(discretization )gz.g0k S2&\
g; Fk G2&\, SXk 3D;g[ E9 #~k- D: ]R3
SGSk 3D-[ E\- 9/qr3 f: SGS}\ ,-.g= Y AB6g zz.
Monte Carle methodl /Q 0?@ 89/ 7k
// file: simulated_call_euro.cc
// author: Bernt Arne Oedegaard
#include // standard mathematical functions
#include "random.h" // definition of random number generator
#include // define the max() function
double option_price_call_european_simulated( double S,
double X,
double r,
double sigma,
double time,
int no_sims)
{
double sigma_sqr = sigma * sigma;
double R = (r - 0.5 * sigma_sqr) *time;
double SD = sigma * sqrt(time);
double sum_payoffs = 0.0;
for (int n=1; n
-
8/18/2019 C++lanquage for financial engineering
49/113
-
8/18/2019 C++lanquage for financial engineering
50/113
2004-9-20
49 2004, !"#
g\,
\
-
8/18/2019 C++lanquage for financial engineering
51/113
2004-9-20
50 2004, !"#
q z, abm\ gV2 0\ 0WX
-
8/18/2019 C++lanquage for financial engineering
52/113
2004-9-20
51 2004, !"#
double nn = 2.0*b/sigma_sqr;
double m = 2.0*r/sigma_sqr;
double K = 1.0- exp(- r*time);double q2 = (- (nn- 1) +sqrt(pow((nn- 1), 2.0)+(4*m/K)))*0.5;
// seed value from paper
double q2_inf = 0.5 * ( (- nn- 1.0) + sqrt(pow((nn- 1), 2.0)+4.0*m));
double S_star_inf = X / (1.0 - 1.0/q2_inf);
double h2 = - (b*time+2.0*sigma*time_sqrt)*(X/(S_star_inf- X));
double S_seed = X + (S_star_inf- X)*(1.0- exp(h2));
int no_iterations=0; // iterate on S to find S_star, using Newton steps
double Si=S_seed;
double g=1;
double gprime=1.0;
while ((fabs(g) >ACCURACY)
&& (fabs(gprime) >ACCURACY) // to avoid exploding Newton's
&& ( no_iterations++0.0)) {
double c = option_price_european_call_payout(Si, X, r, b, sigma, time);
double d1 = (log(Si/X)+(b+0.5*sigma_sqr) *time)/(sigma*time_sqrt);
g=(1.0- 1.0/q2) *Si- X- c+(1.0/q2) *Si*exp((b- r) *time) *N(d1);
gprime=( 1.0- 1.0/q2)*(1.0- exp((b- r) *time) *N(d1))
+(1.0/q2) *exp((b- r) *time) *n(d1)*(1.0/(sigma*time_sqrt));
Si=Si- (g/gprime);
};
double S_star = 0;
if (fabs(g) >ACCURACY) { S_star = S_seed; } // did not converge
else { S_star = Si; };
double C=0;
double c = option_price_european_call_payout(S, X, r, b, sigma, time);
if (S>=S_star) {
C=S- X;
}
else {
double d1 = (log(S_star/X)+(b+0.5*sigma_sqr) *time)/(sigma*time_sqrt);
double A2 = (1.0- exp((b- r) *time) *N(d1))* (S_star/q2);
C=c+A2*pow((S/S_star), q2);
};
return max(C, c); // know value will never be less than BS value
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/
-
8/18/2019 C++lanquage for financial engineering
53/113
2004-9-20
52 2004, !"#
}
q!-,\ Barone Adesi 2% ijq }B. p, ij\ p {~ Barone- Adesi and Whaley (1987) k zz.g ijk G2&\ Hull (1993) 3 >= 14A k&P ?Y # zz.
7.2 Geske- Johnsoncl :;t Mw@89 C ':/ 89
Geske and J ohnson (1984) k&\
-
8/18/2019 C++lanquage for financial engineering
54/113
2004-9-20
53 2004, !"#
Chapter 8. ?@ \]^_(Futures algoritms)
: |k&\ N/ 0S3 ,-J,k jV2\ abcdk G2 {32tbq lz.
Subsections
• N/0S3 ,Q+u(Pricing of futures contract)
• N/
-
8/18/2019 C++lanquage for financial engineering
55/113
2004-9-20
54 2004, !"#
• ghR~k 3l &u
8.2?@89
(Options on futures)
N/k Gl
-
8/18/2019 C++lanquage for financial engineering
56/113
2004-9-20
55 2004, !"#
#include // mathematics library
#include "normdist.h" // normal distribution
double futures_option_price_call_european_black(
double F, // futures price
double X, // exercise price
double r, // interest rate
double sigma, // volatility
double time) // time to maturity
{
double sigma_sqr = sigma*sigma;
double time_sqrt = sqrt(time);
double d1 = (log (F/X) + 0.5 * sigma_sqr * time) / (sigma * time_sqrt);
double d2 = d1 - sigma * time_sqrt;
return exp(- r*time)*(F * N(d1) - X * N(d2));
};
8.2.2b~I@l /Q #
-
8/18/2019 C++lanquage for financial engineering
57/113
2004-9-20
56 2004, !"#
futures_prices[0] = F*pow(d, no_steps);
int i;
for (i=1; i
-
8/18/2019 C++lanquage for financial engineering
58/113
2004-9-20
57 2004, !"#
BC 89
0?@
89
4CD
-
8/18/2019 C++lanquage for financial engineering
59/113
2004-9-20
58 2004, !"#
double X, // exercise,
double r, // r_domestic,
double r_f, // r_foreign,double sigma, // volatility,
double time) // time to maturity
{
double sigma_sqr = sigma*sigma;
double time_sqrt = sqrt(time);
double d1 = (log(S/X) + (r- r_f+ (0.5*sigma_sqr)) * time)/(sigma*time_sqrt);
double d2 = d1 - sigma * time_sqrt;
return S * exp(- r_f*time) * N(d1) - X * exp(- r*time) * N(d2);
};
D] jE
4CD 12
-
8/18/2019 C++lanquage for financial engineering
60/113
2004-9-20
59 2004, !"#
double u = exp(sigma*sqrt(t_delta));
double d = 1.0/u;
double uu= u*u;double pUp = (exp((r- r_f) *t_delta) - d)/(u- d); // adjust for foreign int.rate
double pDown = 1.0 - pUp;
exchange_rates[0] = S*pow(d, no_steps);
int i;
for (i=1; i
-
8/18/2019 C++lanquage for financial engineering
61/113
2004-9-20
60 2004, !"#
2D, vwD3 ST
Uz.z} gq1 ) 5u2, g BQ\ 9R AB, WJR(flat)Xgzb lz.
vwD3 ST3 3P ,Q3 0rIm\ ,[IF\ ]92:z.
// file bonds_price_both.cc
// author: Bernt A Oedegaard.
#include
#include
double bonds_price(const vector& coupon_times,
const vector& coupon_amounts,
const vector& principal_times,
const vector& principal_amounts,
const double& r)
// calculate bond price when term structure is flat,
// given both coupon and principals
{
double p = 0;
for (unsigned i=0;i
-
8/18/2019 C++lanquage for financial engineering
62/113
2004-9-20
61 2004, !"#
const vector& cashflows,
const double& r) {
// calculate bond price when term structure is flat,double p=0;
for (unsigned i=0;i p( .`q gV-b z[}, lU) '()*(cash flow ) -k gV-b z[
Ez.ST> p(3 %g\ !z[ ]B-[ Eb, ST3 2h p(8 '()*q nM-@ &z.g %g, ]B-, 2\
STP zD, !(\ LWl ST, ! ]3 -Ygz.! ST\ D: 0g gqg\, D: 0g p:gI\[q ?4J Y
AB, zz.!mY 29k&\ 67l STq nM-b zW^X '()*(cash flow )}\ tb zW@
q$(.).X!") UV9 #W[b zz.g-k gr(v%) oc0r3 STq tq.
// file bonds_price.cc
// author: Bernt A Oedegaard.
#include
#include
double bonds_price_discrete(const vector& cashflow_times,
const vector& cashflows,
const double& r) {
// calculate bond price when term structure is flat,
double p=0;
for (unsigned i=0;i
-
8/18/2019 C++lanquage for financial engineering
63/113
2004-9-20
62 2004, !"#
z} ) J,q *,Y # M k zD&3 [s\ Y8-\ W#gz.8q ZD 9R AB, JRl ST\ 67l
Y8W#, Uz.
9R ABq LWl o7term_structurexoXq ,u2P z{z.abcd\ YZ.\ Yg[3 $;WX 2 Y81
b\ 5jq +5$\ 9F\ &@Y # zW@ &Wd(gz.
// file bonds_price_termstru.cc
// author: Bernt Arne Odegaard
#include
#include "term_structure_class.h"
double bonds_price(const vector& cashflow_times,
const vector& cashflows,
const term_structure_class& d) {
double p = 0;
for (unsigned i=0;i
-
8/18/2019 C++lanquage for financial engineering
64/113
2004-9-20
63 2004, !"#
10.3H6b9
10.3.1 IJ H6b9
29&,
• \ ,lk zD& '()*(cash flow)g\,
• \ Y81g\,$1 q [s-\ Y833 ,lk zD&3 '+,Q
TN, j)k&3 9RAB\ YZ(flat)-zb :z.
// file bonds_duration.cc
// author: Bernt Arne Odegaard
#include
#include
double bonds_duration(const vector& cashflow_times,
const vector& cashflows,
const double& r)
// calculate the duration of a bond, simple case where the term
// structure is flat, interest rate r.
{
double S=0;
double D1=0;
for (unsigned i=0;i;WX\
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/
-
8/18/2019 C++lanquage for financial engineering
65/113
2004-9-20
64 2004, !"#
// file duration.cc
// author: Bernt A Oedegaard.
#include
#include "term_structure_class.h"
double bonds_duration(const vector& cashflow_times,
const vector& cashflow_amounts,
const term_structure_class& d ) {
double S=0;
double D1=0;
for (unsigned i=0;i
-
8/18/2019 C++lanquage for financial engineering
66/113
2004-9-20
65 2004, !"#
const vector& cashflows,
const double& bond_price) {
double y = bonds_yield_to_maturity(cashflow_times, cashflows, bond_price);return bonds_duration(cashflow_times, cashflows, y); // use YTM in duration
};
10.3.3 +
-
8/18/2019 C++lanquage for financial engineering
67/113
2004-9-20
66 2004, !"#
// file bonds_convexity.cc
// author: Bernt A Oedegaard.// calculate convexity of a bond.
#include
#include
double bonds_convexity(const vector& cashflow_times,
const vector& cashflow_amounts,
const double& y )
{
double C=0;
for (unsigned i=0;i
-
8/18/2019 C++lanquage for financial engineering
68/113
2004-9-20
67 2004, !"#
// file exotics_lookback_call.cc
// author: Bernt A Oedegaard
#include
#include "normdist.h"
double exotics_lookback_european_call(double S,
double Smin,
double r,
double q,
double sigma,
double time){
if (r==q) return 0;
double sigma_sqr=sigma*sigma;
double time_sqrt = sqrt(time);
double a1 = (log(S/Smin) + (r- q+sigma_sqr/2.0) *time)/(sigma*time_sqrt);
double a2 = a1- sigma*time_sqrt;
double a3 = (log(S/Smin) + (- r+q+sigma_sqr/2.0) *time)/(sigma*time_sqrt);
double Y1 = 2.0 * (r- q- sigma_sqr/2.0) *log(S/Smin) /sigma_sqr;
return S * exp(- q*time) *N(a1)
- S * exp(- q*time)*(sigma_sqr/(2.0*(r- q))) *N(- a1)
- Smin * exp(- r*time)*(N(a2)- (sigma_sqr/(2*(r- q))) *exp(Y1) *N(- a3));
};
2m,[ g; ;8 Im\
YZ[z.
D] jE
Hull (1993) 3 16|k gml
-
8/18/2019 C++lanquage for financial engineering
69/113
2004-9-20
68 2004, !"#
Subsections
• qr ,Q3 ,-.g=
• @0AB3 u3
• ,Q •u
• &u-3 ANe#3 CD
jk ':/ .56b9
`|a\ D+, ,Qg ,-.g= 2\[q \btq. 2 A STq nMlz. 1 A\ ~3 ,lk zD&3 f:
,Q}g ABl STgz. g0) g 9/qrk} 3D-\ pg f: ,Q}g ]Bl
ut, 2\ STgz.
// file simulate_underlying_terminal.cc
#include
#include "random.h"
double simulate_terminal_price(double S, // current value of underlying
double r, // interest rate
double sigma, // volatitily
double time) // time to final date
{
double R = (r - 0.5 * pow(sigma, 2) ) *time;
double SD = sigma * sqrt(time);
return S * exp(R + SD * random_normal());
};
tz 5>;WX\ $n=l3 M9Rk Uc& zdl ,lk zD&3 ,Q\ ,-.g= Y AB, zz. abcd3
A')
-
8/18/2019 C++lanquage for financial engineering
70/113
2004-9-20
69 2004, !"#
void simulate_price_sequence(double S, // current value of underlying
double r, // interest ratedouble sigma, // volatitily
double time, // time to final date
int no_steps, // number of steps
vector& prices ) {
if (prices.size()
-
8/18/2019 C++lanquage for financial engineering
71/113
2004-9-20
70 2004, !"#
double payoff_european_put(double& price, double& X){
return max(0.0, X- price);};
zI3 8X& ,Q3 u3 fG b\ fUk 3D-\ l e#3 fG N1\
r@lz. g0) fik C++ |Dk &,U /?g\, STL(Standard Template Library)3 abcdgz.
bz{ 8: JK
-
8/18/2019 C++lanquage for financial engineering
72/113
-
8/18/2019 C++lanquage for financial engineering
73/113
2004-9-20
72 2004, !"#
double derivative_price_european_simulated ( double S, double r, double sigma, double time,
double payoff(vector& prices),int no_steps, int no_sims) {
double sum_payoffs=0;
vector prices(no_steps);
for (int n=0; n
-
8/18/2019 C++lanquage for financial engineering
74/113
2004-9-20
73 2004, !"#
double payoff(vector& prices),
int no_steps,
int no_sims){
double X = S;
double c_bs = option_price_call_black_scholes(S, X, r, sigma, time);
vector prices(no_steps, 0.0);
double sum_payoffs=0;
double sum_payoffs_bs=0;
for (int n=0; n
-
8/18/2019 C++lanquage for financial engineering
75/113
2004-9-20
74 2004, !"#
g Uz. 29&,
\ Black Scholes EFgz. l3 4
g F\ A'-9 c2&\, D: ,l3 4l2q BAY AB, zz.!e[} fgcu W#\ LT :o, h[9
#~k, g l) ~C, 2[ Eb, iQk& i.@ &z. 0r=3 D5,\ Q-9 c2&\
-
8/18/2019 C++lanquage for financial engineering
76/113
2004-9-20
75 2004, !"#
double sigma,
double time_to_maturity,
double lambda,double kappa,
double delta) {
const int MAXN=50;
double tau=time_to_maturity;
double sigma_sqr = sigma*sigma;
double delta_sqr = delta*delta;
double lambdaprime = lambda * (1+kappa);
double gamma = log(1+kappa);
double c = exp(- lambdaprime*tau)*
option_price_call_black_scholes(S, X, sigma, r- lambda*kappa, tau);
double log_n = 0;
for (int n=1;n
-
8/18/2019 C++lanquage for financial engineering
77/113
2004-9-20
76 2004, !"#
JK ?r NOg%b -\ 9m) (1 ?sk&P\ k/ ̀ gV2b zR 0WX, vilm(Markowitz), C"l
0gz.9:;8 ,u), cX%\ ?rWX Tu 2\, NO99WX/`3 +u) $D' 9G #0k& ?r\ fU2 -7Y b\ $D' ?r pg YZF #, zz.
// file mv_calc.cc
// author: Bernt A Oedegaard
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/
-
8/18/2019 C++lanquage for financial engineering
78/113
2004-9-20
77 2004, !"#
// basic calculations for mean variance analysis
#include "newmat.h" #include
double mv_calculate_mean(const Matrix& e, const Matrix& w){
Matrix tmp = e.t() *w;
return tmp.element(0,0);
};
double mv_calculate_variance(const Matrix& V, const Matrix& w){
Matrix tmp = w.t() *V*w;
return tmp.element(0,0);
};
double mv_calculate_st_dev(const Matrix& V, const Matrix& w){
double var = mv_calculate_variance(V, w);
return sqrt(var);
};
VW =k XYZ^[
ELP3 CS BQg >\ STk\, D: $D' 9G#043 fU?r LMNcO 2@2(analytic solution)g\,
}, r@W# zz. $D'.9G #04 ) g-3 F\ 3T\ Sgz.
BSBQ >\ MV(JK?r) foD3 r@Fk S2&\ Huang and Litzenberger (1988)3 3|\ }B-%.
// file mv_calc_port_unconstrained.cc
// author: Bernt A Oedegaard
#include "newmat.h"
ReturnMatrix mv_calculate_portfolio_given_mean_unconstrained(const Matrix& e,
const Matrix& V,
double r){
int no_assets=e.Nrows();
Matrix ones = Matrix(no_assets, 1); for (int i=0;i
-
8/18/2019 C++lanquage for financial engineering
79/113
2004-9-20
78 2004, !"#
Matrix Vinv = V.i(); // inverse of V
Matrix A = (ones.t() *Vinv*e); double a = A.element(0,0);
Matrix B = e.t() *Vinv*e; double b = B.element(0,0);Matrix C = ones.t() *Vinv*ones; double c = C.element(0,0);
Matrix D = B*C - A*A; double d = D.element(0,0);
Matrix Vinv1=Vinv*ones;
Matrix Vinve=Vinv*e;
Matrix g = (Vinv1*b - Vinve*a)*(1.0/d);
Matrix h = (Vinve*c - Vinv1*a)*(1.0/d);
Matrix w = g + h*r;
w.Release();
return w;
};
|\](short sales)/ ^Ap_
*C3 7ok&\ ELP, O|-, ;2[[ E\z.! STk\ LMNcO3 ,]-k 0 A) ! g=g%b -\
CS BQ\ "g[ EW@ r Uz.
ELP3 Cl\ "L\ STk\, g-3 f;2 ~Cq J AB, zz.
29&,
g 0r (2 % X!") X!"3 MRq 9G-\ 0) g gM3 $;\ pD& q8z.!m^Xk g-3 ij\
cfsqp X sc\ 2 % #I9(quadratic solver)q gV2 0r\ -b zz. '+ OR /&k& g0) M;WX gV2b
zz. (: ! ij\ MD; 60, 5>;8 f;2 67WX f6Uz. Tc, Y# z\ 0) $; W#q u3-2
Cl BQ3 N1\ C 3 &l67WX&
-
8/18/2019 C++lanquage for financial engineering
80/113
2004-9-20
79 2004, !"#
// calculate a mean variance portfolio under short sales constraints
#include "mv_calc.h"
#include "cfsqp_op.h" // optimize using CFSQP#include "mymatrix.h" //
int MV_SHORT_no_assets; // global values because they need to be
double MV_SHORT_r; // available in criterion function
Matrix* MV_SHORT_e;
Matrix* MV_SHORT_V;
double MV_SHORT_objective(double x[]){
Matrix X(MV_SHORT_no_assets, 1);
for (int i=0;i
-
8/18/2019 C++lanquage for financial engineering
81/113
2004-9-20
80 2004, !"#
// expected return equals r
MV_SHORT_no_assets = e.Nrows();
MV_SHORT_V = &V;MV_SHORT_e = &e;
MV_SHORT_r = r;
Matrix w = null_matrix(MV_SHORT_no_assets, 1);
// check whether it is feasible to find optimum. Only if r is between
// min and max in e;
double r_min = e.element(0,0);
double r_max = e.element(0,0);
int i_min = 0;
int i_max = 0;
int i;
for (i=1;ir_max) | | (r
-
8/18/2019 C++lanquage for financial engineering
82/113
2004-9-20
81 2004, !"#
double min_var = CFSQP_optimize_with_constraints_and_bounds(
x,
MV_SHORT_no_assets,MV_SHORT_objective,
0,0,0,2, // 2
linear equality constraints
MV_SHORT_constraints,
x_min,
x_max);
for (i=0; i gq1R3 S0)q &u-\ 2m abcd\ \bt9X lz.
Subsections
• 9RAB3 0r
• '+ STU 9RAB3 gV
o NDtR(qrst )
§ #043 NDtR
§ NP(c3 NDtR(qrst )
14 gq1 9RAB(term structure )\ NDtR, McCulloch(1975, 3 % XY%8), Nelson- Siegel RDi 3P,|k& SGU q[q g
V-2 9RABq . YZ.\ W#DKq I\ 10;Im> 69 gq13 74RD(Stocastic proc ess )\ •ulz !k n{ (c
9RABq &u-\ g!; Im ((cRD)g zz. (*q$)
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/
-
8/18/2019 C++lanquage for financial engineering
83/113
-
8/18/2019 C++lanquage for financial engineering
84/113
-
8/18/2019 C++lanquage for financial engineering
85/113
2004-9-20
84 2004, !"#
if (time >= t_max) return obs_forwards[no_obs- 1]; // later than latest obs
int t=1; // find which two observations we are betweenwhile ( (tobs_times[t])) { ++t; };
double lambda = (obs_times[t]- time)/(obs_times[t]- obs_times[t- 1]);
// by ordering assumption, time is between t- 1, t
double r = obs_forwards[t- 1] * lambda + obs_forwards[t] * (1.0- lambda);
return r;
};
Subsections
• Nelson Siegel W#D(1987)
• Bliss R~(1989)
• 3 % X%8
5` }p/ #,[ 8\ #04\, McCulloch R~) Y81\
R~2-b zz.
Nelson Siegel g+@ (1987)
// file nels_sie.cc
// author: Bernt A Oedegaard// purpose: Calculate the term structure proposed by Nelson and Siegel
// Parsimonious Modeling of Yield Curves, J ournal of Business, (1987)
#include
double term_structure_yield_nelson_siegel(double t,
double beta0, double beta1, double beta2,
double lambda ) {
if (t==0.0) return beta0;
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/
-
8/18/2019 C++lanquage for financial engineering
86/113
2004-9-20
85 2004, !"#
double tl = t/lambda;
double r = beta0 + (beta1+beta2) * ((1- exp(- tl)) /tl) + beta2 * exp(- tl);
return r;};
Bliss IS(1989)
Nelson and Siegel (1987) R~3 7|WX&Bliss (1989), C"2Iz.
g0k\ 5 A3 $%V` 3 &ug AB-z.
// file termstru_yield_bliss.cc
// author: Bernt A Oedgaard
#include
double term_structure_yield_bliss(double t, double gamma0, double gamma1, double gamma2,
double lambda1, double lambda2) {
double r;
double t1 = t/lambda1;
double t2 = t/lambda2;
r = gamma0
+ gamma1 * ( (1- exp(- t1)) / t1 )
+ gamma2 * ( ( 1- exp(- t2)) / t2 )
+ gamma2 * ( - exp(- t2));
return r;
};
Cubic spline( 3* h•&4)
3 % XY%8 N\ gVl 9R AB &u3 Im) McCulloch (1971) k 32 C"2Iz.zk !(\ b5l R~
McCulloch (1975) P C"Bz.b g0>\ CPX Litzenberger and Rolfo (1984) P 3 % XY%8 N\ gV-b
zz.
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/
-
8/18/2019 C++lanquage for financial engineering
87/113
2004-9-20
86 2004, !"#
29k q jQ k Gl [,W#gz. ij3 l(Knot)g%b lz.N\ &u-9 c2&\ A3
#, AB-z.
X%8 ij3 l(knot)g a5'z@, g0) 67l ND P7, Uz.
// file: cu_spline.cc
// author: Bernt A Oedegaard
#include
#include
double term_structure_discount_factor_cubic_spline(double t,
double b1,
double c1,
double d1,
const vector& f,
const vector& knots)
{
// calculate the discount factor for the spline functional form.
double d = 1.0
+ b1*t
+ c1*(pow(t, 2))
+ d1*(pow(t, 3));
for (int i=0;i= knots[i]) { d += f[i] * (pow((t- knots[i]), 3)); }
else { break; };
};
return d;
};
Subsections
• Vasicek R~
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/
-
8/18/2019 C++lanquage for financial engineering
88/113
2004-9-20
87 2004, !"#
• Cox Ingersoll Ross R~
o Y813 0r
o ^_ ̀ X!"
• CIR R~k 3l &u
o Y81
5` }p IS15
gM @( section )k&\ 9R AB3 W#q ( R#;8 ImWX &u-\ ?iIm\ t8z.zIWX 9R AB3
SCR~(economic model )\ \bt9X lz.
Vasicek IS
Vasicek (1977)k 32 Am2Iz.
// file vasicek.cc
// author: Bernt A Oedegaard
#include "math.h"
double term_structure_discount_factor_vasicek(double time,
double r,
double a, double b, double sigma){
double A, B;
double sigma_sqr = sigma*sigma;
double aa = a*a;
15 4Z.Bu( |2zL(stoch astic process )- gh .1a Yt g- wm .Bu Z_3nV ?LYm
Kw(.2+ Kw)-m ^1.1z xkTr
-
8/18/2019 C++lanquage for financial engineering
89/113
2004-9-20
88 2004, !"#
if (a==0.0){
B = time;
A = exp(sigma_sqr*pow(time, 3))/6.0;}
else {
B = (1.0 - exp(- a*time)) /a;
A = exp( ((B- time)*(aa*b- 0.5*sigma_sqr)) /aa - ((sigma_sqr*B*B)/(4*a)));
};
double d = A*exp(- B*r);
return d;
}
Cox Ingersoll Ross IS16
g R~) Cox et al. (1985) k 9:2b zD, 5> KD R~(equilibrium mo del )\ 9/X A2b zD aG;8
?sk&\ . gVUz.
i4-/ 7k
69 gq1)
T ,lk zD&3 Y81)
29&,
16 Vasicek.1zm b9 CIR.1( `am dwJ. r σ i L(9m k.6 ?@. [• zL( square root process)* 4Z.Bu( '1
. !p'" `O~; Z!Y# 9Gi Vasicek.1( 4T,i y+U .Bu. (̀- ). P' ?m E[V #W' ?@.(ABC)
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/
-
8/18/2019 C++lanquage for financial engineering
90/113
2004-9-20
89 2004, !"#
bl z!,[ R#(parameter)3 3V\ g-h pz.
1. - 69 gq1
2. - JKP7 $%V ̀
3. - ,| cX% $%V ̀
4. - |9 JK
5. - ?r
YZ[ \]^_
// file termstru_discfact_cir.cc
// author: Bernt A Oedegaard
#include // mathematics library
double term_structure_discount_factor_cir(double t,
double r,
double kappa,
double lambda,
double theta,
double sigma)
// this is the original CIR formulation of their term structure.
{
double sigma_sqr=pow(sigma, 2);
double gamma = sqrt(pow((kappa+lambda), 2)+2.0*sigma_sqr);
double denum = (gamma+kappa+lambda)*(exp(gamma*t)- 1) +2*gamma;
double p=2*kappa*theta/sigma_sqr;
double enum1= 2*gamma*exp(0.5*(kappa+lambda+gamma) *t);
double A = pow((enum1/denum), p);
double B = (2*(exp(gamma*t)- 1)) /denum;
double dfact=A*exp(- B*r);
return dfact;
};
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/
-
8/18/2019 C++lanquage for financial engineering
91/113
2004-9-20
90 2004, !"#
Brown and Dybvig l /. #
-
8/18/2019 C++lanquage for financial engineering
92/113
2004-9-20
91 2004, !"#
Chapter 16. ]
-
8/18/2019 C++lanquage for financial engineering
93/113
2004-9-20
92 2004, !"#
// file bondopt_call_coupon.cc
// author: Bernt A Oedegaard.
#include
#include "normdist.h"
#include "fin_algoritms.h"
double bond_option_price_call_coupon_bond_black_scholes(
double B, double X, double r, double sigma, double time,
vectorcoupon_times, vectorcoupon_amounts){
for (unsigned int i=0;i
-
8/18/2019 C++lanquage for financial engineering
94/113
2004-9-20
93 2004, !"#
int no_steps) // call on a zero coupon
bond.
{double delta_t = bond_maturity/no_steps;
double u=exp(S*sqrt(delta_t));
double d=1/u;
double p_up = (exp(M*delta_t) - d)/(u- d);
double p_down = 1.0- p_up;
vectorr(no_steps+1);
r[0]=interest*pow(d, no_steps);
double uu=u*u;
int i;
for (i=1;i
-
8/18/2019 C++lanquage for financial engineering
95/113
2004-9-20
94 2004, !"#
Vasicek IS/ FG ': Q pg ,ulz.
29&, , , \ =#X lz.gV Y813 0rIm) ab zz, 4mQ| E3 0r) g-h pg Uz.
\ ,lk zD&3 Y81 3 g](zero - coupon )33 ,QWX lz. }9 , }95k zD&3
Y81g 8 4mQ| E3 ,lk zD&3 ,Q) g-h pz.(J amshidan (1989) # Hull (1993) }B.)
29&,
gz.
b 3 STk\
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/
-
8/18/2019 C++lanquage for financial engineering
96/113
2004-9-20
95 2004, !"#
Uz.
// file bondopt_call_vasicek.cc
// author: Bernt A Oedegaard.
#include
#include "normdist.h"
#include "fin_algoritms.h"
double bond_option_price_call_zero_vasicek(double X, // exercise price
double r, // current interest rate
double option_time_to_maturity,
double bond_time_to_maturity,
double a, // parameters
double b,
double sigma)
{
double T_t = option_time_to_maturity;
double s_t = bond_time_to_maturity;
double T_s = s_t- T_t;
double v_t_T;
double sigma_P;
if (a==0.0) {
v_t_T = sigma * sqrt ( T_t ) ;
sigma_P = sigma*T_s*sqrt(T_t);
}
else {
v_t_T = sqrt (sigma*sigma*(1- exp(- 2*a*T_t))/(2*a));
double B_T_s = (1- exp(- a*T_s)) /a;
sigma_P = v_t_T*B_T_s;
};
double h = (1.0/sigma_P) * log (
term_structure_discount_factor_vasicek(s_t, r, a, b, sigma)/
(term_structure_discount_factor_vasicek(T_t, r, a, b, sigma) *X) )
+ sigma_P/2.0;
double c =
term_structure_discount_factor_vasicek(s_t, r, a, b, sigma) *N(h)
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/
-
8/18/2019 C++lanquage for financial engineering
97/113
2004-9-20
96 2004, !"#
- X*term_structure_discount_factor_vasicek(T_t, r, a, b, sigma) *N(h- sigma_P);
return c;
};
-
8/18/2019 C++lanquage for financial engineering
98/113
2004-9-20
97 2004, !"#
// normdist.cc
// numerical approximations to univariate N(z) and bivariate N(a, b, rho)// normal distributions
#include // math functions.
#ifndef PI
#define PI 3.141592653589793238462643
#endif
double n(double z) { // normal distribution function
return (1.0/sqrt(2.0*PI)) *exp(- 0.5*z*z);
};
double n(double r, double mu, double sigma) { // normal distribution function
double nv = 1.0/(sqrt(2.0*PI) *sigma);
double z=(r- mu) /sigma;
nv *= exp(- 0.5*z*z);
return nv;
};
// cumulative univariate normal distribution.
// This is a numerical approximation to the normal distribution.
// See Abramowitz and Stegun: Handbook of Mathemathical functions
// for description. The arguments to the functions are assumed
// normalized to a (0,1 ) distribution.
double N(double z) {
double b1 = 0.31938153;
double b2 = - 0.356563782;
double b3 = 1.781477937;
double b4 = - 1.821255978;
double b5 = 1.330274429;
double p = 0.2316419;
double c2 = 0.3989423;
if (z > 6.0) { return 1.0; }; // this guards against overflow
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/
-
8/18/2019 C++lanquage for financial engineering
99/113
2004-9-20
98 2004, !"#
if (z
-
8/18/2019 C++lanquage for financial engineering
100/113
2004-9-20
99 2004, !"#
if ( ( a=0.0 ) && (rho>=0.0) ) {
return N(a) - N(a, - b, - rho);
}else if ( (a>=0.0) && (b=0.0) ) {
return N(b) - N(- a, b, - rho);
}
else if ( (a>=0.0) && (b>=0.0) && (rho= 0.0 ) {
double denum = sqrt(a*a - 2*rho*a*b + b*b);
double rho1 = ((rho * a - b) * sgn(a)) /denum;
double rho2 = ((rho * b - a) * sgn(b)) /denum;
double delta=(1.0- sgn(a) *sgn(b))/4.0;
return N(a, 0.0, rho1) + N(b, 0.0, rho2) - delta;
};
return - 99.9; // should never get here
};
D]op / References
65 e$ udij\ Abramowiz and Stegun (1964)q }B. Hull, 1993, ('+ 5" 2000)g3 ge$ ud?Lk
Sl Ku abcd A'\ }BY 0.
Cqql aQ rYs t. uv / A note on C++ and the source code
Subsections
• p, ij3 k#
• %glmc
• ( CnnYm! %vq cl Cnn2•
• #a 9r
o [#W#
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/
-
8/18/2019 C++lanquage for financial engineering
101/113
2004-9-20
100 2004, !"#
o s?t ?
• xu3 f; u3
• for XvgMwM3 &F
• #include 3 AB
• xoX3 Ay
• z{ |Dk zD&3 *|
• .efX
•
wh
bd
/ Source availability
p, ij\ Aq3 X Yg[)*q$GAH;WX\ http://finance.bi.no/~bernt/gcc_prog/*X/ ̀ZIP DFk&
$U $5X& k#Y # zz.g0Z)GNU C++ 3 f. q%)*$GAq, g pbq &1999/9/9,lk&3
gs9.*!cb ff 78g i' =Kgz.p, ijk&\ C++3 STL(Standard Template Library)q gV-b z9
#~k, z{ ^$5mk&\ Rw $5g ^$5 ,F-[ E\[P Roz.}S y.g jV3 ^$5m, ABl #4
$53 /Z\ Sb2 tz@, STL #4 $5g z{ $54(g pg 9G-\ 0WX X!"\ M #,
zz. :~&X gV-b z\ NDG#3 %glmc\ newmat X scb zW\, g0) eH- %g.Xgz.f.3
q%) $Bl FTP jgMk& newmat09.zip b\ newmat09.tar.gz X I
-
8/18/2019 C++lanquage for financial engineering
102/113
2004-9-20
101 2004, !"#
=9k Gu2 ;n A h u b q u3-@(q),
*;u) : Matrix Ainv = A.i(); h
;) : Matrix C = A * b.t(); h
v' IuFWX&3 3 2: Matrix x = A.i() *b; X& 9GY #, zz.
NDG#3 ST\ ;n vr3 ]9, ,F-@ LT 4V-, Uz.T$l %glmcq NO-@, 9 ]>q m/lz.
' Cqq•O z{| 4Q Cqq.Q
C b\ Cnnq Ro\ STk\ . Rq 0gz, 3A3 X!"WX jV-b z\ CnnK43 5k G2 •4lz.
Subsections
• [#W#
• s?> t ?
+1 5} / Mathematical operators
R+g+ / Exponentiation
jB vr 9r ( )\ !GX jVY # z[}, [#W#\ |D3 5/k&\ >b, #a S03 %glmc
]k& u32\ W#X& A'2b zz.
• pow(x, n) \ \ 0rlz.
• exp(r) \ \ 0rlz.
•
~=B Uw / Increment and decrement.
e#q 10 s,(b\ tU),[b o\ #, () |Dk&\
int i=0
i = i+1
i = i- 1
X 9G-[}, C++k&\ ?, g-h pg 9GY #, zz.
int i=0
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/
-
8/18/2019 C++lanquage for financial engineering
103/113
2004-9-20
102 2004, !"#
i++
i- -
g0) ,t;g%b\ D-9 Dw[}, &=;8 rg ̀ ABq mn2 #\ Uc-, W #P zD, '?J *V;8 0) Ezb DY # zz.8q Z@date %b -\ xoXq u32, ! WzI1 X3 S\ 2b oW@ g-h pg
9G-\ 0}WX i'z.
date d(1,1,1995)
d++
+>\ 2jan95 , Uz.
n•/ a7 j, jV-9 Mk u32D z[ EW@ r Uz.! #~k C |DY Cnnk&\ W#Y L%Xq
u3l #4 $5(header file)\ gVlz. 8q Z@ :~&, () EFk& gV-\ ud ?L3 N; ud ;P W#
N(z)k&\ normdist.h X N|-b zz.
-
8/18/2019 C++lanquage for financial engineering
104/113
2004-9-20
103 2004, !"#
#ifndef _NORMAL_DIST_H_
#define _NORMAL_DIST_H_
double n(double z); // normal distribution function
double n(double r, double mu, double sigmasqr); // normal distribution function
double N(double z); // cumulative probability of normal
double N(double a, double b, double rho); // cum prob of bivariate normal
#endif
g #4 $5k&\ 2 A3 ud ?L3 74 ;P W#(1 e#3 STh 2 e#3 ST)q u3-b zz. }S N()k
1 A3 S} Q\ 0)
-
8/18/2019 C++lanquage for financial engineering
105/113
2004-9-20
104 2004, !"#
tj3 D> / Acknowledgements.
g ~&q +=k& EAl go, 5J () %5\ &8z.X!"3 q!q [;-\ 0P zIz.! ]k&P KJ 4Vl ,jY [;\ 2 9 ?Z3 g*\ 49-2 tj3 ?\ Mlz.
EARAUJ [email protected]
Michael L Locher
Lars Gregori
Steve Bellantoni
d
( N4 ()*+,)
Gamma
Gamma
Theta
Theta
Rho
Rho
Barone- Adesi and Whaley
Barone- Ades- Whaleymk no\
-
8/18/2019 C++lanquage for financial engineering
106/113
2004-9-20
105 2004, !"#
CIR
estimated
CIR R~k 3l &u class
xoX3 Ay
Cox Ingersoll Ross, see CIR
CIR R~k 3l &u
currency
'{ 12
-
8/18/2019 C++lanquage for financial engineering
107/113
2004-9-20
106 2004, !"#
explicit
4,; 2m3 ^_ ̀ X!"(4mQ|
-
8/18/2019 C++lanquage for financial engineering
108/113
2004-9-20
107 2004, !"#
Merton
Jump Diffusion
J ump diffusion R~ modified duration
#u 5.g=
np
'+ ,-
option
currency
'{ 12
-
8/18/2019 C++lanquage for financial engineering
109/113
2004-9-20
108 2004, !"#
,-.g=k 3l ; ?im
theta
Thetaunique irr
23 4563 78
vega
Vega
volatility
implied
.+ef6(implied volatility)
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/
-
8/18/2019 C++lanquage for financial engineering
110/113
2004-9-20
109 2004, !"#
D]op / Bibliography
Milton Abramowiz and Irene A Stegun.
Handbo ok of Mathematical Functions .
National Bureau of Standards, 1964.
Giovanni Barone- Adesi and Robert E Whaley.
Efficient analytic approximation of American option values.
Journal of Finance , 42(2):- 20, J une 1987.
Per Berck and Knut Syds!ter.
Matematisk Formelsamling fo r konomer .
Universitetsforlaget, 2 edition, 1995.
Fisher Black.
The pricing of commodity contracts.
Journal of Financial Econom ics , 3:- 79, 1976.
Fisher Black and M S Scholes.
The pricing of options and corporate liabilities.
Journal of Political Economy , 7:- 54, 1973.
Robert R Bliss.
Fitting term structures to bond prices.
Working paper, University of Chicago, J anuary 1989.
Phelim P Boyle.
Options: A Monte Carlo approach.
Journal of Financial Econom ics , 4:- 38, 1977.
Richard A Brealey and Stewart C Myers.
Principles of Co rporate Financ e .
McGraw- Hill, fourth edition, 1996.
Michael Brennan and Eduardo Schwartz.
Finite difference methods and jump processes arising in the pricing of contingent claims: A synthesis.
Journal of Financial and Quantitative Analysis , 13:- 74, 1978.
Stephen J Brown and Philip H Dybvig.
The empirical implications of the Cox, Ingersoll, Ross theory of the term structure of interest rates.
Journal of Finance , 41:- 32, 1986.
J Cox, S Ross, and M Rubinstein.
Option pricing: A simplified approach.
Journal of Financial Econom ics , 7:- 263, 1979.
J ohn Cox and Mark Rubinstein.
Options m arkets .
Prentice- Hall, 1985.
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/
-
8/18/2019 C++lanquage for financial engineering
111/113
2004-9-20
110 2004, !"#
J ohn C Cox, J onathan E Ingersoll, and Stephen A Ross.
A theory of the term structure of interest rates.
Econometrica , 53:- 408, 1985.M B Garman and S W Kohlhagen.
Foreign currency option values.
Journal of International Money and Finance , 2:- 37, 1983.
Robert Geske.
The valuation of compound options.
Journal of Financial Econom ics , 7:- 81, March 1979.
Robert Geske and H E J ohnson.
The american put valued analytically.
Journal of Finance , XXXIX(5), December 1984.
M Barry Goldman, Howard B Sosin, and Mary Ann Gatto.
Path- dependent options: Buy at the low, sell at the high.
Journal of Finance , 34, December 1979.
J O Grabbe.
The pricing of call and put options on foreign exchange.
Journal of International Money and Finance , 2:- 53, 1983.
Chi- fu Huang and Robert H. Litzenberger.
Foundations for financial econo mics .
North- Holland, 1988.
J ohn Hull.
Option s, Futures and other Derivative Securities .
Prentice- Hall, second edition, 1993.
J ohn Hull.
Option s, Futures and ot her Derivatives .
Prentice- Hall, third edition, 1997.
F J amshidan.
An exact bond option pricing formula.
Journal of Finance , 44:- 9, March 1989.
Stanley B Lippman.
C+ + primer .
Addison- Wesley, 2 edition, 1992.
Robert H. Litzenberger and J aques Rolfo.
An international study of tax effects on government bonds.
Journal of Finance , 39:- 22, 1984.
J Houston McCulloch.
Measuring the term structure of interest rates.
Journal of Business , 44:- 31, 1971.
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/
-
8/18/2019 C++lanquage for financial engineering
112/113
2004-9-20
111 2004, !"#
J Houston McCulloch.
The tax adjusted yield curve.
Journal of Finance , 30:- 829, 1975.Robert C Merton.
The theory of rational option pricing.
Bell Journal , 4:- 183, 1973.
David R Musser and Atul Saini.
STL Tutorial and Reference G uide: C+ + programming with the standard template library .
Addison- Wesley, 1996.
Charles R Nelson and Andrew F Siegel.
Parsimonious modelling of yield curves.
Journal of Business , 60(4):- 89, 1987.
Carl J Norstrom.
A sufficient conditions for a unique nonnegative internal rate of return.
Journal of Financial and Quantitative Analysis , 7(3):- 39, 1972.
William Press, Saul A Teukolsky, William T Vetterling, and Brian P Flannery.
Numerical Recipes in C .
Cambridge University Press, second edition, 1992.
Richard J Rendleman and Brit J Bartter.
Two- state option pricing.
Journal of Finance , 34(5):- 1110, December 1979.
Richard J Rendleman and Brit J Bartter.
The pricing of options on debt securities.
Journal of Financial and Quantitative Analysis , 15(1):- 24, March 1980.
Richard Roll.
An analytical formula for unprotected American call options on stocks with known dividends.
Journal of Financial Econom ics , 5:- 58, 1977.
Stephen A Ross, Randolph Westerfield, and J effrey F J affe.
Corporate Financ e .
Irwin, fourth edition, 1996.
Mark Rubinstein.
Exotic options.
University of California, Berkeley, working paper, 1993.
William F Sharpe and Gordon J Alexander.
Investments .
Prentice- Hall, 4 edition, 1990.
Bjarne Stroustrup.
The C+ + Programm ing language .
Addison- Wesley, 2 edition, 1991.
O Vasicek.
PDF created with pdfFactory trial version www.pdffactory.com
http://www.pdffactory.com/http://www.pdffactory.com/
-
8/18/2019 C++lanquage for financial engineering
113/113
2004-9-20
An equilibrium characterization of the term structure.
Journal of Financial Econom ics , 5:- 88, 1977.
Robert E Whaley.On the valuation of American call options on stocks with known dividends.
Journal of Financial Econom ics , 9:- 1, 1981.
Paul Wilmott, J eff Dewynne, and Sam Howison.
Option Pricing, Mathematical models and c om putation .
Oxford Financial Press, 1994.
ISBN 0 9522082 02.