1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * Copyright (C) 2012 Tino Kluge <tino.kluge@hrz.tu-chemnitz.de>
14 #ifndef INCLUDED_SCADDINS_SOURCE_PRICING_BLACK_SCHOLES_HXX
15 #define INCLUDED_SCADDINS_SOURCE_PRICING_BLACK_SCHOLES_HXX
17 // options prices and greeks in the Black-Scholes model
18 // also known as TV (theoretical value)
29 Gamma
= 2, // d^2/dS^2
32 Volga
= 5, // d^2/dsigma^2
33 Vanna
= 6, // d^2/dsigma dS
53 // barrier observed continuously or just at maturity (truncated payoff)
67 // binary option cash (domestic)
68 // call - pays 1 if S_T is above strike K
69 // put - pays 1 if S_T is below strike K
70 double bincash(double S
, double vol
, double rd
, double rf
,
72 types::PutCall pc
, types::Greeks greeks
);
74 // binary option asset (foreign)
75 // call - pays S_T if S_T is above strike K
76 // put - pays S_T if S_T is below strike K
77 double binasset(double S
, double vol
, double rd
, double rf
,
79 types::PutCall pc
, types::Greeks greeks
);
81 // vanilla put/call option
82 // call pays (S_T-K)^+
84 // this is the same as: +/- (binasset - K*bincash)
85 double putcall(double S
, double vol
, double rd
, double rf
,
87 types::PutCall putcall
, types::Greeks greeks
);
90 // truncated put/call option, single barrier
91 // need to specify whether it's down-and-out or up-and-out
92 // regular (keeps monotonicity): down-and-out for call, up-and-out for put
93 // reverse (destroys monoton): up-and-out for call, down-and-out for put
94 // call pays (S_T-K)^+
96 double putcalltrunc(double S
, double vol
, double rd
, double rf
,
97 double tau
, double K
, double B
,
98 types::PutCall pc
, types::KOType kotype
,
99 types::Greeks greeks
);
102 // wrapper function for put/call option which combines
103 // double/single/no truncation barrier
104 // B1<=0 - assume no lower barrier
105 // B2<=0 - assume no upper barrier
106 double putcalltrunc(double S
, double vol
, double rd
, double rf
,
107 double tau
, double K
, double B1
, double B2
,
108 types::PutCall pc
, types::Greeks greek
);
111 // touch/no-touch options (cash/asset or nothing payoff profile)
112 double touch(double S
, double vol
, double rd
, double rf
,
113 double tau
, double B1
, double B2
, types::ForDom fd
,
114 types::BarrierKIO kio
, types::BarrierActive bcont
,
115 types::Greeks greek
);
118 // barrier option (put/call payoff profile)
119 double barrier(double S
, double vol
, double rd
, double rf
,
120 double tau
, double K
, double B1
, double B2
,
122 types::PutCall pc
, types::BarrierKIO kio
,
123 types::BarrierActive bcont
,
124 types::Greeks greek
);
127 // probability of hitting a barrier
128 double prob_hit(double S
, double vol
, double mu
,
129 double tau
, double B1
, double B2
);
132 // probability of being in-the-money, ie payoff is greater zero,
133 // assuming payoff(S_T) > 0 iff S_T in [B1, B2]
134 double prob_in_money(double S
, double vol
, double mu
,
135 double tau
, double B1
, double B2
);
136 double prob_in_money(double S
, double vol
, double mu
,
137 double tau
, double K
, double B1
, double B2
,
143 } // namespace pricing
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */