Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
crifconfiguration.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2024 AcadiaSoft Inc.
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/crifconfiguration.hpp
20 \brief CRIF configuration interface
21*/
22
23#include <boost/algorithm/string/predicate.hpp>
26
27namespace ore {
28namespace analytics {
29
30string periodToLabels2(const QuantLib::Period& p) {
31 if ((p.units() == QuantLib::Months && p.length() == 3) || (p.units() == QuantLib::Weeks && p.length() == 13)) {
32 return "Libor3m";
33 } else if ((p.units() == QuantLib::Months && p.length() == 6) || (p.units() == QuantLib::Weeks && p.length() == 26)) {
34 return "Libor6m";
35 } else if ((p.units() == QuantLib::Days && p.length() == 1) || p == 1 * QuantLib::Weeks) {
36 // 7 days here is based on ISDA SIMM FAQ and Implementation Questions, Sep 4, 2019 Section E.9
37 // Sub curve to be used for CNY seven-day repo rate (closest is OIS).
38 return "OIS";
39 } else if ((p.units() == QuantLib::Months && p.length() == 1) || (p.units() == QuantLib::Weeks && p.length() == 2) ||
40 (p.units() == QuantLib::Weeks && p.length() == 4) || (p.units() == QuantLib::Days && p.length() >= 28 && p.length() <= 31)) {
41 // 2 weeks here is based on ISDA SIMM Methodology paragraph 14:
42 // "Any sub curve not given on the above list should be mapped to its closest equivalent."
43 // A 2 week rate is more like sub-period than OIS.
44 return "Libor1m";
45 } else if ((p.units() == QuantLib::Months && p.length() == 12) || (p.units() == QuantLib::Years && p.length() == 1) ||
46 (p.units() == QuantLib::Weeks && p.length() == 52)) {
47 return "Libor12m";
48 } else {
49 return "";
50 }
51}
52
53std::string CrifConfiguration::label2(const QuantLib::Period& p) const {
54 std::string label2 = periodToLabels2(p);
55 QL_REQUIRE(!label2.empty(), "Could not determine SIMM Label2 for period " << p);
56 return label2;
57}
58
59std::string CrifConfiguration::label2(const QuantLib::ext::shared_ptr<QuantLib::InterestRateIndex>& irIndex) const {
60 std::string label2;
61 if (boost::algorithm::starts_with(irIndex->name(), "BMA")) {
62 // There was no municipal until later so override this in
63 // derived configurations and use 'Prime' in base
64 label2 = "Prime";
65 } else if (irIndex->familyName() == "Prime") {
66 label2 = "Prime";
67 } else if(QuantLib::ext::dynamic_pointer_cast<QuantExt::TermRateIndex>(irIndex) != nullptr) {
68 // see ISDA-SIMM-FAQ_Methodology-and-Implementation_20220323_clean.pdf: E.8 Term RFR rate risk should be treated as RFR rate risk
69 label2 = "OIS";
70 } else {
71 label2 = periodToLabels2(irIndex->tenor());
72 QL_REQUIRE(!label2.empty(), "Could not determine SIMM Label2 for index " << irIndex->name());
73 }
74 return label2;
75}
76}}
virtual std::string label2(const QuantLib::ext::shared_ptr< QuantLib::InterestRateIndex > &irIndex) const
CRIF configuration interface.
string periodToLabels2(const QuantLib::Period &p)