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 qle/instruments/commodityforward.hpp
20 \brief Instrument representing a commodity forward contract
21
22 \ingroup instruments
23*/
24
25#ifndef quantext_commodity_forward_hpp
26#define quantext_commodity_forward_hpp
27
28#include <ql/currency.hpp>
29#include <ql/instrument.hpp>
30#include <ql/position.hpp>
33
34namespace QuantExt {
35
36/*! Instrument representing a commodity forward contract.
37
38 \ingroup instruments
39*/
40class CommodityForward : public QuantLib::Instrument {
41public:
42 class arguments;
43 class engine;
44
45 //! \name Constructors
46 //@{
47 /*! Constructs a cash settled or physically settled commodity forward instrument.
48
49 \param index The underlying commodity index.
50 \param currency The currency of the commodity trade.
51 \param position Long (Short) for buying (selling) commodity forward
52 \param quantity Number of underlying commodity units referenced
53 \param maturityDate Maturity date of forward. For a cash settled forward, this is the date on which the
54 underlying price is observed.
55 \param strike The agreed forward price
56 \param physicallySettled Set to \c true if the forward is physically settled and \c false if the forward is
57 cash settled. If omitted, physical settlement is assumed.
58 \param paymentDate If the forward is cash settled, provide a date on or after the \p maturityDate for
59 the cash settlement payment. If omitted, it is assumed equal to \p maturityDate.
60 \param payCcy If cash settled, the settlement currency
61 \param fixingDate If cash settled, the fixing date
62 \param fxIndex If cash settled, the FX index from which to take the fixing on the fixing date
63 */
64 CommodityForward(const QuantLib::ext::shared_ptr<CommodityIndex>& index, const QuantLib::Currency& currency,
65 QuantLib::Position::Type position, QuantLib::Real quantity, const QuantLib::Date& maturityDate,
66 QuantLib::Real strike, bool physicallySettled = true, const Date& paymentDate = Date(),
67 const QuantLib::Currency& payCcy = Currency(), const Date& fixingDate = Date(),
68 const QuantLib::ext::shared_ptr<QuantExt::FxIndex>& fxIndex = nullptr);
69 //@}
70
71 //! \name Instrument interface
72 //@{
73 bool isExpired() const override;
75 //@}
76
77 //! \name Inspectors
78 //@{
79 const QuantLib::ext::shared_ptr<CommodityIndex>& index() const { return index_; }
80 const QuantLib::Currency& currency() const { return currency_; }
81 QuantLib::Position::Type position() const { return position_; }
82 QuantLib::Real quantity() const { return quantity_; }
83 const QuantLib::Date& maturityDate() const { return maturityDate_; }
84 QuantLib::Real strike() const { return strike_; }
85 bool physicallySettled() const { return physicallySettled_; }
86 const QuantLib::Date& paymentDate() const { return paymentDate_; }
87 Currency payCcy() const { return payCcy_; }
88 Date fixingDate() const { return fixingDate_; }
89 QuantLib::ext::shared_ptr<QuantExt::FxIndex> fxIndex() const { return fxIndex_; }
90 //@}
91
92private:
93 QuantLib::ext::shared_ptr<CommodityIndex> index_;
94 QuantLib::Currency currency_;
95 QuantLib::Position::Type position_;
96 QuantLib::Real quantity_;
97 QuantLib::Date maturityDate_;
98 QuantLib::Real strike_;
100 QuantLib::Date paymentDate_;
101 Currency payCcy_;
102 QuantLib::ext::shared_ptr<FxIndex> fxIndex_;
104};
105
106//! \ingroup instruments
108public:
109 QuantLib::ext::shared_ptr<CommodityIndex> index;
110 QuantLib::Currency currency;
111 QuantLib::Position::Type position;
112 QuantLib::Real quantity;
113 QuantLib::Date maturityDate;
114 QuantLib::Real strike;
116 QuantLib::Date paymentDate;
117 Currency payCcy;
118 QuantLib::ext::shared_ptr<FxIndex> fxIndex;
120 void validate() const override;
121};
122
123//! \ingroup instruments
124class CommodityForward::engine : public QuantLib::GenericEngine<CommodityForward::arguments, Instrument::results> {};
125} // namespace QuantExt
126
127#endif
QuantLib::ext::shared_ptr< FxIndex > fxIndex
QuantLib::ext::shared_ptr< CommodityIndex > index
QuantLib::ext::shared_ptr< FxIndex > fxIndex_
bool isExpired() const override
const QuantLib::ext::shared_ptr< CommodityIndex > & index() const
QuantLib::Currency currency_
QuantLib::ext::shared_ptr< QuantExt::FxIndex > fxIndex() const
const QuantLib::Date & maturityDate() const
QuantLib::ext::shared_ptr< CommodityIndex > index_
QuantLib::Position::Type position() const
const QuantLib::Currency & currency() const
void setupArguments(QuantLib::PricingEngine::arguments *) const override
const QuantLib::Date & paymentDate() const
QuantLib::Real quantity() const
QuantLib::Position::Type position_
QuantLib::Real strike() const
commodity index class for holding commodity spot and futures price histories and forwarding.
FX index class.