QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.38
Loading...
Searching...
No Matches
kirkengine.cpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2010 Klaus Spanderen
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
23#include <utility>
24
25namespace QuantLib {
26
27 KirkEngine::KirkEngine(ext::shared_ptr<GeneralizedBlackScholesProcess> process1,
28 ext::shared_ptr<GeneralizedBlackScholesProcess> process2,
29 Real correlation)
30 : SpreadBlackScholesVanillaEngine(std::move(process1), std::move(process2), correlation) {
31 }
32
34 Real f1, Real f2, Real strike, Option::Type optionType,
35 Real variance1, Real variance2, DiscountFactor df) const {
36
37 const Real f = f1/(f2 + strike);
38 const Real v
39 = std::sqrt(variance1
40 + variance2*squared(f2/(f2+strike))
41 - 2*rho_*std::sqrt(variance1*variance2)
42 *(f2/(f2+strike)));
43
44 BlackCalculator black(
45 ext::make_shared<PlainVanillaPayoff>(
46 optionType,1.0),
47 f, v, df);
48
49 return (f2 + strike)*black.value();
50 }
51}
52
Black-formula calculator class.
Black 1976 calculator class.
KirkEngine(ext::shared_ptr< GeneralizedBlackScholesProcess > process1, ext::shared_ptr< GeneralizedBlackScholesProcess > process2, Real correlation)
Definition: kirkengine.cpp:27
virtual void calculate() const =0
QL_REAL Real
real number
Definition: types.hpp:50
Real DiscountFactor
discount factor between dates
Definition: types.hpp:66
kirk formulae, due to Kirk (1995)
functionals and combinators not included in the STL
Definition: any.hpp:37
T squared(T x)
Definition: functional.hpp:37
STL namespace.
ext::shared_ptr< BlackVolTermStructure > v