Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
analyticeuropeanengine.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2022 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19#include <ql/exercise.hpp>
20#include <ql/pricingengines/blackcalculator.hpp>
22#include <utility>
23
24using std::vector;
25using std::string;
26
27namespace QuantExt {
28
29using namespace QuantLib;
30
32
33 QuantLib::AnalyticEuropeanEngine::calculate();
34
35 if (flipResults_) {
36
37 // Invert strike, spot, forward
38
39 auto resToInvert = vector<string>({"spot", "forward", "strike"});
40 for (const string& res : resToInvert) {
41 auto it = results_.additionalResults.find(res);
42 if (it != results_.additionalResults.end())
43 it->second = 1. / boost::any_cast<Real>(it->second);
44 }
45
46 // Swap riskFreeDiscount and dividendDiscount, discountFactor stays what it is
47
48 Real rfDiscount = Null<Real>();
49 Real divDiscount = Null<Real>();
50
51 if (auto tmp = results_.additionalResults.find("riskFreeDiscount"); tmp != results_.additionalResults.end())
52 rfDiscount = boost::any_cast<Real>(tmp->second);
53 if (auto tmp = results_.additionalResults.find("dividendDiscount"); tmp != results_.additionalResults.end())
54 divDiscount = boost::any_cast<Real>(tmp->second);
55
56 results_.additionalResults["riskFreeDiscount"] = divDiscount;
57 results_.additionalResults["dividendDiscount"] = rfDiscount;
58
59 }
60}
61
62} // namespace QuantExt
Wrapper of QuantLib analytic European engine to allow for flipping back some of the additional result...
const Instrument::results * results_
Definition: cdsoption.cpp:81