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

Market Implementation. More...

#include <ored/marketdata/marketimpl.hpp>

+ Inheritance diagram for MarketImpl:
+ Collaboration diagram for MarketImpl:

Public Member Functions

 MarketImpl (const bool handlePseudoCurrencies)
 
Market interface
Date asofDate () const override
 Get the asof Date. More...
 
Handle< YieldTermStructure > yieldCurve (const YieldCurveType &type, const string &ccy, const string &configuration=Market::defaultConfiguration) const override
 Yield Curves. More...
 
Handle< YieldTermStructure > discountCurveImpl (const string &ccy, const string &configuration=Market::defaultConfiguration) const override
 
Handle< YieldTermStructure > yieldCurve (const string &name, const string &configuration=Market::defaultConfiguration) const override
 
Handle< IborIndexiborIndex (const string &indexName, const string &configuration=Market::defaultConfiguration) const override
 
Handle< SwapIndex > swapIndex (const string &indexName, const string &configuration=Market::defaultConfiguration) const override
 
Handle< QuantLib::SwaptionVolatilityStructure > swaptionVol (const string &key, const string &configuration=Market::defaultConfiguration) const override
 Swaptions. More...
 
string shortSwapIndexBase (const string &key, const string &configuration=Market::defaultConfiguration) const override
 
string swapIndexBase (const string &key, const string &configuration=Market::defaultConfiguration) const override
 
Handle< QuantLib::SwaptionVolatilityStructure > yieldVol (const string &securityID, const string &configuration=Market::defaultConfiguration) const override
 Yield volatility. More...
 
QuantLib::Handle< QuantExt::FxIndexfxIndexImpl (const string &fxIndex, const string &configuration=Market::defaultConfiguration) const override
 FX. More...
 
Handle< Quote > fxRateImpl (const string &ccypair, const string &configuration=Market::defaultConfiguration) const override
 
Handle< Quote > fxSpotImpl (const string &ccypair, const string &configuration=Market::defaultConfiguration) const override
 
Handle< BlackVolTermStructurefxVolImpl (const string &ccypair, const string &configuration=Market::defaultConfiguration) const override
 
Handle< QuantExt::CreditCurvedefaultCurve (const string &, const string &configuration=Market::defaultConfiguration) const override
 Default Curves and Recovery Rates. More...
 
Handle< Quote > recoveryRate (const string &, const string &configuration=Market::defaultConfiguration) const override
 
Handle< QuantExt::CreditVolCurvecdsVol (const string &name, const string &configuration=Market::defaultConfiguration) const override
 CDS volatilities. More...
 
Handle< QuantExt::BaseCorrelationTermStructurebaseCorrelation (const string &name, const string &configuration=Market::defaultConfiguration) const override
 Base correlation structures. More...
 
Handle< OptionletVolatilityStructure > capFloorVol (const string &key, const string &configuration=Market::defaultConfiguration) const override
 CapFloor volatilities. More...
 
std::pair< string, QuantLib::Period > capFloorVolIndexBase (const string &key, const string &configuration=Market::defaultConfiguration) const override
 
Handle< QuantExt::YoYOptionletVolatilitySurface > yoyCapFloorVol (const string &name, const string &configuration=Market::defaultConfiguration) const override
 YoY Inflation CapFloor volatilities. More...
 
virtual Handle< ZeroInflationIndex > zeroInflationIndex (const string &indexName, const string &configuration=Market::defaultConfiguration) const override
 Inflation Indexes. More...
 
virtual Handle< YoYInflationIndex > yoyInflationIndex (const string &indexName, const string &configuration=Market::defaultConfiguration) const override
 
virtual Handle< CPIVolatilitySurfacecpiInflationCapFloorVolatilitySurface (const string &indexName, const string &configuration=Market::defaultConfiguration) const override
 Inflation Cap Floor Volatility Surfaces. More...
 
Handle< Quote > equitySpot (const string &eqName, const string &configuration=Market::defaultConfiguration) const override
 Equity curves. More...
 
Handle< QuantExt::EquityIndex2equityCurve (const string &eqName, const string &configuration=Market::defaultConfiguration) const override
 
Handle< YieldTermStructure > equityDividendCurve (const string &eqName, const string &configuration=Market::defaultConfiguration) const override
 
Handle< BlackVolTermStructureequityVol (const string &eqName, const string &configuration=Market::defaultConfiguration) const override
 Equity volatilities. More...
 
Handle< YieldTermStructure > equityForecastCurve (const string &eqName, const string &configuration=Market::defaultConfiguration) const override
 Equity forecasting curves. More...
 
Handle< Quote > securitySpread (const string &securityID, const string &configuration=Market::defaultConfiguration) const override
 Bond Spreads. More...
 
Handle< QuantExt::InflationIndexObserverbaseCpis (const string &index, const string &configuration=Market::defaultConfiguration) const
 Cpi Base Quotes. More...
 
QuantLib::Handle< QuantExt::PriceTermStructurecommodityPriceCurve (const string &commodityName, const string &configuration=Market::defaultConfiguration) const override
 Commodity curves. More...
 
QuantLib::Handle< QuantExt::CommodityIndexcommodityIndex (const std::string &commodityName, const std::string &configuration=Market::defaultConfiguration) const override
 Commodity index. More...
 
QuantLib::Handle< QuantLib::BlackVolTermStructure > commodityVolatility (const string &commodityName, const string &configuration=Market::defaultConfiguration) const override
 Commodity volatility. More...
 
Handle< QuantExt::CorrelationTermStructurecorrelationCurve (const string &index1, const string &index2, const string &configuration=Market::defaultConfiguration) const override
 Correlation curves. More...
 
Conditional Prepayment Rates
QuantLib::Handle< Quote > cpr (const string &securityID, const string &configuration=Market::defaultConfiguration) const override
 
- Public Member Functions inherited from Market
 Market (const bool handlePseudoCurrencies)
 Constructor. More...
 
virtual ~Market ()
 Destructor. More...
 
virtual Date asofDate () const =0
 Get the asof Date. More...
 
Handle< YieldTermStructure > discountCurve (const string &ccy, const string &configuration=Market::defaultConfiguration) const
 
QuantLib::Handle< QuantExt::FxIndexfxIndex (const string &fxIndex, const string &configuration=Market::defaultConfiguration) const
 
Handle< Quote > fxRate (const string &ccypair, const string &configuration=Market::defaultConfiguration) const
 
Handle< Quote > fxSpot (const string &ccypair, const string &configuration=Market::defaultConfiguration) const
 
Handle< BlackVolTermStructurefxVol (const string &ccypair, const string &configuration=Market::defaultConfiguration) const
 
string commodityCurveLookup (const string &pm) const
 
bool handlePseudoCurrencies () const
 

Disable copying

Date asof_
 
QuantLib::ext::shared_ptr< FXTriangulationfx_
 
map< tuple< string, YieldCurveType, string >, Handle< YieldTermStructure > > yieldCurves_
 
map< pair< string, string >, Handle< IborIndex > > iborIndices_
 
map< pair< string, string >, Handle< SwapIndex > > swapIndices_
 
map< pair< string, string >, Handle< QuantLib::SwaptionVolatilityStructure > > swaptionCurves_
 
map< pair< string, string >, pair< string, string > > swaptionIndexBases_
 
map< pair< string, string >, Handle< QuantLib::SwaptionVolatilityStructure > > yieldVolCurves_
 
map< pair< string, string >, Handle< BlackVolTermStructure > > fxVols_
 
map< pair< string, string >, Handle< QuantExt::CreditCurve > > defaultCurves_
 
map< pair< string, string >, Handle< QuantExt::CreditVolCurve > > cdsVols_
 
map< pair< string, string >, Handle< QuantExt::BaseCorrelationTermStructure > > baseCorrelations_
 
map< pair< string, string >, Handle< Quote > > recoveryRates_
 
map< pair< string, string >, Handle< OptionletVolatilityStructure > > capFloorCurves_
 
map< pair< string, string >, std::pair< string, QuantLib::Period > > capFloorIndexBase_
 
map< pair< string, string >, Handle< YoYOptionletVolatilitySurface > > yoyCapFloorVolSurfaces_
 
map< pair< string, string >, Handle< ZeroInflationIndex > > zeroInflationIndices_
 
map< pair< string, string >, Handle< YoYInflationIndex > > yoyInflationIndices_
 
map< pair< string, string >, Handle< CPIVolatilitySurface > > cpiInflationCapFloorVolatilitySurfaces_
 
map< pair< string, string >, Handle< Quote > > equitySpots_
 
map< pair< string, string >, Handle< BlackVolTermStructure > > equityVols_
 
map< pair< string, string >, Handle< Quote > > securitySpreads_
 
map< pair< string, string >, Handle< QuantExt::InflationIndexObserver > > baseCpis_
 
map< tuple< string, string, string >, Handle< QuantExt::CorrelationTermStructure > > correlationCurves_
 
map< pair< string, string >, QuantLib::Handle< QuantExt::CommodityIndex > > commodityIndices_
 
map< pair< string, string >, QuantLib::Handle< QuantLib::BlackVolTermStructure > > commodityVols_
 
map< pair< string, string >, QuantLib::Handle< QuantExt::EquityIndex2 > > equityCurves_
 
map< pair< string, string >, Handle< Quote > > cprs_
 
map< string, std::set< QuantLib::ext::shared_ptr< TermStructure > > > refreshTs_
 
 MarketImpl (const MarketImpl &)=delete
 
MarketImploperator= (const MarketImpl &)=delete
 
void refresh (const string &configuration=Market::defaultConfiguration) override
 Send an explicit update() call to all term structures. More...
 
virtual void require (const MarketObject o, const string &name, const string &configuration, const bool forceBuild=false) const
 
void addSwapIndex (const string &swapindex, const string &discountIndex, const string &configuration=Market::defaultConfiguration) const
 add a swap index to the market More...
 
pair< string, string > swapIndexBases (const string &key, const string &configuration=Market::defaultConfiguration) const
 

Additional Inherited Members

- Static Public Attributes inherited from Market
static const string defaultConfiguration = "default"
 Default configuration label. More...
 
static const string inCcyConfiguration = "inccy"
 InCcy configuration label. More...
 
- Protected Attributes inherited from Market
bool handlePseudoCurrencies_ = false
 

Detailed Description

Market Implementation.

The MarketImpl class differs from the Market base class in that it contains concrete maps of term structures, and it implements the interface.

Definition at line 53 of file marketimpl.hpp.

Constructor & Destructor Documentation

◆ MarketImpl() [1/2]

MarketImpl ( const bool  handlePseudoCurrencies)
explicit

Definition at line 55 of file marketimpl.hpp.

bool handlePseudoCurrencies() const
Definition: market.hpp:339
Market(const bool handlePseudoCurrencies)
Constructor.
Definition: market.hpp:166

◆ MarketImpl() [2/2]

MarketImpl ( const MarketImpl )
delete

Member Function Documentation

◆ asofDate()

Date asofDate ( ) const
overridevirtual

Get the asof Date.

Implements Market.

Definition at line 60 of file marketimpl.hpp.

60{ return asof_; }

◆ yieldCurve() [1/2]

Handle< YieldTermStructure > yieldCurve ( const YieldCurveType type,
const string &  ccy,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Yield Curves.

Implements Market.

Definition at line 74 of file marketimpl.cpp.

75 {
76 // we allow for standard (i.e. not convention based) ibor index names as keys and return the index forward curve in
77 // case of a match
78 QuantLib::ext::shared_ptr<IborIndex> notUsed;
79 if (tryParseIborIndex(key, notUsed)) {
80 return iborIndex(key, configuration)->forwardingTermStructure();
81 }
82 // no ibor index found under key => look for a genuine yield curve
83 DLOG("no ibor index found under '" << key << "' - look for a genuine yield curve");
84 if (type == YieldCurveType::Discount)
85 require(MarketObject::DiscountCurve, key, configuration);
86 else if (type == YieldCurveType::Yield)
87 require(MarketObject::YieldCurve, key, configuration);
88 else if (type == YieldCurveType::EquityDividend)
89 require(MarketObject::EquityCurve, key, configuration);
90 else {
91 QL_FAIL("yield curve type not handled");
92 }
93 return lookup<Handle<YieldTermStructure>>(yieldCurves_, key, type, configuration, "yield curve / ibor index");
94}
map< tuple< string, YieldCurveType, string >, Handle< YieldTermStructure > > yieldCurves_
Definition: marketimpl.hpp:208
Handle< IborIndex > iborIndex(const string &indexName, const string &configuration=Market::defaultConfiguration) const override
Definition: marketimpl.cpp:107
virtual void require(const MarketObject o, const string &name, const string &configuration, const bool forceBuild=false) const
Definition: marketimpl.hpp:201
bool tryParseIborIndex(const string &s, QuantLib::ext::shared_ptr< IborIndex > &index)
Try to convert std::string to QuantLib::IborIndex.
#define DLOG(text)
Logging Macro (Level = Debug)
Definition: log.hpp:554
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ discountCurveImpl()

Handle< YieldTermStructure > discountCurveImpl ( const string &  ccy,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Implements Market.

Definition at line 96 of file marketimpl.cpp.

96 {
97 require(MarketObject::DiscountCurve, key, configuration);
98 return lookup<Handle<YieldTermStructure>>(yieldCurves_, key, YieldCurveType::Discount, configuration,
99 "discount curve");
100}
+ Here is the call graph for this function:

◆ yieldCurve() [2/2]

Handle< YieldTermStructure > yieldCurve ( const string &  name,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Implements Market.

Definition at line 102 of file marketimpl.cpp.

102 {
103 require(MarketObject::YieldCurve, key, configuration);
104 return yieldCurve(YieldCurveType::Yield, key, configuration);
105}
Handle< YieldTermStructure > yieldCurve(const YieldCurveType &type, const string &ccy, const string &configuration=Market::defaultConfiguration) const override
Yield Curves.
Definition: marketimpl.cpp:74
+ Here is the call graph for this function:

◆ iborIndex()

Handle< IborIndex > iborIndex ( const string &  indexName,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Implements Market.

Definition at line 107 of file marketimpl.cpp.

107 {
108 require(MarketObject::IndexCurve, key, configuration);
109 return lookup<Handle<IborIndex>>(iborIndices_, key, configuration, "ibor index");
110}
map< pair< string, string >, Handle< IborIndex > > iborIndices_
Definition: marketimpl.hpp:209
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ swapIndex()

Handle< SwapIndex > swapIndex ( const string &  indexName,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Implements Market.

Definition at line 112 of file marketimpl.cpp.

112 {
113 require(MarketObject::SwapIndexCurve, key, configuration);
114 return lookup<Handle<SwapIndex>>(swapIndices_, key, configuration, "swap index");
115}
map< pair< string, string >, Handle< SwapIndex > > swapIndices_
Definition: marketimpl.hpp:210
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ swaptionVol()

Handle< QuantLib::SwaptionVolatilityStructure > swaptionVol ( const string &  key,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Swaptions.

Implements Market.

Definition at line 117 of file marketimpl.cpp.

118 {
119 require(MarketObject::SwaptionVol, key, configuration);
120 auto it = swaptionCurves_.find(make_pair(configuration, key));
121 if (it != swaptionCurves_.end())
122 return it->second;
123 // try the default config with the same key
124 if (configuration != Market::defaultConfiguration) {
126 auto it2 = swaptionCurves_.find(make_pair(Market::defaultConfiguration, key));
127 if (it2 != swaptionCurves_.end())
128 return it2->second;
129 }
130 // if key is an index name and we have a swaption curve for its ccy, we return that
131 QuantLib::ext::shared_ptr<IborIndex> index;
132 if (!tryParseIborIndex(key, index)) {
133 QL_FAIL("did not find swaption curve for key '" << key << "'");
134 }
135 auto ccy = index->currency().code();
136 require(MarketObject::SwaptionVol, ccy, configuration);
137 auto it3 = swaptionCurves_.find(make_pair(configuration, ccy));
138 if (it3 != swaptionCurves_.end()) {
139 return it3->second;
140 }
141 // check if we have a curve for the ccy in the default config
142 if (configuration != Market::defaultConfiguration) {
143 require(MarketObject::SwaptionVol, ccy, configuration);
144 auto it4 = swaptionCurves_.find(make_pair(Market::defaultConfiguration, ccy));
145 if (it4 != swaptionCurves_.end())
146 return it4->second;
147 }
148 QL_FAIL("did not find swaption curve for key '" << key << "'");
149}
static const string defaultConfiguration
Default configuration label.
Definition: market.hpp:296
map< pair< string, string >, Handle< QuantLib::SwaptionVolatilityStructure > > swaptionCurves_
Definition: marketimpl.hpp:211
+ Here is the call graph for this function:

◆ shortSwapIndexBase()

string shortSwapIndexBase ( const string &  key,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Implements Market.

Definition at line 184 of file marketimpl.cpp.

184 {
185 return swapIndexBases(key, configuration).first;
186}
pair< string, string > swapIndexBases(const string &key, const string &configuration=Market::defaultConfiguration) const
Definition: marketimpl.cpp:151
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ swapIndexBase()

string swapIndexBase ( const string &  key,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Implements Market.

Definition at line 188 of file marketimpl.cpp.

188 {
189 return swapIndexBases(key, configuration).second;
190}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ yieldVol()

Handle< QuantLib::SwaptionVolatilityStructure > yieldVol ( const string &  securityID,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Yield volatility.

Implements Market.

Definition at line 192 of file marketimpl.cpp.

193 {
194 require(MarketObject::YieldVol, key, configuration);
195 return lookup<Handle<QuantLib::SwaptionVolatilityStructure>>(yieldVolCurves_, key, configuration,
196 "yield volatility curve");
197}
map< pair< string, string >, Handle< QuantLib::SwaptionVolatilityStructure > > yieldVolCurves_
Definition: marketimpl.hpp:213
+ Here is the call graph for this function:

◆ fxIndexImpl()

Handle< QuantExt::FxIndex > fxIndexImpl ( const string &  fxIndex,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

FX.

Implements Market.

Definition at line 199 of file marketimpl.cpp.

199 {
200 QL_REQUIRE(fx_ != nullptr,
201 "MarketImpl::fxIndex(" << fxIndex << "): fx_ is null. This is an internal error. Contact dev.");
202 return fx_->getIndex(fxIndex, this, configuration);
203}
QuantLib::Handle< QuantExt::FxIndex > fxIndex(const string &fxIndex, const string &configuration=Market::defaultConfiguration) const
Definition: market.cpp:151
QuantLib::ext::shared_ptr< FXTriangulation > fx_
Definition: marketimpl.hpp:206
+ Here is the call graph for this function:

◆ fxRateImpl()

Handle< Quote > fxRateImpl ( const string &  ccypair,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Implements Market.

Definition at line 205 of file marketimpl.cpp.

205 {
206 // if rate requested for a currency against itself, return 1.0
207 if (ccypair.substr(0,3) == ccypair.substr(3))
208 return Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(1.0));
209 return fxIndex(ccypair, configuration)->fxQuote();
210}
+ Here is the call graph for this function:

◆ fxSpotImpl()

Handle< Quote > fxSpotImpl ( const string &  ccypair,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Implements Market.

Definition at line 212 of file marketimpl.cpp.

212 {
213 if (ccypair.substr(0, 3) == ccypair.substr(3))
214 return Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(1.0));
215 return fxIndex(ccypair, configuration)->fxQuote(true);
216}
+ Here is the call graph for this function:

◆ fxVolImpl()

Handle< BlackVolTermStructure > fxVolImpl ( const string &  ccypair,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Implements Market.

Definition at line 218 of file marketimpl.cpp.

218 {
219 require(MarketObject::FXVol, ccypair, configuration);
220 auto it = fxVols_.find(make_pair(configuration, ccypair));
221 if (it != fxVols_.end())
222 return it->second;
223 else {
224 // check for reverse EURUSD or USDEUR and add to the map
225 QL_REQUIRE(ccypair.length() == 6, "invalid ccy pair length");
226 std::string ccypairInverted = ccypair.substr(3, 3) + ccypair.substr(0, 3);
227 require(MarketObject::FXVol, ccypairInverted, configuration);
228 it = fxVols_.find(make_pair(configuration, ccypairInverted));
229 if (it != fxVols_.end()) {
230 Handle<BlackVolTermStructure> h(QuantLib::ext::make_shared<QuantExt::BlackInvertedVolTermStructure>(it->second));
231 h->enableExtrapolation();
232 // we have found a surface for the inverted pair.
233 // so we can invert the surface and store that under the original pair.
234 fxVols_[make_pair(configuration, ccypair)] = h;
235 return h;
236 } else {
237 if (configuration == Market::defaultConfiguration)
238 QL_FAIL("did not find fx vol object " << ccypair);
239 else
240 return fxVol(ccypair, Market::defaultConfiguration);
241 }
242 }
243}
Handle< BlackVolTermStructure > fxVol(const string &ccypair, const string &configuration=Market::defaultConfiguration) const
Definition: market.cpp:287
map< pair< string, string >, Handle< BlackVolTermStructure > > fxVols_
Definition: marketimpl.hpp:214
+ Here is the call graph for this function:

◆ defaultCurve()

Handle< QuantExt::CreditCurve > defaultCurve ( const string &  key,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Default Curves and Recovery Rates.

Implements Market.

Definition at line 245 of file marketimpl.cpp.

245 {
246 require(MarketObject::DefaultCurve, key, configuration);
247 return lookup<Handle<QuantExt::CreditCurve>>(defaultCurves_, key, configuration, "default curve");
248}
map< pair< string, string >, Handle< QuantExt::CreditCurve > > defaultCurves_
Definition: marketimpl.hpp:215
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ recoveryRate()

Handle< Quote > recoveryRate ( const string &  key,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Implements Market.

Definition at line 250 of file marketimpl.cpp.

250 {
251 // recovery rates can be built together with default curve or securities
252 require(MarketObject::DefaultCurve, key, configuration);
253 require(MarketObject::Security, key, configuration);
254 return lookup<Handle<Quote>>(recoveryRates_, key, configuration, "recovery rate");
255}
map< pair< string, string >, Handle< Quote > > recoveryRates_
Definition: marketimpl.hpp:218
+ Here is the call graph for this function:

◆ cdsVol()

Handle< QuantExt::CreditVolCurve > cdsVol ( const string &  name,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

CDS volatilities.

Implements Market.

Definition at line 257 of file marketimpl.cpp.

257 {
258 require(MarketObject::CDSVol, key, configuration);
259 return lookup<Handle<QuantExt::CreditVolCurve>>(cdsVols_, key, configuration, "cds vol curve");
260}
map< pair< string, string >, Handle< QuantExt::CreditVolCurve > > cdsVols_
Definition: marketimpl.hpp:216
+ Here is the call graph for this function:

◆ baseCorrelation()

Handle< QuantExt::BaseCorrelationTermStructure > baseCorrelation ( const string &  name,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Base correlation structures.

Implements Market.

Definition at line 263 of file marketimpl.cpp.

263 {
264 require(MarketObject::BaseCorrelation, key, configuration);
265 return lookup<Handle<QuantExt::BaseCorrelationTermStructure>>(baseCorrelations_, key, configuration,
266 "base correlation curve");
267}
map< pair< string, string >, Handle< QuantExt::BaseCorrelationTermStructure > > baseCorrelations_
Definition: marketimpl.hpp:217
+ Here is the call graph for this function:

◆ capFloorVol()

Handle< OptionletVolatilityStructure > capFloorVol ( const string &  key,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

CapFloor volatilities.

Implements Market.

Definition at line 269 of file marketimpl.cpp.

269 {
270 require(MarketObject::CapFloorVol, key, configuration);
271 auto it = capFloorCurves_.find(make_pair(configuration, key));
272 if (it != capFloorCurves_.end())
273 return it->second;
274 // first try the default config with the same key
275 if (configuration != Market::defaultConfiguration) {
277 auto it2 = capFloorCurves_.find(make_pair(Market::defaultConfiguration, key));
278 if (it2 != capFloorCurves_.end())
279 return it2->second;
280 }
281 // if key is an index name and we have a cap floor surface for its ccy, we return that
282 QuantLib::ext::shared_ptr<IborIndex> index;
283 if (!tryParseIborIndex(key, index)) {
284 QL_FAIL("did not find capfloor curve for key '" << key << "'");
285 }
286 auto ccy = index->currency().code();
287 require(MarketObject::CapFloorVol, ccy, configuration);
288 auto it3 = capFloorCurves_.find(make_pair(configuration, ccy));
289 if (it3 != capFloorCurves_.end()) {
290 return it3->second;
291 }
292 // check if we have a curve for the ccy in the default config
293 if (configuration != Market::defaultConfiguration) {
294 require(MarketObject::CapFloorVol, ccy, configuration);
295 auto it4 = capFloorCurves_.find(make_pair(Market::defaultConfiguration, ccy));
296 if (it4 != capFloorCurves_.end())
297 return it4->second;
298 }
299 QL_FAIL("did not find capfloor curve for key '" << key << "'");
300}
map< pair< string, string >, Handle< OptionletVolatilityStructure > > capFloorCurves_
Definition: marketimpl.hpp:219
+ Here is the call graph for this function:

◆ capFloorVolIndexBase()

std::pair< string, QuantLib::Period > capFloorVolIndexBase ( const string &  key,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Implements Market.

Definition at line 302 of file marketimpl.cpp.

303 {
304 require(MarketObject::CapFloorVol, key, configuration);
305 auto it = capFloorIndexBase_.find(make_pair(configuration, key));
306 if (it != capFloorIndexBase_.end())
307 return it->second;
308 // first try the default config with the same key
309 if (configuration != Market::defaultConfiguration) {
311 auto it2 = capFloorIndexBase_.find(make_pair(Market::defaultConfiguration, key));
312 if (it2 != capFloorIndexBase_.end())
313 return it2->second;
314 }
315 // if key is an index name and we have a cap floor surface for its ccy, we return that
316 QuantLib::ext::shared_ptr<IborIndex> index;
317 if (!tryParseIborIndex(key, index)) {
318 return std::make_pair(string(),0*Days);
319 }
320 auto ccy = index->currency().code();
321 require(MarketObject::CapFloorVol, ccy, configuration);
322 auto it3 = capFloorIndexBase_.find(make_pair(configuration, ccy));
323 if (it3 != capFloorIndexBase_.end()) {
324 return it3->second;
325 }
326 // check if we have a curve for the ccy in the default config
327 if (configuration != Market::defaultConfiguration) {
328 require(MarketObject::CapFloorVol, ccy, configuration);
329 auto it4 = capFloorIndexBase_.find(make_pair(Market::defaultConfiguration, ccy));
330 if (it4 != capFloorIndexBase_.end())
331 return it4->second;
332 }
333 return std::make_pair(string(), 0 * Days);
334}
map< pair< string, string >, std::pair< string, QuantLib::Period > > capFloorIndexBase_
Definition: marketimpl.hpp:220
+ Here is the call graph for this function:

◆ yoyCapFloorVol()

Handle< YoYOptionletVolatilitySurface > yoyCapFloorVol ( const string &  name,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

YoY Inflation CapFloor volatilities.

Implements Market.

Definition at line 336 of file marketimpl.cpp.

336 {
338 return lookup<Handle<YoYOptionletVolatilitySurface>>(yoyCapFloorVolSurfaces_, key, configuration,
339 "yoy inflation capfloor curve");
340}
map< pair< string, string >, Handle< YoYOptionletVolatilitySurface > > yoyCapFloorVolSurfaces_
Definition: marketimpl.hpp:221
+ Here is the call graph for this function:

◆ zeroInflationIndex()

Handle< ZeroInflationIndex > zeroInflationIndex ( const string &  indexName,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Inflation Indexes.

Implements Market.

Definition at line 342 of file marketimpl.cpp.

342 {
343 require(MarketObject::ZeroInflationCurve, indexName, configuration);
344 return lookup<Handle<ZeroInflationIndex>>(zeroInflationIndices_, indexName, configuration, "zero inflation index");
345}
map< pair< string, string >, Handle< ZeroInflationIndex > > zeroInflationIndices_
Definition: marketimpl.hpp:222
+ Here is the call graph for this function:

◆ yoyInflationIndex()

Handle< YoYInflationIndex > yoyInflationIndex ( const string &  indexName,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Implements Market.

Definition at line 347 of file marketimpl.cpp.

347 {
348 require(MarketObject::YoYInflationCurve, indexName, configuration);
349 return lookup<Handle<YoYInflationIndex>>(yoyInflationIndices_, indexName, configuration, "yoy inflation index");
350}
map< pair< string, string >, Handle< YoYInflationIndex > > yoyInflationIndices_
Definition: marketimpl.hpp:223
+ Here is the call graph for this function:

◆ cpiInflationCapFloorVolatilitySurface()

Handle< CPIVolatilitySurface > cpiInflationCapFloorVolatilitySurface ( const string &  indexName,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Inflation Cap Floor Volatility Surfaces.

Implements Market.

Definition at line 352 of file marketimpl.cpp.

353 {
354 require(MarketObject::ZeroInflationCapFloorVol, indexName, configuration);
355 return lookup<Handle<CPIVolatilitySurface>>(cpiInflationCapFloorVolatilitySurfaces_, indexName, configuration,
356 "cpi cap floor volatility surface");
357}
map< pair< string, string >, Handle< CPIVolatilitySurface > > cpiInflationCapFloorVolatilitySurfaces_
Definition: marketimpl.hpp:224
+ Here is the call graph for this function:

◆ equitySpot()

Handle< Quote > equitySpot ( const string &  eqName,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Equity curves.

Implements Market.

Definition at line 359 of file marketimpl.cpp.

359 {
360 require(MarketObject::EquityCurve, key, configuration);
361 return lookup<Handle<Quote>>(equitySpots_, key, configuration, "equity spot");
362}
map< pair< string, string >, Handle< Quote > > equitySpots_
Definition: marketimpl.hpp:225
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ equityCurve()

Handle< QuantExt::EquityIndex2 > equityCurve ( const string &  eqName,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Implements Market.

Definition at line 364 of file marketimpl.cpp.

364 {
365 require(MarketObject::EquityCurve, key, configuration);
366 return lookup<Handle<QuantExt::EquityIndex2>>(equityCurves_, key, configuration, "equity curve");
367};
map< pair< string, string >, QuantLib::Handle< QuantExt::EquityIndex2 > > equityCurves_
Definition: marketimpl.hpp:232
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ equityDividendCurve()

Handle< YieldTermStructure > equityDividendCurve ( const string &  eqName,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Implements Market.

Definition at line 369 of file marketimpl.cpp.

369 {
370 require(MarketObject::EquityCurve, key, configuration);
371 return lookup<Handle<YieldTermStructure>>(yieldCurves_, key, YieldCurveType::EquityDividend, configuration,
372 "dividend yield curve");
373}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ equityVol()

Handle< BlackVolTermStructure > equityVol ( const string &  eqName,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Equity volatilities.

Implements Market.

Definition at line 375 of file marketimpl.cpp.

375 {
376 require(MarketObject::EquityVol, key, configuration);
377 return lookup<Handle<BlackVolTermStructure>>(equityVols_, key, configuration, "equity vol curve");
378}
map< pair< string, string >, Handle< BlackVolTermStructure > > equityVols_
Definition: marketimpl.hpp:226
+ Here is the call graph for this function:

◆ equityForecastCurve()

Handle< YieldTermStructure > equityForecastCurve ( const string &  eqName,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Equity forecasting curves.

Implements Market.

Definition at line 380 of file marketimpl.cpp.

380 {
381 require(MarketObject::EquityCurve, eqName, configuration);
382 return equityCurve(eqName, configuration)->equityForecastCurve();
383}
Handle< QuantExt::EquityIndex2 > equityCurve(const string &eqName, const string &configuration=Market::defaultConfiguration) const override
Definition: marketimpl.cpp:364
+ Here is the call graph for this function:

◆ securitySpread()

Handle< Quote > securitySpread ( const string &  securityID,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Bond Spreads.

Implements Market.

Definition at line 385 of file marketimpl.cpp.

385 {
386 require(MarketObject::Security, key, configuration);
387 return lookup<Handle<Quote>>(securitySpreads_, key, configuration, "security spread");
388}
map< pair< string, string >, Handle< Quote > > securitySpreads_
Definition: marketimpl.hpp:227
+ Here is the call graph for this function:

◆ baseCpis()

Handle< QuantExt::InflationIndexObserver > baseCpis ( const string &  index,
const string &  configuration = Market::defaultConfiguration 
) const

Cpi Base Quotes.

Definition at line 390 of file marketimpl.cpp.

390 {
391 require(MarketObject::ZeroInflationCurve, key, configuration);
392 return lookup<Handle<QuantExt::InflationIndexObserver>>(baseCpis_, key, configuration, "base CPI");
393}
map< pair< string, string >, Handle< QuantExt::InflationIndexObserver > > baseCpis_
Definition: marketimpl.hpp:228
+ Here is the call graph for this function:

◆ commodityPriceCurve()

Handle< PriceTermStructure > commodityPriceCurve ( const string &  commodityName,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Commodity curves.

Implements Market.

Definition at line 395 of file marketimpl.cpp.

396 {
397 return commodityIndex(commodityName, configuration)->priceCurve();
398}
QuantLib::Handle< QuantExt::CommodityIndex > commodityIndex(const std::string &commodityName, const std::string &configuration=Market::defaultConfiguration) const override
Commodity index.
Definition: marketimpl.cpp:400
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ commodityIndex()

Handle< CommodityIndex > commodityIndex ( const std::string &  commodityName,
const std::string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Commodity index.

Implements Market.

Definition at line 400 of file marketimpl.cpp.

400 {
401 require(MarketObject::CommodityCurve, commodityName, configuration);
402 return lookup<Handle<CommodityIndex>>(commodityIndices_, commodityName, configuration, "commodity indices");
403}
map< pair< string, string >, QuantLib::Handle< QuantExt::CommodityIndex > > commodityIndices_
Definition: marketimpl.hpp:230
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ commodityVolatility()

Handle< BlackVolTermStructure > commodityVolatility ( const string &  commodityName,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Commodity volatility.

Implements Market.

Definition at line 405 of file marketimpl.cpp.

406 {
407 require(MarketObject::CommodityVolatility, commodityName, configuration);
408 return lookup<Handle<BlackVolTermStructure>>(commodityVols_, commodityName, configuration, "commodity volatility");
409}
map< pair< string, string >, QuantLib::Handle< QuantLib::BlackVolTermStructure > > commodityVols_
Definition: marketimpl.hpp:231
+ Here is the call graph for this function:

◆ correlationCurve()

Handle< QuantExt::CorrelationTermStructure > correlationCurve ( const string &  index1,
const string &  index2,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Correlation curves.

Implements Market.

Definition at line 411 of file marketimpl.cpp.

412 {
413 // straight pair
414 require(MarketObject::Correlation, index1 + "&" + index2, configuration);
415 auto it = correlationCurves_.find(make_tuple(configuration, index1, index2));
416 if (it != correlationCurves_.end())
417 return it->second;
418 // inverse pair
419 require(MarketObject::Correlation, index2 + "&" + index1, configuration);
420 it = correlationCurves_.find(make_tuple(configuration, index2, index1));
421 if (it != correlationCurves_.end())
422 return it->second;
423 // inverse fx index1
424 if (isFxIndex(index1)) {
425 require(MarketObject::Correlation, inverseFxIndex(index1) + "&" + index2, configuration);
426 it = correlationCurves_.find(make_tuple(configuration, inverseFxIndex(index1), index2));
427 if (it != correlationCurves_.end())
428 return Handle<QuantExt::CorrelationTermStructure>(
429 QuantLib::ext::make_shared<QuantExt::NegativeCorrelationTermStructure>(it->second));
430 require(MarketObject::Correlation, index2 + "&" + inverseFxIndex(index1), configuration);
431 it = correlationCurves_.find(make_tuple(configuration, index2, inverseFxIndex(index1)));
432 if (it != correlationCurves_.end())
433 return Handle<QuantExt::CorrelationTermStructure>(
434 QuantLib::ext::make_shared<QuantExt::NegativeCorrelationTermStructure>(it->second));
435 }
436 // inverse fx index2
437 if (isFxIndex(index2)) {
438 require(MarketObject::Correlation, index1 + "&" + inverseFxIndex(index2), configuration);
439 it = correlationCurves_.find(make_tuple(configuration, index1, inverseFxIndex(index2)));
440 if (it != correlationCurves_.end())
441 return Handle<QuantExt::CorrelationTermStructure>(
442 QuantLib::ext::make_shared<QuantExt::NegativeCorrelationTermStructure>(it->second));
443 require(MarketObject::Correlation, inverseFxIndex(index2) + "&" + index1, configuration);
444 it = correlationCurves_.find(make_tuple(configuration, inverseFxIndex(index2), index1));
445 if (it != correlationCurves_.end())
446 return Handle<QuantExt::CorrelationTermStructure>(
447 QuantLib::ext::make_shared<QuantExt::NegativeCorrelationTermStructure>(it->second));
448 }
449 // both fx indices inverted
450 if (isFxIndex(index1) && isFxIndex(index2)) {
451 require(MarketObject::Correlation, inverseFxIndex(index1) + "&" + inverseFxIndex(index2), configuration);
452 it = correlationCurves_.find(make_tuple(configuration, inverseFxIndex(index1), inverseFxIndex(index2)));
453 if (it != correlationCurves_.end())
454 return it->second;
455 require(MarketObject::Correlation, inverseFxIndex(index2) + "&" + inverseFxIndex(index1), configuration);
456 it = correlationCurves_.find(make_tuple(configuration, inverseFxIndex(index2), inverseFxIndex(index1)));
457 if (it != correlationCurves_.end())
458 return it->second;
459 }
460 // if not found, fall back to default configuration
461 if (configuration == Market::defaultConfiguration) {
462 QL_FAIL("did not find object " << index1 << "/" << index2 << " in CorrelationCurves");
463 } else {
464 return correlationCurve(index1, index2, Market::defaultConfiguration);
465 }
466}
map< tuple< string, string, string >, Handle< QuantExt::CorrelationTermStructure > > correlationCurves_
Definition: marketimpl.hpp:229
Handle< QuantExt::CorrelationTermStructure > correlationCurve(const string &index1, const string &index2, const string &configuration=Market::defaultConfiguration) const override
Correlation curves.
Definition: marketimpl.cpp:411
bool isFxIndex(const std::string &indexName)
std::string inverseFxIndex(const std::string &indexName)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cpr()

Handle< Quote > cpr ( const string &  securityID,
const string &  configuration = Market::defaultConfiguration 
) const
overridevirtual

Implements Market.

Definition at line 468 of file marketimpl.cpp.

468 {
469 require(MarketObject::Security, securityID, configuration);
470 return lookup<Handle<Quote>>(cprs_, securityID, configuration, "cpr");
471}
map< pair< string, string >, Handle< Quote > > cprs_
Definition: marketimpl.hpp:233
+ Here is the call graph for this function:

◆ operator=()

MarketImpl & operator= ( const MarketImpl )
delete

◆ refresh()

void refresh ( const string &  configuration = Market::defaultConfiguration)
overridevirtual

Send an explicit update() call to all term structures.

Reimplemented from Market.

Definition at line 513 of file marketimpl.cpp.

513 {
514
515 auto it = refreshTs_.find(configuration);
516 if (it == refreshTs_.end()) {
517 it = refreshTs_.insert(make_pair(configuration, std::set<QuantLib::ext::shared_ptr<TermStructure>>())).first;
518 }
519
520 if (it->second.empty()) {
521 for (auto& x : yieldCurves_) {
522 if (get<0>(x.first) == configuration || get<0>(x.first) == Market::defaultConfiguration)
523 it->second.insert(*x.second);
524 }
525 for (auto& x : iborIndices_) {
526 if (x.first.first == configuration || x.first.first == Market::defaultConfiguration) {
527 Handle<YieldTermStructure> y = x.second->forwardingTermStructure();
528 if (!y.empty())
529 it->second.insert(*y);
530 }
531 }
532 for (auto& x : swapIndices_) {
533 if (x.first.first == configuration || x.first.first == Market::defaultConfiguration) {
534 Handle<YieldTermStructure> y = x.second->forwardingTermStructure();
535 if (!y.empty())
536 it->second.insert(*y);
537 y = x.second->discountingTermStructure();
538 if (!y.empty())
539 it->second.insert(*y);
540 }
541 }
542 for (auto& x : swaptionCurves_) {
543 if (x.first.first == configuration || x.first.first == Market::defaultConfiguration)
544 it->second.insert(*x.second);
545 }
546 for (auto& x : capFloorCurves_) {
547 if (x.first.first == configuration || x.first.first == Market::defaultConfiguration)
548 it->second.insert(*x.second);
549 }
550 for (auto& x : yoyCapFloorVolSurfaces_) {
551 if (x.first.first == configuration || x.first.first == Market::defaultConfiguration)
552 it->second.insert(*x.second);
553 }
554 for (auto& x : fxVols_) {
555 if (x.first.first == configuration || x.first.first == Market::defaultConfiguration)
556 it->second.insert(*x.second);
557 }
558 for (auto& x : defaultCurves_) {
559 if (x.first.first == configuration || x.first.first == Market::defaultConfiguration)
560 it->second.insert(*x.second->curve());
561 }
562 for (auto& x : cdsVols_) {
563 if (x.first.first == configuration || x.first.first == Market::defaultConfiguration)
564 it->second.insert(*x.second);
565 }
566 for (auto& x : baseCorrelations_) {
567 if (x.first.first == configuration || x.first.first == Market::defaultConfiguration)
568 it->second.insert(*x.second);
569 }
570 for (auto& x : zeroInflationIndices_) {
571 if (x.first.first == configuration || x.first.first == Market::defaultConfiguration) {
572 it->second.insert(*x.second->zeroInflationTermStructure());
573 }
574 }
575 for (auto& x : yoyInflationIndices_) {
576 if (x.first.first == configuration || x.first.first == Market::defaultConfiguration) {
577 it->second.insert(*x.second->yoyInflationTermStructure());
578 }
579 }
581 if (x.first.first == configuration || x.first.first == Market::defaultConfiguration)
582 it->second.insert(*x.second);
583 }
584 for (auto& x : yoyCapFloorVolSurfaces_) {
585 if (x.first.first == configuration || x.first.first == Market::defaultConfiguration)
586 it->second.insert(*x.second);
587 }
588 for (auto& x : equityVols_) {
589 if (x.first.first == configuration || x.first.first == Market::defaultConfiguration)
590 it->second.insert(*x.second);
591 }
592 for (auto& x : equityCurves_) {
593 if (x.first.first == configuration || x.first.first == Market::defaultConfiguration) {
594 Handle<YieldTermStructure> y = x.second->equityForecastCurve();
595 if (!y.empty())
596 it->second.insert(*y);
597 y = x.second->equityDividendCurve();
598 if (!y.empty())
599 it->second.insert(*y);
600 }
601 }
602 for (auto& x : commodityIndices_) {
603 if (x.first.first == configuration || x.first.first == Market::defaultConfiguration) {
604 const auto& pts = x.second->priceCurve();
605 if (!pts.empty())
606 it->second.insert(*pts);
607 }
608 }
609 for (auto& x : commodityVols_) {
610 if (x.first.first == configuration || x.first.first == Market::defaultConfiguration)
611 it->second.insert(*x.second);
612 }
613
614 for (auto& x : correlationCurves_) {
615 if (get<0>(x.first) == configuration || get<0>(x.first) == Market::defaultConfiguration)
616 it->second.insert(*x.second);
617 }
618 }
619
620 // term structures might be wrappers around nested termstructures that need to be updated as well,
621 // therefore we need to call deepUpdate() (=update() if no such nesting is present)
622 for (auto& x : it->second)
623 x->deepUpdate();
624
625} // refresh
map< string, std::set< QuantLib::ext::shared_ptr< TermStructure > > > refreshTs_
Definition: marketimpl.hpp:240

◆ require()

virtual void require ( const MarketObject  o,
const string &  name,
const string &  configuration,
const bool  forceBuild = false 
) const
protectedvirtual

Require a market object, this can be used in derived classes to build objects lazily. If the method is not overwritten in a derived class, it is assumed that the class builds all market object upfront.

For FXVols and Correlations the require is not 'hard', e.g. both EURUSD and USDEUR might be required for FXVols, but only one of them is expected to be actually built (the other one is then constructed on the fly from the first one). Therefore no error should be thrown in the implementation of require(), if an object is ultimately not found, an appropriate error will be thrown from this class.

An object is required for a single configuration. If it can't be built for this configuration, it should be tried to be built for the "default" configuration instead, because this is used as a fallback.

Notice that correlation curves are required with '&' as a delimiter between the indexes.

Reimplemented in TodaysMarket.

Definition at line 201 of file marketimpl.hpp.

202 {}
+ Here is the caller graph for this function:

◆ addSwapIndex()

void addSwapIndex ( const string &  swapindex,
const string &  discountIndex,
const string &  configuration = Market::defaultConfiguration 
) const
protected

add a swap index to the market

Definition at line 473 of file marketimpl.cpp.

473 {
474 if (swapIndices_.find(make_pair(configuration, swapIndex)) != swapIndices_.end())
475 return;
476 try {
477 std::vector<string> tokens;
478 split(tokens, swapIndex, boost::is_any_of("-"));
479 QL_REQUIRE(tokens.size() == 3 || tokens.size() == 4,
480 "three or four tokens required in " << swapIndex << ": CCY-CMS-TENOR or CCY-CMS-TAG-TENOR");
481 QL_REQUIRE(tokens[0].size() == 3, "invalid currency code in " << swapIndex);
482 QL_REQUIRE(tokens[1] == "CMS", "expected CMS as second token in " << swapIndex);
483
484 Handle<YieldTermStructure> discounting, forwarding;
485 QuantLib::ext::shared_ptr<IborIndex> dummeyIndex;
486 if (tryParseIborIndex(discountIndex, dummeyIndex))
487 discounting = iborIndex(discountIndex, configuration)->forwardingTermStructure();
488 else
489 discounting = yieldCurve(discountIndex, configuration);
490
491 const QuantLib::ext::shared_ptr<Conventions>& conventions = InstrumentConventions::instance().conventions();
492 auto swapCon = QuantLib::ext::dynamic_pointer_cast<data::SwapIndexConvention>(conventions->get(swapIndex));
493 QL_REQUIRE(swapCon, "expected SwapIndexConvention for " << swapIndex);
494 auto conIbor = QuantLib::ext::dynamic_pointer_cast<data::IRSwapConvention>(conventions->get(swapCon->conventions()));
495 auto conOisComp = QuantLib::ext::dynamic_pointer_cast<data::OisConvention>(conventions->get(swapCon->conventions()));
496 auto conOisAvg = QuantLib::ext::dynamic_pointer_cast<data::AverageOisConvention>(conventions->get(swapCon->conventions()));
497 QL_REQUIRE(conIbor || conOisComp || conOisAvg,
498 "expected IRSwapConvention, OisConvention, AverageOisConvention for " << swapCon->conventions());
499
500 string fi = conIbor ? conIbor->indexName() : (conOisComp ? conOisComp->indexName() : conOisAvg->indexName());
501 if (isGenericIborIndex(fi))
502 forwarding = discounting;
503 else
504 forwarding = iborIndex(fi, configuration)->forwardingTermStructure();
505
506 QuantLib::ext::shared_ptr<SwapIndex> si = data::parseSwapIndex(swapIndex, forwarding, discounting);
507 swapIndices_[make_pair(configuration, swapIndex)] = Handle<SwapIndex>(si);
508 } catch (std::exception& e) {
509 QL_FAIL("Failure in MarketImpl::addSwapIndex() with index " << swapIndex << " : " << e.what());
510 }
511}
Handle< SwapIndex > swapIndex(const string &indexName, const string &configuration=Market::defaultConfiguration) const override
Definition: marketimpl.cpp:112
QuantLib::ext::shared_ptr< SwapIndex > parseSwapIndex(const string &s, const Handle< YieldTermStructure > &f, const Handle< YieldTermStructure > &d)
Convert std::string to QuantLib::SwapIndex.
bool isGenericIborIndex(const string &indexName)
Return true if the indexName is that of a generic ibor index, otherwise false.
Size size(const ValueType &v)
Definition: value.cpp:145
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ swapIndexBases()

pair< string, string > swapIndexBases ( const string &  key,
const string &  configuration = Market::defaultConfiguration 
) const
private

Definition at line 151 of file marketimpl.cpp.

151 {
152 require(MarketObject::SwaptionVol, key, configuration);
153 auto it = swaptionIndexBases_.find(make_pair(configuration, key));
154 if (it != swaptionIndexBases_.end())
155 return it->second;
156 // try the default config with the same key
157 if (configuration != Market::defaultConfiguration) {
159 auto it2 = swaptionIndexBases_.find(make_pair(Market::defaultConfiguration, key));
160 if (it2 != swaptionIndexBases_.end())
161 return it2->second;
162 }
163 // if key is an index name and we have a swaption curve for its ccy, we return that
164 QuantLib::ext::shared_ptr<IborIndex> index;
165 if (!tryParseIborIndex(key, index)) {
166 QL_FAIL("did not find swaption index bases for key '" << key << "'");
167 }
168 auto ccy = index->currency().code();
169 require(MarketObject::SwaptionVol, ccy, configuration);
170 auto it3 = swaptionIndexBases_.find(make_pair(configuration, ccy));
171 if (it3 != swaptionIndexBases_.end()) {
172 return it3->second;
173 }
174 // check if we have a curve for the ccy in the default config
175 if (configuration != Market::defaultConfiguration) {
176 require(MarketObject::SwaptionVol, ccy, configuration);
177 auto it4 = swaptionIndexBases_.find(make_pair(Market::defaultConfiguration, ccy));
178 if (it4 != swaptionIndexBases_.end())
179 return it4->second;
180 }
181 QL_FAIL("did not find swaption index bases for key '" << key << "'");
182}
map< pair< string, string >, pair< string, string > > swaptionIndexBases_
Definition: marketimpl.hpp:212
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ asof_

Date asof_
protected

Definition at line 204 of file marketimpl.hpp.

◆ fx_

QuantLib::ext::shared_ptr<FXTriangulation> fx_
protected

Definition at line 206 of file marketimpl.hpp.

◆ yieldCurves_

map<tuple<string, YieldCurveType, string>, Handle<YieldTermStructure> > yieldCurves_
mutableprotected

Definition at line 208 of file marketimpl.hpp.

◆ iborIndices_

map<pair<string, string>, Handle<IborIndex> > iborIndices_
mutableprotected

Definition at line 209 of file marketimpl.hpp.

◆ swapIndices_

map<pair<string, string>, Handle<SwapIndex> > swapIndices_
mutableprotected

Definition at line 210 of file marketimpl.hpp.

◆ swaptionCurves_

map<pair<string, string>, Handle<QuantLib::SwaptionVolatilityStructure> > swaptionCurves_
mutableprotected

Definition at line 211 of file marketimpl.hpp.

◆ swaptionIndexBases_

map<pair<string, string>, pair<string, string> > swaptionIndexBases_
mutableprotected

Definition at line 212 of file marketimpl.hpp.

◆ yieldVolCurves_

map<pair<string, string>, Handle<QuantLib::SwaptionVolatilityStructure> > yieldVolCurves_
mutableprotected

Definition at line 213 of file marketimpl.hpp.

◆ fxVols_

map<pair<string, string>, Handle<BlackVolTermStructure> > fxVols_
mutableprotected

Definition at line 214 of file marketimpl.hpp.

◆ defaultCurves_

map<pair<string, string>, Handle<QuantExt::CreditCurve> > defaultCurves_
mutableprotected

Definition at line 215 of file marketimpl.hpp.

◆ cdsVols_

map<pair<string, string>, Handle<QuantExt::CreditVolCurve> > cdsVols_
mutableprotected

Definition at line 216 of file marketimpl.hpp.

◆ baseCorrelations_

map<pair<string, string>, Handle<QuantExt::BaseCorrelationTermStructure> > baseCorrelations_
mutableprotected

Definition at line 217 of file marketimpl.hpp.

◆ recoveryRates_

map<pair<string, string>, Handle<Quote> > recoveryRates_
mutableprotected

Definition at line 218 of file marketimpl.hpp.

◆ capFloorCurves_

map<pair<string, string>, Handle<OptionletVolatilityStructure> > capFloorCurves_
mutableprotected

Definition at line 219 of file marketimpl.hpp.

◆ capFloorIndexBase_

map<pair<string, string>, std::pair<string, QuantLib::Period> > capFloorIndexBase_
mutableprotected

Definition at line 220 of file marketimpl.hpp.

◆ yoyCapFloorVolSurfaces_

map<pair<string, string>, Handle<YoYOptionletVolatilitySurface> > yoyCapFloorVolSurfaces_
mutableprotected

Definition at line 221 of file marketimpl.hpp.

◆ zeroInflationIndices_

map<pair<string, string>, Handle<ZeroInflationIndex> > zeroInflationIndices_
mutableprotected

Definition at line 222 of file marketimpl.hpp.

◆ yoyInflationIndices_

map<pair<string, string>, Handle<YoYInflationIndex> > yoyInflationIndices_
mutableprotected

Definition at line 223 of file marketimpl.hpp.

◆ cpiInflationCapFloorVolatilitySurfaces_

map<pair<string, string>, Handle<CPIVolatilitySurface> > cpiInflationCapFloorVolatilitySurfaces_
mutableprotected

Definition at line 224 of file marketimpl.hpp.

◆ equitySpots_

map<pair<string, string>, Handle<Quote> > equitySpots_
mutableprotected

Definition at line 225 of file marketimpl.hpp.

◆ equityVols_

map<pair<string, string>, Handle<BlackVolTermStructure> > equityVols_
mutableprotected

Definition at line 226 of file marketimpl.hpp.

◆ securitySpreads_

map<pair<string, string>, Handle<Quote> > securitySpreads_
mutableprotected

Definition at line 227 of file marketimpl.hpp.

◆ baseCpis_

map<pair<string, string>, Handle<QuantExt::InflationIndexObserver> > baseCpis_
mutableprotected

Definition at line 228 of file marketimpl.hpp.

◆ correlationCurves_

map<tuple<string, string, string>, Handle<QuantExt::CorrelationTermStructure> > correlationCurves_
mutableprotected

Definition at line 229 of file marketimpl.hpp.

◆ commodityIndices_

map<pair<string, string>, QuantLib::Handle<QuantExt::CommodityIndex> > commodityIndices_
mutableprotected

Definition at line 230 of file marketimpl.hpp.

◆ commodityVols_

map<pair<string, string>, QuantLib::Handle<QuantLib::BlackVolTermStructure> > commodityVols_
mutableprotected

Definition at line 231 of file marketimpl.hpp.

◆ equityCurves_

map<pair<string, string>, QuantLib::Handle<QuantExt::EquityIndex2> > equityCurves_
mutableprotected

Definition at line 232 of file marketimpl.hpp.

◆ cprs_

map<pair<string, string>, Handle<Quote> > cprs_
mutableprotected

Definition at line 233 of file marketimpl.hpp.

◆ refreshTs_

map<string, std::set<QuantLib::ext::shared_ptr<TermStructure> > > refreshTs_
protected

Definition at line 240 of file marketimpl.hpp.