20#include <boost/make_shared.hpp>
35 QuantLib::ext::shared_ptr<QuantExt::CommodityIndex> const&, std::string const&> {
41 std::string
keyImpl(
const Currency&, QuantLib::ext::shared_ptr<QuantExt::CommodityIndex>
const&, QuantLib::ext::shared_ptr<QuantExt::CommodityIndex>
const&, std::string
const&
id)
override {
60 QuantLib::ext::shared_ptr<QuantLib::PricingEngine>
engineImpl(
const Currency& ccy, QuantLib::ext::shared_ptr<QuantExt::CommodityIndex>
const& longIndex, QuantLib::ext::shared_ptr<QuantExt::CommodityIndex>
const& shortIndex,
string const&
id)
override{
62 Handle<QuantLib::BlackVolTermStructure> volLong =
64 Handle<QuantLib::BlackVolTermStructure> volShort =
67 Handle<QuantExt::CorrelationTermStructure> rho{
nullptr};
73 <<
", using default value " << beta);
75 if(longIndex->underlyingName() == shortIndex->underlyingName()){
76 rho = Handle<QuantExt::CorrelationTermStructure>(QuantLib::ext::make_shared<QuantExt::FlatCorrelation>(0,QuantLib::NullCalendar(), 1.0, QuantLib::Actual365Fixed()));
78 rho =
market_->correlationCurve(
"COMM-"+longIndex->underlyingName(),
"COMM-"+shortIndex->underlyingName(),
82 return QuantLib::ext::make_shared<QuantExt::CommoditySpreadOptionAnalyticalEngine>(yts, volLong, volShort, rho, beta);
Abstract template engine builder class.
Abstract template EngineBuilder class that can cache engines and coupon pricers.
Base Engine builder for Commodity Spread Options.
CommoditySpreadOptionBaseEngineBuilder(const std::string &model, const std::string &engine, const std::set< std::string > &tradeTypes)
std::string keyImpl(const Currency &, QuantLib::ext::shared_ptr< QuantExt::CommodityIndex > const &, QuantLib::ext::shared_ptr< QuantExt::CommodityIndex > const &, std::string const &id) override
Analytical Engine builder for Commodity Spread Options.
CommoditySpreadOptionEngineBuilder()
QuantLib::ext::shared_ptr< QuantLib::PricingEngine > engineImpl(const Currency &ccy, QuantLib::ext::shared_ptr< QuantExt::CommodityIndex > const &longIndex, QuantLib::ext::shared_ptr< QuantExt::CommodityIndex > const &shortIndex, string const &id) override
QuantLib::ext::shared_ptr< Market > market_
const string & engine() const
Return the engine name.
const set< string > & tradeTypes() const
Return the possible trade types.
map< string, string > engineParameters_
const string & model() const
Return the model name.
const string & configuration(const MarketContext &key)
Return a configuration (or the default one if key not found)
Real parseReal(const string &s)
Convert text to Real.
#define ALOG(text)
Logging Macro (Level = Alert)