Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
simmbucketmapper.hpp
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
19/*! \file orea/simm/simmbucketmapper.hpp
20 \brief Abstract base class for classes that map SIMM qualifiers to buckets
21*/
22
23#pragma once
24
25#include <orea/simm/crif.hpp>
26#include <ql/time/date.hpp>
27
28#include <string>
29
30namespace ore {
31namespace analytics {
32
34public:
36 std::string name, lookupName;
38 };
39
40 //! Destructor
41 virtual ~SimmBucketMapper() {}
42
43 /*! Return the SIMM <em>bucket</em> for a given SIMM <em>RiskType</em> and
44 SIMM <em>Qualifier</em> (using valid mappings only)
45
46 \warning An error is thrown if there is no <em>bucket</em>
47 for the combination.
48 */
49 virtual std::string bucket(const CrifRecord::RiskType& riskType, const std::string& qualifier) const = 0;
50
51 //! Check if the given SIMM <em>RiskType</em> has a bucket structure.
52 virtual bool hasBuckets(const CrifRecord::RiskType& riskType) const = 0;
53
54 //! Check if the given \p riskType and \p qualifier has a mapping (which is valid, and matches the fallback flag if given)
55 virtual bool has(const CrifRecord::RiskType& riskType, const std::string& qualifier, boost::optional<bool> fallback = boost::none) const = 0;
56
57 //! Add a single \p bucket mapping for \p qualifier with risk type \p riskType
58 /*! \todo Not very convenient. If deemed useful, add more methods for adding
59 mappings e.g. <code>addMappingRange</code> that adds a range of
60 mappings at once
61 */
62 virtual void addMapping(const CrifRecord::RiskType& riskType, const std::string& qualifier,
63 const std::string& bucket, const std::string& validFrom = "", const std::string& validTo = "", bool fallback = false) = 0;
64
65 virtual const std::set<FailedMapping>& failedMappings() const = 0;
66
68 for (const auto& cr : crif) {
69 if (!cr.isSimmParameter() && hasBuckets(cr.riskType)) {
70 addMapping(cr.riskType, cr.qualifier, cr.bucket);
71 }
72 }
73 }
74};
75
77 return std::make_tuple(a.name, a.lookupName, a.riskType, a.lookupRiskType) <
78 std::make_tuple(b.name, b.lookupName, b.riskType, b.lookupRiskType);
79}
80
81} // namespace analytics
82} // namespace ore
void updateFromCrif(const ore::analytics::Crif &crif)
virtual const std::set< FailedMapping > & failedMappings() const =0
virtual bool hasBuckets(const CrifRecord::RiskType &riskType) const =0
Check if the given SIMM RiskType has a bucket structure.
virtual void addMapping(const CrifRecord::RiskType &riskType, const std::string &qualifier, const std::string &bucket, const std::string &validFrom="", const std::string &validTo="", bool fallback=false)=0
Add a single bucket mapping for qualifier with risk type riskType.
virtual std::string bucket(const CrifRecord::RiskType &riskType, const std::string &qualifier) const =0
virtual bool has(const CrifRecord::RiskType &riskType, const std::string &qualifier, boost::optional< bool > fallback=boost::none) const =0
Check if the given riskType and qualifier has a mapping (which is valid, and matches the fallback fla...
virtual ~SimmBucketMapper()
Destructor.
Struct for holding CRIF records.
bool operator<(const Dividend &d1, const Dividend &d2)