-
Notifications
You must be signed in to change notification settings - Fork 0
/
Black.h
127 lines (91 loc) · 4.32 KB
/
Black.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/* Black Forward Option Price Model 25/04/2014
$$$$$$$$$$$$$$$$$$$$$$$$
$ Black.h - header $
$$$$$$$$$$$$$$$$$$$$$$$$
Copyright (C) 2014 W.B. Yates
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/
History:
Black European option forward price model (see Hull (6th edition), page 332)
Suitable for pricing options on bonds for example
Examples
Black b;
// for these params option price is 1.11664 (see Hull, Example 14.8, page 333)
double T = 4.0 / 12.0;
double forwardPrice = 20;
double rate = 0.09;
double vol = 0.25;
double strike = 20;
double call = false;
std::cout << "value is " << b.value(strike, forwardPrice, vol, rate, T, call) << std::endl;
std::cout << "value is " << b.impliedVol(strike, forwardPrice, 1.11664, rate, T) << std::endl;
*/
#ifndef __BLACK_H__
#define __BLACK_H__
class Black
{
public:
Black() {}
virtual ~Black() {}
double
value( double strike, // option strike
double forwardPrice, // underlying asset's forward value
double vol, // volatility
double rate, // risk free rate of interest
double T, // time to maturity (year fraction)
bool call = true ) const;
double
impliedVol( double strike, // option strike
double forwardPrice, // underlying asset's forward value
double marketPrice, // market price of option
double rate, // risk free rate of interest
double T ) const; // time to maturity (year fraction)
double // rate of change of option price with respect to time
theta( double strike, // option strike
double forwardPrice, // underlying asset's forward value
double vol, // volatility
double rate, // risk free rate of interest
double T, // time to maturity (year fraction)
bool call = true ) const;
double // rate of change of option price with respect to price of underlying asset
delta( double strike, // option strike
double forwardPrice, // underlying asset's forward value
double vol, // volatility
double rate, // risk free rate of interest
double T, // time to maturity (year fraction)
bool call = true ) const;
double // rate of change of delta (derivative of delta or curvature)
gamma( double strike, // option strike
double forwardPrice, // underlying asset's forward value
double vol, // volatility
double rate, // risk free rate of interest
double T ) const; // time to maturity (year fraction)
double // rate of change of option price with respect to risk free interest rate
rho( double strike, // option strike
double forwardPrice, // underlying asset's forward value
double vol, // volatility
double rate, // risk free rate of interest
double T, // time to maturity (year fraction)
bool call = true ) const;
double // rate of change of option price with respect to volatility
vega( double strike, // option strike
double forwardPrice, // underlying asset's forward value
double vol, // volatility
double rate, // risk free rate of interest
double T ) const; // time to maturity (year fraction)
double // the cumulative normal distribution function
N( double x ) const;
double // derivative of the cumulative normal distribution function
DN( double x ) const;
private:
};
#endif
///