Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CachingOptionEngineBuilder< T, Args > Class Template Reference

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

+ Inheritance diagram for CachingOptionEngineBuilder< T, Args >:
+ Collaboration diagram for CachingOptionEngineBuilder< T, Args >:

Public Member Functions

 CachingOptionEngineBuilder (const string &model, const string &engine, const set< string > &tradeTypes, const AssetClass &assetClass)
 
- 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::GeneralizedBlackScholesProcess > getBlackScholesProcess (const string &assetName, const Currency &ccy, const AssetClass &assetClassUnderlying, const std::vector< Time > &timePoints={}, const bool useFxSpot=true)
 
- Protected Member Functions inherited from CachingEngineBuilder< T, U, Args >
virtual T keyImpl (Args...)=0
 
virtual QuantLib::ext::shared_ptr< U > engineImpl (Args...)=0
 

Protected Attributes

AssetClass assetClass_
 
- 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

template<class T, typename... Args>
class ore::data::CachingOptionEngineBuilder< T, Args >

Definition at line 44 of file vanillaoption.hpp.

Constructor & Destructor Documentation

◆ CachingOptionEngineBuilder()

CachingOptionEngineBuilder ( const string &  model,
const string &  engine,
const set< string > &  tradeTypes,
const AssetClass assetClass 
)

Definition at line 46 of file vanillaoption.hpp.

48 : CachingPricingEngineBuilder<T, Args...>(model, engine, tradeTypes), assetClass_(assetClass) {}
const string & engine() const
Return the engine name.
const set< string > & tradeTypes() const
Return the possible trade types.
const string & model() const
Return the model name.
CachingEngineBuilder< T, PricingEngine, Args... > CachingPricingEngineBuilder

Member Function Documentation

◆ getBlackScholesProcess()

QuantLib::ext::shared_ptr< QuantLib::GeneralizedBlackScholesProcess > getBlackScholesProcess ( const string &  assetName,
const Currency &  ccy,
const AssetClass assetClassUnderlying,
const std::vector< Time > &  timePoints = {},
const bool  useFxSpot = true 
)
protected

Definition at line 51 of file vanillaoption.hpp.

54 {},
55 const bool useFxSpot = true) {
56
59
60 if (assetClassUnderlying == AssetClass::EQ) {
61 Handle<BlackVolTermStructure> vol = this->market_->equityVol(assetName, config);
62 if (!timePoints.empty()) {
63 vol = Handle<BlackVolTermStructure>(QuantLib::ext::make_shared<VVTS>(vol, timePoints));
64 vol->enableExtrapolation();
65 }
66 return QuantLib::ext::make_shared<QuantLib::GeneralizedBlackScholesProcess>(
67 this->market_->equitySpot(assetName, config), this->market_->equityDividendCurve(assetName, config),
68 this->market_->equityForecastCurve(assetName, config), vol);
69
70 } else if (assetClassUnderlying == AssetClass::FX) {
71 const string& ccyPairCode = assetName + ccy.code();
72 Handle<BlackVolTermStructure> vol = this->market_->fxVol(ccyPairCode, config);
73 if (!timePoints.empty()) {
74 vol = Handle<BlackVolTermStructure>(QuantLib::ext::make_shared<VVTS>(vol, timePoints));
75 vol->enableExtrapolation();
76 }
77 if (useFxSpot) {
78 return QuantLib::ext::make_shared<QuantLib::GeneralizedBlackScholesProcess>(
79 this->market_->fxSpot(ccyPairCode, config), this->market_->discountCurve(assetName, config),
80 this->market_->discountCurve(ccy.code(), config), vol);
81 }
82 return QuantLib::ext::make_shared<QuantLib::GeneralizedBlackScholesProcess>(
83 this->market_->fxRate(ccyPairCode, config), this->market_->discountCurve(assetName, config),
84 this->market_->discountCurve(ccy.code(), config), vol);
85
86
87 } else if (assetClassUnderlying == AssetClass::COM) {
88
89 Handle<BlackVolTermStructure> vol = this->market_->commodityVolatility(assetName, config);
90 if (!timePoints.empty()) {
91 vol = Handle<BlackVolTermStructure>(QuantLib::ext::make_shared<VVTS>(vol, timePoints));
92 vol->enableExtrapolation();
93 }
94
95 // Create the commodity convenience yield curve for the process
96 Handle<QuantExt::PriceTermStructure> priceCurve = this->market_->commodityPriceCurve(assetName, config);
97 Handle<Quote> commoditySpot(QuantLib::ext::make_shared<QuantExt::DerivedPriceQuote>(priceCurve));
98 Handle<YieldTermStructure> discount = this->market_->discountCurve(ccy.code(), config);
99 Handle<YieldTermStructure> yield(
100 QuantLib::ext::make_shared<QuantExt::PriceTermStructureAdapter>(*priceCurve, *discount));
101 yield->enableExtrapolation();
102
103 return QuantLib::ext::make_shared<QuantLib::GeneralizedBlackScholesProcess>(commoditySpot, yield, discount, vol);
104
105 } else {
106 QL_FAIL("Asset class of " << (int)assetClassUnderlying << " not recognized.");
107 }
108 }
QuantLib::ext::shared_ptr< Market > market_
const string & configuration(const MarketContext &key)
Return a configuration (or the default one if key not found)

Member Data Documentation

◆ assetClass_

AssetClass assetClass_
protected

Definition at line 109 of file vanillaoption.hpp.