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

Analytical Engine builder for Commodity Spread Options. More...

#include <ored/portfolio/builders/commodityspreadoption.hpp>

+ Inheritance diagram for CommoditySpreadOptionEngineBuilder:
+ Collaboration diagram for CommoditySpreadOptionEngineBuilder:

Public Member Functions

 CommoditySpreadOptionEngineBuilder ()
 
- Public Member Functions inherited from CommoditySpreadOptionBaseEngineBuilder
 CommoditySpreadOptionBaseEngineBuilder (const std::string &model, const std::string &engine, const std::set< std::string > &tradeTypes)
 
- Public Member Functions inherited from CachingEngineBuilder< T, U, Args >
 CachingEngineBuilder (const string &model, const string &engine, const set< string > &tradeTypes)
 
QuantLib::ext::shared_ptr< U > engine (Args... params)
 Return a PricingEngine or a FloatingRateCouponPricer. More...
 
void reset () override
 reset the builder (e.g. clear cache) More...
 
- Public Member Functions inherited from EngineBuilder
 EngineBuilder (const string &model, const string &engine, const set< string > &tradeTypes)
 
virtual ~EngineBuilder ()
 Virtual destructor. More...
 
const string & model () const
 Return the model name. More...
 
const string & engine () const
 Return the engine name. More...
 
const set< string > & tradeTypes () const
 Return the possible trade types. More...
 
const string & configuration (const MarketContext &key)
 Return a configuration (or the default one if key not found) More...
 
virtual void reset ()
 reset the builder (e.g. clear cache) More...
 
void init (const QuantLib::ext::shared_ptr< Market > market, const map< MarketContext, string > &configurations, const map< string, string > &modelParameters, const map< string, string > &engineParameters, const std::map< std::string, std::string > &globalParameters={})
 Initialise this Builder with the market and parameters to use. More...
 
const set< std::pair< string, QuantLib::ext::shared_ptr< QuantExt::ModelBuilder > > > & modelBuilders () const
 return model builders More...
 
std::string engineParameter (const std::string &p, const std::vector< std::string > &qualifiers={}, const bool mandatory=true, const std::string &defaultValue="") const
 
std::string modelParameter (const std::string &p, const std::vector< std::string > &qualifiers={}, const bool mandatory=true, const std::string &defaultValue="") const
 

Protected Member Functions

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
 
- Protected Member Functions inherited from CommoditySpreadOptionBaseEngineBuilder
std::string keyImpl (const Currency &, QuantLib::ext::shared_ptr< QuantExt::CommodityIndex > const &, QuantLib::ext::shared_ptr< QuantExt::CommodityIndex > const &, std::string const &id) override
 
- Protected Member Functions inherited from CachingEngineBuilder< T, U, Args >
virtual T keyImpl (Args...)=0
 
virtual QuantLib::ext::shared_ptr< U > engineImpl (Args...)=0
 

Additional Inherited Members

- Protected Attributes inherited from CachingEngineBuilder< T, U, Args >
map< T, QuantLib::ext::shared_ptr< U > > engines_
 
- Protected Attributes inherited from EngineBuilder
string model_
 
string engine_
 
set< string > tradeTypes_
 
QuantLib::ext::shared_ptr< Marketmarket_
 
map< MarketContext, string > configurations_
 
map< string, string > modelParameters_
 
map< string, string > engineParameters_
 
std::map< std::string, std::string > globalParameters_
 
set< std::pair< string, QuantLib::ext::shared_ptr< QuantExt::ModelBuilder > > > modelBuilders_
 

Detailed Description

Analytical Engine builder for Commodity Spread Options.

Pricing engines are cached by currency

Definition at line 54 of file commodityspreadoption.hpp.

Constructor & Destructor Documentation

◆ CommoditySpreadOptionEngineBuilder()

Definition at line 56 of file commodityspreadoption.hpp.

57 : CommoditySpreadOptionBaseEngineBuilder("BlackScholes", "CommoditySpreadOptionEngine", {"CommoditySpreadOption"}){}
CommoditySpreadOptionBaseEngineBuilder(const std::string &model, const std::string &engine, const std::set< std::string > &tradeTypes)

Member Function Documentation

◆ engineImpl()

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 
)
overrideprotected

Definition at line 60 of file commodityspreadoption.hpp.

60 {
61 Handle<YieldTermStructure> yts = market_->discountCurve(ccy.code(), configuration(MarketContext::pricing));
62 Handle<QuantLib::BlackVolTermStructure> volLong =
63 market_->commodityVolatility(longIndex->underlyingName(), configuration(MarketContext::pricing));
64 Handle<QuantLib::BlackVolTermStructure> volShort =
65 market_->commodityVolatility(shortIndex->underlyingName(), configuration(MarketContext::pricing));
66 Real beta = 0;
67 Handle<QuantExt::CorrelationTermStructure> rho{nullptr};
68 auto param = engineParameters_.find("beta");
69 if (param != engineParameters_.end())
70 beta = parseReal(param->second);
71 else {
72 ALOG("Missing engine parameter 'beta' for " << model() << " " << EngineBuilder::engine()
73 << ", using default value " << beta);
74 }
75 if(longIndex->underlyingName() == shortIndex->underlyingName()){ // calendar spread option
76 rho = Handle<QuantExt::CorrelationTermStructure>(QuantLib::ext::make_shared<QuantExt::FlatCorrelation>(0,QuantLib::NullCalendar(), 1.0, QuantLib::Actual365Fixed()));
77 }else {
78 rho = market_->correlationCurve("COMM-"+longIndex->underlyingName(), "COMM-"+shortIndex->underlyingName(),
80
81 }
82 return QuantLib::ext::make_shared<QuantExt::CommoditySpreadOptionAnalyticalEngine>(yts, volLong, volShort, rho, beta);
83 }
QuantLib::ext::shared_ptr< Market > market_
const string & engine() const
Return the engine name.
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.
Definition: parsers.cpp:112
#define ALOG(text)
Logging Macro (Level = Alert)
Definition: log.hpp:544
+ Here is the call graph for this function: