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

Engine Builder for Pairwise Variance Swaps. More...

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

+ Inheritance diagram for PairwiseVarSwapEngineBuilder:
+ Collaboration diagram for PairwiseVarSwapEngineBuilder:

Public Member Functions

 PairwiseVarSwapEngineBuilder ()
 
- 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 &underlyingName1, const string &underlyingName2, const Currency &ccy, const Date &accrEndDate, const AssetClass &assetClassUnderlyings) override
 
virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl (const string &underlyingName1, const string &underlyingName2, const Currency &ccy, const Date &accrEndDate, const AssetClass &assetClassUnderlyings) 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 Pairwise Variance Swaps.

Pricing engines are cached by equity/currency

Definition at line 52 of file pairwisevarianceswap.hpp.

Constructor & Destructor Documentation

◆ PairwiseVarSwapEngineBuilder()

Definition at line 56 of file pairwisevarianceswap.hpp.

57 : CachingEngineBuilder("BlackScholes", "PairwiseVarianceSwapEngine",
58 {"EquityPairwiseVarianceSwap", "FxPairwiseVarianceSwap"}) {}
CachingEngineBuilder(const string &model, const string &engine, const set< string > &tradeTypes)

Member Function Documentation

◆ keyImpl()

virtual string keyImpl ( const string &  underlyingName1,
const string &  underlyingName2,
const Currency &  ccy,
const Date &  accrEndDate,
const AssetClass assetClassUnderlyings 
)
overrideprotectedvirtual

Definition at line 61 of file pairwisevarianceswap.hpp.

62 {
63 return underlyingName1 + "/" + underlyingName2 + "/" + ccy.code();
64 }

◆ engineImpl()

virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl ( const string &  underlyingName1,
const string &  underlyingName2,
const Currency &  ccy,
const Date &  accrEndDate,
const AssetClass assetClassUnderlyings 
)
overrideprotectedvirtual

Definition at line 66 of file pairwisevarianceswap.hpp.

68 {
69 QuantLib::ext::shared_ptr<GeneralizedBlackScholesProcess> gbsp1, gbsp2;
70 QuantLib::ext::shared_ptr<Index> index1, index2;
71 if (assetClassUnderlyings == AssetClass::EQ) {
72 gbsp1 = QuantLib::ext::make_shared<GeneralizedBlackScholesProcess>(
73 market_->equitySpot(underlyingName1, configuration(ore::data::MarketContext::pricing)),
74 market_->equityDividendCurve(underlyingName1, configuration(ore::data::MarketContext::pricing)),
75 market_->equityForecastCurve(underlyingName1, configuration(ore::data::MarketContext::pricing)),
76 market_->equityVol(underlyingName1, configuration(ore::data::MarketContext::pricing)));
77 index1 = market_->equityCurve(underlyingName1).currentLink();
78 gbsp2 = QuantLib::ext::make_shared<GeneralizedBlackScholesProcess>(
79 market_->equitySpot(underlyingName2, configuration(ore::data::MarketContext::pricing)),
80 market_->equityDividendCurve(underlyingName2, configuration(ore::data::MarketContext::pricing)),
81 market_->equityForecastCurve(underlyingName2, configuration(ore::data::MarketContext::pricing)),
82 market_->equityVol(underlyingName2, configuration(ore::data::MarketContext::pricing)));
83 index2 = market_->equityCurve(underlyingName2).currentLink();
84 } else if (assetClassUnderlyings == AssetClass::FX) {
85 const auto fxIndex1 = market_->fxIndex("FX-" + underlyingName1);
86 const auto fxIndex2 = market_->fxIndex("FX-" + underlyingName2);
87 const string& ccyPairCode1 = fxIndex1->sourceCurrency().code() + fxIndex1->targetCurrency().code();
88 const string& ccyPairCode2 = fxIndex2->sourceCurrency().code() + fxIndex2->targetCurrency().code();
89 gbsp1 = QuantLib::ext::make_shared<GeneralizedBlackScholesProcess>(
91 fxIndex1->targetCurve(), fxIndex1->sourceCurve(),
93 gbsp2 = QuantLib::ext::make_shared<GeneralizedBlackScholesProcess>(
95 fxIndex2->targetCurve(), fxIndex2->sourceCurve(),
97 index1 = fxIndex1.currentLink();
98 index2 = fxIndex2.currentLink();
99
100 } else {
101 QL_FAIL("Asset class of " + underlyingName1 + " and " + underlyingName2 + " not recognized.");
102 }
103
104 QuantLib::Handle<QuantExt::CorrelationTermStructure> corrCurve(
105 QuantLib::ext::make_shared<QuantExt::FlatCorrelation>(0, NullCalendar(), 0.0, Actual365Fixed()));
106 Handle<Quote> correlation(
107 QuantLib::ext::make_shared<QuantExt::CorrelationValue>(corrCurve, corrCurve->timeFromReference(accrEndDate)));
108
109 try {
110 corrCurve =
111 market_->correlationCurve(index1->name(), index2->name(), configuration(MarketContext::pricing));
112 } catch (...) {
113 WLOG("no correlation curve for " << index1->name() << ", " << index2->name()
114 << " found, fall back to zero correlation");
115 }
116
117 return QuantLib::ext::make_shared<QuantExt::PairwiseVarianceSwapEngine>(
118 index1, index2, gbsp1, gbsp2,
119 market_->discountCurve(ccy.code(), configuration(ore::data::MarketContext::pricing)), correlation);
120 }
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: