Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
imscheduleresults.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/simm/imscheduleresults.hpp
20 \brief Class for holding IMSchedule results
21*/
22
23#pragma once
24
25#include <map>
26
29#include <ql/types.hpp>
30
31namespace ore {
32namespace analytics {
33
35
37
38 IMScheduleResult(const QuantLib::Real& grossIM = 0.0, const QuantLib::Real& grossRC = 0.0,
39 const QuantLib::Real& netRC = 0.0, const QuantLib::Real& ngr = 0.0,
40 const QuantLib::Real& scheduleIM = 0.0)
42
43 QuantLib::Real grossIM;
44 QuantLib::Real grossRC;
45 QuantLib::Real netRC;
46 QuantLib::Real NGR;
47 QuantLib::Real scheduleIM;
48};
49
50/*! A container for Schedule IM results broken down by product class, risk class
51 and margin type.
52*/
54public:
55 IMScheduleResults(const std::string& ccy = "") : ccy_(ccy){};
56
57 /*! Add initial margin value \p im to the results container for the given combination of
58 Schedule <em>product class</em>, <em>risk class</em> and <em>margin type</em>
59
60 \remark If there is already a result in the container for that combination, it is
61 overwritten. Can check this using the <code>has</code> method before adding.
62 */
63 void add(const CrifRecord::ProductClass& pc, const std::string& calculationCurrency,
64 const QuantLib::Real grossIM, const QuantLib::Real grossRC, const QuantLib::Real netRC,
65 const QuantLib::Real ngr, const QuantLib::Real scheduleIM);
66
67 //! Convert Schedule IM amounts to a different currency
68 // void convert(const QuantLib::ext::shared_ptr<ore::data::Market>& market, const std::string& currency);
69 // void convert(QuantLib::Real fxSpot, const std::string& currency);
70
71 /*! Get the initial margin value from the results container for the given combination of
72 Schedule <em>product class</em>, <em>risk class</em> and <em>margin type</em>
73
74 \warning returns <code>QuantLib::Null<QuantLib::Real></code> if there is no initial margin
75 value in the results for the given combination. Can avoid this by first checking
76 the results using the <code>has</code> method.
77 */
78 IMScheduleResult get(const CrifRecord::ProductClass& pc) const;
79
80 /*! Check if there is an initial margin value in the results container for the given combination of
81 Schedule <em>product class</em>, <em>risk class</em> and <em>margin type</em>
82 */
83 bool has(const CrifRecord::ProductClass& pc) const;
84
85 //! Return true if the container is empty, otherwise false
86 bool empty() const;
87
88 //! Clear the results from the container
89 void clear();
90
91 //! Return the map containing the results
92 // Not nice to do this i.e. exposing inner implementation but it
93 // allows to iterate over results cleanly. Would be better to subclass
94 // std::iterator in this class.
95 const std::map<CrifRecord::ProductClass, IMScheduleResult>& data() const { return data_; }
96
97 const std::string& currency() const { return ccy_; }
98
99 std::string& currency() { return ccy_; }
100
101private:
102 std::map<CrifRecord::ProductClass, IMScheduleResult> data_;
103 std::string ccy_;
104};
105
106} // namespace analytics
107} // namespace ore
bool has(const CrifRecord::ProductClass &pc) const
const std::string & currency() const
IMScheduleResults(const std::string &ccy="")
const std::map< CrifRecord::ProductClass, IMScheduleResult > & data() const
Return the map containing the results.
bool empty() const
Return true if the container is empty, otherwise false.
std::map< CrifRecord::ProductClass, IMScheduleResult > data_
void add(const CrifRecord::ProductClass &pc, const std::string &calculationCurrency, const QuantLib::Real grossIM, const QuantLib::Real grossRC, const QuantLib::Real netRC, const QuantLib::Real ngr, const QuantLib::Real scheduleIM)
void clear()
Clear the results from the container.
SIMM configuration interface.
IMScheduleResult(const QuantLib::Real &grossIM=0.0, const QuantLib::Real &grossRC=0.0, const QuantLib::Real &netRC=0.0, const QuantLib::Real &ngr=0.0, const QuantLib::Real &scheduleIM=0.0)