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

Commodity Average Price Option. More...

#include <qle/instruments/commodityapo.hpp>

+ Inheritance diagram for CommodityAveragePriceOption:
+ Collaboration diagram for CommodityAveragePriceOption:

Classes

class  arguments
 Arguments for commodity APO calculation More...
 
class  engine
 base class for APO engines More...
 

Public Member Functions

 CommodityAveragePriceOption (const QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlow > &flow, const ext::shared_ptr< Exercise > &exercise, const Real quantity, const Real strikePrice, Option::Type type, Settlement::Type delivery=Settlement::Physical, Settlement::Method settlementMethod=Settlement::PhysicalOTC, const Real barrierLevel=Null< Real >(), Barrier::Type barrierType=Barrier::Type::DownIn, Exercise::Type barrierStyle=Exercise::American, const QuantLib::ext::shared_ptr< FxIndex > &fxIndex=nullptr)
 
Instrument interface
bool isExpired () const override
 
void setupArguments (PricingEngine::arguments *) const override
 

Inspectors

QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlowflow_
 
Real quantity_
 
Real strikePrice_
 
Option::Type type_
 
QuantLib::Settlement::Type settlementType_
 
QuantLib::Settlement::Method settlementMethod_
 
QuantLib::ext::shared_ptr< FxIndexfxIndex_
 
Real barrierLevel_
 
Barrier::Type barrierType_
 
Exercise::Type barrierStyle_
 
Settlement::Type settlementType () const
 
Settlement::Method settlementMethod () const
 
const QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlow > & underlyingFlow () const
 
const QuantLib::ext::shared_ptr< FxIndex > & fxIndex () const
 
Real barrierLevel () const
 
Barrier::Type barrierType () const
 
Exercise::Type barrierStyle () const
 
Real effectiveStrike () const
 
Real accrued (const Date &refDate) const
 

Detailed Description

Commodity Average Price Option.

Definition at line 41 of file commodityapo.hpp.

Constructor & Destructor Documentation

◆ CommodityAveragePriceOption()

CommodityAveragePriceOption ( const QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlow > &  flow,
const ext::shared_ptr< Exercise > &  exercise,
const Real  quantity,
const Real  strikePrice,
Option::Type  type,
Settlement::Type  delivery = Settlement::Physical,
Settlement::Method  settlementMethod = Settlement::PhysicalOTC,
const Real  barrierLevel = Null<Real>(),
Barrier::Type  barrierType = Barrier::Type::DownIn,
Exercise::Type  barrierStyle = Exercise::American,
const QuantLib::ext::shared_ptr< FxIndex > &  fxIndex = nullptr 
)

Definition at line 25 of file commodityapo.cpp.

33 : Option(ext::shared_ptr<Payoff>(), exercise), flow_(flow), quantity_(quantity), strikePrice_(strikePrice),
36 flow_->alwaysForwardNotifications();
37 registerWith(flow_);
38 if (fxIndex_)
39 registerWith(fxIndex_);
40}
QuantLib::Settlement::Type settlementType_
QuantLib::ext::shared_ptr< FxIndex > fxIndex_
const QuantLib::ext::shared_ptr< FxIndex > & fxIndex() const
QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlow > flow_
QuantLib::Settlement::Method settlementMethod_
Exercise::Type barrierStyle() const
Settlement::Method settlementMethod() const

Member Function Documentation

◆ isExpired()

bool isExpired ( ) const
override

Definition at line 42 of file commodityapo.cpp.

42{ return detail::simple_event(flow_->date()).hasOccurred(); }

◆ setupArguments()

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

Definition at line 71 of file commodityapo.cpp.

71 {
72 Option::setupArguments(args);
73
74 CommodityAveragePriceOption::arguments* arguments = dynamic_cast<CommodityAveragePriceOption::arguments*>(args);
75
76 QL_REQUIRE(arguments != 0, "wrong argument type");
77 QL_REQUIRE(flow_->gearing() > 0.0, "The gearing on an APO must be positive");
78
79 Date today = Settings::instance().evaluationDate();
80
81 arguments->quantity = quantity_;
82 arguments->strikePrice = strikePrice_;
83 arguments->effectiveStrike = effectiveStrike();
84 arguments->accrued = accrued(today);
85 arguments->type = type_;
86 arguments->settlementType = settlementType_;
87 arguments->settlementMethod = settlementMethod_;
88 arguments->barrierLevel = barrierLevel_;
89 arguments->barrierType = barrierType_;
90 arguments->barrierStyle = barrierStyle_;
91 arguments->exercise = exercise_;
92 arguments->flow = flow_;
93 arguments->fxIndex = fxIndex_;
94}
Real accrued(const Date &refDate) const
+ Here is the call graph for this function:

◆ settlementType()

Settlement::Type settlementType ( ) const

Definition at line 62 of file commodityapo.hpp.

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

◆ settlementMethod()

Settlement::Method settlementMethod ( ) const

Definition at line 63 of file commodityapo.hpp.

63{ return settlementMethod_; }
+ Here is the caller graph for this function:

◆ underlyingFlow()

const QuantLib::ext::shared_ptr< CommodityIndexedAverageCashFlow > & underlyingFlow ( ) const

Definition at line 64 of file commodityapo.hpp.

64{ return flow_; }

◆ fxIndex()

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

Definition at line 66 of file commodityapo.hpp.

66{ return fxIndex_; }

◆ barrierLevel()

Real barrierLevel ( ) const

Definition at line 67 of file commodityapo.hpp.

67{ return barrierLevel_; }

◆ barrierType()

Barrier::Type barrierType ( ) const

Definition at line 68 of file commodityapo.hpp.

68{ return barrierType_; }

◆ barrierStyle()

Exercise::Type barrierStyle ( ) const

Definition at line 69 of file commodityapo.hpp.

69{ return barrierStyle_; }

◆ effectiveStrike()

Real effectiveStrike ( ) const

Definition at line 44 of file commodityapo.cpp.

44 {
45 return (strikePrice_ - flow_->spread()) / flow_->gearing();
46}
+ Here is the caller graph for this function:

◆ accrued()

Real accrued ( const Date &  refDate) const

Definition at line 48 of file commodityapo.cpp.

48 {
49 Real tmp = 0.0;
50
51 // If all of the pricing dates are greater than today => no accrued
52 if (refDate >= flow_->indices().begin()->first) {
53 for (const auto& kv : flow_->indices()) {
54 // Break on the first pricing date that is greater than today
55 if (refDate < kv.first) {
56 break;
57 }
58 // Update accrued where pricing date is on or before today
59 Real fxRate = (fxIndex_)?fxIndex_->fixing(kv.first):1.;
60 tmp += fxRate*kv.second->fixing(kv.first);
61 }
62 // We should have pricing dates in the period but check.
63 auto n = flow_->indices().size();
64 QL_REQUIRE(n > 0, "APO coupon accrued calculation has a degenerate coupon.");
65 tmp /= n;
66 }
67
68 return tmp;
69}
+ Here is the caller graph for this function:

Member Data Documentation

◆ flow_

QuantLib::ext::shared_ptr<CommodityIndexedAverageCashFlow> flow_
private

Definition at line 76 of file commodityapo.hpp.

◆ quantity_

Real quantity_
private

Definition at line 77 of file commodityapo.hpp.

◆ strikePrice_

Real strikePrice_
private

Definition at line 78 of file commodityapo.hpp.

◆ type_

Option::Type type_
private

Definition at line 79 of file commodityapo.hpp.

◆ settlementType_

QuantLib::Settlement::Type settlementType_
private

Definition at line 80 of file commodityapo.hpp.

◆ settlementMethod_

QuantLib::Settlement::Method settlementMethod_
private

Definition at line 81 of file commodityapo.hpp.

◆ fxIndex_

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

Definition at line 82 of file commodityapo.hpp.

◆ barrierLevel_

Real barrierLevel_
private

Definition at line 83 of file commodityapo.hpp.

◆ barrierType_

Barrier::Type barrierType_
private

Definition at line 84 of file commodityapo.hpp.

◆ barrierStyle_

Exercise::Type barrierStyle_
private

Definition at line 85 of file commodityapo.hpp.