Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
swap.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 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 portfolio/swap.hpp
20 \brief Swap trade data model and serialization
21 \ingroup tradedata
22*/
23
24#pragma once
25
28
29namespace ore {
30namespace data {
31
32//! Serializable Swap, Single and Cross Currency
33/*!
34 \ingroup tradedata
35*/
36class Swap : public Trade {
37public:
38 //! Default constructor
39 Swap(const string swapType = "Swap") : Trade(swapType) {}
40
41 Swap(const Envelope& env, const string swapType = "Swap") : Trade(swapType, env) {}
42
43 //! Constructor with vector of LegData
44 Swap(const Envelope& env, const vector<LegData>& legData, const string swapType = "Swap",
45 const std::string settlement = "Physical")
46 : Trade(swapType, env), legData_(legData), settlement_(settlement) {}
47
48 //! Constructor with two legs
49 Swap(const Envelope& env, const LegData& leg0, const LegData& leg1, const string swapType = "Swap",
50 const std::string settlement = "Physical")
51 : Trade(swapType, env), legData_({leg0, leg1}), settlement_(settlement) {}
52
53 //! Build QuantLib/QuantExt instrument, link pricing engine
54 virtual void build(const QuantLib::ext::shared_ptr<EngineFactory>&) override;
55 virtual void setIsdaTaxonomyFields();
56 QuantLib::Real notional() const override;
57 std::string notionalCurrency() const override;
58
59 //! Add underlying index names
60 std::map<AssetClass, std::set<std::string>>
61 underlyingIndices(const QuantLib::ext::shared_ptr<ReferenceDataManager>& referenceDataManager = nullptr) const override;
62
63 //! Settlement Type can be set to "Cash" for NDF. Default value is "Physical"
64 const string& settlement() const { return settlement_; }
65
66 //! \name Serialisation
67 //@{
68 virtual void fromXML(XMLNode* node) override;
69 virtual XMLNode* toXML(XMLDocument& doc) const override;
70 //@}
71
72 //! \name Inspectors
73 //@{
74 const vector<LegData>& legData() const { return legData_; }
75 //@}
76
77 const std::map<std::string,boost::any>& additionalData() const override;
78
79protected:
80 virtual QuantLib::ext::shared_ptr<LegData> createLegData() const;
81
82 vector<LegData> legData_;
84 bool isXCCY_ = false;
85
86private:
89};
90
91std::string isdaSubProductSwap(const std::string& tradeId, const vector<LegData>& legData);
92
93} // namespace data
94} // namespace ore
Serializable object holding generic trade data, reporting dimensions.
Definition: envelope.hpp:51
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
bool isResetting_
Definition: swap.hpp:87
string settlement_
Definition: swap.hpp:83
bool isXCCY_
Definition: swap.hpp:84
Swap(const Envelope &env, const LegData &leg0, const LegData &leg1, const string swapType="Swap", const std::string settlement="Physical")
Constructor with two legs.
Definition: swap.hpp:49
vector< LegData > legData_
Definition: swap.hpp:82
const string & settlement() const
Settlement Type can be set to "Cash" for NDF. Default value is "Physical".
Definition: swap.hpp:64
Size notionalTakenFromLeg_
Definition: swap.hpp:88
Swap(const string swapType="Swap")
Default constructor.
Definition: swap.hpp:39
Swap(const Envelope &env, const string swapType="Swap")
Definition: swap.hpp:41
Swap(const Envelope &env, const vector< LegData > &legData, const string swapType="Swap", const std::string settlement="Physical")
Constructor with vector of LegData.
Definition: swap.hpp:44
Trade base class.
Definition: trade.hpp:55
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
leg data model and serialization
@ data
Definition: log.hpp:77
std::string isdaSubProductSwap(const std::string &tradeId, const vector< LegData > &legData)
Definition: swap.cpp:323
Serializable Credit Default Swap.
Definition: namespaces.docs:23
base trade data model and serialization