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

Market. More...

#include <ored/marketdata/market.hpp>

+ Inheritance diagram for Market:
+ Collaboration diagram for Market:

Public Member Functions

 Market (const bool handlePseudoCurrencies)
 Constructor. More...
 
virtual ~Market ()
 Destructor. More...
 
virtual Date asofDate () const =0
 Get the asof Date. More...
 
Yield Curves
virtual Handle< YieldTermStructure > yieldCurve (const YieldCurveType &type, const string &name, const string &configuration=Market::defaultConfiguration) const =0
 
Handle< YieldTermStructure > discountCurve (const string &ccy, const string &configuration=Market::defaultConfiguration) const
 
virtual Handle< YieldTermStructure > discountCurveImpl (const string &ccy, const string &configuration=Market::defaultConfiguration) const =0
 
virtual Handle< YieldTermStructure > yieldCurve (const string &name, const string &configuration=Market::defaultConfiguration) const =0
 
virtual Handle< IborIndexiborIndex (const string &indexName, const string &configuration=Market::defaultConfiguration) const =0
 
virtual Handle< SwapIndex > swapIndex (const string &indexName, const string &configuration=Market::defaultConfiguration) const =0
 
Swaptions
virtual Handle< SwaptionVolatilityStructureswaptionVol (const string &key, const string &configuration=Market::defaultConfiguration) const =0
 
virtual string shortSwapIndexBase (const string &key, const string &configuration=Market::defaultConfiguration) const =0
 
virtual string swapIndexBase (const string &key, const string &configuration=Market::defaultConfiguration) const =0
 
Yield volatilities
virtual Handle< SwaptionVolatilityStructureyieldVol (const string &securityID, const string &configuration=Market::defaultConfiguration) const =0
 
Foreign Exchange
QuantLib::Handle< QuantExt::FxIndexfxIndex (const string &fxIndex, const string &configuration=Market::defaultConfiguration) const
 
virtual QuantLib::Handle< QuantExt::FxIndexfxIndexImpl (const string &fxIndex, const string &configuration=Market::defaultConfiguration) const =0
 
Handle< Quote > fxRate (const string &ccypair, const string &configuration=Market::defaultConfiguration) const
 
virtual Handle< Quote > fxRateImpl (const string &ccypair, const string &configuration=Market::defaultConfiguration) const =0
 
Handle< Quote > fxSpot (const string &ccypair, const string &configuration=Market::defaultConfiguration) const
 
virtual Handle< Quote > fxSpotImpl (const string &ccypair, const string &configuration=Market::defaultConfiguration) const =0
 
Handle< BlackVolTermStructurefxVol (const string &ccypair, const string &configuration=Market::defaultConfiguration) const
 
virtual Handle< BlackVolTermStructurefxVolImpl (const string &ccypair, const string &configuration=Market::defaultConfiguration) const =0
 
Default Curves and Recovery Rates
virtual Handle< QuantExt::CreditCurvedefaultCurve (const string &, const string &configuration=Market::defaultConfiguration) const =0
 
virtual Handle< Quote > recoveryRate (const string &, const string &configuration=Market::defaultConfiguration) const =0
 
(Index) CDS Option volatilities
virtual Handle< QuantExt::CreditVolCurvecdsVol (const string &, const string &configuration=Market::defaultConfiguration) const =0
 
Base Correlation term structures
virtual Handle< QuantExt::BaseCorrelationTermStructurebaseCorrelation (const string &, const string &configuration=Market::defaultConfiguration) const =0
 
Stripped Cap/Floor volatilities i.e. caplet/floorlet volatilities
virtual Handle< OptionletVolatilityStructure > capFloorVol (const string &key, const string &configuration=Market::defaultConfiguration) const =0
 
virtual std::pair< std::string, QuantLib::Period > capFloorVolIndexBase (const string &key, const string &configuration=Market::defaultConfiguration) const =0
 
Stripped YoY Inflation Cap/Floor volatilities i.e. caplet/floorlet volatilities
virtual Handle< QuantExt::YoYOptionletVolatilitySurface > yoyCapFloorVol (const string &indexName, const string &configuration=Market::defaultConfiguration) const =0
 
virtual Handle< ZeroInflationIndex > zeroInflationIndex (const string &indexName, const string &configuration=Market::defaultConfiguration) const =0
 Inflation Indexes. More...
 
virtual Handle< YoYInflationIndex > yoyInflationIndex (const string &indexName, const string &configuration=Market::defaultConfiguration) const =0
 
virtual Handle< CPIVolatilitySurfacecpiInflationCapFloorVolatilitySurface (const string &indexName, const string &configuration=Market::defaultConfiguration) const =0
 CPI Inflation Cap Floor Volatility Surfaces. More...
 
Equity curves
virtual Handle< Quote > equitySpot (const string &eqName, const string &configuration=Market::defaultConfiguration) const =0
 
virtual Handle< YieldTermStructure > equityDividendCurve (const string &eqName, const string &configuration=Market::defaultConfiguration) const =0
 
virtual Handle< YieldTermStructure > equityForecastCurve (const string &eqName, const string &configuration=Market::defaultConfiguration) const =0
 
virtual Handle< QuantExt::EquityIndex2equityCurve (const string &eqName, const string &configuration=Market::defaultConfiguration) const =0
 
BondSpreads
virtual Handle< Quote > securitySpread (const string &securityID, const string &configuration=Market::defaultConfiguration) const =0
 
Commodity price curves and indices
virtual QuantLib::Handle< QuantExt::PriceTermStructurecommodityPriceCurve (const std::string &commodityName, const std::string &configuration=Market::defaultConfiguration) const =0
 
virtual QuantLib::Handle< QuantExt::CommodityIndexcommodityIndex (const std::string &commodityName, const std::string &configuration=Market::defaultConfiguration) const =0
 
Commodity volatility
virtual QuantLib::Handle< QuantLib::BlackVolTermStructure > commodityVolatility (const std::string &commodityName, const std::string &configuration=Market::defaultConfiguration) const =0
 
Correlation
virtual QuantLib::Handle< QuantExt::CorrelationTermStructurecorrelationCurve (const std::string &index1, const std::string &index2, const std::string &configuration=Market::defaultConfiguration) const =0
 

Equity volatilities

static const string defaultConfiguration = "default"
 Default configuration label. More...
 
static const string inCcyConfiguration = "inccy"
 InCcy configuration label. More...
 
virtual Handle< BlackVolTermStructureequityVol (const string &eqName, const string &configuration=Market::defaultConfiguration) const =0
 
virtual void refresh (const string &)
 Refresh term structures for a given configuration. More...
 

Conditional Prepayment Rates

bool handlePseudoCurrencies_ = false
 
std::map< string, Handle< Quote > > spotCache_
 
std::map< string, Handle< BlackVolTermStructure > > volCache_
 
std::map< string, Handle< YieldTermStructure > > discountCurveCache_
 
std::map< string, Handle< Quote > > fxRateCache_
 
std::map< std::pair< string, string >, QuantLib::Handle< QuantExt::FxIndex > > fxIndicesCache_
 
virtual Handle< Quote > cpr (const string &securityID, const string &configuration=Market::defaultConfiguration) const =0
 
string commodityCurveLookup (const string &pm) const
 
bool handlePseudoCurrencies () const
 
Handle< Quote > getFxBaseQuote (const string &ccy, const string &config) const
 
Handle< Quote > getFxSpotBaseQuote (const string &ccy, const string &config) const
 
Handle< BlackVolTermStructuregetVolatility (const string &ccy, const string &config) const
 
string getCorrelationIndexName (const string &ccy) const
 

Detailed Description

Market.

Base class for central repositories containing all term structure objects needed in instrument pricing.

Definition at line 163 of file market.hpp.

Constructor & Destructor Documentation

◆ Market()

Market ( const bool  handlePseudoCurrencies)
explicit

Constructor.

Definition at line 166 of file market.hpp.

◆ ~Market()

virtual ~Market ( )
virtual

Destructor.

Definition at line 169 of file market.hpp.

169{}

Member Function Documentation

◆ asofDate()

virtual Date asofDate ( ) const
pure virtual

Get the asof Date.

Implemented in DummyMarket, MarketImpl, and WrappedMarket.

+ Here is the caller graph for this function:

◆ yieldCurve() [1/2]

virtual Handle< YieldTermStructure > yieldCurve ( const YieldCurveType type,
const string &  name,
const string &  configuration = Market::defaultConfiguration 
) const
pure virtual

Implemented in DummyMarket, MarketImpl, and WrappedMarket.

◆ discountCurve()

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

Definition at line 351 of file market.cpp.

351 {
352 if (!handlePseudoCurrencies_ || GlobalPseudoCurrencyMarketParameters::instance().get().treatAsFX)
353 return discountCurveImpl(ccy, config);
354
355 string baseCcy = GlobalPseudoCurrencyMarketParameters::instance().get().baseCurrency;
356
357 if (hasPseudoCurrencyConfig(ccy)) {
358 DLOG("Market::discount() requested for PM " << ccy);
359 if (discountCurveCache_.find(ccy) == discountCurveCache_.end()) {
360 auto baseDiscount = discountCurveImpl(baseCcy, config);
361 auto priceCurve = commodityPriceCurve(commodityCurveLookup(ccy), config);
362 QL_REQUIRE(!priceCurve.empty(),
363 "Failed to get Commodity Price curve for " << ccy << " using " << commodityCurveLookup(ccy));
365 Handle<YieldTermStructure>(QuantLib::ext::make_shared<QuantExt::PriceTermStructureAdapter>(
366 priceCurve.currentLink(), baseDiscount.currentLink(), fxRate(ccy + baseCcy, config)));
367 discountCurveCache_[ccy]->enableExtrapolation();
368 }
369 return discountCurveCache_[ccy];
370 }
371
372 return discountCurveImpl(ccy, config);
373}
std::map< string, Handle< YieldTermStructure > > discountCurveCache_
Definition: market.hpp:348
Handle< Quote > fxRate(const string &ccypair, const string &configuration=Market::defaultConfiguration) const
Definition: market.cpp:216
virtual QuantLib::Handle< QuantExt::PriceTermStructure > commodityPriceCurve(const std::string &commodityName, const std::string &configuration=Market::defaultConfiguration) const =0
virtual Handle< YieldTermStructure > discountCurveImpl(const string &ccy, const string &configuration=Market::defaultConfiguration) const =0
string commodityCurveLookup(const string &pm) const
Definition: market.cpp:112
#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()

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

Implemented in MarketImpl, WrappedMarket, and DummyMarket.

+ Here is the caller graph for this function:

◆ yieldCurve() [2/2]

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

◆ iborIndex()

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

Implemented in DummyMarket, MarketImpl, and WrappedMarket.

◆ swapIndex()

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

Implemented in DummyMarket, MarketImpl, and WrappedMarket.

◆ swaptionVol()

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

Implemented in DummyMarket, MarketImpl, and WrappedMarket.

◆ shortSwapIndexBase()

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

Implemented in DummyMarket, WrappedMarket, and MarketImpl.

◆ swapIndexBase()

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

Implemented in DummyMarket, WrappedMarket, and MarketImpl.

◆ yieldVol()

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

Implemented in DummyMarket, MarketImpl, and WrappedMarket.

◆ fxIndex()

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

Definition at line 151 of file market.cpp.

151 {
152 if (!handlePseudoCurrencies_ || GlobalPseudoCurrencyMarketParameters::instance().get().treatAsFX)
153 return fxIndexImpl(fxIndex, configuration);
154
155 std::string familyName;
156 std::string forCcy;
157 std::string domCcy;
158
159 if (isFxIndex(fxIndex)) {
160 auto ind = parseFxIndex(fxIndex);
161 familyName = ind->familyName();
162 forCcy = ind->sourceCurrency().code();
163 domCcy = ind->targetCurrency().code();
164 } else {
165 familyName = "GENERIC";
166 forCcy = fxIndex.substr(0, 3);
167 domCcy = fxIndex.substr(3);
168 }
169
170 if (hasPseudoCurrencyConfigPair(forCcy + domCcy)) {
171 DLOG("Market::fxIndex() requested for PM pair " << forCcy << domCcy);
172 string index = "FX-" + familyName + "-" + forCcy + "-" + domCcy;
173 Handle<QuantExt::FxIndex> fxInd;
174 auto it = fxIndicesCache_.find(make_pair(configuration, index));
175 // if no index found we build it
176 if (it == fxIndicesCache_.end()) {
177 // Parse the index we have with no term structures
178 QuantLib::ext::shared_ptr<QuantExt::FxIndex> fxIndexBase = parseFxIndex(index);
179
180 string source = fxIndexBase->sourceCurrency().code();
181 string target = fxIndexBase->targetCurrency().code();
182
183 // use todays rate here
184 Handle<Quote> spot = fxRate(source + target, configuration);
185
186 Handle<YieldTermStructure> sorTS = discountCurve(source, configuration);
187 Handle<YieldTermStructure> tarTS = discountCurve(target, configuration);
188
189 // spot is always zero here as we use the fxRates, which give rate today
190 Natural spotDays = 0;
191 Calendar calendar = NullCalendar();
192
193 if (source != target) {
194 try {
195 auto [sDays, cal, _] = getFxIndexConventions(fxIndex);
196 calendar = cal;
197 } catch (...) {
198 WLOG("Market::fxIndex Cannot find commodity conventions for " << fxIndex);
199 }
200 }
201 fxInd = Handle<QuantExt::FxIndex>(QuantLib::ext::make_shared<QuantExt::FxIndex>(
202 fxIndexBase->familyName(), spotDays, fxIndexBase->sourceCurrency(), fxIndexBase->targetCurrency(),
203 calendar, spot, sorTS, tarTS));
204 // add it to the cache
205 fxIndicesCache_[make_pair(configuration, index)] = fxInd;
206 } else {
207 fxInd = it->second;
208 }
209 return fxInd;
210 }
211 return fxIndexImpl(fxIndex, configuration);
212}
std::map< std::pair< string, string >, QuantLib::Handle< QuantExt::FxIndex > > fxIndicesCache_
Definition: market.hpp:351
QuantLib::Handle< QuantExt::FxIndex > fxIndex(const string &fxIndex, const string &configuration=Market::defaultConfiguration) const
Definition: market.cpp:151
virtual QuantLib::Handle< QuantExt::FxIndex > fxIndexImpl(const string &fxIndex, const string &configuration=Market::defaultConfiguration) const =0
Handle< YieldTermStructure > discountCurve(const string &ccy, const string &configuration=Market::defaultConfiguration) const
Definition: market.cpp:351
QuantLib::ext::shared_ptr< FxIndex > parseFxIndex(const string &s, const Handle< Quote > &fxSpot, const Handle< YieldTermStructure > &sourceYts, const Handle< YieldTermStructure > &targetYts, const bool useConventions)
Convert std::string to QuantExt::FxIndex.
#define WLOG(text)
Logging Macro (Level = Warning)
Definition: log.hpp:550
Calendar calendar
Definition: utilities.cpp:441
bool isFxIndex(const std::string &indexName)
std::tuple< Natural, Calendar, BusinessDayConvention > getFxIndexConventions(const string &index)
Definition: marketdata.cpp:160
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fxIndexImpl()

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

Implemented in MarketImpl, WrappedMarket, and DummyMarket.

+ Here is the caller graph for this function:

◆ fxRate()

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

Definition at line 216 of file market.cpp.

216 {
217 if (!handlePseudoCurrencies_ || GlobalPseudoCurrencyMarketParameters::instance().get().treatAsFX)
218 return fxRateImpl(pair, config);
219 if (hasPseudoCurrencyConfigPair(pair)) {
220 DLOG("Market::fxSpot() requested for PM pair " << pair);
221 if (fxRateCache_.find(pair) == fxRateCache_.end()) {
222 // Get the FX Spot rate. Rather than deal with all the combinations we just get the FX rate for each vs
223 // the baseCcy and create a ratio quote. This might mean we have combined a USD/USD spot quote below,
224 // but it all works fine and this is cleaner code.
225 //
226 // Note that we could just call market->fxSpot(forCode, domCode) and this would give us the correct
227 // quote from the markets FXTriangulation, however this would create a depedendacy on the pair
228 // and cause the configuration builder to go off building XAU-IN-USD and the like.
229 auto forBaseSpot = getFxBaseQuote(pair.substr(0, 3), config);
230 auto domBaseSpot = getFxBaseQuote(pair.substr(3), config);
231 auto fx = Handle<Quote>(QuantLib::ext::make_shared<CompositeQuote<std::function<Real(Real, Real)>>>(
232 forBaseSpot, domBaseSpot, [](Real a, Real b) { return b > 0.0 ? a / b : 0.0; }));
233 DLOG("Market returning " << fx->value() << " for " << pair << ".");
234 fxRateCache_[pair] = fx;
235 }
236 return fxRateCache_[pair];
237 }
238 return fxRateImpl(pair, config);
239}
std::map< string, Handle< Quote > > fxRateCache_
Definition: market.hpp:350
virtual Handle< Quote > fxRateImpl(const string &ccypair, const string &configuration=Market::defaultConfiguration) const =0
Handle< Quote > getFxBaseQuote(const string &ccy, const string &config) const
Definition: market.cpp:120
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fxRateImpl()

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

Implemented in DummyMarket, MarketImpl, and WrappedMarket.

+ Here is the caller graph for this function:

◆ fxSpot()

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

Definition at line 241 of file market.cpp.

241 {
242 if (!handlePseudoCurrencies_ || GlobalPseudoCurrencyMarketParameters::instance().get().treatAsFX)
243 return fxSpotImpl(pair, config);
244 if (hasPseudoCurrencyConfigPair(pair)) {
245 DLOG("Market::fxSpot() requested for PM pair " << pair);
246 if (spotCache_.find(pair) == spotCache_.end()) {
247 // Get the FX Spot rate. Rather than deal with all the combinations we just get the FX rate for each vs
248 // the baseCcy and create a ratio quote. This might mean we have combined a USD/USD spot quote below,
249 // but it all works fine and this is cleaner code.
250 //
251 // Note that we could just call market->fxSpot(forCode, domCode) and this would give us the correct
252 // quote from the markets FXTriangulation, however this would create a depedendacy on the pair
253 // and cause the configuration builder to go off building XAU-IN-USD and the like.
254 auto forBaseSpot = getFxSpotBaseQuote(pair.substr(0, 3), config);
255 auto domBaseSpot = getFxSpotBaseQuote(pair.substr(3), config);
256 auto fx = Handle<Quote>(QuantLib::ext::make_shared<CompositeQuote<std::function<Real(Real, Real)>>>(
257 forBaseSpot, domBaseSpot, [](Real a, Real b) { return b > 0.0 ? a / b : 0.0; }));
258 DLOG("Market returning " << fx->value() << " for " << pair << ".");
259 spotCache_[pair] = fx;
260 }
261 return spotCache_[pair];
262 }
263 return fxSpotImpl(pair, config);
264}
virtual Handle< Quote > fxSpotImpl(const string &ccypair, const string &configuration=Market::defaultConfiguration) const =0
Handle< Quote > getFxSpotBaseQuote(const string &ccy, const string &config) const
Definition: market.cpp:135
std::map< string, Handle< Quote > > spotCache_
Definition: market.hpp:346
+ Here is the call graph for this function:

◆ fxSpotImpl()

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

Implemented in DummyMarket, MarketImpl, and WrappedMarket.

+ Here is the caller graph for this function:

◆ fxVol()

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

Definition at line 287 of file market.cpp.

287 {
288 if (!handlePseudoCurrencies_ || GlobalPseudoCurrencyMarketParameters::instance().get().treatAsFX)
289 return fxVolImpl(pair, config);
290
291 if (hasPseudoCurrencyConfigPair(pair)) {
292 DLOG("Market::fxVol() requested for PM pair " << pair);
293 if (volCache_.find(pair) == volCache_.end()) {
294
295 Handle<BlackVolTermStructure> vol;
296
297 auto forCode = pair.substr(0, 3);
298 auto domCode = pair.substr(3);
299
300 // we handle the easy and common case first.
301 if (forCode == GlobalPseudoCurrencyMarketParameters::instance().get().baseCurrency ||
302 domCode == GlobalPseudoCurrencyMarketParameters::instance().get().baseCurrency) {
303 // this is a straight mapping
304 string pm =
305 forCode == GlobalPseudoCurrencyMarketParameters::instance().get().baseCurrency ? domCode : forCode;
306 auto comVol = commodityVolatility(commodityCurveLookup(pm), config);
307 if (domCode == GlobalPseudoCurrencyMarketParameters::instance().get().baseCurrency)
308 vol = comVol;
309 else
310 vol = Handle<BlackVolTermStructure>(
311 QuantLib::ext::make_shared<QuantExt::BlackInvertedVolTermStructure>(comVol));
312 } else {
313
314 // otherwise we must triangulate - we get both surfaces vs baseCcy
315 auto forBaseVol = getVolatility(forCode, config);
316 auto domBaseVol = getVolatility(domCode, config);
317
318 // get the correlation
319 string forIndex = getCorrelationIndexName(forCode);
320 string domIndex = getCorrelationIndexName(domCode);
321 Handle<QuantExt::CorrelationTermStructure> rho;
322 try {
323 rho = correlationCurve(forIndex, domIndex, config);
324 } catch (std::exception& e) {
325 // No correlation, if we have a default we use it
326 WLOG("No correlation found for " << forIndex << "/" << domIndex);
327 if (GlobalPseudoCurrencyMarketParameters::instance().get().defaultCorrelation != Null<Real>()) {
328 WLOG("Using default correlation value "
329 << GlobalPseudoCurrencyMarketParameters::instance().get().defaultCorrelation);
330 rho = Handle<QuantExt::CorrelationTermStructure>(QuantLib::ext::make_shared<QuantExt::FlatCorrelation>(
331 asofDate(), GlobalPseudoCurrencyMarketParameters::instance().get().defaultCorrelation,
332 ActualActual(ActualActual::ISDA)));
333 } else {
334 QL_FAIL("No Correlation which is needed for PseudoCurrency Volatility :" << e.what());
335 }
336 }
337
338 // build and return triangulation
339 vol = Handle<BlackVolTermStructure>(
340 QuantLib::ext::make_shared<QuantExt::BlackTriangulationATMVolTermStructure>(forBaseVol, domBaseVol, rho));
341 }
342
343 DLOG("Market returning vol surface for " << pair << ".");
344 volCache_[pair] = vol;
345 }
346 return volCache_[pair];
347 }
348 return fxVolImpl(pair, config);
349}
virtual QuantLib::Handle< QuantLib::BlackVolTermStructure > commodityVolatility(const std::string &commodityName, const std::string &configuration=Market::defaultConfiguration) const =0
std::map< string, Handle< BlackVolTermStructure > > volCache_
Definition: market.hpp:347
Handle< BlackVolTermStructure > getVolatility(const string &ccy, const string &config) const
Definition: market.cpp:266
virtual QuantLib::Handle< QuantExt::CorrelationTermStructure > correlationCurve(const std::string &index1, const std::string &index2, const std::string &configuration=Market::defaultConfiguration) const =0
virtual Date asofDate() const =0
Get the asof Date.
string getCorrelationIndexName(const string &ccy) const
Definition: market.cpp:275
virtual Handle< BlackVolTermStructure > fxVolImpl(const string &ccypair, const string &configuration=Market::defaultConfiguration) const =0
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fxVolImpl()

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

Implemented in DummyMarket, MarketImpl, and WrappedMarket.

+ Here is the caller graph for this function:

◆ defaultCurve()

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

◆ recoveryRate()

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

◆ cdsVol()

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

Implemented in DummyMarket, MarketImpl, and WrappedMarket.

◆ baseCorrelation()

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

Implemented in DummyMarket, MarketImpl, and WrappedMarket.

◆ capFloorVol()

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

Implemented in DummyMarket, MarketImpl, and WrappedMarket.

◆ capFloorVolIndexBase()

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

Implemented in DummyMarket, MarketImpl, and WrappedMarket.

◆ yoyCapFloorVol()

virtual Handle< QuantExt::YoYOptionletVolatilitySurface > yoyCapFloorVol ( const string &  indexName,
const string &  configuration = Market::defaultConfiguration 
) const
pure virtual

Implemented in DummyMarket, WrappedMarket, and MarketImpl.

◆ zeroInflationIndex()

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

Inflation Indexes.

Implemented in DummyMarket, MarketImpl, and WrappedMarket.

◆ yoyInflationIndex()

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

Implemented in DummyMarket, MarketImpl, and WrappedMarket.

◆ cpiInflationCapFloorVolatilitySurface()

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

CPI Inflation Cap Floor Volatility Surfaces.

Implemented in DummyMarket, MarketImpl, and WrappedMarket.

◆ equitySpot()

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

Implemented in DummyMarket, MarketImpl, and WrappedMarket.

◆ equityDividendCurve()

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

Implemented in DummyMarket, MarketImpl, and WrappedMarket.

◆ equityForecastCurve()

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

Implemented in DummyMarket, MarketImpl, and WrappedMarket.

◆ equityCurve()

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

Implemented in DummyMarket, MarketImpl, and WrappedMarket.

◆ equityVol()

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

Implemented in DummyMarket, MarketImpl, and WrappedMarket.

◆ refresh()

virtual void refresh ( const string &  )
virtual

Refresh term structures for a given configuration.

Reimplemented in MarketImpl, and WrappedMarket.

Definition at line 293 of file market.hpp.

293{}

◆ securitySpread()

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

◆ commodityPriceCurve()

virtual QuantLib::Handle< QuantExt::PriceTermStructure > commodityPriceCurve ( const std::string &  commodityName,
const std::string &  configuration = Market::defaultConfiguration 
) const
pure virtual

Implemented in DummyMarket, WrappedMarket, and MarketImpl.

+ Here is the caller graph for this function:

◆ commodityIndex()

virtual QuantLib::Handle< QuantExt::CommodityIndex > commodityIndex ( const std::string &  commodityName,
const std::string &  configuration = Market::defaultConfiguration 
) const
pure virtual

Implemented in DummyMarket, MarketImpl, and WrappedMarket.

◆ commodityVolatility()

virtual QuantLib::Handle< QuantLib::BlackVolTermStructure > commodityVolatility ( const std::string &  commodityName,
const std::string &  configuration = Market::defaultConfiguration 
) const
pure virtual

Implemented in DummyMarket, WrappedMarket, and MarketImpl.

+ Here is the caller graph for this function:

◆ correlationCurve()

virtual QuantLib::Handle< QuantExt::CorrelationTermStructure > correlationCurve ( const std::string &  index1,
const std::string &  index2,
const std::string &  configuration = Market::defaultConfiguration 
) const
pure virtual

Implemented in DummyMarket, WrappedMarket, and MarketImpl.

+ Here is the caller graph for this function:

◆ cpr()

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

Implemented in DummyMarket, MarketImpl, and WrappedMarket.

◆ commodityCurveLookup()

string commodityCurveLookup ( const string &  pm) const

Definition at line 112 of file market.cpp.

112 {
113 QL_REQUIRE(handlePseudoCurrencies_, "Market::commodityCurveLookup() disabled - this is an internal error.");
114 auto it = GlobalPseudoCurrencyMarketParameters::instance().get().curves.find(pm);
115 QL_REQUIRE(it != GlobalPseudoCurrencyMarketParameters::instance().get().curves.end(),
116 "Unable to find a commodity curve for pseudo currency " << pm << " in Market");
117 return it->second;
118}
+ Here is the caller graph for this function:

◆ handlePseudoCurrencies()

bool handlePseudoCurrencies ( ) const

Definition at line 339 of file market.hpp.

339{ return handlePseudoCurrencies_; }

◆ getFxBaseQuote()

Handle< Quote > getFxBaseQuote ( const string &  ccy,
const string &  config 
) const
private

Definition at line 120 of file market.cpp.

120 {
121 QL_REQUIRE(handlePseudoCurrencies_, "Market::commodityCurveLookup() disabled - this is an internal error.");
122 if (hasPseudoCurrencyConfig(ccy)) {
123 auto priceCurve = commodityPriceCurve(commodityCurveLookup(ccy), config);
124 QL_REQUIRE(!priceCurve.empty(),
125 "Failed to get Commodity Price curve for " << ccy << " using " << commodityCurveLookup(ccy));
126 TLOG("PseudoCurrencyMarket building DerivedPriceQuote for "
127 << ccy << "/" << GlobalPseudoCurrencyMarketParameters::instance().get().baseCurrency
128 << " with curve that has minTime of " << priceCurve->minTime());
129 return Handle<Quote>(QuantLib::ext::make_shared<QuantExt::DerivedPriceQuote>(priceCurve));
130 } else {
131 return fxRateImpl(ccy + GlobalPseudoCurrencyMarketParameters::instance().get().baseCurrency, config);
132 }
133}
#define TLOG(text)
Logging Macro (Level = Data)
Definition: log.hpp:556
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFxSpotBaseQuote()

Handle< Quote > getFxSpotBaseQuote ( const string &  ccy,
const string &  config 
) const
private

Definition at line 135 of file market.cpp.

135 {
136 QL_REQUIRE(handlePseudoCurrencies_, "Market::commodityCurveLookup() disabled - this is an internal error.");
137 if (hasPseudoCurrencyConfig(ccy)) {
138 // TODO: this gives back the commodity rate at t=0, should be at spot
139 auto priceCurve = commodityPriceCurve(commodityCurveLookup(ccy), config);
140 QL_REQUIRE(!priceCurve.empty(),
141 "Failed to get Commodity Price curve for " << ccy << " using " << commodityCurveLookup(ccy));
142 TLOG("PseudoCurrencyMarket building DerivedPriceQuote for "
143 << ccy << "/" << GlobalPseudoCurrencyMarketParameters::instance().get().baseCurrency
144 << " with curve that has minTime of " << priceCurve->minTime());
145 return Handle<Quote>(QuantLib::ext::make_shared<QuantExt::DerivedPriceQuote>(priceCurve));
146 } else {
147 return fxSpotImpl(ccy + GlobalPseudoCurrencyMarketParameters::instance().get().baseCurrency, config);
148 }
149}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getVolatility()

Handle< BlackVolTermStructure > getVolatility ( const string &  ccy,
const string &  config 
) const
private

Definition at line 266 of file market.cpp.

266 {
267 QL_REQUIRE(handlePseudoCurrencies_, "Market::getVolatility() disabled - this is an internal error.");
268 if (hasPseudoCurrencyConfig(ccy)) {
269 return commodityVolatility(commodityCurveLookup(ccy), config);
270 } else {
271 return fxVolImpl(ccy + GlobalPseudoCurrencyMarketParameters::instance().get().baseCurrency, config);
272 }
273}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCorrelationIndexName()

string getCorrelationIndexName ( const string &  ccy) const
private

Definition at line 275 of file market.cpp.

275 {
276 QL_REQUIRE(handlePseudoCurrencies_, "Market::getCorrelationIndexName() disabled - this is an internal error.");
277 if (hasPseudoCurrencyConfig(ccy)) {
278 // e.g. COMM-PM:XAUUSD
279 return "COMM-" + commodityCurveLookup(ccy);
280 } else {
281 // e.g. FX-GENERIC-XAU-USD
282 return "FX-" + GlobalPseudoCurrencyMarketParameters::instance().get().fxIndexTag + "-" + ccy + "-" +
283 GlobalPseudoCurrencyMarketParameters::instance().get().baseCurrency;
284 }
285}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ defaultConfiguration

const string defaultConfiguration = "default"
static

Default configuration label.

Definition at line 296 of file market.hpp.

◆ inCcyConfiguration

const string inCcyConfiguration = "inccy"
static

InCcy configuration label.

Definition at line 299 of file market.hpp.

◆ handlePseudoCurrencies_

bool handlePseudoCurrencies_ = false
protected

Definition at line 342 of file market.hpp.

◆ spotCache_

std::map<string, Handle<Quote> > spotCache_
mutableprivate

Definition at line 346 of file market.hpp.

◆ volCache_

std::map<string, Handle<BlackVolTermStructure> > volCache_
mutableprivate

Definition at line 347 of file market.hpp.

◆ discountCurveCache_

std::map<string, Handle<YieldTermStructure> > discountCurveCache_
mutableprivate

Definition at line 348 of file market.hpp.

◆ fxRateCache_

std::map<string, Handle<Quote> > fxRateCache_
mutableprivate

Definition at line 350 of file market.hpp.

◆ fxIndicesCache_

std::map<std::pair<string, string>, QuantLib::Handle<QuantExt::FxIndex> > fxIndicesCache_
mutableprivate

Definition at line 351 of file market.hpp.