Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
commodityforward.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 ored/portfolio/commodityforward.hpp
20 \brief Commodity forward representation
21
22 \ingroup tradedata
23*/
24
25#pragma once
26
28
29namespace ore {
30namespace data {
31
32//! Serializable Commodity forward contract
33//! \ingroup tradedata
34class CommodityForward : public Trade {
35public:
36 //! \name Constructors
37 //@{
38 //! Default constructor
40
41 //! Detailed constructor with explicit future expiry date.
42 CommodityForward(const Envelope& envelope, const std::string& position, const std::string& commodityName,
43 const std::string& currency, QuantLib::Real quantity, const std::string& maturityDate,
44 QuantLib::Real strike);
45
46 //! Detailed constructor with explicit future expiry date.
47 CommodityForward(const Envelope& envelope, const std::string& position, const std::string& commodityName,
48 const std::string& currency, QuantLib::Real quantity, const std::string& maturityDate,
49 QuantLib::Real strike, const QuantLib::Date& futureExpiryDate,
50 const boost::optional<bool>& physicallySettled = true,
51 const Date& paymentDate = Date());
52
53 //! Detailed constructor with explicit future expiry offset and calendar.
54 CommodityForward(const Envelope& envelope, const std::string& position, const std::string& commodityName,
55 const std::string& currency, QuantLib::Real quantity, const std::string& maturityDate,
56 QuantLib::Real strike, const QuantLib::Period& futureExpiryOffset,
57 const QuantLib::Calendar& offsetCalendar,
58 const boost::optional<bool>& physicallySettled = true,
59 const Date& paymentDate = Date());
60 //@}
61
62 //! \name Inspectors
63 //@{
64 std::string position() { return position_; }
65 std::string commodityName() { return commodityName_; }
66 std::string currency() { return currency_; }
67 QuantLib::Real quantity() { return quantity_; }
68 std::string maturityDate() { return maturityDate_; }
69 QuantLib::Real strike() { return strike_; }
70 const boost::optional<bool>& isFuturePrice() const { return isFuturePrice_; }
71 const QuantLib::Date& futureExpiryDate() const { return futureExpiryDate_; }
72 const QuantLib::Period& futureExpiryOffset() const { return futureExpiryOffset_; }
74 const boost::optional<bool>& physicallySettled() const { return physicallySettled_; }
75 const QuantLib::Date& paymentDate() const { return paymentDate_; }
76 //@}
77
78 //! \name Trade interface
79 //@{
80 void build(const QuantLib::ext::shared_ptr<EngineFactory>&) override;
81 QuantLib::Real notional() const override;
82
83 //! Add underlying Commodity names
84 std::map<AssetClass, std::set<std::string>>
85 underlyingIndices(const QuantLib::ext::shared_ptr<ReferenceDataManager>& referenceDataManager = nullptr) const override;
86 //@}
87
88 //! \name Serialisation
89 //@{
90 virtual void fromXML(XMLNode* node) override;
91 virtual XMLNode* toXML(XMLDocument& doc) const override;
92 //@}
93
94private:
95 std::string position_;
96 std::string commodityName_;
97 std::string currency_;
98 QuantLib::Real quantity_;
99 std::string maturityDate_;
100 QuantLib::Real strike_;
101
102 /*! Indicates if the forward underlying is a commodity future settlement price, \c true, or a spot price \c false.
103 If not explicitly set, it is assumed to be \c false.
104 */
105 boost::optional<bool> isFuturePrice_;
106
107 /*! An explicit expiry date for the underlying future contract. This can be used if the trade references a
108 future contract settlement price and the forward's maturity date does not match the future contract expiry
109 date.
110 */
111 QuantLib::Date futureExpiryDate_;
112
113 //! Future expiry offset and calendar
114 QuantLib::Period futureExpiryOffset_;
116
117 boost::optional<bool> physicallySettled_;
118 QuantLib::Date paymentDate_;
119
120 //! NDF currency, index and fixing date
121 QuantLib::Date fixingDate_;
122 std::string fxIndex_;
123 std::string payCcy_;
124
125};
126} // namespace data
127} // namespace ore
QuantLib::Currency currency_
const QuantLib::Date & maturityDate() const
QuantLib::Date paymentDate_
QuantLib::Position::Type position() const
const QuantLib::Currency & currency() const
const QuantLib::Date & paymentDate() const
QuantLib::Real quantity() const
QuantLib::Position::Type position_
QuantLib::Date maturityDate_
QuantLib::Real strike() const
bool physicallySettled() const
CommodityForward(const Envelope &envelope, const std::string &position, const std::string &commodityName, const std::string &currency, QuantLib::Real quantity, const std::string &maturityDate, QuantLib::Real strike)
Detailed constructor with explicit future expiry date.
const boost::optional< bool > & isFuturePrice() const
const boost::optional< bool > & physicallySettled() const
CommodityForward(const Envelope &envelope, const std::string &position, const std::string &commodityName, const std::string &currency, QuantLib::Real quantity, const std::string &maturityDate, QuantLib::Real strike, const QuantLib::Date &futureExpiryDate, const boost::optional< bool > &physicallySettled=true, const Date &paymentDate=Date())
Detailed constructor with explicit future expiry date.
const QuantLib::Calendar & offsetCalendar() const
QuantLib::Period futureExpiryOffset_
Future expiry offset and calendar.
QuantLib::Date fixingDate_
NDF currency, index and fixing date.
const QuantLib::Date & futureExpiryDate() const
const QuantLib::Period & futureExpiryOffset() const
boost::optional< bool > physicallySettled_
boost::optional< bool > isFuturePrice_
QuantLib::Calendar offsetCalendar_
const QuantLib::Date & paymentDate() const
CommodityForward(const Envelope &envelope, const std::string &position, const std::string &commodityName, const std::string &currency, QuantLib::Real quantity, const std::string &maturityDate, QuantLib::Real strike, const QuantLib::Period &futureExpiryOffset, const QuantLib::Calendar &offsetCalendar, const boost::optional< bool > &physicallySettled=true, const Date &paymentDate=Date())
Detailed constructor with explicit future expiry offset and calendar.
Serializable object holding generic trade data, reporting dimensions.
Definition: envelope.hpp:51
Trade base class.
Definition: trade.hpp:55
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23
base trade data model and serialization