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>
16 // options prices and greeks in the Black-Scholes model
17 // also known as TV (theoretical value)
28 Gamma
= 2, // d^2/dS^2
31 Volga
= 5, // d^2/dsigma^2
32 Vanna
= 6, // d^2/dsigma dS
52 // barrier observed continuously or just at maturity (truncated payoff)
66 // binary option cash (domestic)
67 // call - pays 1 if S_T is above strike K
68 // put - pays 1 if S_T is below strike K
69 double bincash(double S
, double vol
, double rd
, double rf
,
71 types::PutCall pc
, types::Greeks greeks
);
73 // binary option asset (foreign)
74 // call - pays S_T if S_T is above strike K
75 // put - pays S_T if S_T is below strike K
76 double binasset(double S
, double vol
, double rd
, double rf
,
78 types::PutCall pc
, types::Greeks greeks
);
80 // vanilla put/call option
81 // call pays (S_T-K)^+
83 // this is the same as: +/- (binasset - K*bincash)
84 double putcall(double S
, double vol
, double rd
, double rf
,
86 types::PutCall putcall
, types::Greeks greeks
);
89 // truncated put/call option, single barrier
90 // need to specify whether it's down-and-out or up-and-out
91 // regular (keeps monotonicity): down-and-out for call, up-and-out for put
92 // reverse (destroys monoton): up-and-out for call, down-and-out for put
93 // call pays (S_T-K)^+
95 double putcalltrunc(double S
, double vol
, double rd
, double rf
,
96 double tau
, double K
, double B
,
97 types::PutCall pc
, types::KOType kotype
,
98 types::Greeks greeks
);
101 // wrapper function for put/call option which combines
102 // double/single/no truncation barrier
103 // B1<=0 - assume no lower barrier
104 // B2<=0 - assume no upper barrier
105 double putcalltrunc(double S
, double vol
, double rd
, double rf
,
106 double tau
, double K
, double B1
, double B2
,
107 types::PutCall pc
, types::Greeks greek
);
110 // touch/no-touch options (cash/asset or nothing payoff profile)
111 double touch(double S
, double vol
, double rd
, double rf
,
112 double tau
, double B1
, double B2
, types::ForDom fd
,
113 types::BarrierKIO kio
, types::BarrierActive bcont
,
114 types::Greeks greek
);
117 // barrier option (put/call payoff profile)
118 double barrier(double S
, double vol
, double rd
, double rf
,
119 double tau
, double K
, double B1
, double B2
,
121 types::PutCall pc
, types::BarrierKIO kio
,
122 types::BarrierActive bcont
,
123 types::Greeks greek
);
126 // probability of hitting a barrier
127 double prob_hit(double S
, double vol
, double mu
,
128 double tau
, double B1
, double B2
);
131 // probability of being in-the-money, ie payoff is greater zero,
132 // assuming payoff(S_T) > 0 iff S_T in [B1, B2]
133 double prob_in_money(double S
, double vol
, double mu
,
134 double tau
, double B1
, double B2
);
135 double prob_in_money(double S
, double vol
, double mu
,
136 double tau
, double K
, double B1
, double B2
,
142 } // namespace pricing
146 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */