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

#include <qle/pricingengines/commodityapoengine.hpp>

+ Inheritance diagram for CommodityAveragePriceOptionAnalyticalEngine:
+ Collaboration diagram for CommodityAveragePriceOptionAnalyticalEngine:

Public Member Functions

void calculate () const override
 
 CommodityAveragePriceOptionBaseEngine (const QuantLib::Handle< QuantLib::YieldTermStructure > &discountCurve, const QuantLib::Handle< QuantExt::BlackScholesModelWrapper > &model, QuantLib::Real beta=0.0)
 
 CommodityAveragePriceOptionBaseEngine (const QuantLib::Handle< QuantLib::YieldTermStructure > &discountCurve, const QuantLib::Handle< QuantLib::BlackVolTermStructure > &vol, QuantLib::Real beta=0.0)
 
- Public Member Functions inherited from CommodityAveragePriceOptionBaseEngine
 CommodityAveragePriceOptionBaseEngine (const QuantLib::Handle< QuantLib::YieldTermStructure > &discountCurve, const QuantLib::Handle< QuantExt::BlackScholesModelWrapper > &model, QuantLib::Real beta=0.0)
 
 CommodityAveragePriceOptionBaseEngine (const QuantLib::Handle< QuantLib::YieldTermStructure > &discountCurve, const QuantLib::Handle< QuantLib::BlackVolTermStructure > &vol, QuantLib::Real beta=0.0)
 

Additional Inherited Members

- Protected Member Functions inherited from CommodityAveragePriceOptionBaseEngine
QuantLib::Real rho (const QuantLib::Date &ed_1, const QuantLib::Date &ed_2) const
 Return the correlation between two future expiry dates ed_1 and ed_2. More...
 
bool isModelDependent () const
 
bool barrierTriggered (const Real price, const bool logPrice) const
 
bool alive (const bool barrierTriggered) const
 
- Protected Attributes inherited from CommodityAveragePriceOptionBaseEngine
QuantLib::Handle< QuantLib::YieldTermStructure > discountCurve_
 
QuantLib::Handle< QuantLib::BlackVolTermStructure > volStructure_
 
QuantLib::Real beta_
 
QuantLib::Real logBarrier_
 

Detailed Description

Commodity APO Analytical Engine Analytical pricing based on the two-moment Turnbull-Wakeman approximation. Reference: Iain Clark, Commodity Option Pricing, Wiley, section 2.7.4 See also the documentation in the ORE+ product catalogue.

Definition at line 114 of file commodityapoengine.hpp.

Member Function Documentation

◆ calculate()

void calculate ( ) const
override

Definition at line 258 of file commodityapoengine.cpp.

258 {
259
260 QL_REQUIRE(arguments_.barrierLevel == Null<Real>(),
261 "CommodityAveragePriceOptionAnalyticalEngine does not support barrier feature. Use MC engine instead.");
262
263 // Populate some additional results that don't change
264 auto& mp = results_.additionalResults;
265 Real discount = discountCurve_->discount(arguments_.flow->date());
266 mp["gearing"] = arguments_.flow->gearing();
267 mp["spread"] = arguments_.flow->spread();
268 mp["strike"] = arguments_.strikePrice;
269 mp["payment_date"] = arguments_.flow->date();
270 mp["accrued"] = arguments_.accrued;
271 mp["discount"] = discount;
272 if(arguments_.fxIndex)
273 mp["FXIndex"] = arguments_.fxIndex->name();
274
275 // If not model dependent, return early.
276 if (!isModelDependent()) {
277 mp["effective_strike"] = arguments_.effectiveStrike;
278 mp["npv"] = results_.value;
279 return;
280 }
281
282 // We will read the volatility off the surface at the effective strike
283 // We should only get this far when the effectiveStrike > 0 but will check anyway
284 Real effectiveStrike = arguments_.effectiveStrike - arguments_.accrued;
285 QL_REQUIRE(effectiveStrike > 0.0, "calculateSpot: expected effectiveStrike to be positive");
286
287 // Valuation date
288
291 std::bind(&CommodityAveragePriceOptionAnalyticalEngine::rho, this, std::placeholders::_1, std
292 ::placeholders::_2), effectiveStrike);
293
294 if (arguments_.flow->useFuturePrice()) {
295 mp["futureVols"] = matchedMoments.futureVols;
296 } else {
297 mp["spotVols"] = matchedMoments.spotVols;
298 }
299
300 // Populate results
301 results_.value = arguments_.quantity * arguments_.flow->gearing() *
302 blackFormula(arguments_.type, effectiveStrike, matchedMoments.firstMoment(),
303 matchedMoments.stdDev(), discount);
304
305 // Add more additional results
306 // Could be part of a strip so we add the value also.
307 mp["effective_strike"] = effectiveStrike;
308 mp["forward"] = matchedMoments.forward;
309 mp["exp_A_2"] = matchedMoments.EA2;
310 mp["tte"] = matchedMoments.timeToExpriy();
311 mp["sigma"] = matchedMoments.sigma;
312 mp["npv"] = results_.value;
313 mp["times"] = matchedMoments.times;
314 mp["forwards"] = matchedMoments.forwards;
315 mp["beta"] = beta_;
316}
const Instrument::results * results_
Definition: cdsoption.cpp:81
QuantLib::Real rho(const QuantLib::Date &ed_1, const QuantLib::Date &ed_2) const
Return the correlation between two future expiry dates ed_1 and ed_2.
QuantLib::Handle< QuantLib::YieldTermStructure > discountCurve_
QuantLib::Handle< QuantLib::BlackVolTermStructure > volStructure_
MomentMatchingResults matchFirstTwoMomentsTurnbullWakeman(const ext::shared_ptr< CommodityIndexedAverageCashFlow > &flow, const ext::shared_ptr< QuantLib::BlackVolTermStructure > &vol, const std::function< double(const QuantLib::Date &expiry1, const QuantLib::Date &expiry2)> &rho, QuantLib::Real strike)
Swap::arguments * arguments_
+ Here is the call graph for this function:

◆ CommodityAveragePriceOptionBaseEngine() [1/2]

CommodityAveragePriceOptionBaseEngine ( const QuantLib::Handle< QuantLib::YieldTermStructure > &  discountCurve,
const QuantLib::Handle< QuantExt::BlackScholesModelWrapper > &  model,
QuantLib::Real  beta = 0.0 
)

◆ CommodityAveragePriceOptionBaseEngine() [2/2]

CommodityAveragePriceOptionBaseEngine ( const QuantLib::Handle< QuantLib::YieldTermStructure > &  discountCurve,
const QuantLib::Handle< QuantLib::BlackVolTermStructure > &  vol,
QuantLib::Real  beta = 0.0 
)

Definition at line 82 of file commodityapoengine.cpp.

155 : discountCurve_(discountCurve), volStructure_(vol), beta_(beta) {
156 QL_REQUIRE(beta_ >= 0.0, "beta >= 0 required, found " << beta_);
157 registerWith(discountCurve_);
158 registerWith(volStructure_);
159}