Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
commodityswap.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2019 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 ored/portfolio/commodityswap.hpp
20 \brief Commodity Swap data model and serialization
21 \ingroup tradedata
22*/
23
24#pragma once
25
31
32namespace ore {
33namespace data {
34
35/*! Serializable Commodity Swap
36 \ingroup tradedata
37*/
39public:
40 CommoditySwap() : ore::data::Trade("CommoditySwap") {}
41
42 CommoditySwap(const ore::data::Envelope& env, const std::vector<ore::data::LegData>& legs)
43 : Trade("CommoditySwap", env), legData_(legs) {}
44
45 void build(const QuantLib::ext::shared_ptr<ore::data::EngineFactory>&) override;
46 QuantLib::Real notional() const override;
47
48 //! Add underlying Commodity names
49 std::map<ore::data::AssetClass, std::set<std::string>>
50 underlyingIndices(const QuantLib::ext::shared_ptr<ore::data::ReferenceDataManager>& referenceDataManager = nullptr) const override;
51
52 //! \name Inspectors
53 //@{
54 const std::vector<ore::data::LegData>& legData() const { return legData_; }
55 //@}
56
57 //! \name Serialisation
58 //@{
59 virtual void fromXML(ore::data::XMLNode* node) override;
60 virtual ore::data::XMLNode* toXML(ore::data::XMLDocument& doc) const override;
61 //@}
62
63 const std::map<std::string,boost::any>& additionalData() const override;
64
65private:
66 QuantLib::ext::shared_ptr<ore::data::LegData> createLegData() const { return QuantLib::ext::make_shared<ore::data::LegData>(); }
67
68 // Perform checks before attempting to build
69 void check() const;
70
71 // Build a leg
72 void buildLeg(const QuantLib::ext::shared_ptr<ore::data::EngineFactory>& ef,
73 const ore::data::LegData& legDatum, const std::string& configuration);
74
75 std::vector<ore::data::LegData> legData_;
76};
77
78} // namespace data
79} // namespace ore
const std::vector< ore::data::LegData > & legData() const
void buildLeg(const QuantLib::ext::shared_ptr< ore::data::EngineFactory > &ef, const ore::data::LegData &legDatum, const std::string &configuration)
std::vector< ore::data::LegData > legData_
virtual void fromXML(ore::data::XMLNode *node) override
QuantLib::Real notional() const override
Return the current notional in npvCurrency. See individual sub-classes for the precise definition.
CommoditySwap(const ore::data::Envelope &env, const std::vector< ore::data::LegData > &legs)
virtual ore::data::XMLNode * toXML(ore::data::XMLDocument &doc) const override
QuantLib::ext::shared_ptr< ore::data::LegData > createLegData() const
void build(const QuantLib::ext::shared_ptr< ore::data::EngineFactory > &) override
std::map< ore::data::AssetClass, std::set< std::string > > underlyingIndices(const QuantLib::ext::shared_ptr< ore::data::ReferenceDataManager > &referenceDataManager=nullptr) const override
Add underlying Commodity names.
const std::map< std::string, boost::any > & additionalData() const override
returns all additional data returned by the trade once built
Serializable object holding generic trade data, reporting dimensions.
Definition: envelope.hpp:51
Serializable object holding leg data.
Definition: legdata.hpp:844
Trade base class.
Definition: trade.hpp:55
const std::vector< QuantLib::Leg > & legs() const
Definition: trade.hpp:143
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
leg data for commodity leg types
leg data model and serialization
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23
trade schedule data model and serialization
base trade data model and serialization
Trade Factory.