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

Commodity Spread Option. More...

#include <qle/instruments/commodityspreadoption.hpp>

+ Inheritance diagram for CommoditySpreadOption:
+ Collaboration diagram for CommoditySpreadOption:

Classes

class  arguments
 Arguments for commodity spread option calculation More...
 
class  engine
 base class for commodity spread option engines More...
 

Public Member Functions

 CommoditySpreadOption (const QuantLib::ext::shared_ptr< CommodityCashFlow > &longAssetCashflow, const QuantLib::ext::shared_ptr< CommodityCashFlow > &shortAssetCashflow, const ext::shared_ptr< Exercise > &exercise, const Real quantity, const Real strikePrice, Option::Type type, const QuantLib::Date &paymentDate=Date(), const QuantLib::ext::shared_ptr< FxIndex > &longAssetFxIndex=nullptr, const QuantLib::ext::shared_ptr< FxIndex > &shortAssetFxIndex=nullptr, Settlement::Type delivery=Settlement::Physical, Settlement::Method settlementMethod=Settlement::PhysicalOTC)
 
Instrument interface
bool isExpired () const override
 
void setupArguments (PricingEngine::arguments *) const override
 

Inspectors

QuantLib::ext::shared_ptr< CommodityCashFlowlongAssetFlow_
 
QuantLib::ext::shared_ptr< CommodityCashFlowshortAssetFlow_
 
Real quantity_
 
Real strikePrice_
 
Option::Type type_
 
Date paymentDate_
 
QuantLib::ext::shared_ptr< FxIndexlongAssetFxIndex_
 
QuantLib::ext::shared_ptr< FxIndexshortAssetFxIndex_
 
QuantLib::Settlement::Type settlementType_
 
QuantLib::Settlement::Method settlementMethod_
 
const QuantLib::ext::shared_ptr< CommodityCashFlow > & underlyingLongAssetFlow () const
 
const QuantLib::ext::shared_ptr< CommodityCashFlow > & underlyingShortAssetFlow () const
 
const QuantLib::ext::shared_ptr< FxIndex > & longAssetFxIndex () const
 
const QuantLib::ext::shared_ptr< FxIndex > & shortAssetFxIndex () const
 
Real effectiveStrike () const
 
bool isCalendarSpread () const
 

Detailed Description

Commodity Spread Option.

Definition at line 39 of file commodityspreadoption.hpp.

Constructor & Destructor Documentation

◆ CommoditySpreadOption()

CommoditySpreadOption ( const QuantLib::ext::shared_ptr< CommodityCashFlow > &  longAssetCashflow,
const QuantLib::ext::shared_ptr< CommodityCashFlow > &  shortAssetCashflow,
const ext::shared_ptr< Exercise > &  exercise,
const Real  quantity,
const Real  strikePrice,
Option::Type  type,
const QuantLib::Date &  paymentDate = Date(),
const QuantLib::ext::shared_ptr< FxIndex > &  longAssetFxIndex = nullptr,
const QuantLib::ext::shared_ptr< FxIndex > &  shortAssetFxIndex = nullptr,
Settlement::Type  delivery = Settlement::Physical,
Settlement::Method  settlementMethod = Settlement::PhysicalOTC 
)

Definition at line 27 of file commodityspreadoption.cpp.

35 : Option(ext::shared_ptr<Payoff>(), exercise), longAssetFlow_(longAssetFlow), shortAssetFlow_(shortAssetFlow),
36 quantity_(quantity), strikePrice_(strikePrice), type_(type), paymentDate_(paymentDate),
38 settlementMethod_(settlementMethod) {
39 registerWith(longAssetFlow_);
40 registerWith(shortAssetFlow_);
41 QL_REQUIRE(ext::dynamic_pointer_cast<CommodityIndexedCashFlow>(longAssetFlow_) ||
42 QuantLib::ext::dynamic_pointer_cast<CommodityIndexedAverageCashFlow>(longAssetFlow_),
43 "Expect commodity floating cashflows");
44 QL_REQUIRE(ext::dynamic_pointer_cast<CommodityIndexedCashFlow>(shortAssetFlow_) ||
45 QuantLib::ext::dynamic_pointer_cast<CommodityIndexedAverageCashFlow>(shortAssetFlow_),
46 "Expect commodity floating cashflows");
47 if (auto avgFlow = QuantLib::ext::dynamic_pointer_cast<CommodityIndexedAverageCashFlow>(longAssetFlow_)) {
48 QL_REQUIRE(exercise_->lastDate() >= avgFlow->indices().rbegin()->first,
49 "exercise Date hast to be after last observation date");
50 }
51 if (auto avgFlow = QuantLib::ext::dynamic_pointer_cast<CommodityIndexedAverageCashFlow>(shortAssetFlow_)) {
52 QL_REQUIRE(exercise_->lastDate() >= avgFlow->indices().rbegin()->first,
53 "exercise Date hast to be after last observation date");
54 }
55
57 registerWith(longAssetFxIndex_);
59 registerWith(shortAssetFxIndex_);
60 if (paymentDate_ == Date()) {
61 paymentDate_ = std::max(longAssetFlow_->date(), shortAssetFlow_->date());
62 }
63}
QuantLib::Settlement::Type settlementType_
const QuantLib::ext::shared_ptr< FxIndex > & shortAssetFxIndex() const
const QuantLib::ext::shared_ptr< FxIndex > & longAssetFxIndex() const
QuantLib::Settlement::Method settlementMethod_
QuantLib::ext::shared_ptr< CommodityCashFlow > longAssetFlow_
QuantLib::ext::shared_ptr< CommodityCashFlow > shortAssetFlow_
QuantLib::ext::shared_ptr< FxIndex > longAssetFxIndex_
QuantLib::ext::shared_ptr< FxIndex > shortAssetFxIndex_

Member Function Documentation

◆ isExpired()

bool isExpired ( ) const
override

Definition at line 65 of file commodityspreadoption.cpp.

65{ return paymentDate_ < Settings::instance().evaluationDate(); }

◆ setupArguments()

void setupArguments ( PricingEngine::arguments *  args) const
override

Definition at line 71 of file commodityspreadoption.cpp.

71 {
72 Option::setupArguments(args);
73
74 CommoditySpreadOption::arguments* arguments = dynamic_cast<CommoditySpreadOption::arguments*>(args);
75
76 QL_REQUIRE(arguments != 0, "wrong argument type");
77 QL_REQUIRE(longAssetFlow_->gearing() > 0.0, "The gearing on an APO must be positive");
78
79 arguments->quantity = quantity_;
80 arguments->strikePrice = strikePrice_;
81 arguments->effectiveStrike = effectiveStrike();
82 arguments->type = type_;
83 arguments->settlementType = settlementType_;
84 arguments->settlementMethod = settlementMethod_;
85 arguments->exercise = exercise_;
86 arguments->longAssetFlow = underlyingLongAssetFlow();
87 arguments->shortAssetFlow = underlyingShortAssetFlow();
88 arguments->longAssetFxIndex = longAssetFxIndex();
89 arguments->shortAssetFxIndex = shortAssetFxIndex();
90 arguments->paymentDate = paymentDate_;
91 arguments->longAssetLastPricingDate = longAssetFlow_->lastPricingDate();
92 arguments->shortAssetLastPricingDate = shortAssetFlow_->lastPricingDate();
93}
const QuantLib::ext::shared_ptr< CommodityCashFlow > & underlyingShortAssetFlow() const
const QuantLib::ext::shared_ptr< CommodityCashFlow > & underlyingLongAssetFlow() const
+ Here is the call graph for this function:

◆ underlyingLongAssetFlow()

const QuantLib::ext::shared_ptr< CommodityCashFlow > & underlyingLongAssetFlow ( ) const

Definition at line 61 of file commodityspreadoption.hpp.

61{ return longAssetFlow_; }
+ Here is the caller graph for this function:

◆ underlyingShortAssetFlow()

const QuantLib::ext::shared_ptr< CommodityCashFlow > & underlyingShortAssetFlow ( ) const

Definition at line 62 of file commodityspreadoption.hpp.

62{ return shortAssetFlow_; }
+ Here is the caller graph for this function:

◆ longAssetFxIndex()

const QuantLib::ext::shared_ptr< FxIndex > & longAssetFxIndex ( ) const

Definition at line 64 of file commodityspreadoption.hpp.

64{ return longAssetFxIndex_; }
+ Here is the caller graph for this function:

◆ shortAssetFxIndex()

const QuantLib::ext::shared_ptr< FxIndex > & shortAssetFxIndex ( ) const

Definition at line 65 of file commodityspreadoption.hpp.

65{ return shortAssetFxIndex_; }
+ Here is the caller graph for this function:

◆ effectiveStrike()

Real effectiveStrike ( ) const

Definition at line 67 of file commodityspreadoption.cpp.

67 {
68 return (strikePrice_ - longAssetFlow_->spread() + shortAssetFlow_->spread());
69}
+ Here is the caller graph for this function:

◆ isCalendarSpread()

bool isCalendarSpread ( ) const

Member Data Documentation

◆ longAssetFlow_

QuantLib::ext::shared_ptr<CommodityCashFlow> longAssetFlow_
private

Definition at line 73 of file commodityspreadoption.hpp.

◆ shortAssetFlow_

QuantLib::ext::shared_ptr<CommodityCashFlow> shortAssetFlow_
private

Definition at line 74 of file commodityspreadoption.hpp.

◆ quantity_

Real quantity_
private

Definition at line 75 of file commodityspreadoption.hpp.

◆ strikePrice_

Real strikePrice_
private

Definition at line 76 of file commodityspreadoption.hpp.

◆ type_

Option::Type type_
private

Definition at line 77 of file commodityspreadoption.hpp.

◆ paymentDate_

Date paymentDate_
private

Definition at line 78 of file commodityspreadoption.hpp.

◆ longAssetFxIndex_

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

Definition at line 79 of file commodityspreadoption.hpp.

◆ shortAssetFxIndex_

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

Definition at line 80 of file commodityspreadoption.hpp.

◆ settlementType_

QuantLib::Settlement::Type settlementType_
private

Definition at line 81 of file commodityspreadoption.hpp.

◆ settlementMethod_

QuantLib::Settlement::Method settlementMethod_
private

Definition at line 82 of file commodityspreadoption.hpp.