Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
inflationswap.cpp
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
20
21namespace ore {
22namespace data {
23
24InflationSwap::InflationSwap(const Envelope& env, const vector<LegData>& legData)
25 : Swap(env, legData, "InflationSwap") {}
26
27InflationSwap::InflationSwap(const Envelope& env, const LegData& leg0, const LegData& leg1)
28 : Swap(env, leg0, leg1, "InflationSwap") {}
29
30void InflationSwap::checkInflationSwap(const vector<LegData>& legData) {
31 // An Inflation Swap must have at least one CPI or YY leg
32 bool hasInflationLeg = false;
33 for (Size i = 0; i < legData.size(); i++)
34 if (legData[i].legType() == "CPI" || legData[i].legType() == "YY") {
35 hasInflationLeg = true;
36 break;
37 }
38 QL_REQUIRE(hasInflationLeg, "InflationSwap must have at least one inflation leg (e.g. CPI, YY)");
39}
40
41void InflationSwap::build(const QuantLib::ext::shared_ptr<EngineFactory>& engineFactory) {
42
43 DLOG("InflationSwap::build() called for " << id());
44
46
47 Swap::build(engineFactory);
48}
49
52
53 // ISDA taxonomy, override Swap settings Base Product and add Transaction here
54 additionalData_["isdaBaseProduct"] = string("Inflation Swap");
55 if (std::find_if(legData_.begin(), legData_.end(), [](const LegData& d) { return d.legType() == "CPI"; }) !=
56 legData_.end())
57 additionalData_["isdaTransaction"] = string("Zero Coupon");
58 else if (std::find_if(legData_.begin(), legData_.end(), [](const LegData& d) { return d.legType() == "YY"; }) !=
59 legData_.end())
60 additionalData_["isdaTransaction"] = string("Year on Year");
61}
62
63} // namespace data
64} // namespace ore
Serializable object holding generic trade data, reporting dimensions.
Definition: envelope.hpp:51
void setIsdaTaxonomyFields() override
void checkInflationSwap(const vector< LegData > &legData)
InflationSwap()
Default constructor.
virtual void build(const QuantLib::ext::shared_ptr< EngineFactory > &) override
Trade interface.
Serializable object holding leg data.
Definition: legdata.hpp:844
Serializable Swap, Single and Cross Currency.
Definition: swap.hpp:36
const vector< LegData > & legData() const
Definition: swap.hpp:74
vector< LegData > legData_
Definition: swap.hpp:82
virtual void setIsdaTaxonomyFields()
Definition: swap.cpp:220
virtual void build(const QuantLib::ext::shared_ptr< EngineFactory > &) override
Build QuantLib/QuantExt instrument, link pricing engine.
Definition: swap.cpp:45
std::map< std::string, boost::any > additionalData_
Definition: trade.hpp:224
Cross Currency Swap data model and serialization.
@ data
Definition: log.hpp:77
#define DLOG(text)
Logging Macro (Level = Debug)
Definition: log.hpp:554
Serializable Credit Default Swap.
Definition: namespaces.docs:23