Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Classes | List of all members
CommodityForward Class Reference

#include <qle/instruments/commodityforward.hpp>

+ Inheritance diagram for CommodityForward:
+ Collaboration diagram for CommodityForward:

Classes

class  arguments
 
class  engine
 

Public Member Functions

Constructors
 CommodityForward (const QuantLib::ext::shared_ptr< CommodityIndex > &index, const QuantLib::Currency &currency, QuantLib::Position::Type position, QuantLib::Real quantity, const QuantLib::Date &maturityDate, QuantLib::Real strike, bool physicallySettled=true, const Date &paymentDate=Date(), const QuantLib::Currency &payCcy=Currency(), const Date &fixingDate=Date(), const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &fxIndex=nullptr)
 
Instrument interface
bool isExpired () const override
 
void setupArguments (QuantLib::PricingEngine::arguments *) const override
 

Inspectors

QuantLib::ext::shared_ptr< CommodityIndexindex_
 
QuantLib::Currency currency_
 
QuantLib::Position::Type position_
 
QuantLib::Real quantity_
 
QuantLib::Date maturityDate_
 
QuantLib::Real strike_
 
bool physicallySettled_
 
QuantLib::Date paymentDate_
 
Currency payCcy_
 
QuantLib::ext::shared_ptr< FxIndexfxIndex_
 
Date fixingDate_
 
const QuantLib::ext::shared_ptr< CommodityIndex > & index () const
 
const QuantLib::Currency & currency () const
 
QuantLib::Position::Type position () const
 
QuantLib::Real quantity () const
 
const QuantLib::Date & maturityDate () const
 
QuantLib::Real strike () const
 
bool physicallySettled () const
 
const QuantLib::Date & paymentDate () const
 
Currency payCcy () const
 
Date fixingDate () const
 
QuantLib::ext::shared_ptr< QuantExt::FxIndexfxIndex () const
 

Detailed Description

Instrument representing a commodity forward contract.

Definition at line 40 of file commodityforward.hpp.

Constructor & Destructor Documentation

◆ CommodityForward()

CommodityForward ( const QuantLib::ext::shared_ptr< CommodityIndex > &  index,
const QuantLib::Currency &  currency,
QuantLib::Position::Type  position,
QuantLib::Real  quantity,
const QuantLib::Date &  maturityDate,
QuantLib::Real  strike,
bool  physicallySettled = true,
const Date &  paymentDate = Date(),
const QuantLib::Currency &  payCcy = Currency(),
const Date &  fixingDate = Date(),
const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &  fxIndex = nullptr 
)

Constructs a cash settled or physically settled commodity forward instrument.

Parameters
indexThe underlying commodity index.
currencyThe currency of the commodity trade.
positionLong (Short) for buying (selling) commodity forward
quantityNumber of underlying commodity units referenced
maturityDateMaturity date of forward. For a cash settled forward, this is the date on which the underlying price is observed.
strikeThe agreed forward price
physicallySettledSet to true if the forward is physically settled and false if the forward is cash settled. If omitted, physical settlement is assumed.
paymentDateIf the forward is cash settled, provide a date on or after the maturityDate for the cash settlement payment. If omitted, it is assumed equal to maturityDate.
payCcyIf cash settled, the settlement currency
fixingDateIf cash settled, the fixing date
fxIndexIf cash settled, the FX index from which to take the fixing on the fixing date

Definition at line 28 of file commodityforward.cpp.

36
37 QL_REQUIRE(quantity_ > 0, "Commodity forward quantity should be positive: " << quantity);
38 QL_REQUIRE(strike_ > 0 || close_enough(strike_, 0.0), "Commodity forward strike should be greater than or equal to 0: " << strike);
39
41 QL_REQUIRE(paymentDate_ == Date(), "CommodityForward: payment date (" << io::iso_date(paymentDate_) <<
42 ") should not be provided for physically settled commodity forwards.");
43 }
44
45 if (!physicallySettled_ && paymentDate_ != Date()) {
46 QL_REQUIRE(paymentDate_ >= maturityDate_, "CommodityForward: payment date (" << io::iso_date(paymentDate_) <<
47 ") for a cash settled commodity forward should be on or after the maturity date (" <<
48 io::iso_date(maturityDate_) << ").");
49 }
50
51 if (!physicallySettled_ && fixingDate_ != Date()) {
52 QL_REQUIRE(paymentDate_ >= fixingDate_,
53 "CommodityNonDeliverableForward: payment date ("
54 << io::iso_date(paymentDate_) << ") for a commodity NDF should be on or after the fixing date ("
55 << io::iso_date(fixingDate_) << ").");
56 }
57
58 registerWith(index_);
59}
QuantLib::ext::shared_ptr< FxIndex > fxIndex_
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
const QuantLib::Date & paymentDate() const
QuantLib::Real quantity() const
QuantLib::Position::Type position_
QuantLib::Real strike() const
Filter close_enough(const RandomVariable &x, const RandomVariable &y)
+ Here is the call graph for this function:

Member Function Documentation

◆ isExpired()

bool isExpired ( ) const
override

Definition at line 61 of file commodityforward.cpp.

61 {
62 if (physicallySettled_ || paymentDate_ == Date()) {
63 return detail::simple_event(maturityDate_).hasOccurred();
64 } else {
65 return detail::simple_event(paymentDate_).hasOccurred();
66 }
67}
+ Here is the caller graph for this function:

◆ setupArguments()

void setupArguments ( QuantLib::PricingEngine::arguments ) const
override

Definition at line 69 of file commodityforward.cpp.

69 {
70 auto* arguments = dynamic_cast<CommodityForward::arguments*>(args);
71 QL_REQUIRE(arguments != nullptr, "wrong argument type in CommodityForward");
72
73 arguments->index = index_;
74 arguments->currency = currency_;
75 arguments->position = position_;
76 arguments->quantity = quantity_;
77 arguments->maturityDate = maturityDate_;
78 arguments->strike = strike_;
79 arguments->physicallySettled = physicallySettled_;
80 arguments->paymentDate = paymentDate_;
81 arguments->payCcy = payCcy_;
82 arguments->fixingDate = fixingDate_;
83 arguments->fxIndex = fxIndex_;
84}

◆ index()

const QuantLib::ext::shared_ptr< CommodityIndex > & index ( ) const

Definition at line 79 of file commodityforward.hpp.

79{ return index_; }
+ Here is the caller graph for this function:

◆ currency()

const QuantLib::Currency & currency ( ) const

Definition at line 80 of file commodityforward.hpp.

80{ return currency_; }
+ Here is the caller graph for this function:

◆ position()

QuantLib::Position::Type position ( ) const

Definition at line 81 of file commodityforward.hpp.

81{ return position_; }
+ Here is the caller graph for this function:

◆ quantity()

QuantLib::Real quantity ( ) const

Definition at line 82 of file commodityforward.hpp.

82{ return quantity_; }
+ Here is the caller graph for this function:

◆ maturityDate()

const QuantLib::Date & maturityDate ( ) const

Definition at line 83 of file commodityforward.hpp.

83{ return maturityDate_; }
+ Here is the caller graph for this function:

◆ strike()

QuantLib::Real strike ( ) const

Definition at line 84 of file commodityforward.hpp.

84{ return strike_; }
+ Here is the caller graph for this function:

◆ physicallySettled()

bool physicallySettled ( ) const

Definition at line 85 of file commodityforward.hpp.

85{ return physicallySettled_; }

◆ paymentDate()

const QuantLib::Date & paymentDate ( ) const

Definition at line 86 of file commodityforward.hpp.

86{ return paymentDate_; }

◆ payCcy()

Currency payCcy ( ) const

Definition at line 87 of file commodityforward.hpp.

87{ return payCcy_; }

◆ fixingDate()

Date fixingDate ( ) const

Definition at line 88 of file commodityforward.hpp.

88{ return fixingDate_; }

◆ fxIndex()

QuantLib::ext::shared_ptr< QuantExt::FxIndex > fxIndex ( ) const

Definition at line 89 of file commodityforward.hpp.

89{ return fxIndex_; }

Member Data Documentation

◆ index_

QuantLib::ext::shared_ptr<CommodityIndex> index_
private

Definition at line 93 of file commodityforward.hpp.

◆ currency_

QuantLib::Currency currency_
private

Definition at line 94 of file commodityforward.hpp.

◆ position_

QuantLib::Position::Type position_
private

Definition at line 95 of file commodityforward.hpp.

◆ quantity_

QuantLib::Real quantity_
private

Definition at line 96 of file commodityforward.hpp.

◆ maturityDate_

QuantLib::Date maturityDate_
private

Definition at line 97 of file commodityforward.hpp.

◆ strike_

QuantLib::Real strike_
private

Definition at line 98 of file commodityforward.hpp.

◆ physicallySettled_

bool physicallySettled_
private

Definition at line 99 of file commodityforward.hpp.

◆ paymentDate_

QuantLib::Date paymentDate_
private

Definition at line 100 of file commodityforward.hpp.

◆ payCcy_

Currency payCcy_
private

Definition at line 101 of file commodityforward.hpp.

◆ fxIndex_

QuantLib::ext::shared_ptr<FxIndex> fxIndex_
private

Definition at line 102 of file commodityforward.hpp.

◆ fixingDate_

Date fixingDate_
private

Definition at line 103 of file commodityforward.hpp.