Bump version to 6.0-36
[LibreOffice.git] / scaddins / source / pricing / black_scholes.hxx
blobcdcb20b841820672231e8783088eedb0ce378515
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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)
20 namespace sca {
21 namespace pricing {
23 namespace bs {
25 namespace types {
26 enum Greeks {
27 Value = 0,
28 Delta = 1, // d/dS
29 Gamma = 2, // d^2/dS^2
30 Theta = 3, // d/dt
31 Vega = 4, // d/dsigma
32 Volga = 5, // d^2/dsigma^2
33 Vanna = 6, // d^2/dsigma dS
34 Rho_d = 7, // d/dr_d
35 Rho_f = 8 // d/dr_f
38 enum PutCall {
39 Call = 1,
40 Put = -1
43 enum KOType {
44 Regular = 0,
45 Reverse = 1
48 enum BarrierKIO {
49 KnockIn = -1,
50 KnockOut = 1
53 // barrier observed continuously or just at maturity (truncated payoff)
54 enum BarrierActive {
55 Continuous = 0,
56 Maturity = 1
59 enum ForDom {
60 Domestic = 0,
61 Foreign = 1
64 } // namespace types
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,
71 double tau, double K,
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,
78 double tau, double K,
79 types::PutCall pc, types::Greeks greeks);
81 // vanilla put/call option
82 // call pays (S_T-K)^+
83 // put pays (K-S_T)^+
84 // this is the same as: +/- (binasset - K*bincash)
85 double putcall(double S, double vol, double rd, double rf,
86 double tau, double K,
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)^+
95 // put pays (K-S_T)^+
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);
110 // barrier
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);
117 // barrier
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,
121 double rebate,
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,
138 types::PutCall pc);
141 } // namespace bs
143 } // namespace pricing
144 } // namespace sca
147 #endif
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */