Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
marketcalibrationreport.hpp
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/*! \file orea/app/marketcalibrationreport.hpp
20 \brief ORE Analytics Manager
21*/
22#pragma once
23
28
29namespace ore {
30namespace analytics {
32public:
33
36 CalibrationFilters(const std::string& calibrationFilter) {
37 if (!calibrationFilter.empty()) {
38 std::string tmp = calibrationFilter;
39 boost::algorithm::to_upper(tmp);
40 std::vector<std::string> tokens;
41 boost::split(tokens, tmp, boost::is_any_of(","), boost::token_compress_on);
42 mdFilterFixings = std::find(tokens.begin(), tokens.end(), "FIXINGS") != tokens.end();
43 mdFilterMarketData = std::find(tokens.begin(), tokens.end(), "MARKETDATA") != tokens.end();
44 mdFilterCurves = std::find(tokens.begin(), tokens.end(), "CURVES") != tokens.end();
45 mdFilterInfCurves = std::find(tokens.begin(), tokens.end(), "INFLATIONCURVES") != tokens.end();
46 mdFilterCommCurves = std::find(tokens.begin(), tokens.end(), "COMMODITYCURVES") != tokens.end();
47 mdFilterFxVols = std::find(tokens.begin(), tokens.end(), "FXVOLS") != tokens.end();
48 mdFilterEqVols = std::find(tokens.begin(), tokens.end(), "EQVOLS") != tokens.end();
49 mdFilterIrVols = std::find(tokens.begin(), tokens.end(), "IRVOLS") != tokens.end();
50 mdFilterCommVols = std::find(tokens.begin(), tokens.end(), "COMMVOLS") != tokens.end();
51 }
52 }
53
54 bool mdFilterFixings = true;
55 bool mdFilterMarketData = true;
56 bool mdFilterCurves = true;
57 bool mdFilterInfCurves = true;
58 bool mdFilterCommCurves = true;
59 bool mdFilterFxVols = true;
60 bool mdFilterEqVols = true;
61 bool mdFilterIrVols = true;
62 bool mdFilterCommVols = true;
63 };
64
65 MarketCalibrationReportBase(const std::string& calibrationFilter);
66 virtual ~MarketCalibrationReportBase() = default;
67
68 virtual void initialise(const std::string& label) {};
69
70 // Add yield curve data to array
71 virtual void addYieldCurve(const QuantLib::Date& refdate,
72 QuantLib::ext::shared_ptr<ore::data::YieldCurveCalibrationInfo> yts, const std::string& name,
73 bool isDiscount, const std::string& label) = 0;
74
75 // Add inflation curve data to array
76 virtual void addInflationCurve(const QuantLib::Date& refdate,
77 QuantLib::ext::shared_ptr<ore::data::InflationCurveCalibrationInfo> yts,
78 const std::string& name, const std::string& label) = 0;
79
80 virtual void addCommodityCurve(const QuantLib::Date& refdate,
81 QuantLib::ext::shared_ptr<ore::data::CommodityCurveCalibrationInfo> yts,
82 std::string const& name, std::string const& label) = 0;
83
84 // Add fx/eq/comm vol curve data to array
85 virtual void addFxVol(const QuantLib::Date& refdate, QuantLib::ext::shared_ptr<ore::data::FxEqCommVolCalibrationInfo> vol,
86 const std::string& name, const std::string& label) = 0;
87 virtual void addEqVol(const QuantLib::Date& refdate, QuantLib::ext::shared_ptr<ore::data::FxEqCommVolCalibrationInfo> vol,
88 const std::string& name, const std::string& label) = 0;
89 virtual void addCommVol(const QuantLib::Date& refdate, QuantLib::ext::shared_ptr<ore::data::FxEqCommVolCalibrationInfo> vol,
90 const std::string& name, const std::string& label) = 0;
91
92 // Add ir vol curve data to array
93 virtual void addIrVol(const QuantLib::Date& refdate, QuantLib::ext::shared_ptr<ore::data::IrVolCalibrationInfo> vol,
94 const std::string& name, const std::string& label) = 0;
95
96 // populate the calibration reports
97 virtual void populateReport(const QuantLib::ext::shared_ptr<ore::data::Market>& market,
98 const QuantLib::ext::shared_ptr<ore::data::TodaysMarketParameters>& todaysMarketParams,
99 const std::string& label = std::string());
100
101 // write out to file, should be overwritten in derived classes
102 virtual QuantLib::ext::shared_ptr<ore::data::Report> outputCalibrationReport() = 0;
103
104private:
106};
107
109public:
110 MarketCalibrationReport(const std::string& calibrationFilter,
111 const QuantLib::ext::shared_ptr<ore::data::Report>& report);
112
113 QuantLib::ext::shared_ptr<ore::data::Report> outputCalibrationReport() override;
114
115 void addYieldCurve(const QuantLib::Date& refdate, QuantLib::ext::shared_ptr<ore::data::YieldCurveCalibrationInfo> yts,
116 const std::string& name, bool isDiscount, const std::string& label) override;
117
118 // Add inflation curve data to array
119 void addInflationCurve(const QuantLib::Date& refdate,
120 QuantLib::ext::shared_ptr<ore::data::InflationCurveCalibrationInfo> yts, const std::string& name,
121 const std::string& label) override;
122
123 // Add commodity curve data to array
124 void addCommodityCurve(const QuantLib::Date& refdate,
125 QuantLib::ext::shared_ptr<ore::data::CommodityCurveCalibrationInfo> yts, const std::string& name,
126 const std::string& label) override;
127
128 // Add fx/eq/comm vol curve data to array
129 void addFxVol(const QuantLib::Date& refdate, QuantLib::ext::shared_ptr<ore::data::FxEqCommVolCalibrationInfo> vol,
130 const std::string& name, const std::string& label) override;
131 void addEqVol(const QuantLib::Date& refdate, QuantLib::ext::shared_ptr<ore::data::FxEqCommVolCalibrationInfo> vol,
132 const std::string& name, const std::string& label) override;
133 void addCommVol(const QuantLib::Date& refdate, QuantLib::ext::shared_ptr<ore::data::FxEqCommVolCalibrationInfo> vol,
134 const std::string& name, const std::string& label) override;
135
136 // Add ir vol curve data to array
137 void addIrVol(const QuantLib::Date& refdate, QuantLib::ext::shared_ptr<ore::data::IrVolCalibrationInfo> vol,
138 const std::string& name, const std::string& label) override;
139
140private:
141 QuantLib::ext::shared_ptr<ore::data::Report> report_;
142
143 // a map of already reported calibrations
144 std::map<std::string, std::map<std::string, std::set<std::string>>> calibrations_;
145
146 void addRowReport(const std::string& moType, const std::string& moId, const std::string& resId,
147 const std::string& key1, const std::string& key2, const std::string& key3,
148 const boost::any& value);
149 void addEqFxVol(const std::string& type, QuantLib::ext::shared_ptr<ore::data::FxEqCommVolCalibrationInfo> vol,
150 const std::string& id, const std::string& label);
151 const bool checkCalibrations(std::string label, std::string type, std::string id) const;
152};
153
154} // namespace analytics
155} // namespace ore
virtual void addInflationCurve(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::InflationCurveCalibrationInfo > yts, const std::string &name, const std::string &label)=0
virtual void addFxVol(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::FxEqCommVolCalibrationInfo > vol, const std::string &name, const std::string &label)=0
virtual void populateReport(const QuantLib::ext::shared_ptr< ore::data::Market > &market, const QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameters > &todaysMarketParams, const std::string &label=std::string())
virtual void addCommVol(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::FxEqCommVolCalibrationInfo > vol, const std::string &name, const std::string &label)=0
virtual void addCommodityCurve(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::CommodityCurveCalibrationInfo > yts, std::string const &name, std::string const &label)=0
virtual QuantLib::ext::shared_ptr< ore::data::Report > outputCalibrationReport()=0
virtual void addYieldCurve(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::YieldCurveCalibrationInfo > yts, const std::string &name, bool isDiscount, const std::string &label)=0
virtual void addIrVol(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::IrVolCalibrationInfo > vol, const std::string &name, const std::string &label)=0
virtual void addEqVol(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::FxEqCommVolCalibrationInfo > vol, const std::string &name, const std::string &label)=0
virtual void initialise(const std::string &label)
void addYieldCurve(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::YieldCurveCalibrationInfo > yts, const std::string &name, bool isDiscount, const std::string &label) override
void addEqFxVol(const std::string &type, QuantLib::ext::shared_ptr< ore::data::FxEqCommVolCalibrationInfo > vol, const std::string &id, const std::string &label)
void addCommVol(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::FxEqCommVolCalibrationInfo > vol, const std::string &name, const std::string &label) override
void addCommodityCurve(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::CommodityCurveCalibrationInfo > yts, const std::string &name, const std::string &label) override
const bool checkCalibrations(std::string label, std::string type, std::string id) const
std::map< std::string, std::map< std::string, std::set< std::string > > > calibrations_
QuantLib::ext::shared_ptr< ore::data::Report > outputCalibrationReport() override
void addInflationCurve(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::InflationCurveCalibrationInfo > yts, const std::string &name, const std::string &label) override
void addEqVol(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::FxEqCommVolCalibrationInfo > vol, const std::string &name, const std::string &label) override
void addIrVol(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::IrVolCalibrationInfo > vol, const std::string &name, const std::string &label) override
void addFxVol(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::FxEqCommVolCalibrationInfo > vol, const std::string &name, const std::string &label) override
QuantLib::ext::shared_ptr< ore::data::Report > report_
void addRowReport(const std::string &moType, const std::string &moId, const std::string &resId, const std::string &key1, const std::string &key2, const std::string &key3, const boost::any &value)
string name