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

Engine Builder for Composite European Equity Options. More...

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

+ Inheritance diagram for EquityEuropeanCompositeEngineBuilder:
+ Collaboration diagram for EquityEuropeanCompositeEngineBuilder:

Public Member Functions

 EquityEuropeanCompositeEngineBuilder ()
 
- 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

virtual string keyImpl (const string &equityName, const Currency &equityCcy, const Currency &strikeCcy, const Date &expiry) override
 
virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl (const string &equityName, const Currency &equityCcy, const Currency &strikeCcy, const Date &expiry) 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

Engine Builder for Composite European Equity Options.

Pricing engines are cached by asset/asset currency/strike currency

Definition at line 45 of file equitycompositeoption.hpp.

Constructor & Destructor Documentation

◆ EquityEuropeanCompositeEngineBuilder()

Definition at line 48 of file equitycompositeoption.hpp.

49 : CachingEngineBuilder("BlackScholes", "AnalyticEuropeanEngine", {"EquityEuropeanCompositeOption"}) {}
CachingEngineBuilder(const string &model, const string &engine, const set< string > &tradeTypes)

Member Function Documentation

◆ keyImpl()

virtual string keyImpl ( const string &  equityName,
const Currency &  equityCcy,
const Currency &  strikeCcy,
const Date &  expiry 
)
overrideprotectedvirtual

Definition at line 52 of file equitycompositeoption.hpp.

53 {
54 return equityName + "/" + equityCcy.code() + "/" + strikeCcy.code() + "/" + to_string(expiry);
55 }
std::string to_string(const LocationInfo &l)
Definition: ast.cpp:28
+ Here is the call graph for this function:

◆ engineImpl()

virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl ( const string &  equityName,
const Currency &  equityCcy,
const Currency &  strikeCcy,
const Date &  expiry 
)
overrideprotectedvirtual

Definition at line 57 of file equitycompositeoption.hpp.

58 {
59
61
62 // FOR = Underlyign CCY and DOM = Strike Currency
63 // -> converting underlying ccy into strike ccy by multiply eq spot by fx spot
64 string ccyPairCode = equityCcy.code() + strikeCcy.code();
65
66 Handle<Quote> equitySpot = this->market_->equitySpot(equityName, config);
67 Handle<Quote> fxSpot = this->market_->fxRate(ccyPairCode, config);
68
69 std::function<Real(const Real&, const Real&)> multiply = [](const Real& a, const Real& b) { return a * b; };
70
71 using scaledQuoted = CompositeQuote<std::function<Real(const Real&, const Real&)>>;
72
73 Handle<Quote> spot(QuantLib::ext::make_shared<scaledQuoted>(equitySpot, fxSpot, multiply));
74
75 auto dividendCurve = this->market_->equityDividendCurve(equityName, config);
76
77 auto equtiyForcastCurve = this->market_->equityForecastCurve(equityName, config);
78
79 auto equityIndex = this->market_->equityCurve(equityName, config);
80
81 Handle<BlackVolTermStructure> eqVol = this->market_->equityVol(equityName, config);
82 Handle<BlackVolTermStructure> fxVol = this->market_->fxVol(ccyPairCode, config);
83
84 auto strikeCcyDiscountCurve = this->market_->discountCurve(strikeCcy.code(), config);
85
86 auto fxIndex = market_->fxIndex(equityCcy.code() + strikeCcy.code()).currentLink();
87
88 // Try Catch and 0 correlation fallback
89 Handle<QuantExt::CorrelationTermStructure> correlation;
90 try {
91 correlation = this->market_->correlationCurve(
92 "FX-GENERIC-" + equityCcy.code() + "-" + strikeCcy.code(), "EQ-" + equityName, config);
93 } catch (...) {
94 WLOG("Couldnt find correlation curve "
95 << " FX - GENERIC - " << equityCcy.code() << " -" << strikeCcy.code() << "&EQ - " << equityName << ". will fallback to zero correlation");
96 correlation = Handle<QuantExt::CorrelationTermStructure>(QuantLib::ext::make_shared<QuantExt::FlatCorrelation>(0, WeekendsOnly(), 0, Actual365Fixed()));
97 }
98
99 Handle<BlackVolTermStructure> vol(
100 QuantLib::ext::make_shared<QuantExt::BlackVolatilitySurfaceProxy>(*eqVol, *equityIndex, *equityIndex, *fxVol, fxIndex, *correlation));
101
102 auto blackScholesProcess = QuantLib::ext::make_shared<QuantLib::GeneralizedBlackScholesProcess>(
103 spot, dividendCurve, strikeCcyDiscountCurve, vol);
104
105 Handle<YieldTermStructure> discountCurve =
106 market_->discountCurve(strikeCcy.code(), configuration(MarketContext::pricing));
107
108 return QuantLib::ext::make_shared<QuantLib::AnalyticEuropeanEngine>(blackScholesProcess, discountCurve);
109 }
QuantLib::ext::shared_ptr< Market > market_
const string & configuration(const MarketContext &key)
Return a configuration (or the default one if key not found)
#define WLOG(text)
Logging Macro (Level = Warning)
Definition: log.hpp:550
+ Here is the call graph for this function: