24#ifndef quantext_commodity_apo_engine_hpp
25#define quantext_commodity_apo_engine_hpp
31#include <ql/termstructures/volatility/equityfx/blackvoltermstructure.hpp>
32#include <ql/termstructures/yieldtermstructure.hpp>
36namespace CommodityAveragePriceOptionMomementMatching {
44 std::vector<QuantLib::Real>
times;
64 const ext::shared_ptr<CommodityIndexedAverageCashFlow>& flow,
65 const ext::shared_ptr<QuantLib::BlackVolTermStructure>& vol,
66 const std::function<
double(
const QuantLib::Date& expiry1,
const QuantLib::Date& expiry2)>& rho,
67 QuantLib::Real strike = QuantLib::Null<QuantLib::Real>());
78 const QuantLib::Handle<QuantExt::BlackScholesModelWrapper>& model,
79 QuantLib::Real beta = 0.0);
83 const QuantLib::Handle<QuantLib::BlackVolTermStructure>& vol,
84 QuantLib::Real beta = 0.0);
88 QuantLib::Real
rho(
const QuantLib::Date& ed_1,
const QuantLib::Date& ed_2)
const;
127 const QuantLib::Handle<QuantExt::BlackScholesModelWrapper>& model,
128 QuantLib::Size samples, QuantLib::Real beta = 0.0,
129 const QuantLib::Size seed = 42)
134 const QuantLib::Handle<QuantLib::BlackVolTermStructure>& vol,
135 QuantLib::Size samples, QuantLib::Real beta = 0.0,
136 const QuantLib::Size seed = 42)
155 void setupFuture(std::vector<QuantLib::Real>& outVolatilities, QuantLib::Matrix& outSqrtCorr,
156 std::vector<QuantLib::Real>& outPrices, std::vector<QuantLib::Size>& futureIndex,
157 QuantLib::Real strike)
const;
164 std::vector<QuantLib::Real>
timegrid(std::vector<QuantLib::Date>& outDates)
const;
wrapper around a vector of BS processes
base class for APO engines
void calculate() const override
bool barrierTriggered(const Real price, const bool logPrice) const
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.
CommodityAveragePriceOptionBaseEngine(const QuantLib::Handle< QuantLib::YieldTermStructure > &discountCurve, const QuantLib::Handle< QuantExt::BlackScholesModelWrapper > &model, QuantLib::Real beta=0.0)
bool isModelDependent() const
QuantLib::Handle< QuantLib::YieldTermStructure > discountCurve_
QuantLib::Real logBarrier_
QuantLib::Handle< QuantLib::BlackVolTermStructure > volStructure_
bool alive(const bool barrierTriggered) const
CommodityAveragePriceOptionMonteCarloEngine(const QuantLib::Handle< QuantLib::YieldTermStructure > &discountCurve, const QuantLib::Handle< QuantLib::BlackVolTermStructure > &vol, QuantLib::Size samples, QuantLib::Real beta=0.0, const QuantLib::Size seed=42)
CommodityAveragePriceOptionMonteCarloEngine(const QuantLib::Handle< QuantLib::YieldTermStructure > &discountCurve, const QuantLib::Handle< QuantExt::BlackScholesModelWrapper > &model, QuantLib::Size samples, QuantLib::Real beta=0.0, const QuantLib::Size seed=42)
void calculate() const override
void calculateFuture() const
Calculations when underlying swap references a commodity spot price.
void setupFuture(std::vector< QuantLib::Real > &outVolatilities, QuantLib::Matrix &outSqrtCorr, std::vector< QuantLib::Real > &outPrices, std::vector< QuantLib::Size > &futureIndex, QuantLib::Real strike) const
std::vector< QuantLib::Real > timegrid(std::vector< QuantLib::Date > &outDates) const
void calculateSpot() const
Calculations when underlying swap references a commodity spot price.
base class for multi path generators
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)
std::vector< QuantLib::Date > indexExpiries
std::vector< QuantLib::Date > pricingDates
std::vector< Real > forwards
std::vector< QuantLib::Real > times
std::vector< Real > futureVols
std::vector< std::string > indexNames
std::vector< QuantLib::Real > fixings
std::vector< Real > spotVols