Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
sensitivityrecord.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2018 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
20
21#include <iomanip>
22#include <ql/math/comparison.hpp>
23
24using QuantLib::close;
25using std::boolalpha;
26using std::fixed;
27using std::ostream;
28using std::setprecision;
29
30namespace ore {
31namespace analytics {
32
34 // Define in terms of operator<
35 return !(*this < sr) && !(sr < *this);
36}
37
39 // Verbose, would be nice to use std::tie but want to use close on the shifts
40
41 if (key_1 != sr.key_1)
42 return key_1 < sr.key_1;
43
44 if (key_2 != sr.key_2)
45 return key_2 < sr.key_2;
46
47 if (tradeId != sr.tradeId)
48 return tradeId < sr.tradeId;
49
50 return false;
51}
52
54 // Define in terms of operator==
55 return !(*this == sr);
56}
57
58SensitivityRecord::operator bool() const {
59 // A SensitivityRecord is false if it is default initialised
60 return *this != SensitivityRecord();
61}
62
64
65std::ostream& operator<<(ostream& out, const SensitivityRecord& sr) {
66 return out << "[" << sr.tradeId << ", " << std::boolalpha << sr.isPar << ", " << sr.key_1 << ", " << sr.desc_1
67 << ", " << fixed << setprecision(6) << sr.shift_1 << ", " << sr.key_2 << ", " << sr.desc_2 << ", "
68 << fixed << setprecision(6) << sr.shift_2 << ", " << sr.currency << ", " << fixed << setprecision(2)
69 << sr.baseNpv << ", " << fixed << setprecision(2) << sr.delta << ", " << fixed << setprecision(2)
70 << sr.gamma << "]";
71}
72
73} // namespace analytics
74} // namespace ore
Data types stored in the scenario class.
Definition: scenario.hpp:48
std::ostream & operator<<(std::ostream &out, EquityReturnType t)
Struct for holding a sensitivity record.
bool operator==(const SensitivityRecord &sr) const
bool operator!=(const SensitivityRecord &sr) const
bool operator<(const SensitivityRecord &sr) const
bool isCrossGamma() const
True if a SensitivityRecord is a cross gamma, otherwise false.