Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
simmbasicnamemapper.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/simmbasicnamemapper.hpp
20 \brief Basic SIMM class for mapping names to SIMM qualifiers
21*/
22
23#pragma once
24
27#include <ql/time/date.hpp>
28
29#include <map>
30#include <string>
31
32namespace ore {
33namespace analytics {
34
36public:
37 /*! Return the SIMM <em>Qualifier</em> for a given external name.
38
39 \warning If the \p externalName cannot be mapped to a qualifier
40 the externalName itself is returned. In this way, the
41 mapper is basic and places the burden on the caller to
42 call it only when a mapping is needed.
43 */
44 std::string qualifier(const std::string& externalName) const override;
45
46 //! Qualifier mapping expiry (ISO date), may be blank and interpreted as QL::maxDate()
47 std::string validTo(const std::string& externalName) const;
48 //! Qualifier mapping expiry (QuantLib date)
49 QuantLib::Date validToDate(const std::string& externalName) const;
50 //! Qualifier mapping start date (ISO date), may be blank and interpreted as QL::minDate()
51 std::string validFrom(const std::string& externalName) const;
52 //! Qualifier mapping startDate (QuantLib date)
53 QuantLib::Date validFromDate(const std::string& externalName) const;
54
55 //! Has qualifier
56 bool hasQualifier(const std::string& externalName) const override;
57
58 //! Has qualifier that is valid w.r.t. given reference date
59 bool hasValidQualifier(const std::string& externalName, const QuantLib::Date& referenceDate) const;
60
61 //! reverse lookup on qualifier
62 std::string externalName(const std::string& qualifier) const override;
63
64 //! \name Serialisation
65 //@{
67 void fromXML(ore::data::XMLNode* node) override;
68 //@}
69
70 //! Add a single mapping
71 /*! \todo Not very convenient. If deemed useful, add more methods for adding
72 mappings e.g. <code>addMappingRange</code> that adds a range of
73 mappings at once
74 */
75 void addMapping(const std::string& externalName, const std::string& qualifier, const std::string& validFrom = "",
76 const std::string& validTo = "");
77
78protected:
79 /*! A mapping from external name to SIMM <em>Qualifier</em>
80 */
81 std::map<std::string, std::string> mapping_;
82
83 /*! Start and expiry date (ISO) of each mapping
84 */
85 std::map<std::string, std::string> validFrom_, validTo_;
86};
87
88} // namespace analytics
89} // namespace ore
std::string validFrom(const std::string &externalName) const
Qualifier mapping start date (ISO date), may be blank and interpreted as QL::minDate()
std::string validTo(const std::string &externalName) const
Qualifier mapping expiry (ISO date), may be blank and interpreted as QL::maxDate()
QuantLib::Date validToDate(const std::string &externalName) const
Qualifier mapping expiry (QuantLib date)
std::map< std::string, std::string > mapping_
void fromXML(ore::data::XMLNode *node) override
QuantLib::Date validFromDate(const std::string &externalName) const
Qualifier mapping startDate (QuantLib date)
std::string externalName(const std::string &qualifier) const override
reverse lookup on qualifier
ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
void addMapping(const std::string &externalName, const std::string &qualifier, const std::string &validFrom="", const std::string &validTo="")
Add a single mapping.
bool hasQualifier(const std::string &externalName) const override
Has qualifier.
std::map< std::string, std::string > validFrom_
std::string qualifier(const std::string &externalName) const override
bool hasValidQualifier(const std::string &externalName, const QuantLib::Date &referenceDate) const
Has qualifier that is valid w.r.t. given reference date.
std::map< std::string, std::string > validTo_
Date referenceDate
Abstract base class for classes that map names to SIMM qualifiers.