Professional Documents
Culture Documents
In VBA, (Visual Basic for Application) the code for a European call option
with the binomial model can be written as:
For i ¼ 0 To n
eCall ¼ eCall + Application.Combin(n, i)*rp_u^i*rp_d^(n - i)* _
Application.Max(S*u^i*d^(n - i) - K, 0)
Next i
End Function
d1 ¼ (Log(S / X) + (r + v * v / 2) * T) / (v * Sqr(T))
d2 ¼ d1 - v * Sqr(T)
Dt ¼ T / n
disc ¼ Exp(-r * Dt)
For i ¼ 1 To n
lSt(i) ¼ lSt(i - 1) * udd
Next i
idx ¼ find_opt_index(lSt, X, n)
For i ¼ 0 To 1
lC1(i) ¼ disc * (p * lC(i + 1) + (1 - p) * lC(i))
lSt1(i) ¼ lSt(i) / D
To find the index closest to the strike for the Black–Scholes smoothing, we use
the following function:
idx ¼ 0
For i ¼ 0 To n - 1
If (lSt(i) >¼ mX) Then Exit For
idx ¼ idx + 1
Next i
find_opt_index ¼ idx - 2
End Function
Appendix: Some Source Codes 465
d1 ¼ (Log(S / X) + (b + v * v / 2) * T) / (v * Sqr(T))
d2 ¼ d1 - v * Sqr(T)
If (mCall) Then
BlackScholes ¼ S*Exp((b - r) * T)*CND(d1) - X*Exp(-r*T)*CND(d2)
Else
BlackScholes ¼ X*Exp(-r*T)*CND(-d2) - S*Exp((b - r)*T)*CND(-d1)
End If
End Function
n ¼ 2 * Int(n / 2) + 1 ’ ¼¼ odd(n);
c1 ¼ Exp(-((z / (n + 1 / 3 + 0.1 / (n + 1))) * _
(z / (n + 1 / 3 + 0.1 / (n + 1)))) * (n + 1 / 6))
PPNormInv ¼ 0.5 + Sgn(z) * Sqr((0.25 * (1 - c1)))
End Function
466 Appendix: Some Source Codes
If (X < 0) Then
X ¼ -X
sign ¼ -1
ElseIf (X > 0) Then
sign ¼ 1
Else ’ (x ¼ 0.0)
CND ¼ 0.5
Exit Function
End If
X ¼ X*0.707106781186547
x2 ¼ X*X
If (X < 0.46875) Then
q1 ¼ 3209.37758913847 + x2*(377.485237685302 + x2* _
(113.86415415105 + x2*(3.16112374387057 + x2* _
0.185777706184603)))
return C[0][Nj];
}
// Back substitution
for (int j ¼ 2*Nj - 2; j >¼ 1; j--)
C[1][j] ¼ (pp[j] - pu*C[1][j+1])/pmp[j];
if (mCall) Then
if (T > 0.0)
BlackScholes ¼ s*Exp((b - r)*T)*CND(d1)
- x*Exp(-r * T)*CND(d2)
Else
BlackScholes ¼ WorksheetFunction.Max(s - x, 0)
Else
if (T > 0.0)
BlackScholes ¼ x*Exp(-r*T)*CND(-d2)
- s*Exp((b - r)*T)*CND(-d1)
Else
BlackScholes ¼ WorksheetFunction.Max(x - s, 0)
End Function
If (T > 0) Then
d1 ¼ (Log(s/x) + (b + v*v/2)*T)/(v*Sqr(T))
Else
d1 ¼ (Log(s/x) + (b + v*v/2)*T)/(v*Sqr(T))
If (mCall) Then
Delta ¼ Exp((b - r)*T)*CND(d1)
Else
Delta ¼ Exp((b - r)*T)*(CND(d1) - 1)
End If
End Function
d1 ¼ (Log(s/x) + (b + v*v/2)*T)/(v*Sqr(T))
Gamma ¼ nd(d1)*Exp((b - r)*T)/(s*v*Sqr(T))
End Function
Appendix: Some Source Codes 471
d1 ¼ (Log(s/x) + (b + v*v/2)*T)/(v*Sqr(T))
Vega ¼ s*Exp((b - r)*T)*nd(d1)*Sqr(T)
End Function
d1 ¼ (Log(s/x) + (b + v*v/2)*T)/(v*Sqr(T))
d2 ¼ d1 - v*Sqr(T)
If (mCall) Then
Theta ¼ -s*Exp((b - r)*T)*nd(d1)*v/(2*Sqr(T)) – _
(b - r)*s*Exp((b - r)*T)*CND(d1) - r*x*Exp(-r*T)*CND(d2)
Else
Theta ¼ -s*Exp((r - b)*T)*nd(d1)*v/(2*Sqr(T)) + _
(b - r)*s*Exp((b - r)*T)*CND(-d1) + r*x*Exp(-r*T)*CND(-d2)
End If
End Function
d1 ¼ (Log(s/x) + (b + v*v/2)*T)/(v*Sqr(T))
d2 ¼ d1 - v*Sqr(T)
If (mCall) Then
If (b ¼ 0) Then
Rho ¼ -T*BlackScholes(1, s, x, T, r, b, v)
Else
Rho ¼ T*x*Exp(-r*T)*CND(d2)
End If
Else
If (b ¼ 0) Then
Rho ¼ -T*BlackScholes(0, s, x, T, r, b, v)
Else
472 Appendix: Some Source Codes
Rho ¼ -T*x*Exp(-r*T)*CND(-d2)
End If
End If
End Function
SX ¼ s - D * Exp(-r * TD)
LowS ¼ 0
i ¼ HighS * 0.5
ci ¼ BlackScholes(mCall, i, x, T - TD, r, r, v)
i ¼ (HighS + LowS)/2
ci ¼ BlackScholes(mCall, i, x, T - TD, r, r, v)
Loop
a1 ¼ (Log(SX/x) + (r + v*v/2)*T)/(v*Sqr(T))
a2 ¼ a1 - v*Sqr(T)
b1 ¼ (Log(SX/i) + (r + v*v/2)*TD)/(v*Sqr(TD))
b2 ¼ b1 - v*Sqr(TD)
Where the function for the bivariate normal distribution is given below.
The bivariate normal distribution is defined as:
( 2 )
1 ðx μx Þ2 2λðx μx Þ y μy y μy
Mðx; y; λÞ ¼ pffiffiffiffiffiffiffiffiffiffiffiffiffi exp þ ;
2πσ x σ y 1 λ2 σ 2x σxσy σ 2y
where μx and μy is the mean of x and y, σ x and σ y the standard deviations. The
correlation function λ is defined by
σ xy
λ ¼ corrðx; yÞ ¼ :
σxσy
sa ¼ 1
sb ¼ 1
am(0) ¼ 0.325303
am(1) ¼ 0.4211071
am(2) ¼ 0.1334425
am(3) ¼ 0.006374323
bm(0) ¼ 0.1337764
bm(1) ¼ 0.6243247
bm(2) ¼ 1.3425378
bm(3) ¼ 2.2626645
Appendix: Some Source Codes 475
MM ¼ 0
aa ¼ a/Sqr(2*(1 - c*c))
bb ¼ b/Sqr(2*(1 - c*c))
For i ¼ 0 To 4
For j ¼ 0 To 4
MM ¼ MM + am(i)*am(j)*f(bm(i), bm(j), aa, bb, c)
Next j
Next i
MM ¼ MM*Sqr(1 - c*c)/3.121592654
End Function
If (b >¼ r) Then
BaroneAdesiWhaleyCall ¼ BlackScholes(mCall, s, x, T, r, b, v)
Exit Function
End If
sk ¼ kc(x, T, r, b, v)
n ¼ 2*b/(v*v)
K ¼ 2*r/(v*v*(1 - Exp(-r*T)))
d1 ¼ (Log(sk/x) + (b + v*v/2)*T)/(v*Sqr(T))
q2 ¼ (-(n - 1) + Sqr((n - 1)*(n - 1) + 4*K))/2
a2 ¼ (sk/q2)*(1 - Exp((b - r)*T)*CND(d1))
BaroneAdesiWhaleyCall ¼ s - x
End Function
476 Appendix: Some Source Codes
sk ¼ kp(x, T, r, b, v)
n ¼ 2*b/(v*v)
K ¼ 2*r/(v*v*(1 - Exp(-r*T)))
d1 ¼ (Log(sk/x) + (b + v*v/2)*T)/(v*Sqr(T))
q1 ¼ (-(n - 1) - Sqr((n - 1)*(n - 1) + 4*K))/2
a1 ¼ -(sk/q1)*(1 - Exp((b - r)*T)*CND(-d1))
BaroneAdesiWhaleyPut ¼ x - s
End Function
M ¼ 2*r/(v*v)
q2u ¼ 1 + 2*M
Su ¼ x/(1 - 1/q2u)
h2 ¼ -(b*T + 2*v*Sqr(T))*x/(Su - x)
Si ¼ x + (Su - x)*(1 - Exp(h2))
If (T ¼ 0) Then T ¼ 0.000000001
K ¼ 2*r/(v*v*(1 - Exp(-r*T)))
d1 ¼ (Log(Si/x) + (b + v*v/2)*T)/(v*Sqr(T))
q2 ¼ 1 + 2*K
LHS ¼ Si - x
RHS ¼ BlackScholes(mCall, Si, x, T, r, b, v) + _
(1 - Exp((b - r)*T)*CND(d1))*Si/q2
bi ¼ Exp((b - r)*T)*CND(d1)*(1 - 1/q2)
bi ¼ bi + (1 - Exp((b - r)*T)*CND(d1)/(v*Sqr(T)))/q2
E ¼ 0.000001
Appendix: Some Source Codes 477
n ¼ 2*b/(v*v)
M ¼ 2*r/(v*v)
q1u ¼ (-(n - 1) - Sqr((n - 1)*(n - 1) + 4*M))/2
Su ¼ x/(1 - 1/q1u)
h1 ¼ (b*T - 2*v*Sqr(T))*x/(x - Su)
Si ¼ Su + (x - Su)*Exp(h1)
If (T ¼ 0) Then T ¼ 0.000000001
K ¼ 2*r/(v*v*(1 - Exp(-r*T)))
d1 ¼ (Log(Si/x) + (b + v*v/2)*T)/(v*Sqr(T))
q1 ¼ (-(n - 1) - Sqr((n - 1)*(n - 1) + 4*K))/2
LHS ¼ x - Si
RHS ¼ BlackScholes(mPUT, Si, x, T, r, b, v) - _
(1 - Exp((b - r)*T)*CND(-d1))*Si/q1
bi ¼ -Exp((b - r)*T)*CND(-d1)*(1 - 1/q1)
bi ¼ bi - (1 + Exp((b - r)*T)*CND(-d1)/(v*Sqr(T)))/q1
E ¼ 0.000001
If (s >¼ i) Then
BjerksundStenslandCall ¼ s - x
Exit Function
End If
Albanese, C., & Campolieti, G. (2006). Advanced derivatives pricing and risk manage-
ment. San Diego: Elsevier Academic Press.
Barone-Adesi, G., et.al. (1999). VaR without correlations for nonlinear portfolios.
Journal of Futures Markets, 19, 583–602.
Barucci, E. (2003). Financial markets theory. New York: Springer.
Berkowitz, J., & O’Brien, J. (2002). How accurate are value-at-risk models at
commercial banks? Journal of Finance, 57, 1093–1111.
Björk, T. (1998). Arbitrage theory in continuous time. Oxford: Oxford University Press.
Black, F. (1976). The pricing of commodity contracts. Journal of financial economics, 3
(1), 167–179.
Black, F., & Scholes, M. (1973). The pricing of options and corporate liabilities. The
Journal of Political Economy, 8, 637–654.
Campbell, S. D. (2005). A review of backtesting and backtesting procedures. Finance
and economics, discussion series Divisions of Research and Statistics and Monetary
Affairs. Federal Reserve Board, Washington, DC.
Clewlow, L., & Strickland, C. (2000). Implementing derivative models. London:
Wiley.
Conroy, R. M. (2003). Binomial option pricing. Darden Graduate School of Business
Administration, University of Virginia. UVA-F-0943
Cox, J., Ross, S. A., & Rubenstein, M. (1979). Option pricing: A simplified approach.
Journal of Financial Economics, 7(1979), 145–166.
Curran, M. (1994). Valuing Asian and Portfolio options by conditioning on the
geometric mean price. Management Science, 40(12), 1705–1711.
Dana, R.-A., & Jeanblanc, M. (2007). Financial markets in continuous time. Berlin:
Springer.
Davis, M., & Etheridge, A. (2006). Louis Bachelier’s theory of speculation: The origins of
modern finance. Princeton: Princeton University Press.
Derman, E. (1996). Model risk. Goldman Sachs Quantitative Strategies Research
Notes.
DeRosa, D. F. (2000). Options on foreign exchange. New York: Wiley.
Drezner, Z. (1978). Computation of the bivariate normal integral. Mathematics of
Computation, 32, 277–279.
Glasserman, P. (2000). Monte Carlo methods in financial engineering. New York:
Springer.
Glasserman, P. (2003). Monte Carlo methods in financial engineering. New York:
Springer.
Glasserman, P. (2004). Monte Carlo methods in financial engineering. New York:
Springer.
Haug, E. (1997). The complete guide to option pricing formulas. New York: McGraw-
Hill.
Ho, T. S. Y., & Lee, S. B. (2005). Securities valuations. Oxford: Oxford University
Press.
Hull, J. Option futures and other derivatives. (9th Edition) Prentice-Hall. ISBN-
13: 978-0133456318
Hunt, P. J., & Kennedy, J. E. (2004). Financial derivative in theory and practise.
Chichester: Wiley.
Ingersoll, J. E. (1987). Theory of financial decision making. Totowa: Rowman &
Littlefield.
Jarrow, R., & Rudd, A. (1983). Option pricing (pp. 183–188). Homewood: Dow
Jones-Irwin.
Jorion, P. (2001). Value at risk: The new benchmark for managing financial risk.
New York: McGraw-Hill.
Kerry B. (2005). A cource in derivative securities. New York: Springer.
Kijima, M. (2003). Stochastic processes with application to finance. London: Chapman
& Hall.
Kwok, Y.-K. (2008). Mathematical models of financial derivatives. New York: Springer.
Leisen, D. (1998). Pricing the American put option: A detailed convergence analysis
for binomial models. Journal of Economic Dynamics and Control, 22, 1419–1444.
Leisen, D., & Reimer, M. (1996). Binomial models for option valuation – Examine
and improving convergence. Applied Mathematical Finance, 3, 319–346.
London, J. (2005). Modeling derivatives in C++. London: Wiley.
Longstaff, F. A. (1989). Pricing options with extendible maturities. Journal of Finance,
45(3), 935–957.
Martin, J. S. (2001). Applied math for derivatives. London: Wiley.
Merton, R. C. (1973). Theory of rational option pricing. The Bell Journal of Economics
and Management Science, 4(1), 141–183.
Merton, C. R. (1976). Option pricing when stock returns are discontinuous. Journal
of Financial Economics, 3, 167–179.
References 483
Munk, C. (2003). Fixed income analysis: Securities, pricing and risk management.
http://citeseerx.ist.psu.edu/viewdoc/download?doi¼10.1.1.129.9912&rep¼rep1&
type¼pdf
Neftci, S. N. (2000). An introduction to the Mathematics of Financial Derivatives.
New York: Academic Press.
Neftci, S. N. (2004). Principles of financial engineering. San Diego: Academic Press.
Pratt, J. W. (1968). A normal approximation for binomial, F, Beta, and other
common, related tail probabilities, II. The Journal of the American Statistical
Association, 63, 1457–1483.
Rebonato, R. (2001). Managing model risk. In C. Alexander (Ed.), Handbook of risk
management. FT-Prentice Hall.
Reiner, E., & Rubinstein, M. (1991). Breaking down the barriers. Risk, 4, 28–35.
Rendleman, R. J., & Bartter, B. J. (1980). The pricing of options on debt securities.
The Journal of Financial and Quantitative Analysis, 15, 11–24.
Ross, S. M. (1983). Stochastic processes. New York: Wiley.
Rubinstein, M. (2000). On the relation between binomial and trinomial option
pricing models. The Journal of Derivatives, 8(2), 47–50.
Schweizer, M. (2012). On Bermudan options. ETH Zurich.
Shreve, Steven. (2004). Stochastic calculus for finance II. New York: Springer.
Shreve, Steven. (2005). Stochastic calculus for finance I. New York: Springer.
Sidenius, J. (2000). LIBOR market models in practice. Journal of Computational
Finance, 3(3), 75–99.
Stoklosa, J. (2007). Studies of barrier options and their sensitivities. The University of
Melbourne.
Tian, Y. (1993). A modified lattice approach to option pricing. Journal of Futures
Markets, 13(5), 564–577.
Trigeorgis, L. (1991). A log-transformed binomial numerical analysis for valuing
complex multi-option investments. Journal of Financial and Quantitative Analysis,
26(3), 309–326.
Wilmott, P. (2000). On quantitative finance. Chichester: Wiley.
Index
correlation option(s), 327–8, 332 drift, 29, 33, 96, 125, 128, 141, 148,
counterparty risk, 8, 10–11, 292 155, 212, 242, 247, 249–51, 262,
co-variance, 83, 84 268
covered call, 383, 429, 440–3
Cox-Ross-Rubenstein, 461
Crank-Nicholson, 69–70, 72, 467 E
credit risk, 3, 7–12, 78 early exercise premium, 228, 236
cross, 203 equity price risk, 8
currency-linked options, 333–9 ES. See expected shortfall (ES)
currency options, 197–235, 289 Eurodollar, 199
currency-protected option, 334 European call option(s), 37, 54, 59, 73,
currency risk, 8, 197, 334, 339 92, 111, 164, 171, 173–6, 188,
CUSIP, 6 196, 214, 231, 283, 299, 342, 461
CVaR. See conditional value at risk (CVaR) European digital FX option, 302
European knock-in option, 304
European knock-out option, 304
D European option(s), 29, 48, 56, 77, 115,
deflators, 351–64 139, 158, 168, 180, 204, 212,
delayed-start options, 318 228–31, 236, 313, 322, 368
delta, 77, 82–4, 169, 173–4, 199–208, European option style, 207, 314–20,
219–25, 284, 294, 308–10, 379, 334, 365, 453
400, 440, 461, 467, 470 European put option, 187
delta decay, 225 exchange option(s), 197, 327, 332–3
delta-gamma-hedging, 285–8 exercise region, 230
delta hedge, 77, 158, 161, 200, 204, exotic options, viii, 35, 289–350
205, 219, 285, 294 expectation value(s), viii, 23, 43, 100,
delta-symmetric strike, 201 105–9, 141, 142, 147–51, 153,
density function, 9, 105, 121–4, 165–7, 164, 172, 190–2, 195, 314, 358
172, 193, 283 expected payoff, viii, 22, 247, 345,
diffusion, 29, 96, 141, 171, 240–3, 351–4
245–88 expected shortfall (ES), 85–9
diffusion process, viii, 28, 146, 147, 242, expected tail loss (ETL), 85
245, 337 explicit finite difference method, 67–8
digital option(s), 216–18, 292–8, 308, exploding spread option, 308
344–5 exponentially weighted moving average
Dirac delta function, 169 model (EWMA), 187
distribution function, 98, 99, 236, 466 exponential weighted VaR, 83
distribution measure, 98 extensible option, 336–7
dividend yield, 174, 214, 273–9
double no touch options, 300–1
Dow Jones Industrial Average, 182, 454 F
down-and-out calls, 307 F-adapted, 96, 109, 142, 247
down-and-out put option, 308 fair game, 23, 24, 37, 109, 246, 247
488 Index
interest rate(s), viii, xi, 7–18, 21–3, log-normal distribution, 19, 44, 45, 73,
29–43, 57–9, 73–5, 83, 92, 98, 121, 133, 167
115, 128, 157–64, 174, 189, long butterfly, 436–9, 449
195–223, 233, 247–56, 278–86, long call, 294, 309, 373, 379, 397,
325, 337–44, 352–467 415–20, 425, 459
interest rate risk, 8, 13, 251 long put, 318, 374, 379–89, 429, 459
International Swaps and Derivatives long sloping synthetic forward, 416–19
Association (ISDA), 6, 7 long straddle, 378, 379, 443–6, 459
intrinsic value, 56, 117, 215, 216, 296, long strangle, 300, 444–9, 459
334, 376, 377 long synthetic forward, 415
ISIN code, 5, 6 Long-term capital management
Itô formula, 140, 147–51, 195, 210, 247 (LTCM), 18
Itô integral, 126, 135 lookback options, 110, 289, 311
Itô lemma, 125–33, 150, 156, 165
M
J marked to the market, 4
Jarrow-Rudd, 46, 47 market indexes, 451–9
Jensen’s unlikeness, 108 market price of risk, 40, 41, 249–52,
Jones, Dow, 182, 291, 454 267, 352, 452
jump diffusion, 240–3, 266 market price of volatility risk, 267, 353
market risk, 7, 8, 12–19, 78
marking-to-model, 14
K Markov, 27, 97, 110–13, 241, 242
kappa, 222 Markov process, 110–13
Knock-out and knock-in options, 289, martingale, vii, viii, 23–8, 31, 37, 62, 93,
298–311 97, 109, 115, 120, 135, 171, 188,
Kolmogorov, 131, 153 233–5, 245–8, 252–9, 266,
kurtosis, 83, 122 269–79, 281, 337, 345, 363
martingale approach, 171–3
martingale measure, 24, 31, 37, 93,
L 233–5, 248, 254, 256–9, 266,
lambda, 224 269–78, 281, 338, 345, 363
least square, 177, 180–2 martingale representation, viii, 245, 255,
Lebesgue integrals, 103 279
legal risk, 8 maximum likelihood, 261–5
Leisen–Reimer model, 48–54, 461–5 maximum likelihood estimator, 187, 264
likelihood process, 252–9, 262–4 measurable, 9, 34, 95–103, 107–9,
Lipschitz, 100 119–20, 143, 255, 261, 271
liquidity risk, 7 measurable space, 95, 107, 261
log-normal, 19, 44, 73, 121–5, 132, model risk, 8, 13–20
167, 198, 212, 247, 266, 315, mollification, 49
323, 344 Monte Carlo, 11, 77, 138
490 Index