Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
testmarket.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19#include <boost/make_shared.hpp>
20#include <boost/test/unit_test.hpp>
21
22#include <ql/currencies/america.hpp>
23#include <ql/indexes/inflation/euhicp.hpp>
24#include <ql/indexes/inflation/ukrpi.hpp>
25#include <ql/termstructures/inflation/inflationhelpers.hpp>
26#include <ql/termstructures/inflation/interpolatedyoyinflationcurve.hpp>
27#include <ql/termstructures/inflation/interpolatedzeroinflationcurve.hpp>
28#include <ql/termstructures/inflation/piecewiseyoyinflationcurve.hpp>
29#include <ql/termstructures/inflation/piecewisezeroinflationcurve.hpp>
30#include <ql/termstructures/iterativebootstrap.hpp>
31#include <ql/termstructures/volatility/inflation/yoyinflationoptionletvolatilitystructure.hpp>
32#include <ql/termstructures/volatility/equityfx/blackconstantvol.hpp>
33#include <ql/termstructures/volatility/equityfx/blackvariancecurve.hpp>
34#include <ql/termstructures/volatility/optionlet/constantoptionletvol.hpp>
35#include <ql/termstructures/volatility/swaption/swaptionconstantvol.hpp>
36#include <ql/termstructures/volatility/swaption/swaptionvolcube.hpp>
37#include <ql/termstructures/volatility/swaption/swaptionvolmatrix.hpp>
38#include <ql/time/calendars/nullcalendar.hpp>
39#include <ql/time/calendars/target.hpp>
40#include <ql/time/calendars/unitedstates.hpp>
41#include <ql/time/daycounters/actualactual.hpp>
42
51
53
54#include <iostream>
55
56#include <test/testmarket.hpp>
57
58using namespace QuantExt;
60
61namespace testsuite {
62
63namespace {
64
65vector<QuantLib::ext::shared_ptr<RateHelper>>
66parRateCurveHelpers(const string& ccy, const vector<string>& parInst, const vector<Period>& parTenor,
67 const vector<Handle<Quote>>& parVal,
68 const Handle<YieldTermStructure> exDiscount = Handle<YieldTermStructure>(),
69 // fx spot to base ccy
70 const Handle<Quote>& fxSpot = Handle<Quote>(),
71 // base currency discount for xccy par instruments
72 const Handle<YieldTermStructure>& fgnDiscount = Handle<YieldTermStructure>(),
73 // pointer to the market that is being built
74 ore::data::Market* market = NULL) {
75
76 BOOST_ASSERT(parInst.size() == parTenor.size());
77 BOOST_ASSERT(parInst.size() == parVal.size());
78 QuantLib::ext::shared_ptr<Conventions> conventions = InstrumentConventions::instance().conventions();
79 vector<QuantLib::ext::shared_ptr<RateHelper>> instruments;
80 for (Size i = 0; i < parInst.size(); ++i) {
81 Handle<Quote> parRateQuote = parVal[i];
82 Period tenor = parTenor[i];
83 QuantLib::ext::shared_ptr<RateHelper> rateHelper;
84 if (parInst[i] == "DEP") {
85 QuantLib::ext::shared_ptr<Convention> conv = conventions->get(ccy + "-DEP-CONVENTIONS");
86 QuantLib::ext::shared_ptr<DepositConvention> depConv = QuantLib::ext::dynamic_pointer_cast<DepositConvention>(conv);
87 std::ostringstream o;
88 o << depConv->index() << "-" << io::short_period(tenor);
89 string indexName = o.str();
90 QuantLib::ext::shared_ptr<IborIndex> index = parseIborIndex(indexName);
91 rateHelper = QuantLib::ext::make_shared<DepositRateHelper>(parRateQuote, index);
92 } else if (parInst[i] == "FRA") {
93 QuantLib::ext::shared_ptr<Convention> conv = conventions->get(ccy + "-FRA-CONVENTIONS");
94 QuantLib::ext::shared_ptr<FraConvention> fraConv = QuantLib::ext::dynamic_pointer_cast<FraConvention>(conv);
95 BOOST_ASSERT(fraConv);
96 BOOST_ASSERT(tenor > fraConv->index()->tenor());
97 Period startTenor = tenor - fraConv->index()->tenor();
98 rateHelper = QuantLib::ext::make_shared<FraRateHelper>(parRateQuote, startTenor, fraConv->index());
99 } else if (parInst[i] == "IRS") {
100 QuantLib::ext::shared_ptr<Convention> conv = conventions->get(ccy + "-6M-SWAP-CONVENTIONS");
101 QuantLib::ext::shared_ptr<IRSwapConvention> swapConv = QuantLib::ext::dynamic_pointer_cast<IRSwapConvention>(conv);
102 BOOST_ASSERT(swapConv);
103 rateHelper = QuantLib::ext::make_shared<SwapRateHelper>(
104 parRateQuote, tenor, swapConv->fixedCalendar(), swapConv->fixedFrequency(), swapConv->fixedConvention(),
105 swapConv->fixedDayCounter(), swapConv->index(), Handle<Quote>(), 0 * Days, exDiscount);
106 } else if (parInst[i] == "OIS") {
107 QuantLib::ext::shared_ptr<Convention> conv = conventions->get(ccy + "-OIS-CONVENTIONS");
108 QuantLib::ext::shared_ptr<OisConvention> oisConv = QuantLib::ext::dynamic_pointer_cast<OisConvention>(conv);
109 BOOST_ASSERT(oisConv);
110 rateHelper = QuantLib::ext::make_shared<QuantExt::OISRateHelper>(
111 oisConv->spotLag(), tenor, parRateQuote, oisConv->index(), oisConv->fixedDayCounter(),
112 oisConv->fixedCalendar(), oisConv->paymentLag(), oisConv->eom(), oisConv->fixedFrequency(),
113 oisConv->fixedConvention(), oisConv->fixedPaymentConvention(), oisConv->rule(), exDiscount, true);
114 } else if (parInst[i] == "FXF") {
115 QuantLib::ext::shared_ptr<Convention> conv = conventions->get(ccy + "-FX-CONVENTIONS");
116 QuantLib::ext::shared_ptr<FXConvention> fxConv = QuantLib::ext::dynamic_pointer_cast<FXConvention>(conv);
117 BOOST_ASSERT(fxConv);
118 QuantLib::ext::dynamic_pointer_cast<SimpleQuote>(*parRateQuote)
119 ->setValue(0.0); // set the fwd and basis points to zero for these tests
120 bool isFxBaseCurrencyCollateralCurrency = false;
121 // the fx swap rate helper interprets the fxSpot as of the spot date, our fx spot here
122 // is as of today, therefore we set up the fx spot helper with zero settlement days
123 // and compute the tenor such that the correct maturity date is still matched
124 Date today = Settings::instance().evaluationDate();
125 Date spotDate = fxConv->advanceCalendar().advance(today, fxConv->spotDays() * Days);
126 Date endDate = fxConv->advanceCalendar().advance(spotDate, tenor);
127 rateHelper = QuantLib::ext::make_shared<FxSwapRateHelper>(parRateQuote, fxSpot, (endDate - today) * Days, 0,
128 NullCalendar(), Unadjusted, false,
129 isFxBaseCurrencyCollateralCurrency, fgnDiscount);
130 } else if (parInst[i] == "XBS") {
131 QuantLib::ext::shared_ptr<Convention> conv = conventions->get(ccy + "-XCCY-BASIS-CONVENTIONS");
132 QuantLib::ext::shared_ptr<CrossCcyBasisSwapConvention> basisConv =
133 QuantLib::ext::dynamic_pointer_cast<CrossCcyBasisSwapConvention>(conv);
134 BOOST_ASSERT(market);
135 QuantLib::ext::shared_ptr<IborIndex> flatIndex =
136 *market->iborIndex(basisConv->flatIndexName(), Market::defaultConfiguration);
137 QuantLib::ext::shared_ptr<IborIndex> spreadIndex =
138 *market->iborIndex(basisConv->spreadIndexName(), Market::defaultConfiguration);
139 BOOST_ASSERT(basisConv);
140 BOOST_ASSERT(flatIndex);
141 BOOST_ASSERT(*flatIndex->forwardingTermStructure());
142 BOOST_ASSERT(spreadIndex);
143 BOOST_ASSERT(*spreadIndex->forwardingTermStructure());
144 BOOST_ASSERT(*fgnDiscount);
145 QuantLib::ext::dynamic_pointer_cast<SimpleQuote>(*parRateQuote)
146 ->setValue(0.0); // set the fwd and basis points to zero for these tests
147 bool flatIsDomestic = true; // assumes fxSpot is in form 1*BaseCcy = X*Ccy
148 rateHelper = QuantLib::ext::make_shared<CrossCcyBasisSwapHelper>(
149 parRateQuote, fxSpot, basisConv->settlementDays(), basisConv->settlementCalendar(), tenor,
150 basisConv->rollConvention(), flatIndex, spreadIndex, fgnDiscount, exDiscount, basisConv->eom(),
151 flatIsDomestic);
152 } else {
153 BOOST_ERROR("Unrecognised par rate instrument in curve construction - " << i);
154 }
155 instruments.push_back(rateHelper);
156 }
157 return instruments;
158}
159
160vector<QuantLib::ext::shared_ptr<DefaultProbabilityHelper>>
161parRateCurveHelpers(const string& name, const vector<Period>& parTenor, const vector<Handle<Quote>>& parVal,
162 const Handle<YieldTermStructure> exDiscount = Handle<YieldTermStructure>(),
163 // pointer to the market that is being built
164 ore::data::Market* market = NULL) {
165 BOOST_ASSERT(parTenor.size() == parVal.size());
166 QuantLib::ext::shared_ptr<Conventions> conventions = InstrumentConventions::instance().conventions();
167 vector<QuantLib::ext::shared_ptr<DefaultProbabilityHelper>> instruments;
168 Date today = Settings::instance().evaluationDate();
169 for (Size i = 0; i < parTenor.size(); ++i) {
170 Handle<Quote> parRateQuote = parVal[i];
171 Period tenor = parTenor[i];
172 QuantLib::ext::shared_ptr<QuantExt::CdsHelper> rateHelper;
173 QuantLib::ext::shared_ptr<Convention> conv = conventions->get("CDS-STANDARD-CONVENTIONS");
174 QuantLib::ext::shared_ptr<CdsConvention> cdsConv = QuantLib::ext::dynamic_pointer_cast<CdsConvention>(conv);
175 BOOST_ASSERT(cdsConv);
176 BOOST_ASSERT(market);
177 Real recoveryRate = market->recoveryRate(name, Market::defaultConfiguration)->value();
178
179 BOOST_ASSERT(*exDiscount);
180 rateHelper = QuantLib::ext::make_shared<QuantExt::SpreadCdsHelper>(
181 parRateQuote, tenor, cdsConv->settlementDays(), cdsConv->calendar(), cdsConv->frequency(),
182 cdsConv->paymentConvention(), cdsConv->rule(), cdsConv->dayCounter(), recoveryRate, exDiscount,
183 true, QuantExt::CreditDefaultSwap::ProtectionPaymentTime::atDefault, today + cdsConv->settlementDays());
184 instruments.push_back(rateHelper);
185 }
186 return instruments;
187}
188
189Handle<YieldTermStructure> parRateCurve(const Date& asof, const vector<QuantLib::ext::shared_ptr<RateHelper>>& rateHelpers) {
190 Handle<YieldTermStructure> yieldTs(QuantLib::ext::make_shared<PiecewiseYieldCurve<QuantLib::Discount, QuantLib::LogLinear>>(
191 asof, rateHelpers, ActualActual(ActualActual::ISDA),
192 PiecewiseYieldCurve<QuantLib::Discount, QuantLib::LogLinear>::bootstrap_type(1.0e-12)));
193 yieldTs->enableExtrapolation();
194 return yieldTs;
195}
196
197Handle<DefaultProbabilityTermStructure>
198parRateCurve(const Date& asof, const vector<QuantLib::ext::shared_ptr<QuantExt::DefaultProbabilityHelper>>& rateHelpers) {
199 Handle<DefaultProbabilityTermStructure> dps(
200 QuantLib::ext::make_shared<QuantLib::PiecewiseDefaultCurve<QuantLib::SurvivalProbability, QuantLib::Linear>>(
201 asof, rateHelpers, Actual360()));
202 dps->enableExtrapolation();
203 return dps;
204}
205
206} // namespace
207
208
209TestMarket::TestMarket(Date asof, bool swapVolCube) : MarketImpl(false) {
210
212
213 asof_ = asof;
214
215 // build discount
216 yieldCurves_[make_tuple(Market::defaultConfiguration, YieldCurveType::Discount, "EUR")] = flatRateYts(0.02);
217 yieldCurves_[make_tuple(Market::defaultConfiguration, YieldCurveType::Discount, "USD")] = flatRateYts(0.03);
218 yieldCurves_[make_tuple(Market::defaultConfiguration, YieldCurveType::Discount, "GBP")] = flatRateYts(0.04);
219 yieldCurves_[make_tuple(Market::defaultConfiguration, YieldCurveType::Discount, "CHF")] = flatRateYts(0.01);
220 yieldCurves_[make_tuple(Market::defaultConfiguration, YieldCurveType::Discount, "JPY")] = flatRateYts(0.005);
221 yieldCurves_[make_tuple(Market::defaultConfiguration, YieldCurveType::Discount, "CAD")] = flatRateYts(0.005);
222 yieldCurves_[make_tuple(Market::defaultConfiguration, YieldCurveType::Discount, "SEK")] = flatRateYts(0.005);
223
224 // build ibor indices
225 vector<pair<string, Real>> indexData = {
226 {"EUR-EONIA", 0.01}, {"EUR-EURIBOR-3M", 0.015}, {"EUR-EURIBOR-6M", 0.02},
227 {"USD-FedFunds", 0.01}, {"USD-LIBOR-1M", 0.02}, {"USD-LIBOR-3M", 0.03}, {"USD-LIBOR-6M", 0.05},
228 {"GBP-SONIA", 0.01}, {"GBP-LIBOR-3M", 0.03}, {"GBP-LIBOR-6M", 0.04},
229 {"CHF-LIBOR-3M", 0.01}, {"CHF-TOIS", 0.02}, {"CHF-LIBOR-6M", 0.02},
230 {"JPY-LIBOR-6M", 0.01}, {"JPY-TONAR", 0.01}, {"JPY-LIBOR-3M", 0.01},
231 {"CAD-CDOR-3M", 0.02}, {"CAD-CORRA", 0.01},
232 {"SEK-STIBOR-3M", 0.02}};
233
234 for (auto id : indexData) {
235 Handle<IborIndex> h(parseIborIndex(id.first, flatRateYts(id.second)));
236 iborIndices_[make_pair(Market::defaultConfiguration, id.first)] = h;
237
238 // set up dummy fixings for the past 400 days
239 for (Date d = asof - 400; d < asof; d++) {
240 if (h->isValidFixingDate(d))
241 h->addFixing(d, 0.01);
242 }
243 }
244
245 // swap index
246 addSwapIndex("EUR-CMS-2Y", "EUR-EONIA", Market::defaultConfiguration);
247 addSwapIndex("EUR-CMS-30Y", "EUR-EONIA", Market::defaultConfiguration);
248 addSwapIndex("USD-CMS-2Y", "USD-FedFunds", Market::defaultConfiguration);
249 addSwapIndex("USD-CMS-30Y", "USD-FedFunds", Market::defaultConfiguration);
250 addSwapIndex("GBP-CMS-2Y", "GBP-SONIA", Market::defaultConfiguration);
251 addSwapIndex("GBP-CMS-30Y", "GBP-SONIA", Market::defaultConfiguration);
252 addSwapIndex("CHF-CMS-2Y", "CHF-LIBOR-6M", Market::defaultConfiguration);
253 addSwapIndex("CHF-CMS-30Y", "CHF-LIBOR-6M", Market::defaultConfiguration);
254 addSwapIndex("JPY-CMS-2Y", "JPY-LIBOR-6M", Market::defaultConfiguration);
255 addSwapIndex("JPY-CMS-30Y", "JPY-LIBOR-6M", Market::defaultConfiguration);
256
257 // add fx rates
258 std::map<std::string, Handle<Quote>> quotes;
259 quotes["EURUSD"] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(1.2));
260 quotes["EURGBP"] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.8));
261 quotes["EURCHF"] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(1.0));
262 quotes["EURCAD"] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(1.0));
263 quotes["EURSEK"] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(1.0));
264 quotes["EURJPY"] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(128.0));
265 fx_ = QuantLib::ext::make_shared<FXTriangulation>(quotes);
266
267 // build fx vols
268 fxVols_[make_pair(Market::defaultConfiguration, "EURUSD")] = flatRateFxv(0.12);
269 fxVols_[make_pair(Market::defaultConfiguration, "EURGBP")] = flatRateFxv(0.15);
270 fxVols_[make_pair(Market::defaultConfiguration, "EURCHF")] = flatRateFxv(0.15);
271 fxVols_[make_pair(Market::defaultConfiguration, "EURJPY")] = flatRateFxv(0.15);
272 fxVols_[make_pair(Market::defaultConfiguration, "GBPCHF")] = flatRateFxv(0.15);
273
274 // Add Equity Spots
275 equitySpots_[make_pair(Market::defaultConfiguration, "SP5")] =
276 Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(2147.56));
277 equitySpots_[make_pair(Market::defaultConfiguration, "Lufthansa")] =
278 Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(12.75));
279
280 equityVols_[make_pair(Market::defaultConfiguration, "SP5")] = flatRateFxv(0.2514);
281 equityVols_[make_pair(Market::defaultConfiguration, "Lufthansa")] = flatRateFxv(0.30);
282
283 yieldCurves_[make_tuple(Market::defaultConfiguration, YieldCurveType::EquityDividend, "SP5")] = flatRateDiv(0.01);
284 yieldCurves_[make_tuple(Market::defaultConfiguration, YieldCurveType::EquityDividend, "Lufthansa")] =
285 flatRateDiv(0.0);
286
287 equityCurves_[make_pair(Market::defaultConfiguration, "SP5")] = Handle<EquityIndex2>(QuantLib::ext::make_shared<EquityIndex2>(
288 "SP5", UnitedStates(UnitedStates::Settlement), parseCurrency("USD"), equitySpot("SP5"), yieldCurve(YieldCurveType::Discount, "USD"),
289 yieldCurve(YieldCurveType::EquityDividend, "SP5")));
290 equityCurves_[make_pair(Market::defaultConfiguration, "Lufthansa")] =
291 Handle<EquityIndex2>(QuantLib::ext::make_shared<EquityIndex2>(
292 "Lufthansa", TARGET(), parseCurrency("EUR"), equitySpot("Lufthansa"),
293 yieldCurve(YieldCurveType::Discount, "EUR"), yieldCurve(YieldCurveType::EquityDividend, "Lufthansa")));
294
295 swaptionIndexBases_[make_pair(Market::defaultConfiguration, "EUR")] = std::make_pair("EUR-CMS-2Y", "EUR-CMS-30Y");
296 swaptionIndexBases_[make_pair(Market::defaultConfiguration, "USD")] = std::make_pair("USD-CMS-2Y", "USD-CMS-30Y");
297 swaptionIndexBases_[make_pair(Market::defaultConfiguration, "GBP")] = std::make_pair("GBP-CMS-2Y", "GBP-CMS-30Y");
298 swaptionIndexBases_[make_pair(Market::defaultConfiguration, "CHF")] = std::make_pair("CHF-CMS-2Y", "CHF-CMS-30Y");
299 swaptionIndexBases_[make_pair(Market::defaultConfiguration, "JPY")] = std::make_pair("JPY-CMS-2Y", "JPY-CMS-30Y");
300
301 // build swaption vols
302
303 if (swapVolCube) {
304 vector<Real> shiftStrikes = {-0.02, -0.01, -0.005, -0.0025, 0.0, 0.0025, 0.005, 0.01, 0.02};
305 vector<Period> optionTenors = {2 * Weeks, 1 * Months, 3 * Months, 6 * Months, 1 * Years, 2 * Years,
306 3 * Years, 5 * Years, 10 * Years, 15 * Years, 20 * Years, 30 * Years};
307 vector<Period> swapTenors = {1 * Years, 2 * Years, 3 * Years, 4 * Years, 5 * Years,
308 7 * Years, 10 * Years, 15 * Years, 20 * Years, 30 * Years};
309 DayCounter dc = Actual365Fixed();
310 Calendar cal = TARGET();
311 BusinessDayConvention bdc = Following;
312 vector<vector<Handle<Quote>>> parQuotes(
313 optionTenors.size(),
314 vector<Handle<Quote>>(swapTenors.size(), Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.02))));
315
316 vector<vector<Real>> shift(optionTenors.size(), vector<Real>(swapTenors.size(), 0.0));
317 vector<string> ccys = {"USD", "JPY"};
318 QuantLib::ext::shared_ptr<SwaptionVolatilityStructure> atm(new SwaptionVolatilityMatrix(
319 asof_, cal, bdc, optionTenors, swapTenors, parQuotes, dc, true, QuantLib::Normal, shift));
320
321 Handle<SwaptionVolatilityStructure> hATM(atm);
322 vector<vector<Handle<Quote>>> cubeQuotes(
323 optionTenors.size() * swapTenors.size(),
324 vector<Handle<Quote>>(shiftStrikes.size(), Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.02))));
325
326 for (auto name : ccys) {
327 Handle<SwapIndex> si = swapIndex(swapIndexBase(name));
328 Handle<SwapIndex> ssi = swapIndex(shortSwapIndexBase(name));
329
330 QuantLib::ext::shared_ptr<SwaptionVolatilityCube> tmp(new QuantExt::SwaptionVolCube2(
331 hATM, optionTenors, swapTenors, shiftStrikes, cubeQuotes, *si, *ssi, false, true, false));
332 tmp->enableExtrapolation();
333
334 Handle<SwaptionVolatilityStructure> svp =
335 Handle<SwaptionVolatilityStructure>(QuantLib::ext::make_shared<SwaptionVolCubeWithATM>(tmp));
337 }
338
339 } else {
345 }
346
347 // build cap/floor vol structures
348 capFloorCurves_[make_pair(Market::defaultConfiguration, "EUR")] = flatRateCvs(0.0050, Normal);
349 capFloorCurves_[make_pair(Market::defaultConfiguration, "USD")] = flatRateCvs(0.0060, Normal);
350 capFloorCurves_[make_pair(Market::defaultConfiguration, "GBP")] = flatRateCvs(0.0055, Normal);
351 capFloorCurves_[make_pair(Market::defaultConfiguration, "CHF")] = flatRateCvs(0.0045, Normal);
352 capFloorCurves_[make_pair(Market::defaultConfiguration, "JPY")] = flatRateCvs(0.0040, Normal);
353
354 // build default curves
357 defaultCurves_[make_pair(Market::defaultConfiguration, "BondIssuer0")] = flatRateDcs(0.0);
358 defaultCurves_[make_pair(Market::defaultConfiguration, "BondIssuer1")] = flatRateDcs(0.0);
359
360 recoveryRates_[make_pair(Market::defaultConfiguration, "dc")] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.4));
362 Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.4));
363 recoveryRates_[make_pair(Market::defaultConfiguration, "BondIssuer0")] =
364 Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.0));
365 recoveryRates_[make_pair(Market::defaultConfiguration, "BondIssuer1")] =
366 Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.4));
367
368 yieldCurves_[make_tuple(Market::defaultConfiguration, YieldCurveType::Yield, "BondCurve0")] = flatRateYts(0.05);
369 yieldCurves_[make_tuple(Market::defaultConfiguration, YieldCurveType::Yield, "BondCurve1")] = flatRateYts(0.05);
370
372 Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.0));
374 Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.0));
375
376 cdsVols_[make_pair(Market::defaultConfiguration, "dc")] =
377 Handle<QuantExt::CreditVolCurve>(QuantLib::ext::make_shared<QuantExt::CreditVolCurveWrapper>(flatRateFxv(0.12)));
378
379 Handle<IborIndex> hGBP(ore::data::parseIborIndex(
380 "GBP-LIBOR-6M", yieldCurves_[make_tuple(Market::defaultConfiguration, YieldCurveType::Discount, "GBP")]));
381 // FIXME: We have defined that above already
382 iborIndices_[make_pair(Market::defaultConfiguration, "GBP-LIBOR-6M")] = hGBP;
383
384 // Some test cases need a different definition of UKRPI index, curve and vol structure
385 // We there fore added the new UKROi as UKRP1 and keep the "original" below.
386
387 // build inflation indices
388 auto zeroIndex = Handle<ZeroInflationIndex>(QuantLib::ext::make_shared<UKRPI>(true, flatZeroInflationCurve(0.02, 0.01)));
389 zeroInflationIndices_[make_pair(Market::defaultConfiguration, "UKRP1")] = zeroIndex;
390 yoyInflationIndices_[make_pair(Market::defaultConfiguration, "UKRP1")] = Handle<YoYInflationIndex>(
391 QuantLib::ext::make_shared<QuantExt::YoYInflationIndexWrapper>(*zeroIndex, false, flatYoYInflationCurve(0.02, 0.01)));
392
393 // build inflation cap / floor vol curves
396
397 // build UKRPI fixing history
398 Date cpiFixingEnd(1, asof_.month(), asof_.year());
399 Date cpiFixingStart = cpiFixingEnd - Period(14, Months);
400 Schedule fixingDatesUKRPI = MakeSchedule().from(cpiFixingStart).to(cpiFixingEnd).withTenor(1 * Months);
401 Real fixingRatesUKRPI[] = {258.5, 258.9, 258.6, 259.8, 259.6, 259.5, 259.8, 260.6,
402 258.8, 260.0, 261.1, 261.4, 262.1, 264.3, 265.2};
403
404 // build UKRPI index
405 QuantLib::ext::shared_ptr<ZeroInflationIndex> ii = parseZeroInflationIndex("UKRPI");
406 QuantLib::ext::shared_ptr<YoYInflationIndex> yi = QuantLib::ext::make_shared<QuantExt::YoYInflationIndexWrapper>(ii, false);
407
408 RelinkableHandle<ZeroInflationTermStructure> hcpi;
409 ii = QuantLib::ext::shared_ptr<UKRPI>(new UKRPI(hcpi));
410 for (Size i = 0; i < fixingDatesUKRPI.size(); i++) {
411 // std::cout << i << ", " << fixingDatesUKRPI[i] << ", " << fixingRatesUKRPI[i] << std::endl;
412 ii->addFixing(fixingDatesUKRPI[i], fixingRatesUKRPI[i], true);
413 };
414
415 // build EUHICPXT fixing history
416 Schedule fixingDatesEUHICPXT = MakeSchedule().from(cpiFixingStart).to(cpiFixingEnd).withTenor(1 * Months);
417 Real fixingRatesEUHICPXT[] = {258.5, 258.9, 258.6, 259.8, 259.6, 259.5, 259.8, 260.6,
418 258.8, 260.0, 261.1, 261.4, 262.1, 264.3, 265.2};
419
420 // build EUHICPXT index
421 QuantLib::ext::shared_ptr<ZeroInflationIndex> euii = parseZeroInflationIndex("EUHICPXT");
422 QuantLib::ext::shared_ptr<YoYInflationIndex> euyi = QuantLib::ext::make_shared<QuantExt::YoYInflationIndexWrapper>(euii, false);
423
424 RelinkableHandle<ZeroInflationTermStructure> euhcpi;
425 euii = QuantLib::ext::shared_ptr<EUHICPXT>(new EUHICPXT(euhcpi));
426 for (Size i = 0; i < fixingDatesEUHICPXT.size(); i++) {
427 euii->addFixing(fixingDatesEUHICPXT[i], fixingRatesEUHICPXT[i], true);
428 };
429
430 vector<Date> datesZCII = {asof_,
431 asof_ + 1 * Years,
432 asof_ + 2 * Years,
433 asof_ + 3 * Years,
434 asof_ + 4 * Years,
435 asof_ + 5 * Years,
436 asof_ + 6 * Years,
437 asof_ + 7 * Years,
438 asof_ + 8 * Years,
439 asof_ + 9 * Years,
440 asof_ + 10 * Years,
441 asof_ + 12 * Years,
442 asof_ + 15 * Years,
443 asof_ + 20 * Years};
444
445 vector<Rate> ratesZCII = {2.825, 2.9425, 2.975, 2.983, 3.0, 3.01, 3.008,
446 3.009, 3.013, 3.0445, 3.044, 3.09, 3.109, 3.108};
447
449 makeZeroInflationIndex("EUHICPXT", datesZCII, ratesZCII, euii,
450 yieldCurves_[make_tuple(Market::defaultConfiguration, YieldCurveType::Discount, "EUR")]);
452 makeZeroInflationIndex("UKRPI", datesZCII, ratesZCII, ii,
453 yieldCurves_[make_tuple(Market::defaultConfiguration, YieldCurveType::Discount, "GBP")]);
454
456 makeYoYInflationIndex("UKRPI", datesZCII, ratesZCII, yi,
457 yieldCurves_[make_tuple(Market::defaultConfiguration, YieldCurveType::Discount, "GBP")]);
458
460 flatCpiVolSurface(0.05);
462
463 // Commodity price curves and spots
464 Actual365Fixed ccDayCounter;
465 vector<Period> commTenors = {0 * Days, 365 * Days, 730 * Days, 1825 * Days};
466
467 // Gold curve
468 vector<Real> prices = {1155.593, 1160.9, 1168.1, 1210};
469 Handle<PriceTermStructure> ptsGold(QuantLib::ext::make_shared<InterpolatedPriceCurve<Linear>>(
470 commTenors, prices, ccDayCounter, USDCurrency()));
471 ptsGold->enableExtrapolation();
472 commodityIndices_[make_pair(Market::defaultConfiguration, "COMDTY_GOLD_USD")] = Handle<CommodityIndex>(
473 QuantLib::ext::make_shared<CommoditySpotIndex>("COMDTY_GOLD_USD", NullCalendar(), ptsGold));
474
475 // WTI Oil curve
476 prices = {30.89, 41.23, 44.44, 49.18};
477 Handle<PriceTermStructure> ptsOil(QuantLib::ext::make_shared<InterpolatedPriceCurve<Linear>>(
478 commTenors, prices, ccDayCounter, USDCurrency()));
479 ptsOil->enableExtrapolation();
480 commodityIndices_[make_pair(Market::defaultConfiguration, "COMDTY_WTI_USD")] = Handle<CommodityIndex>(
481 QuantLib::ext::make_shared<CommoditySpotIndex>("COMDTY_WTI_USD", NullCalendar(), ptsOil));
482
483 // Commodity volatilities
484 commodityVols_[make_pair(Market::defaultConfiguration, "COMDTY_GOLD_USD")] = flatRateFxv(0.15);
485 commodityVols_[make_pair(Market::defaultConfiguration, "COMDTY_WTI_USD")] = flatRateFxv(0.20);
486
487 // Correlations
488 correlationCurves_[make_tuple(Market::defaultConfiguration, "EUR-CMS-10Y", "EUR-CMS-1Y")] = flatCorrelation(0.15);
489 correlationCurves_[make_tuple(Market::defaultConfiguration, "USD-CMS-10Y", "USD-CMS-1Y")] = flatCorrelation(0.2);
490}
491
492Handle<YieldTermStructure> TestMarket::flatRateYts(Real forward) {
493 QuantLib::ext::shared_ptr<YieldTermStructure> yts(
494 new FlatForward(Settings::instance().evaluationDate(), forward, ActualActual(ActualActual::ISDA)));
495 return Handle<YieldTermStructure>(yts);
496}
497
498Handle<BlackVolTermStructure> TestMarket::flatRateFxv(Volatility forward) {
499 QuantLib::ext::shared_ptr<BlackVolTermStructure> fxv(
500 new BlackConstantVol(Settings::instance().evaluationDate(), NullCalendar(), forward, ActualActual(ActualActual::ISDA)));
501 return Handle<BlackVolTermStructure>(fxv);
502}
503
504Handle<YieldTermStructure> TestMarket::flatRateDiv(Real dividend) {
505 QuantLib::ext::shared_ptr<YieldTermStructure> yts(
506 new FlatForward(Settings::instance().evaluationDate(), dividend, ActualActual(ActualActual::ISDA)));
507 return Handle<YieldTermStructure>(yts);
508}
509
510Handle<QuantLib::SwaptionVolatilityStructure>
511TestMarket::flatRateSvs(Volatility forward, VolatilityType type, Real shift) {
512 QuantLib::ext::shared_ptr<QuantLib::SwaptionVolatilityStructure> svs(
513 new QuantLib::ConstantSwaptionVolatility(Settings::instance().evaluationDate(), NullCalendar(),
514 ModifiedFollowing, forward, ActualActual(ActualActual::ISDA), type, shift));
515 return Handle<QuantLib::SwaptionVolatilityStructure>(svs);
516}
517
518Handle<QuantExt::CreditCurve> TestMarket::flatRateDcs(Volatility forward) {
519 QuantLib::ext::shared_ptr<DefaultProbabilityTermStructure> dcs(
520 new FlatHazardRate(asof_, forward, ActualActual(ActualActual::ISDA)));
521 return Handle<QuantExt::CreditCurve>(QuantLib::ext::make_shared<QuantExt::CreditCurve>(Handle<DefaultProbabilityTermStructure>(dcs)));
522}
523
524Handle<OptionletVolatilityStructure> TestMarket::flatRateCvs(Volatility vol, VolatilityType type, Real shift) {
525 QuantLib::ext::shared_ptr<OptionletVolatilityStructure> ts(
526 new QuantLib::ConstantOptionletVolatility(Settings::instance().evaluationDate(), NullCalendar(),
527 ModifiedFollowing, vol, ActualActual(ActualActual::ISDA), type, shift));
528 return Handle<OptionletVolatilityStructure>(ts);
529}
530
531Handle<QuantExt::CorrelationTermStructure> TestMarket::flatCorrelation(Real correlation) {
532 QuantLib::ext::shared_ptr<QuantExt::CorrelationTermStructure> ts(
533 new QuantExt::FlatCorrelation(Settings::instance().evaluationDate(), correlation, ActualActual(ActualActual::ISDA)));
534 return Handle<QuantExt::CorrelationTermStructure>(ts);
535}
536
537Handle<CPICapFloorTermPriceSurface> TestMarket::flatRateCps(Handle<ZeroInflationIndex> infIndex,
538 const std::vector<Rate> cStrikes, std::vector<Rate> fStrikes,
539 std::vector<Period> cfMaturities, Matrix cPrice, Matrix fPrice) {
540 QuantLib::ext::shared_ptr<CPICapFloorTermPriceSurface> ts(
541 new InterpolatedCPICapFloorTermPriceSurface<QuantLib::Bilinear>(
542 1.0, 0.0, infIndex->availabilityLag(), infIndex->zeroInflationTermStructure()->calendar(), Following,
543 ActualActual(ActualActual::ISDA), infIndex.currentLink(), CPI::AsIndex, discountCurve(infIndex->currency().code()), cStrikes, fStrikes, cfMaturities,
544 cPrice, fPrice));
545 return Handle<CPICapFloorTermPriceSurface>(ts);
546}
547
548Handle<QuantLib::CPIVolatilitySurface> TestMarket::flatCpiVolSurface(Volatility v) {
549 Natural settleDays = 0;
550 Calendar cal = TARGET();
551 BusinessDayConvention bdc = Following;
552 DayCounter dc = Actual365Fixed();
553 Period lag = 2 * Months;
554 Frequency freq = Annual;
555 bool interp = false;
556 QuantLib::ext::shared_ptr<QuantLib::ConstantCPIVolatility> cpiCapFloorVolSurface =
557 QuantLib::ext::make_shared<QuantLib::ConstantCPIVolatility>(v, settleDays, cal, bdc, dc, lag, freq, interp);
558 return Handle<QuantLib::CPIVolatilitySurface>(cpiCapFloorVolSurface);
559}
560
561Handle<ZeroInflationIndex> TestMarket::makeZeroInflationIndex(string index, vector<Date> dates, vector<Rate> rates,
562 QuantLib::ext::shared_ptr<ZeroInflationIndex> ii,
563 Handle<YieldTermStructure> yts) {
564 // build UKRPI index
565 QuantLib::ext::shared_ptr<ZeroInflationTermStructure> cpiTS;
566 // now build the helpers ...
567 vector<QuantLib::ext::shared_ptr<BootstrapHelper<ZeroInflationTermStructure>>> instruments;
568 for (Size i = 0; i < dates.size(); i++) {
569 Handle<Quote> quote(QuantLib::ext::shared_ptr<Quote>(new SimpleQuote(rates[i] / 100.0)));
570 QuantLib::ext::shared_ptr<BootstrapHelper<ZeroInflationTermStructure>> anInstrument(new ZeroCouponInflationSwapHelper(
571 quote, Period(2, Months), dates[i], TARGET(), ModifiedFollowing, ActualActual(ActualActual::ISDA), ii, CPI::AsIndex, yts));
572 anInstrument->unregisterWith(Settings::instance().evaluationDate());
573 instruments.push_back(anInstrument);
574 };
575 // we can use historical or first ZCIIS for this
576 // we know historical is WAY off market-implied, so use market implied flat.
577 Rate baseZeroRate = rates[0] / 100.0;
578 QuantLib::ext::shared_ptr<PiecewiseZeroInflationCurve<Linear>> pCPIts(
579 new PiecewiseZeroInflationCurve<Linear>(asof_, TARGET(), ActualActual(ActualActual::ISDA), Period(2, Months), ii->frequency(),
580 baseZeroRate, instruments));
581 pCPIts->recalculate();
582 cpiTS = QuantLib::ext::dynamic_pointer_cast<ZeroInflationTermStructure>(pCPIts);
583 cpiTS->enableExtrapolation(true);
584 cpiTS->unregisterWith(Settings::instance().evaluationDate());
585 return Handle<ZeroInflationIndex>(parseZeroInflationIndex(index, Handle<ZeroInflationTermStructure>(cpiTS)));
586}
587
588Handle<YoYInflationIndex> TestMarket::makeYoYInflationIndex(string index, vector<Date> dates, vector<Rate> rates,
589 QuantLib::ext::shared_ptr<YoYInflationIndex> ii,
590 Handle<YieldTermStructure> yts) {
591 // build UKRPI index
592 QuantLib::ext::shared_ptr<YoYInflationTermStructure> yoyTS;
593 // now build the helpers ...
594 vector<QuantLib::ext::shared_ptr<BootstrapHelper<YoYInflationTermStructure>>> instruments;
595 for (Size i = 0; i < dates.size(); i++) {
596 Handle<Quote> quote(QuantLib::ext::shared_ptr<Quote>(new SimpleQuote(rates[i] / 100.0)));
597 QuantLib::ext::shared_ptr<BootstrapHelper<YoYInflationTermStructure>> anInstrument(new YearOnYearInflationSwapHelper(
598 quote, Period(2, Months), dates[i], TARGET(), ModifiedFollowing, ActualActual(ActualActual::ISDA), ii, yts));
599 instruments.push_back(anInstrument);
600 };
601 // we can use historical or first ZCIIS for this
602 // we know historical is WAY off market-implied, so use market implied flat.
603 Rate baseZeroRate = rates[0] / 100.0;
604 QuantLib::ext::shared_ptr<PiecewiseYoYInflationCurve<Linear>> pYoYts(
605 new PiecewiseYoYInflationCurve<Linear>(asof_, TARGET(), ActualActual(ActualActual::ISDA), Period(2, Months), ii->frequency(),
606 ii->interpolated(), baseZeroRate, instruments));
607 pYoYts->recalculate();
608 yoyTS = QuantLib::ext::dynamic_pointer_cast<YoYInflationTermStructure>(pYoYts);
609 return Handle<YoYInflationIndex>(QuantLib::ext::make_shared<QuantExt::YoYInflationIndexWrapper>(
610 parseZeroInflationIndex(index), false, Handle<YoYInflationTermStructure>(pYoYts)));
611}
612
613Handle<ZeroInflationTermStructure> TestMarket::flatZeroInflationCurve(Real inflationRate, Rate nominalRate) {
614 Date today = Settings::instance().evaluationDate();
615 Period lag = 2 * Months;
616 std::vector<Date> dates;
617 dates.push_back(today - lag);
618 dates.push_back(today + 1 * Years);
619 std::vector<Real> rates(dates.size(), inflationRate);
620 auto curve = QuantLib::ext::make_shared<QuantLib::InterpolatedZeroInflationCurve<Linear>>(
621 today, NullCalendar(), QuantLib::ActualActual(ActualActual::ISDA), 2 * Months, Monthly, dates, rates);
622 curve->enableExtrapolation();
623 return Handle<ZeroInflationTermStructure>(curve);
624}
625
626Handle<YoYInflationTermStructure> TestMarket::flatYoYInflationCurve(Real inflationRate, Rate nominalRate) {
627 Date today = Settings::instance().evaluationDate();
628 Period lag = 2 * Months;
629 std::vector<Date> dates;
630 dates.push_back(today - lag);
631 dates.push_back(today + 1 * Years);
632 std::vector<Real> rates(dates.size(), inflationRate);
633 auto curve = QuantLib::ext::make_shared<QuantLib::InterpolatedYoYInflationCurve<Linear>>(
634 today, NullCalendar(), QuantLib::ActualActual(ActualActual::ISDA), 2 * Months, Monthly, false, dates, rates);
635 curve->enableExtrapolation();
636 return Handle<YoYInflationTermStructure>(curve);
637}
638
639Handle<YoYOptionletVolatilitySurface> TestMarket::flatYoYOptionletVolatilitySurface(Real normalVol) {
640 auto qlTs = QuantLib::ext::make_shared<ConstantYoYOptionletVolatility>(
641 normalVol, 0, NullCalendar(), Unadjusted, ActualActual(ActualActual::ISDA), 2 * Months, Monthly, false, -1.0, 100.0, Normal);
642 return Handle<YoYOptionletVolatilitySurface>(qlTs);
643}
644
646 asof_ = asof;
647
649
650 vector<pair<string, Real>> ccys = {{"EUR", 0.02}, {"USD", 0.03}, {"GBP", 0.04}, {"CHF", 0.02}};
651 vector<pair<string, Real>> o_ccys = {{"JPY", 0.005}};
652 vector<pair<string, Real>> x_ccys = {{"CHF", 0.02}};
653 vector<pair<string, Real>> d_names = {{"dc", 0.001}, {"dc2", 0.001}, {"dc3", 0.001}};
654 map<string, string> d_ccys;
655 d_ccys["dc"] = "USD";
656 d_ccys["dc2"] = "EUR";
657 d_ccys["dc3"] = "GBP";
658 vector<Period> parTenor = {2 * Weeks, 1 * Months, 3 * Months, 6 * Months, 1 * Years, 2 * Years, 3 * Years,
659 5 * Years, 10 * Years, 13 * Years, 15 * Years, 20 * Years, 30 * Years};
660 vector<Period> parTenor2 = {3 * Months, 6 * Months, 1 * Years, 2 * Years, 3 * Years,
661 5 * Years, 10 * Years, 13 * Years, 15 * Years, 20 * Years};
662 vector<Period> parTenor3 = {6 * Months, 1 * Years, 2 * Years, 5 * Years, 10 * Years};
663
664 for (auto it : ccys) {
665 string ccy = it.first;
666 Real parRate = it.second;
667 vector<string> parInst;
668 if (ccy == "JPY")
669 parInst = {"OIS", "OIS", "OIS", "OIS", "OIS", "OIS", "OIS", "OIS", "OIS", "OIS", "OIS", "OIS", "OIS"};
670 else
671 parInst = {"DEP", "DEP", "DEP", "DEP", "FRA", "IRS", "IRS", "IRS", "IRS", "IRS", "IRS", "IRS", "IRS"};
672 vector<Real> parRates(parInst.size(), parRate);
673 createDiscountCurve(ccy, parInst, parTenor, parRates);
674 }
675 for (auto it : o_ccys) {
676 string ccy = it.first;
677 Real parRate = it.second;
678 vector<string> parInst;
679 parInst = {"OIS", "OIS", "OIS", "OIS", "OIS", "OIS", "OIS", "OIS", "OIS", "OIS", "OIS", "OIS", "OIS"};
680 vector<Real> parRates(parInst.size(), parRate);
681 createDiscountCurve(ccy, parInst, parTenor, parRates);
682 }
683
684 // add fx rates
685 // add fx rates
686 std::map<std::string, QuantLib::Handle<QuantLib::Quote>> quotes;
687 quotes["EURUSD"] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(1.2));
688 quotes["EURGBP"] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.8));
689 quotes["EURCHF"] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(1.0));
690 quotes["EURJPY"] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(128.0));
691 fx_ = QuantLib::ext::make_shared<FXTriangulation>(quotes);
692
693 recoveryRates_[make_pair(Market::defaultConfiguration, "dc")] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.4));
695 Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.4));
697 Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.4));
698
699 for (auto it : d_names) {
700 string name = it.first;
701 Real parRate = it.second;
702 string ccy = d_ccys[name];
703 vector<string> parInst;
704 parInst = {"CDS", "CDS", "CDS", "CDS", "CDS", "CDS", "CDS", "CDS", "CDS", "CDS"};
705 vector<Real> parRates(parInst.size(), parRate);
706
707 createDefaultCurve(name, ccy, parInst, parTenor2, parRates);
708 }
709 // build ibor indices
710 vector<pair<string, Real>> indexData = {
711 {"EUR-EONIA", 0.02}, {"EUR-EURIBOR-2W", 0.02}, {"EUR-EURIBOR-1M", 0.02}, {"EUR-EURIBOR-3M", 0.02},
712 {"EUR-EURIBOR-6M", 0.02}, {"USD-FedFunds", 0.03}, {"USD-LIBOR-2W", 0.03}, {"USD-LIBOR-1M", 0.03},
713 {"USD-LIBOR-3M", 0.03}, {"USD-LIBOR-6M", 0.03}, {"GBP-SONIA", 0.04}, {"GBP-LIBOR-2W", 0.04},
714 {"GBP-LIBOR-1M", 0.04}, {"GBP-LIBOR-3M", 0.04}, {"GBP-LIBOR-6M", 0.04}, {"JPY-TONAR", 0.005},
715 {"JPY-LIBOR-2W", 0.005}, {"JPY-LIBOR-1M", 0.005}, {"JPY-LIBOR-3M", 0.005}, {"JPY-LIBOR-6M", 0.005}};
716 vector<pair<string, Real>> singleCurve_indexData = {{"CHF-LIBOR-3M", 0.02}, {"CHF-LIBOR-6M", 0.02}};
717 for (auto id : indexData) {
718 string idxName = id.first;
719 string ccy = idxName.substr(0, 3);
720 vector<string> parInst = {"DEP", "DEP", "DEP", "DEP", "FRA", "IRS", "IRS",
721 "IRS", "IRS", "IRS", "IRS", "IRS", "IRS"};
722 vector<Real> parRates(parInst.size(), id.second);
723 createIborIndex(idxName, parInst, parTenor, parRates, false);
724 }
725 for (auto id : singleCurve_indexData) {
726 string idxName = id.first;
727 string ccy = idxName.substr(0, 3);
728 vector<string> parInst = {"DEP", "DEP", "DEP", "DEP", "FRA", "IRS", "IRS",
729 "IRS", "IRS", "IRS", "IRS", "IRS", "IRS"};
730 vector<Real> parRates(parInst.size(), id.second);
731 createIborIndex(idxName, parInst, parTenor, parRates, true);
732 }
733 // now build the remaining discount curves that have cross-currency dependencies
734 for (auto it : x_ccys) {
735 string baseCcy = "EUR";
736 string ccy = it.first;
737 Real parRate = it.second;
738 vector<string> parInst;
739 parInst = {"FXF", "FXF", "FXF", "FXF", "FXF", "XBS", "XBS", "XBS", "XBS", "XBS", "XBS", "XBS", "XBS"};
740 vector<Real> parRates(parInst.size(), parRate);
741 BOOST_ASSERT(ccy != baseCcy);
742 createXccyDiscountCurve(ccy, baseCcy, parInst, parTenor, parRates);
743 }
744
745 // swap index
746 addSwapIndex("EUR-CMS-2Y", "EUR-EURIBOR-6M", Market::defaultConfiguration);
747 addSwapIndex("EUR-CMS-30Y", "EUR-EURIBOR-6M", Market::defaultConfiguration);
748 addSwapIndex("USD-CMS-2Y", "USD-FedFunds", Market::defaultConfiguration);
749 addSwapIndex("USD-CMS-30Y", "USD-FedFunds", Market::defaultConfiguration);
750 addSwapIndex("GBP-CMS-2Y", "GBP-SONIA", Market::defaultConfiguration);
751 addSwapIndex("GBP-CMS-30Y", "GBP-SONIA", Market::defaultConfiguration);
752 addSwapIndex("CHF-CMS-2Y", "CHF-LIBOR-6M", Market::defaultConfiguration);
753 addSwapIndex("CHF-CMS-30Y", "CHF-LIBOR-6M", Market::defaultConfiguration);
754 addSwapIndex("JPY-CMS-2Y", "JPY-LIBOR-6M", Market::defaultConfiguration);
755 addSwapIndex("JPY-CMS-30Y", "JPY-LIBOR-6M", Market::defaultConfiguration);
756
757 // build fx vols
758 fxVols_[make_pair(Market::defaultConfiguration, "EURUSD")] = flatRateFxv(0.12);
759 fxVols_[make_pair(Market::defaultConfiguration, "EURGBP")] = flatRateFxv(0.15);
760 fxVols_[make_pair(Market::defaultConfiguration, "EURCHF")] = flatRateFxv(0.15);
761 fxVols_[make_pair(Market::defaultConfiguration, "EURJPY")] = flatRateFxv(0.15);
762
763 // build cap/floor vol structures
764 capFloorCurves_[make_pair(Market::defaultConfiguration, "EUR")] = flatRateCvs(0.0050, Normal);
765 capFloorCurves_[make_pair(Market::defaultConfiguration, "USD")] = flatRateCvs(0.0060, Normal);
766 capFloorCurves_[make_pair(Market::defaultConfiguration, "GBP")] = flatRateCvs(0.0055, Normal);
767 capFloorCurves_[make_pair(Market::defaultConfiguration, "CHF")] = flatRateCvs(0.0045, Normal);
768 capFloorCurves_[make_pair(Market::defaultConfiguration, "JPY")] = flatRateCvs(0.0040, Normal);
769
770 // build swaption vols
771 vector<pair<string, Real>> swapvolrates = {
772 {"EUR", 0.2}, {"USD", 0.30}, {"GBP", 0.25}, {"CHF", 0.25}, {"JPY", 0.25}};
773 vector<Period> swapTenors = {2 * Weeks, 1 * Months, 3 * Months, 6 * Months, 1 * Years, 2 * Years, 3 * Years,
774 5 * Years, 10 * Years, 13 * Years, 15 * Years, 20 * Years, 30 * Years};
775 vector<Period> swapTerms = {1 * Years, 2 * Years, 3 * Years, 4 * Years, 5 * Years,
776 7 * Years, 10 * Years, 15 * Years, 20 * Years, 30 * Years};
777
778 swaptionIndexBases_[make_pair(Market::defaultConfiguration, "EUR")] = std::make_pair("EUR-CMS-2Y", "EUR-CMS-30Y");
779 swaptionIndexBases_[make_pair(Market::defaultConfiguration, "USD")] = std::make_pair("USD-CMS-2Y", "USD-CMS-30Y");
780 swaptionIndexBases_[make_pair(Market::defaultConfiguration, "GBP")] = std::make_pair("GBP-CMS-2Y", "GBP-CMS-30Y");
781 swaptionIndexBases_[make_pair(Market::defaultConfiguration, "CHF")] = std::make_pair("CHF-CMS-2Y", "CHF-CMS-30Y");
782 swaptionIndexBases_[make_pair(Market::defaultConfiguration, "JPY")] = std::make_pair("JPY-CMS-2Y", "JPY-CMS-30Y");
783
784 vector<Real> swapStrikes = {-0.02, -0.005, 0, 0.005, 0.02};
785 for (auto it : swapvolrates) {
786 string name = it.first;
787 Real parRate = it.second;
788 vector<Real> parRates(swapTenors.size() * swapTerms.size() * swapStrikes.size(), parRate);
789 createSwaptionVolCurve(name, swapTenors, swapTerms, swapStrikes, parRates);
790 }
791
792 // Add Equity Spots
793 equitySpots_[make_pair(Market::defaultConfiguration, "SP5")] =
794 Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(2147.56));
795 equitySpots_[make_pair(Market::defaultConfiguration, "Lufthansa")] =
796 Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(12.75));
797
798 vector<pair<string, Real>> eqvolrates = {{"SP5", 0.2514}, {"Lufthansa", 0.30}};
799 map<string, string> currencyMap;
800 currencyMap["SP5"] = "USD";
801 currencyMap["Lufthansa"] = "EUR";
802 for (auto it : eqvolrates) {
803 string name = it.first;
804 Real parRate = it.second;
805 vector<Real> parRates(parTenor.size(), parRate);
806 createEquityVolCurve(name, currencyMap[name], parTenor, parRates);
807 }
808
809 yieldCurves_[make_tuple(Market::defaultConfiguration, YieldCurveType::EquityDividend, "SP5")] = flatRateYts(0.01);
810 yieldCurves_[make_tuple(Market::defaultConfiguration, YieldCurveType::EquityDividend, "Lufthansa")] =
811 flatRateYts(0.0);
812
813 vector<string> parInst = {"DEP", "DEP", "DEP", "DEP", "FRA", "IRS", "IRS",
814 "IRS", "IRS", "IRS", "IRS", "IRS", "IRS"};
815 vector<Real> parRates1(parInst.size(), 0.03);
816 vector<Real> parRates2(parInst.size(), 0.02);
817
818 equityCurves_[make_pair(Market::defaultConfiguration, "SP5")] = Handle<EquityIndex2>(QuantLib::ext::make_shared<EquityIndex2>(
819 "SP5", UnitedStates(UnitedStates::Settlement), parseCurrency("USD"), equitySpot("SP5"), yieldCurve(YieldCurveType::Discount, "USD"),
820 yieldCurve(YieldCurveType::EquityDividend, "SP5")));
821 equityCurves_[make_pair(Market::defaultConfiguration, "Lufthansa")] =
822 Handle<EquityIndex2>(QuantLib::ext::make_shared<EquityIndex2>(
823 "Lufthansa", TARGET(), parseCurrency("EUR"), equitySpot("Lufthansa"),
824 yieldCurve(YieldCurveType::Discount, "EUR"), yieldCurve(YieldCurveType::EquityDividend, "Lufthansa")));
825
826 vector<pair<string, Real>> cdsrates = {{"dc", 0.12}, {"dc2", 0.1313}, {"dc3", 0.14}};
827 for (auto it : cdsrates) {
828 string name = it.first;
829 Real parRate = it.second;
830 vector<Real> parRates(parTenor3.size(), parRate);
831 createCdsVolCurve(name, parTenor3, parRates);
832 }
833
834 vector<pair<string, vector<Real>>> bcrates = {{"Tranch1", {0.1, 0.2, 0.3, 0.4, 0.5, 0.6}}};
835 vector<Period> bctenors = {1 * Days, 2 * Days};
836 vector<string> lossLevel = {"0.03", "0.06", "0.09", "0.12", "0.22", "1.00"};
837 for (auto it : bcrates) {
838 string name = it.first;
839 vector<Real> corrRates = it.second;
840 createBaseCorrel(name, bctenors, lossLevel, corrRates);
841 }
842
843 Date cpiFixingEnd(1, asof_.month(), asof_.year());
844 Date cpiFixingStart = cpiFixingEnd - Period(14, Months);
845 Schedule fixingDatesUKRPI = MakeSchedule().from(cpiFixingStart).to(cpiFixingEnd).withTenor(1 * Months);
846 Real fixingRatesUKRPI[] = {258.5, 258.9, 258.6, 259.8, 259.6, 259.5, 259.8, 260.6,
847 258.8, 260.0, 261.1, 261.4, 262.1, -264.3, -265.2};
848
849 RelinkableHandle<ZeroInflationTermStructure> hcpi;
850 QuantLib::ext::shared_ptr<ZeroInflationIndex> ii = QuantLib::ext::shared_ptr<UKRPI>(new UKRPI(hcpi));
851 for (Size i = 0; i < fixingDatesUKRPI.size(); i++) {
852 ii->addFixing(fixingDatesUKRPI[i], fixingRatesUKRPI[i], true);
853 };
854
855 vector<pair<string, vector<Real>>> zirates = {
856 {"UKRPI", {2.825, 2.9425, 2.975, 2.983, 3.0, 3.01, 3.008, 3.009, 3.013}}};
857 vector<Period> zitenors = {6 * Months, 1 * Years, 2 * Years, 3 * Years, 5 * Years,
858 7 * Years, 10 * Years, 15 * Years, 20 * Years};
859 for (auto it : zirates) {
860 string index = it.first;
861 vector<Real> parRates = it.second;
862 vector<string> parInst = {"ZIS", "ZIS", "ZIS", "ZIS", "ZIS", "ZIS", "ZIS", "ZIS", "ZIS"};
863 createZeroInflationIndex(index, parInst, zitenors, parRates, true);
864 }
865 vector<pair<string, vector<Real>>> yyrates = {
866 {"UKRPI", {/*2.825,*/ 2.9425, 2.975, 2.983, 3.0, 3.01, 3.008, 3.009, 3.013}}};
867 vector<Period> yytenors = {1 * Years, 2 * Years, 3 * Years, 5 * Years,
868 7 * Years, 10 * Years, 15 * Years, 20 * Years};
869 for (auto it : yyrates) {
870 string index = it.first;
871 vector<Real> parRates = it.second;
872 vector<string> parInst = {"YYS", "YYS", "YYS", "YYS", "YYS", "YYS", "YYS", "YYS"};
873 createYoYInflationIndex(index, parInst, yytenors, parRates, true);
874 }
875}
876
877void TestMarketParCurves::createDiscountCurve(const string& ccy, const vector<string>& parInst,
878 const vector<Period>& parTenor, const vector<Real>& parRates) {
879 discountRateHelperInstMap_[ccy] = parInst;
880 discountRateHelperTenorsMap_[ccy] = parTenor;
881 vector<Handle<Quote>> parQuotes(parRates.size());
882 for (Size i = 0; i < parRates.size(); ++i)
883 parQuotes[i] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(parRates[i]));
884 discountRateHelperValuesMap_[ccy] = parQuotes;
885 discountRateHelpersMap_[ccy] = parRateCurveHelpers(ccy, parInst, parTenor, discountRateHelperValuesMap_[ccy]);
886 yieldCurves_[make_tuple(Market::defaultConfiguration, YieldCurveType::Discount, ccy)] =
887 parRateCurve(asof_, discountRateHelpersMap_[ccy]);
888}
889
890void TestMarketParCurves::createXccyDiscountCurve(const string& ccy, const string& baseCcy,
891 const vector<string>& parInst, const vector<Period>& parTenor,
892 const vector<Real>& parRates) {
893 discountRateHelperInstMap_[ccy] = parInst;
894 discountRateHelperTenorsMap_[ccy] = parTenor;
895 vector<Handle<Quote>> parQuotes(parRates.size());
896 for (Size i = 0; i < parRates.size(); ++i)
897 parQuotes[i] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(parRates[i]));
898 discountRateHelperValuesMap_[ccy] = parQuotes;
899 Handle<Quote> fxSpot = this->fxSpot(ccy + baseCcy, Market::defaultConfiguration);
900 Handle<YieldTermStructure> baseDiscount = this->discountCurve(baseCcy, Market::defaultConfiguration);
901 Handle<YieldTermStructure> ccyDiscountHandle =
902 Handle<YieldTermStructure>(); // leave unlinked, as this is the curve we are building
903 discountRateHelpersMap_[ccy] = parRateCurveHelpers(ccy, parInst, parTenor, discountRateHelperValuesMap_[ccy],
904 ccyDiscountHandle, fxSpot, baseDiscount, this);
905 yieldCurves_[make_tuple(Market::defaultConfiguration, YieldCurveType::Discount, ccy)] =
906 parRateCurve(asof_, discountRateHelpersMap_[ccy]);
907}
908
909void TestMarketParCurves::createIborIndex(const string& idxName, const vector<string>& parInst,
910 const vector<Period>& parTenor, const vector<Real>& parRates,
911 bool singleCurve) {
912 string ccy = idxName.substr(0, 3);
913 indexCurveRateHelperInstMap_[idxName] = parInst;
914 indexCurveRateHelperTenorsMap_[idxName] = parTenor;
915 vector<Handle<Quote>> parQuotes(parRates.size());
916 for (Size i = 0; i < parRates.size(); ++i)
917 parQuotes[i] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(parRates[i]));
918 indexCurveRateHelperValuesMap_[idxName] = parQuotes;
919 indexCurveRateHelpersMap_[idxName] = parRateCurveHelpers(
920 ccy, parInst, parTenor, indexCurveRateHelperValuesMap_[idxName],
921 singleCurve ? Handle<YieldTermStructure>()
922 : yieldCurves_[make_tuple(Market::defaultConfiguration, YieldCurveType::Discount, ccy)]);
923 Handle<IborIndex> h(parseIborIndex(idxName, parRateCurve(asof_, indexCurveRateHelpersMap_[idxName])));
924 iborIndices_[make_pair(Market::defaultConfiguration, idxName)] = h;
925
926 // set up dummy fixings for the past 400 days
927 for (Date d = asof_ - 400; d < asof_; d++) {
928 if (h->isValidFixingDate(d))
929 h->addFixing(d, 0.01);
930 }
931}
932
933void TestMarketParCurves::createDefaultCurve(const string& name, const string& ccy, const vector<string>& parInst,
934 const vector<Period>& parTenor, const vector<Real>& parRates) {
935 QuantLib::ext::shared_ptr<Conventions> conventions = InstrumentConventions::instance().conventions();
938 vector<Handle<Quote>> parQuotes(parRates.size());
939 for (Size i = 0; i < parRates.size(); ++i)
940 parQuotes[i] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(parRates[i]));
942 QuantLib::ext::shared_ptr<Convention> conv = conventions->get("CDS-STANDARD-CONVENTIONS");
943 Handle<YieldTermStructure> baseDiscount = this->discountCurve(ccy, Market::defaultConfiguration);
945 parRateCurveHelpers(name, parTenor, defaultRateHelperValuesMap_[name], baseDiscount, this);
946
947 defaultCurves_[make_pair(Market::defaultConfiguration, name)] = Handle<QuantExt::CreditCurve>(
948 QuantLib::ext::make_shared<QuantExt::CreditCurve>(parRateCurve(asof_, defaultRateHelpersMap_[name])));
949}
950
951void TestMarketParCurves::createCdsVolCurve(const string& name, const vector<Period>& parTenor,
952 const vector<Real>& parRates) {
954 vector<Handle<Quote>> parQuotes(parRates.size());
955 for (Size i = 0; i < parRates.size(); ++i)
956 parQuotes[i] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(parRates[i]));
957 cdsVolRateHelperValuesMap_[name] = parQuotes;
958
959 DayCounter dc = Actual365Fixed();
960 Calendar cal = TARGET();
961 BusinessDayConvention bdc = Following;
962 vector<Volatility> atmVols(parQuotes.size());
963 vector<Date> dates(parQuotes.size());
964 vector<Time> times(parQuotes.size());
965
966 for (Size i = 0; i < parQuotes.size(); i++) {
967 dates[i] = asof_ + parTenor[i];
968 atmVols[i] = parQuotes[i]->value();
969 times[i] = dc.yearFraction(asof_, dates[i]);
970 }
971
972 // QuantLib::ext::shared_ptr<BlackVolTermStructure> vol(new BlackVarianceCurve(asof_, dates, atmVols, dc));
973 QuantLib::ext::shared_ptr<BlackVolTermStructure> vol(new BlackVarianceCurve3(0, cal, bdc, dc, times, parQuotes));
974 vol->enableExtrapolation();
975 cdsVols_[make_pair(Market::defaultConfiguration, name)] = Handle<QuantExt::CreditVolCurve>(
976 QuantLib::ext::make_shared<QuantExt::CreditVolCurveWrapper>(Handle<BlackVolTermStructure>(vol)));
977}
978
979void TestMarketParCurves::createEquityVolCurve(const string& name, const string& ccy, const vector<Period>& parTenor,
980 const vector<Real>& parRates) {
982 vector<Handle<Quote>> parQuotes(parRates.size());
983 for (Size i = 0; i < parRates.size(); ++i)
984 parQuotes[i] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(parRates[i]));
986
987 DayCounter dc = Actual365Fixed();
988 // use calendat based on ccy, to align with sim market
989 Calendar cal = parseCalendar(ccy);
990 BusinessDayConvention bdc = Following;
991 vector<Date> dates(parQuotes.size());
992 vector<Time> times(parQuotes.size());
993
994 for (Size i = 0; i < parQuotes.size(); i++) {
995 dates[i] = cal.advance(asof_, parTenor[i]);
996 times[i] = dc.yearFraction(asof_, dates[i]);
997 }
998 QuantLib::ext::shared_ptr<BlackVolTermStructure> vol(new BlackVarianceCurve3(0, cal, bdc, dc, times, parQuotes));
999 vol->enableExtrapolation();
1000 equityVols_[make_pair(Market::defaultConfiguration, name)] = Handle<BlackVolTermStructure>(vol);
1001}
1002
1003void TestMarketParCurves::createBaseCorrel(const string& name, const vector<Period>& tenors,
1004 const vector<string>& lossLevel, const vector<Real> quotes) {
1005 Natural settlementDays = 0;
1006 Calendar calendar = TARGET();
1007 BusinessDayConvention bdc = Following;
1008 DayCounter dc = Actual365Fixed();
1009
1010 vector<Handle<Quote>> allQuotes(quotes.size());
1011 vector<vector<Handle<Quote>>> correls(quotes.size());
1012 for (Size i = 0; i < quotes.size(); i++) {
1013 Handle<Quote> sq(QuantLib::ext::make_shared<SimpleQuote>(quotes[i]));
1014 allQuotes[i] = sq;
1015 vector<Handle<Quote>> qt(tenors.size(), sq);
1016 correls[i] = qt;
1017 }
1018 baseCorrRateHelperTenorsMap_[name] = {1 * Days};
1020 baseCorrLossLevelsMap_[name] = lossLevel;
1021
1022 vector<Real> ll_quotes(lossLevel.size());
1023 for (Size j = 0; j < lossLevel.size(); j++) {
1024 ll_quotes[j] = parseReal(lossLevel[j]);
1025 }
1026 auto bcts =
1027 QuantLib::ext::make_shared<QuantExt::InterpolatedBaseCorrelationTermStructure<Bilinear>>(settlementDays, calendar, bdc, tenors, ll_quotes,
1028 correls, dc);
1029 bcts->enableExtrapolation(true);
1031 Handle<QuantExt::BaseCorrelationTermStructure>(bcts);
1032}
1033
1034void TestMarketParCurves::createSwaptionVolCurve(const string& name, const vector<Period>& optionTenors,
1035 const vector<Period>& swapTenors, const vector<Real>& strikeSpreads,
1036 const vector<Real>& parRates) {
1037 DayCounter dc = Actual365Fixed();
1038 Calendar cal = TARGET();
1039 BusinessDayConvention bdc = Following;
1040 swaptionVolRateHelperTenorsMap_[name] = optionTenors;
1042
1043 vector<vector<Handle<Quote>>> parQuotes(optionTenors.size(), vector<Handle<Quote>>(swapTenors.size()));
1044 vector<vector<Handle<Quote>>> cubeQuotes(optionTenors.size() * swapTenors.size(),
1045 vector<Handle<Quote>>(strikeSpreads.size(), Handle<Quote>()));
1046 vector<Handle<Quote>> allQuotes(parRates.size());
1047
1048 vector<vector<Real>> shift(optionTenors.size(), vector<Real>(swapTenors.size(), 0.0));
1049 for (Size i = 0; i < optionTenors.size(); ++i) {
1050 for (Size j = 0; j < swapTenors.size(); ++j) {
1051 for (Size k = 0; k < strikeSpreads.size(); ++k) {
1052 Size l = (i * swapTenors.size() * strikeSpreads.size()) + j * strikeSpreads.size() + k;
1053 Handle<Quote> quote = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(parRates[l]));
1054 if (close_enough(strikeSpreads[k], 0.0))
1055 parQuotes[i][j] = quote;
1056
1057 cubeQuotes[i * swapTenors.size() + j][k] = quote;
1058 allQuotes[l] = quote;
1059 }
1060 }
1061 }
1063 QuantLib::ext::shared_ptr<SwaptionVolatilityStructure> atm(new SwaptionVolatilityMatrix(
1064 asof_, cal, bdc, optionTenors, swapTenors, parQuotes, dc, true, QuantLib::Normal, shift));
1065
1066 Handle<SwaptionVolatilityStructure> hATM(atm);
1067 Handle<SwapIndex> si = swapIndex(swapIndexBase(name));
1068 Handle<SwapIndex> ssi = swapIndex(shortSwapIndexBase(name));
1069
1070 QuantLib::ext::shared_ptr<SwaptionVolatilityCube> tmp(new QuantExt::SwaptionVolCube2(
1071 hATM, optionTenors, swapTenors, strikeSpreads, cubeQuotes, *si, *ssi, false, true, false));
1072 tmp->enableExtrapolation();
1073
1074 Handle<SwaptionVolatilityStructure> svp =
1075 Handle<SwaptionVolatilityStructure>(QuantLib::ext::make_shared<SwaptionVolCubeWithATM>(tmp));
1076
1078}
1079
1080void TestMarketParCurves::createZeroInflationIndex(const string& idxName, const vector<string>& parInst,
1081 const vector<Period>& parTenor, const vector<Real>& parRates,
1082 bool singleCurve) {
1083 QuantLib::ext::shared_ptr<Conventions> conventions = InstrumentConventions::instance().conventions();
1084 zeroInflationRateHelperInstMap_[idxName] = parInst;
1085 zeroInflationRateHelperTenorsMap_[idxName] = parTenor;
1086
1087 vector<Handle<Quote>> parQuotes(parRates.size());
1088 for (Size i = 0; i < parRates.size(); ++i)
1089 parQuotes[i] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(parRates[i] / 100));
1090 zeroInflationRateHelperValuesMap_[idxName] = parQuotes;
1091
1092 QuantLib::ext::shared_ptr<ZeroInflationIndex> zii = parseZeroInflationIndex(idxName);
1093 string ccy = zii->currency().code();
1094 QuantLib::ext::shared_ptr<ore::data::InflationSwapConvention> conv =
1095 QuantLib::ext::dynamic_pointer_cast<ore::data::InflationSwapConvention>(conventions->get(idxName));
1096
1097 std::vector<QuantLib::ext::shared_ptr<ZeroInflationTraits::helper>> instruments;
1098 ;
1099 for (Size i = 0; i < parTenor.size(); i++) {
1100 instruments.push_back(QuantLib::ext::make_shared<ZeroCouponInflationSwapHelper>(
1101 parQuotes[i], conv->observationLag(), asof_ + parTenor[i], conv->infCalendar(), conv->infConvention(),
1102 conv->dayCounter(), zii, conv->interpolated() ? QuantLib::CPI::Linear : QuantLib::CPI::Flat,
1103 yieldCurve(YieldCurveType::Discount, ccy, Market::defaultConfiguration)));
1104 }
1105 QuantLib::ext::shared_ptr<ZeroInflationTermStructure> zeroCurve;
1106 Real baseRate = parQuotes[0]->value();
1107 zeroCurve = QuantLib::ext::shared_ptr<PiecewiseZeroInflationCurve<Linear>>(
1108 new PiecewiseZeroInflationCurve<Linear>(asof_, conv->infCalendar(), conv->dayCounter(), conv->observationLag(),
1109 zii->frequency(), baseRate, instruments));
1110 Handle<ZeroInflationTermStructure> its(zeroCurve);
1111 its->enableExtrapolation();
1112 QuantLib::ext::shared_ptr<ZeroInflationIndex> i =
1113 ore::data::parseZeroInflationIndex(idxName, Handle<ZeroInflationTermStructure>(its));
1114 Handle<ZeroInflationIndex> zh(i);
1115 zeroInflationIndices_[make_pair(Market::defaultConfiguration, idxName)] = zh;
1116}
1117
1118void TestMarketParCurves::createYoYInflationIndex(const string& idxName, const vector<string>& parInst,
1119 const vector<Period>& parTenor, const vector<Real>& parRates,
1120 bool singleCurve) {
1121 QuantLib::ext::shared_ptr<Conventions> conventions = InstrumentConventions::instance().conventions();
1122 yoyInflationRateHelperInstMap_[idxName] = parInst;
1123 yoyInflationRateHelperTenorsMap_[idxName] = parTenor;
1124
1125 vector<Handle<Quote>> parQuotes(parRates.size());
1126 for (Size i = 0; i < parRates.size(); ++i)
1127 parQuotes[i] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(parRates[i] / 100));
1128 yoyInflationRateHelperValuesMap_[idxName] = parQuotes;
1129
1130 QuantLib::ext::shared_ptr<ZeroInflationIndex> zii = parseZeroInflationIndex("UKRPI");
1131 QuantLib::ext::shared_ptr<YoYInflationIndex> yi = QuantLib::ext::make_shared<QuantExt::YoYInflationIndexWrapper>(zii, false);
1132 string ccy = zii->currency().code();
1133 QuantLib::ext::shared_ptr<ore::data::InflationSwapConvention> conv =
1134 QuantLib::ext::dynamic_pointer_cast<ore::data::InflationSwapConvention>(conventions->get(idxName));
1135
1136 std::vector<QuantLib::ext::shared_ptr<YoYInflationTraits::helper>> instruments;
1137 for (Size i = 0; i < parTenor.size(); i++) {
1138 instruments.push_back(QuantLib::ext::make_shared<YearOnYearInflationSwapHelper>(
1139 parQuotes[i], conv->observationLag(), asof_ + parTenor[i], conv->infCalendar(), conv->infConvention(),
1140 conv->dayCounter(), yi, yieldCurve(YieldCurveType::Discount, ccy, Market::defaultConfiguration)));
1141 }
1142 QuantLib::ext::shared_ptr<YoYInflationTermStructure> yoyCurve;
1143
1144 Real baseRate = parQuotes[0]->value();
1145 yoyCurve = QuantLib::ext::shared_ptr<PiecewiseYoYInflationCurve<Linear>>(
1146 new PiecewiseYoYInflationCurve<Linear>(asof_, conv->fixCalendar(), conv->dayCounter(), conv->observationLag(),
1147 yi->frequency(), conv->interpolated(), baseRate, instruments));
1148 yoyCurve->enableExtrapolation();
1149 Handle<YoYInflationTermStructure> its(yoyCurve);
1150 QuantLib::ext::shared_ptr<YoYInflationIndex> i(yi->clone(its));
1151 Handle<YoYInflationIndex> zh(i);
1152 yoyInflationIndices_[make_pair(Market::defaultConfiguration, idxName)] = zh;
1153}
1154
1155Handle<YieldTermStructure> TestMarketParCurves::flatRateYts(Real forward) {
1156 QuantLib::ext::shared_ptr<YieldTermStructure> yts(
1157 new FlatForward(Settings::instance().evaluationDate(), forward, ActualActual(ActualActual::ISDA)));
1158 return Handle<YieldTermStructure>(yts);
1159}
1160Handle<BlackVolTermStructure> TestMarketParCurves::flatRateFxv(Volatility forward) {
1161 QuantLib::ext::shared_ptr<BlackVolTermStructure> fxv(
1162 new BlackConstantVol(Settings::instance().evaluationDate(), NullCalendar(), forward, Actual365Fixed()));
1163 return Handle<BlackVolTermStructure>(fxv);
1164}
1165Handle<QuantLib::SwaptionVolatilityStructure> TestMarketParCurves::flatRateSvs(Volatility forward, VolatilityType type,
1166 Real shift) {
1167 QuantLib::ext::shared_ptr<QuantLib::SwaptionVolatilityStructure> svs(
1168 new QuantLib::ConstantSwaptionVolatility(Settings::instance().evaluationDate(), NullCalendar(),
1169 ModifiedFollowing, forward, ActualActual(ActualActual::ISDA), type, shift));
1170 return Handle<QuantLib::SwaptionVolatilityStructure>(svs);
1171}
1172Handle<DefaultProbabilityTermStructure> TestMarketParCurves::flatRateDcs(Volatility forward) {
1173 QuantLib::ext::shared_ptr<DefaultProbabilityTermStructure> dcs(new FlatHazardRate(asof_, forward, ActualActual(ActualActual::ISDA)));
1174 return Handle<DefaultProbabilityTermStructure>(dcs);
1175}
1176Handle<OptionletVolatilityStructure> TestMarketParCurves::flatRateCvs(Volatility vol, VolatilityType type, Real shift) {
1177 QuantLib::ext::shared_ptr<OptionletVolatilityStructure> ts(new QuantLib::ConstantOptionletVolatility(
1178 Settings::instance().evaluationDate(), NullCalendar(), ModifiedFollowing, vol, ActualActual(ActualActual::ISDA), type, shift));
1179 return Handle<OptionletVolatilityStructure>(ts);
1180}
1181
1183 QuantLib::ext::shared_ptr<Conventions> conventions = QuantLib::ext::make_shared<Conventions>();
1184
1185 // add conventions
1186 conventions->add(QuantLib::ext::make_shared<ore::data::SwapIndexConvention>("EUR-CMS-2Y", "EUR-6M-SWAP-CONVENTIONS"));
1187 conventions->add(QuantLib::ext::make_shared<ore::data::SwapIndexConvention>("EUR-CMS-30Y", "EUR-6M-SWAP-CONVENTIONS"));
1188 conventions->add(QuantLib::ext::make_shared<ore::data::SwapIndexConvention>("USD-CMS-1Y", "USD-3M-SWAP-CONVENTIONS"));
1189 conventions->add(QuantLib::ext::make_shared<ore::data::SwapIndexConvention>("USD-CMS-2Y", "USD-3M-SWAP-CONVENTIONS"));
1190 conventions->add(QuantLib::ext::make_shared<ore::data::SwapIndexConvention>("USD-CMS-30Y", "USD-3M-SWAP-CONVENTIONS"));
1191 conventions->add(QuantLib::ext::make_shared<ore::data::SwapIndexConvention>("GBP-CMS-2Y", "GBP-3M-SWAP-CONVENTIONS"));
1192 conventions->add(QuantLib::ext::make_shared<ore::data::SwapIndexConvention>("GBP-CMS-30Y", "GBP-6M-SWAP-CONVENTIONS"));
1193 conventions->add(QuantLib::ext::make_shared<ore::data::SwapIndexConvention>("CHF-CMS-2Y", "CHF-3M-SWAP-CONVENTIONS"));
1194 conventions->add(QuantLib::ext::make_shared<ore::data::SwapIndexConvention>("CHF-CMS-30Y", "CHF-6M-SWAP-CONVENTIONS"));
1195 conventions->add(QuantLib::ext::make_shared<ore::data::SwapIndexConvention>("JPY-CMS-1Y", "JPY-LIBOR-6M-SWAP-CONVENTIONS"));
1196 conventions->add(QuantLib::ext::make_shared<ore::data::SwapIndexConvention>("JPY-CMS-2Y", "JPY-LIBOR-6M-SWAP-CONVENTIONS"));
1197 conventions->add(QuantLib::ext::make_shared<ore::data::SwapIndexConvention>("JPY-CMS-30Y", "JPY-LIBOR-6M-SWAP-CONVENTIONS"));
1198
1199 conventions->add(QuantLib::ext::make_shared<ore::data::IRSwapConvention>("EUR-6M-SWAP-CONVENTIONS", "TARGET", "Annual", "MF", "30/360", "EUR-EURIBOR-6M"));
1200 conventions->add(QuantLib::ext::make_shared<ore::data::IRSwapConvention>("USD-3M-SWAP-CONVENTIONS", "US", "Semiannual", "MF", "30/360", "USD-LIBOR-3M"));
1201 conventions->add(QuantLib::ext::make_shared<ore::data::IRSwapConvention>("GBP-3M-SWAP-CONVENTIONS", "UK", "Semiannual", "MF", "A365", "GBP-LIBOR-3M"));
1202 conventions->add(QuantLib::ext::make_shared<ore::data::IRSwapConvention>("GBP-6M-SWAP-CONVENTIONS", "UK", "Semiannual", "MF", "A365", "GBP-LIBOR-6M"));
1203 conventions->add(QuantLib::ext::make_shared<ore::data::IRSwapConvention>("CHF-3M-SWAP-CONVENTIONS", "TARGET", "Annual", "MF", "30/360", "CHF-LIBOR-3M"));
1204 conventions->add(QuantLib::ext::make_shared<ore::data::IRSwapConvention>("CHF-6M-SWAP-CONVENTIONS", "TARGET", "Annual", "MF", "30/360", "CHF-LIBOR-6M"));
1205 conventions->add(QuantLib::ext::make_shared<ore::data::IRSwapConvention>("JPY-LIBOR-6M-SWAP-CONVENTIONS", "JP", "Semiannual", "MF", "A365", "JPY-LIBOR-6M"));
1206 conventions->add(QuantLib::ext::make_shared<ore::data::IRSwapConvention>("JPY-6M-SWAP-CONVENTIONS", "JP", "S", "MF", "ACT", "JPY-LIBOR-6M"));
1207 conventions->add(QuantLib::ext::make_shared<ore::data::IRSwapConvention>("USD-6M-SWAP-CONVENTIONS", "US", "S", "MF", "30/360", "USD-LIBOR-6M"));
1208
1209 conventions->add(QuantLib::ext::make_shared<ore::data::DepositConvention>("EUR-DEP-CONVENTIONS", "EUR-EURIBOR"));
1210 conventions->add(QuantLib::ext::make_shared<ore::data::DepositConvention>("USD-DEP-CONVENTIONS", "USD-LIBOR"));
1211 conventions->add(QuantLib::ext::make_shared<ore::data::DepositConvention>("GBP-DEP-CONVENTIONS", "GBP-LIBOR"));
1212 conventions->add(QuantLib::ext::make_shared<ore::data::DepositConvention>("JPY-DEP-CONVENTIONS", "JPY-LIBOR"));
1213 conventions->add(QuantLib::ext::make_shared<ore::data::DepositConvention>("CHF-DEP-CONVENTIONS", "CHF-LIBOR"));
1214
1215 conventions->add(QuantLib::ext::make_shared<ore::data::FraConvention>("EUR-FRA-CONVENTIONS", "EUR-EURIBOR-6M"));
1216 conventions->add(QuantLib::ext::make_shared<ore::data::FraConvention>("USD-FRA-CONVENTIONS", "USD-LIBOR-6M"));
1217 conventions->add(QuantLib::ext::make_shared<ore::data::FraConvention>("GBP-FRA-CONVENTIONS", "GBP-LIBOR-6M"));
1218 conventions->add(QuantLib::ext::make_shared<ore::data::FraConvention>("JPY-FRA-CONVENTIONS", "JPY-LIBOR-6M"));
1219 conventions->add(QuantLib::ext::make_shared<ore::data::FraConvention>("CHF-FRA-CONVENTIONS", "CHF-LIBOR-6M"));
1220
1221 conventions->add(QuantLib::ext::make_shared<FXConvention>("EUR-USD-FX", "0", "EUR", "USD", "10000", "EUR,USD"));
1222 conventions->add(QuantLib::ext::make_shared<FXConvention>("EUR-GBP-FX", "0", "EUR", "GBP", "10000", "EUR,GBP"));
1223 conventions->add(QuantLib::ext::make_shared<FXConvention>("EUR-CHF-FX", "0", "EUR", "CHF", "10000", "EUR,CHF"));
1224 conventions->add(QuantLib::ext::make_shared<FXConvention>("EUR-JPY-FX", "0", "EUR", "JPY", "10000", "EUR,JPY"));
1225
1226 conventions->add(QuantLib::ext::make_shared<ore::data::FXConvention>("CHF-FX-CONVENTIONS", "0", "CHF", "EUR", "10000",
1227 "CHF,EUR", "true"));
1228
1229 conventions->add(QuantLib::ext::make_shared<ore::data::OisConvention>(
1230 "JPY-OIS-CONVENTIONS", "2", "JPY-TONAR", "ACT/365", "JPY", "1", "false", "Annual", "MF", "MF", "Backward"));
1231
1232 conventions->add(QuantLib::ext::make_shared<ore::data::CdsConvention>(
1233 "CDS-STANDARD-CONVENTIONS", "0", "WeekendsOnly", "Quarterly", "Following", "CDS2015", "A360", "true", "true"));
1234
1235 conventions->add(QuantLib::ext::make_shared<ore::data::CrossCcyBasisSwapConvention>(
1236 "CHF-XCCY-BASIS-CONVENTIONS", "2", "CHF,EUR", "MF", "EUR-EURIBOR-6M", "CHF-LIBOR-6M", "false"));
1237
1238 conventions->add(QuantLib::ext::make_shared<ore::data::InflationSwapConvention>("UKRPI", "UK", "MF", "A365", "UKRPI",
1239 "false", "3M", "false", "UK", "MF"));
1240 conventions->add(QuantLib::ext::make_shared<ore::data::InflationSwapConvention>("UKRP1", "UK", "MF", "A365", "UKRPI",
1241 "false", "3M", "false", "UK", "MF"));
1242 InstrumentConventions::instance().setConventions(conventions);
1243}
1244
1245QuantLib::ext::shared_ptr<ore::analytics::ScenarioSimMarketParameters>
1246TestConfigurationObjects::setupSimMarketData(bool hasSwapVolCube, bool hasYYCapVols) {
1247 QuantLib::ext::shared_ptr<ore::analytics::ScenarioSimMarketParameters> simMarketData(
1249
1250 simMarketData->baseCcy() = "EUR";
1251 simMarketData->setDiscountCurveNames({"EUR", "GBP", "USD", "CHF", "JPY"});
1252 simMarketData->setYieldCurveTenors("",
1253 {2 * Weeks, 1 * Months, 3 * Months, 6 * Months, 1 * Years, 2 * Years, 3 * Years,
1254 5 * Years, 10 * Years, 13 * Years, 15 * Years, 20 * Years, 30 * Years});
1255 simMarketData->setIndices({"EUR-EURIBOR-2W", "EUR-EURIBOR-1M", "EUR-EURIBOR-3M", "EUR-EURIBOR-6M", "USD-LIBOR-2W",
1256 "USD-LIBOR-1M", "USD-LIBOR-3M", "USD-LIBOR-6M", "GBP-LIBOR-2W", "GBP-LIBOR-1M",
1257 "GBP-LIBOR-3M", "GBP-LIBOR-6M", "CHF-LIBOR-6M", "JPY-LIBOR-2W", "JPY-LIBOR-1M",
1258 "JPY-LIBOR-3M", "JPY-LIBOR-6M", "JPY-TONAR"});
1259 simMarketData->interpolation() = "LogLinear";
1260 simMarketData->swapIndices()["EUR-CMS-2Y"] = "EUR-EURIBOR-6M";
1261 simMarketData->swapIndices()["EUR-CMS-30Y"] = "EUR-EURIBOR-6M";
1262
1263 simMarketData->setSwapVolTerms("", {1 * Years, 2 * Years, 3 * Years, 4 * Years, 5 * Years, 7 * Years, 10 * Years,
1264 15 * Years, 20 * Years, 30 * Years});
1265 simMarketData->setSwapVolExpiries("",
1266 {2 * Weeks, 1 * Months, 3 * Months, 6 * Months, 1 * Years, 2 * Years, 3 * Years,
1267 5 * Years, 10 * Years, 13 * Years, 15 * Years, 20 * Years, 30 * Years});
1268 simMarketData->setSwapVolKeys({"EUR", "GBP", "USD", "CHF", "JPY"});
1269 simMarketData->swapVolDecayMode() = "ForwardVariance";
1270 simMarketData->setSimulateSwapVols(true); // false;
1271 if (hasSwapVolCube) {
1272 simMarketData->setSwapVolIsCube("", true);
1273 simMarketData->simulateSwapVolATMOnly() = false;
1274 simMarketData->setSwapVolStrikeSpreads("", {-0.02, -0.005, 0.0, 0.005, 0.02});
1275 }
1276
1277 simMarketData->setFxVolExpiries("",
1278 vector<Period>{1 * Months, 3 * Months, 6 * Months, 2 * Years, 3 * Years, 4 * Years, 5 * Years});
1279 simMarketData->setFxVolDecayMode(string("ConstantVariance"));
1280 simMarketData->setSimulateFXVols(true); // false;
1281 simMarketData->setFxVolCcyPairs({"EURUSD", "EURGBP", "EURCHF", "EURJPY"});
1282 simMarketData->setFxVolIsSurface(true);
1283 simMarketData->setFxVolMoneyness(vector<Real>{0.1, 0.5, 1, 1.5, 2, 2.5, 3});
1284 simMarketData->setFxCcyPairs({"EURUSD", "EURGBP", "EURCHF", "EURJPY"});
1285
1286 simMarketData->setSimulateCapFloorVols(true);
1287 simMarketData->capFloorVolDecayMode() = "ForwardVariance";
1288 simMarketData->setCapFloorVolKeys({"EUR", "USD"});
1289 simMarketData->setCapFloorVolExpiries(
1290 "", {6 * Months, 1 * Years, 2 * Years, 3 * Years, 5 * Years, 7 * Years, 10 * Years, 15 * Years, 20 * Years});
1291 simMarketData->setCapFloorVolStrikes("", {0.00, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06});
1292
1293 simMarketData->setDefaultNames({"dc", "dc2", "dc3"});
1294 simMarketData->setDefaultTenors("", {3 * Months, 6 * Months, 1 * Years, 2 * Years, 3 * Years, 5 * Years, 10 * Years,
1295 13 * Years, 15 * Years, 20 * Years});
1296 simMarketData->setSimulateSurvivalProbabilities(true);
1297 simMarketData->setSimulateRecoveryRates(false);
1298 simMarketData->setDefaultCurveCalendars("", "TARGET");
1299
1300 simMarketData->setSimulateCdsVols(true);
1301 simMarketData->cdsVolExpiries() = {6 * Months, 1 * Years, 2 * Years, 5 * Years, 10 * Years};
1302 simMarketData->cdsVolDecayMode() = "ForwardVariance";
1303 simMarketData->setCdsVolNames({"dc", "dc2", "dc3"});
1304
1305 simMarketData->setEquityNames({"SP5", "Lufthansa"});
1306 simMarketData->setEquityDividendTenors("SP5", {6 * Months, 1 * Years, 2 * Years});
1307 simMarketData->setEquityDividendTenors("Lufthansa", {6 * Months, 1 * Years, 2 * Years});
1308
1309 simMarketData->setSimulateEquityVols(true);
1310 simMarketData->setEquityVolDecayMode("ForwardVariance");
1311 simMarketData->setEquityVolNames({"SP5", "Lufthansa"});
1312 simMarketData->setEquityVolExpiries("",
1313 {2 * Weeks, 1 * Months, 3 * Months, 6 * Months, 1 * Years, 2 * Years, 3 * Years,
1314 5 * Years, 10 * Years, 13 * Years, 15 * Years, 20 * Years, 30 * Years});
1315 simMarketData->setEquityVolIsSurface("", true);
1316 simMarketData->setEquityVolMoneyness(
1317 "", {0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 1.0, 1.05, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.5, 3.0});
1318
1319 simMarketData->setSimulateBaseCorrelations(true);
1320 simMarketData->setBaseCorrelationNames({"Tranch1"});
1321 simMarketData->baseCorrelationDetachmentPoints() = {0.03, 0.06, 0.09, 0.12, 0.22, 1.0};
1322 simMarketData->baseCorrelationTerms() = {1 * Days};
1323
1324 simMarketData->setZeroInflationIndices({"UKRPI"});
1325 simMarketData->setZeroInflationTenors("UKRPI", {6 * Months, 1 * Years, 2 * Years, 3 * Years, 5 * Years, 7 * Years,
1326 10 * Years, 15 * Years, 20 * Years});
1327
1328 simMarketData->setYoyInflationIndices({"UKRPI"});
1329 simMarketData->setYoyInflationTenors(
1330 "UKRPI", {1 * Years, 2 * Years, 3 * Years, 5 * Years, 7 * Years, 10 * Years, 15 * Years, 20 * Years});
1331
1332 if (hasYYCapVols) {
1333 simMarketData->setSimulateYoYInflationCapFloorVols(true);
1334 simMarketData->setYoYInflationCapFloorVolNames({"UKRPI"});
1335 simMarketData->setYoYInflationCapFloorVolExpiries(
1336 "UKRPI", {1 * Years, 2 * Years, 3 * Years, 5 * Years, 7 * Years, 10 * Years, 15 * Years, 20 * Years});
1337 simMarketData->setYoYInflationCapFloorVolStrikes("", {-0.02, -0.01, 0.00, 0.01, 0.02, 0.03});
1338 simMarketData->yoyInflationCapFloorVolDecayMode() = "ForwardVariance";
1339 }
1340
1341 return simMarketData;
1342}
1343
1346
1347 cvsData.shiftTenors = {2 * Weeks, 1 * Months, 3 * Months, 6 * Months, 1 * Years, 2 * Years, 3 * Years,
1348 5 * Years, 10 * Years, 13 * Years, 15 * Years, 20 * Years, 30 * Years};
1349 cvsData.shiftType = ShiftType::Absolute;
1350 cvsData.shiftSize = 0.00001;
1351 cvsData.parInstruments = {"DEP", "DEP", "DEP", "DEP", "FRA", "IRS", "IRS",
1352 "IRS", "IRS", "IRS", "IRS", "IRS", "IRS"};
1353
1354 return cvsData;
1355}
1356
1357QuantLib::ext::shared_ptr<ore::analytics::SensitivityScenarioData>
1358TestConfigurationObjects::setupSensitivityScenarioData(bool hasSwapVolCube, bool hasYYCapVols, bool parConversion) {
1359 QuantLib::ext::shared_ptr<ore::analytics::SensitivityScenarioData> sensiData =
1360 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData>(parConversion);
1361 vector<string> oisInstruments = {"OIS", "OIS", "OIS", "OIS", "OIS", "OIS", "OIS",
1362 "OIS", "OIS", "OIS", "OIS", "OIS", "OIS"};
1363 vector<string> xbsInstruments = {"FXF", "FXF", "FXF", "FXF", "FXF", "XBS", "XBS",
1364 "XBS", "XBS", "XBS", "XBS", "XBS", "XBS"};
1365
1367 fxsData.shiftType = ShiftType::Relative;
1368 fxsData.shiftSize = 0.001;
1369
1371 fxvsData.shiftType = ShiftType::Relative;
1372 fxvsData.shiftSize = 0.1;
1373 fxvsData.shiftExpiries = {5 * Years};
1374
1376 cfvsData.shiftType = ShiftType::Absolute;
1377 cfvsData.shiftSize = 0.00001;
1378 cfvsData.shiftExpiries = {1 * Years, 2 * Years, 3 * Years, 5 * Years, 10 * Years};
1379 cfvsData.shiftStrikes = {0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.10};
1380
1382 swvsData.shiftType = ShiftType::Relative;
1383 swvsData.shiftSize = 0.001;
1384 swvsData.shiftExpiries = {2 * Weeks, 1 * Months, 3 * Months, 6 * Months, 1 * Years, 2 * Years, 3 * Years,
1385 5 * Years, 10 * Years, 13 * Years, 15 * Years, 20 * Years, 30 * Years};
1386 swvsData.shiftTerms = {1 * Years, 2 * Years, 3 * Years, 4 * Years, 5 * Years,
1387 7 * Years, 10 * Years, 15 * Years, 20 * Years, 30 * Years};
1388 if (hasSwapVolCube)
1389 swvsData.shiftStrikes = {-0.02, -0.005, 0.0, 0.005, 0.02};
1390
1392 cdsvsData.shiftType = ShiftType::Relative;
1393 cdsvsData.shiftSize = 0.01;
1394 cdsvsData.shiftExpiries = {6 * Months, 1 * Years, 2 * Years, 5 * Years, 10 * Years};
1395
1397 eqsData.shiftType = ShiftType::Relative;
1398 eqsData.shiftSize = 0.01;
1399
1401 eqvsData.shiftType = ShiftType::Relative;
1402 eqvsData.shiftSize = 0.01;
1403 eqvsData.shiftExpiries = {2 * Weeks, 1 * Months, 3 * Months, 6 * Months, 1 * Years, 2 * Years, 3 * Years,
1404 5 * Years, 10 * Years, 13 * Years, 15 * Years, 20 * Years, 30 * Years};
1405
1406 QuantLib::ext::shared_ptr<ore::analytics::SensitivityScenarioData::CurveShiftData> eqdivData =
1407 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>();
1408 eqdivData->shiftType = ShiftType::Absolute;
1409 eqdivData->shiftSize = 0.00001;
1410 eqdivData->shiftTenors = {6 * Months, 1 * Years, 2 * Years};
1411
1413 bcorrData.shiftType = ShiftType::Absolute;
1414 bcorrData.shiftSize = 0.01;
1415 bcorrData.shiftLossLevels = {0.03, 0.06, 0.09, 0.12, 0.22, 1.0};
1416 bcorrData.shiftTerms = {1 * Days};
1417
1418 QuantLib::ext::shared_ptr<ore::analytics::SensitivityScenarioData::CurveShiftParData> zinfData =
1419 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>();
1420 zinfData->shiftType = ShiftType::Absolute;
1421 zinfData->shiftSize = 0.0001;
1422 zinfData->shiftTenors = {6 * Months, 1 * Years, 2 * Years, 3 * Years, 5 * Years,
1423 7 * Years, 10 * Years, 15 * Years, 20 * Years};
1424 zinfData->parInstruments = {"ZIS", "ZIS", "ZIS", "ZIS", "ZIS", "ZIS", "ZIS", "ZIS", "ZIS"};
1425 zinfData->parInstrumentConventions["ZIS"] = "UKRPI";
1426
1427 QuantLib::ext::shared_ptr<ore::analytics::SensitivityScenarioData::CurveShiftParData> yinfData =
1428 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>();
1429 yinfData->shiftType = ShiftType::Absolute;
1430 yinfData->shiftSize = 0.0001;
1431 yinfData->shiftTenors = {1 * Years, 2 * Years, 3 * Years, 5 * Years, 7 * Years, 10 * Years, 15 * Years, 20 * Years};
1432 yinfData->parInstruments = {"YYS", "YYS", "YYS", "YYS", "YYS", "YYS", "YYS", "YYS"};
1433 yinfData->parInstrumentConventions["ZIS"] = "UKRPI";
1434 yinfData->parInstrumentConventions["YYS"] = "UKRPI";
1435
1436 auto yinfCfData = QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CapFloorVolShiftParData>();
1437 yinfCfData->shiftType = ShiftType::Absolute;
1438 yinfCfData->shiftSize = 0.00001;
1439 yinfCfData->shiftExpiries = {1 * Years, 2 * Years, 3 * Years, 5 * Years,
1440 7 * Years, 10 * Years, 15 * Years, 20 * Years};
1441 yinfCfData->shiftStrikes = {-0.02, -0.01, 0.00, 0.01, 0.02, 0.03};
1442 yinfCfData->parInstruments = {"YYS", "YYS", "YYS", "YYS", "YYS", "YYS", "YYS", "YYS"};
1443 yinfCfData->parInstrumentSingleCurve = false;
1444 yinfCfData->parInstrumentConventions["ZIS"] = "UKRPI";
1445 yinfCfData->parInstrumentConventions["YYS"] = "UKRPI";
1446
1447 {
1449 cvsData.parInstrumentSingleCurve = true;
1450 cvsData.parInstrumentConventions["DEP"] = "EUR-DEP-CONVENTIONS";
1451 cvsData.parInstrumentConventions["FRA"] = "EUR-FRA-CONVENTIONS";
1452 cvsData.parInstrumentConventions["IRS"] = "EUR-6M-SWAP-CONVENTIONS";
1453 sensiData->discountCurveShiftData()["EUR"] =
1454 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1455 }
1456
1457 {
1459 cvsData.parInstrumentSingleCurve = true;
1460 cvsData.parInstrumentConventions["DEP"] = "USD-DEP-CONVENTIONS";
1461 cvsData.parInstrumentConventions["FRA"] = "USD-FRA-CONVENTIONS";
1462 cvsData.parInstrumentConventions["IRS"] = "USD-3M-SWAP-CONVENTIONS";
1463 sensiData->discountCurveShiftData()["USD"] =
1464 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1465 }
1466
1467 {
1469 cvsData.parInstrumentSingleCurve = true;
1470 cvsData.parInstrumentConventions["DEP"] = "GBP-DEP-CONVENTIONS";
1471 cvsData.parInstrumentConventions["FRA"] = "GBP-FRA-CONVENTIONS";
1472 cvsData.parInstrumentConventions["IRS"] = "GBP-6M-SWAP-CONVENTIONS";
1473 sensiData->discountCurveShiftData()["GBP"] =
1474 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1475 }
1476
1477 {
1479 cvsData.parInstrumentSingleCurve = true;
1480 cvsData.parInstrumentConventions["DEP"] = "JPY-DEP-CONVENTIONS";
1481 cvsData.parInstrumentConventions["FRA"] = "JPY-FRA-CONVENTIONS";
1482 cvsData.parInstrumentConventions["IRS"] = "JPY-6M-SWAP-CONVENTIONS";
1483 cvsData.parInstrumentConventions["OIS"] = "JPY-OIS-CONVENTIONS";
1484 cvsData.parInstruments = oisInstruments; // aligned with market setup
1485 sensiData->discountCurveShiftData()["JPY"] =
1486 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1487 }
1488 {
1490 cvsData.parInstrumentSingleCurve = true;
1491 cvsData.parInstrumentConventions["DEP"] = "CHF-DEP-CONVENTIONS";
1492 cvsData.parInstrumentConventions["FRA"] = "CHF-FRA-CONVENTIONS";
1493 cvsData.parInstrumentConventions["IRS"] = "CHF-6M-SWAP-CONVENTIONS";
1494 cvsData.parInstrumentConventions["FXF"] = "CHF-FX-CONVENTIONS";
1495 cvsData.parInstrumentConventions["XBS"] = "CHF-XCCY-BASIS-CONVENTIONS";
1496 cvsData.parInstruments = xbsInstruments; // aligned with market setup
1497 sensiData->discountCurveShiftData()["CHF"] =
1498 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1499 }
1500 {
1502 cvsData.parInstrumentSingleCurve = false;
1503 cvsData.parInstrumentConventions["DEP"] = "EUR-DEP-CONVENTIONS";
1504 cvsData.parInstrumentConventions["FRA"] = "EUR-FRA-CONVENTIONS";
1505 cvsData.parInstrumentConventions["IRS"] = "EUR-6M-SWAP-CONVENTIONS";
1506 sensiData->indexCurveShiftData()["EUR-EURIBOR-2W"] =
1507 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1508 }
1509 {
1511 cvsData.parInstrumentSingleCurve = false;
1512 cvsData.parInstrumentConventions["DEP"] = "EUR-DEP-CONVENTIONS";
1513 cvsData.parInstrumentConventions["FRA"] = "EUR-FRA-CONVENTIONS";
1514 cvsData.parInstrumentConventions["IRS"] = "EUR-6M-SWAP-CONVENTIONS";
1515 sensiData->indexCurveShiftData()["EUR-EURIBOR-1M"] =
1516 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1517 }
1518 {
1520 cvsData.parInstrumentSingleCurve = false;
1521 cvsData.parInstrumentConventions["DEP"] = "EUR-DEP-CONVENTIONS";
1522 cvsData.parInstrumentConventions["FRA"] = "EUR-FRA-CONVENTIONS";
1523 cvsData.parInstrumentConventions["IRS"] = "EUR-6M-SWAP-CONVENTIONS";
1524 sensiData->indexCurveShiftData()["EUR-EURIBOR-3M"] =
1525 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1526 }
1527 {
1529 cvsData.parInstrumentSingleCurve = false;
1530 cvsData.parInstrumentConventions["DEP"] = "EUR-DEP-CONVENTIONS";
1531 cvsData.parInstrumentConventions["FRA"] = "EUR-FRA-CONVENTIONS";
1532 cvsData.parInstrumentConventions["IRS"] = "EUR-6M-SWAP-CONVENTIONS";
1533 sensiData->indexCurveShiftData()["EUR-EURIBOR-6M"] =
1534 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1535 }
1536 {
1538 cvsData.parInstrumentSingleCurve = false;
1539 cvsData.parInstrumentConventions["DEP"] = "USD-DEP-CONVENTIONS";
1540 cvsData.parInstrumentConventions["FRA"] = "USD-FRA-CONVENTIONS";
1541 cvsData.parInstrumentConventions["IRS"] = "USD-6M-SWAP-CONVENTIONS";
1542 sensiData->indexCurveShiftData()["USD-LIBOR-2W"] =
1543 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1544 }
1545 {
1547 cvsData.parInstrumentSingleCurve = false;
1548 cvsData.parInstrumentConventions["DEP"] = "USD-DEP-CONVENTIONS";
1549 cvsData.parInstrumentConventions["FRA"] = "USD-FRA-CONVENTIONS";
1550 cvsData.parInstrumentConventions["IRS"] = "USD-6M-SWAP-CONVENTIONS";
1551 sensiData->indexCurveShiftData()["USD-LIBOR-1M"] =
1552 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1553 }
1554 {
1556 cvsData.parInstrumentSingleCurve = false;
1557 cvsData.parInstrumentConventions["DEP"] = "USD-DEP-CONVENTIONS";
1558 cvsData.parInstrumentConventions["FRA"] = "USD-FRA-CONVENTIONS";
1559 cvsData.parInstrumentConventions["IRS"] = "USD-6M-SWAP-CONVENTIONS";
1560 sensiData->indexCurveShiftData()["USD-LIBOR-3M"] =
1561 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1562 }
1563 {
1565 cvsData.parInstrumentSingleCurve = false;
1566 cvsData.parInstrumentConventions["DEP"] = "USD-DEP-CONVENTIONS";
1567 cvsData.parInstrumentConventions["FRA"] = "USD-FRA-CONVENTIONS";
1568 cvsData.parInstrumentConventions["IRS"] = "USD-6M-SWAP-CONVENTIONS";
1569 sensiData->indexCurveShiftData()["USD-LIBOR-6M"] =
1570 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1571 }
1572 {
1574 cvsData.parInstrumentSingleCurve = false;
1575 cvsData.parInstrumentConventions["DEP"] = "GBP-DEP-CONVENTIONS";
1576 cvsData.parInstrumentConventions["FRA"] = "GBP-FRA-CONVENTIONS";
1577 cvsData.parInstrumentConventions["IRS"] = "GBP-6M-SWAP-CONVENTIONS";
1578 sensiData->indexCurveShiftData()["GBP-LIBOR-2W"] =
1579 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1580 }
1581 {
1583 cvsData.parInstrumentSingleCurve = false;
1584 cvsData.parInstrumentConventions["DEP"] = "GBP-DEP-CONVENTIONS";
1585 cvsData.parInstrumentConventions["FRA"] = "GBP-FRA-CONVENTIONS";
1586 cvsData.parInstrumentConventions["IRS"] = "GBP-6M-SWAP-CONVENTIONS";
1587 sensiData->indexCurveShiftData()["GBP-LIBOR-1M"] =
1588 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1589 }
1590 {
1592 cvsData.parInstrumentSingleCurve = false;
1593 cvsData.parInstrumentConventions["DEP"] = "GBP-DEP-CONVENTIONS";
1594 cvsData.parInstrumentConventions["FRA"] = "GBP-FRA-CONVENTIONS";
1595 cvsData.parInstrumentConventions["IRS"] = "GBP-6M-SWAP-CONVENTIONS";
1596 sensiData->indexCurveShiftData()["GBP-LIBOR-3M"] =
1597 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1598 }
1599 {
1601 cvsData.parInstrumentSingleCurve = false;
1602 cvsData.parInstrumentConventions["DEP"] = "GBP-DEP-CONVENTIONS";
1603 cvsData.parInstrumentConventions["FRA"] = "GBP-FRA-CONVENTIONS";
1604 cvsData.parInstrumentConventions["IRS"] = "GBP-6M-SWAP-CONVENTIONS";
1605 sensiData->indexCurveShiftData()["GBP-LIBOR-6M"] =
1606 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1607 }
1608 {
1610 cvsData.parInstrumentSingleCurve = false;
1611 cvsData.parInstrumentConventions["DEP"] = "JPY-DEP-CONVENTIONS";
1612 cvsData.parInstrumentConventions["FRA"] = "JPY-FRA-CONVENTIONS";
1613 cvsData.parInstrumentConventions["IRS"] = "JPY-6M-SWAP-CONVENTIONS";
1614 cvsData.parInstrumentConventions["OIS"] = "JPY-OIS-CONVENTIONS";
1615 sensiData->indexCurveShiftData()["JPY-TONAR"] =
1616 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1617 }
1618 {
1620 cvsData.parInstrumentSingleCurve = false;
1621 cvsData.parInstrumentConventions["DEP"] = "JPY-DEP-CONVENTIONS";
1622 cvsData.parInstrumentConventions["FRA"] = "JPY-FRA-CONVENTIONS";
1623 cvsData.parInstrumentConventions["IRS"] = "JPY-6M-SWAP-CONVENTIONS";
1624 cvsData.parInstrumentConventions["OIS"] = "JPY-OIS-CONVENTIONS";
1625 sensiData->indexCurveShiftData()["JPY-LIBOR-2W"] =
1626 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1627 }
1628 {
1630 cvsData.parInstrumentSingleCurve = false;
1631 cvsData.parInstrumentConventions["DEP"] = "JPY-DEP-CONVENTIONS";
1632 cvsData.parInstrumentConventions["FRA"] = "JPY-FRA-CONVENTIONS";
1633 cvsData.parInstrumentConventions["IRS"] = "JPY-6M-SWAP-CONVENTIONS";
1634 cvsData.parInstrumentConventions["OIS"] = "JPY-OIS-CONVENTIONS";
1635 sensiData->indexCurveShiftData()["JPY-LIBOR-1M"] =
1636 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1637 }
1638 {
1640 cvsData.parInstrumentSingleCurve = false;
1641 cvsData.parInstrumentConventions["DEP"] = "JPY-DEP-CONVENTIONS";
1642 cvsData.parInstrumentConventions["FRA"] = "JPY-FRA-CONVENTIONS";
1643 cvsData.parInstrumentConventions["IRS"] = "JPY-6M-SWAP-CONVENTIONS";
1644 cvsData.parInstrumentConventions["OIS"] = "JPY-OIS-CONVENTIONS";
1645 sensiData->indexCurveShiftData()["JPY-LIBOR-3M"] =
1646 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1647 }
1648 {
1650 cvsData.parInstrumentSingleCurve = false;
1651 cvsData.parInstrumentConventions["DEP"] = "JPY-DEP-CONVENTIONS";
1652 cvsData.parInstrumentConventions["FRA"] = "JPY-FRA-CONVENTIONS";
1653 cvsData.parInstrumentConventions["IRS"] = "JPY-6M-SWAP-CONVENTIONS";
1654 cvsData.parInstrumentConventions["OIS"] = "JPY-OIS-CONVENTIONS";
1655 sensiData->indexCurveShiftData()["JPY-LIBOR-6M"] =
1656 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1657 }
1658 {
1660 cvsData.parInstrumentSingleCurve = true;
1661 cvsData.parInstrumentConventions["DEP"] = "CHF-DEP-CONVENTIONS";
1662 cvsData.parInstrumentConventions["FRA"] = "CHF-FRA-CONVENTIONS";
1663 cvsData.parInstrumentConventions["IRS"] = "CHF-6M-SWAP-CONVENTIONS";
1664 cvsData.parInstrumentConventions["FXF"] = "CHF-FX-CONVENTIONS";
1665 cvsData.parInstrumentConventions["XBS"] = "CHF-XCCY-BASIS-CONVENTIONS";
1666 sensiData->indexCurveShiftData()["CHF-LIBOR-6M"] =
1667 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1668 }
1669 sensiData->fxShiftData()["EURUSD"] = fxsData;
1670 sensiData->fxShiftData()["EURGBP"] = fxsData;
1671 sensiData->fxShiftData()["EURJPY"] = fxsData;
1672 sensiData->fxShiftData()["EURCHF"] = fxsData;
1673
1674 sensiData->fxVolShiftData()["EURUSD"] = fxvsData;
1675 sensiData->fxVolShiftData()["EURGBP"] = fxvsData;
1676 sensiData->fxVolShiftData()["EURJPY"] = fxvsData;
1677 sensiData->fxVolShiftData()["EURCHF"] = fxvsData;
1678
1679 sensiData->swaptionVolShiftData()["EUR"] = swvsData;
1680 sensiData->swaptionVolShiftData()["GBP"] = swvsData;
1681 sensiData->swaptionVolShiftData()["USD"] = swvsData;
1682 sensiData->swaptionVolShiftData()["JPY"] = swvsData;
1683 sensiData->swaptionVolShiftData()["CHF"] = swvsData;
1684
1685 sensiData->capFloorVolShiftData()["EUR"] =
1686 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CapFloorVolShiftData>(cfvsData);
1687 sensiData->capFloorVolShiftData()["EUR"]->indexName = "EUR-EURIBOR-6M";
1688 sensiData->capFloorVolShiftData()["USD"] =
1689 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CapFloorVolShiftData>(cfvsData);
1690 sensiData->capFloorVolShiftData()["USD"]->indexName = "USD-LIBOR-6M";
1691
1692 sensiData->creditCcys()["dc"] = "USD";
1693 sensiData->creditCcys()["dc2"] = "EUR";
1694 sensiData->creditCcys()["dc3"] = "GBP";
1695 {
1697 cvsData.shiftTenors = {3 * Months, 6 * Months, 1 * Years, 2 * Years, 3 * Years,
1698 5 * Years, 10 * Years, 13 * Years, 15 * Years, 20 * Years};
1699 cvsData.parInstruments = {"CDS", "CDS", "CDS", "CDS", "CDS", "CDS", "CDS", "CDS", "CDS", "CDS"};
1700 cvsData.parInstrumentConventions["CDS"] = "CDS-STANDARD-CONVENTIONS";
1701 sensiData->creditCurveShiftData()["dc"] =
1702 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1703 }
1704 {
1706 cvsData.shiftTenors = {3 * Months, 6 * Months, 1 * Years, 2 * Years, 3 * Years,
1707 5 * Years, 10 * Years, 13 * Years, 15 * Years, 20 * Years};
1708 cvsData.parInstruments = {"CDS", "CDS", "CDS", "CDS", "CDS", "CDS", "CDS", "CDS", "CDS", "CDS"};
1709 cvsData.parInstrumentConventions["CDS"] = "CDS-STANDARD-CONVENTIONS";
1710 sensiData->creditCurveShiftData()["dc2"] =
1711 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1712 }
1713 {
1715 cvsData.shiftTenors = {3 * Months, 6 * Months, 1 * Years, 2 * Years, 3 * Years,
1716 5 * Years, 10 * Years, 13 * Years, 15 * Years, 20 * Years};
1717 cvsData.parInstruments = {"CDS", "CDS", "CDS", "CDS", "CDS", "CDS", "CDS", "CDS", "CDS", "CDS"};
1718 cvsData.parInstrumentConventions["CDS"] = "CDS-STANDARD-CONVENTIONS";
1719 sensiData->creditCurveShiftData()["dc3"] =
1720 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftParData>(cvsData);
1721 }
1722 sensiData->cdsVolShiftData()["dc"] = cdsvsData;
1723 sensiData->cdsVolShiftData()["dc2"] = cdsvsData;
1724 sensiData->cdsVolShiftData()["dc3"] = cdsvsData;
1725
1726 sensiData->equityShiftData()["SP5"] = eqsData;
1727 sensiData->equityShiftData()["Lufthansa"] = eqsData;
1728
1729 sensiData->equityVolShiftData()["SP5"] = eqvsData;
1730 sensiData->equityVolShiftData()["Lufthansa"] = eqvsData;
1731 sensiData->dividendYieldShiftData()["SP5"] = eqdivData;
1732 sensiData->dividendYieldShiftData()["Lufthansa"] = eqdivData;
1733
1734 sensiData->baseCorrelationShiftData()["Tranch1"] = bcorrData;
1735
1736 sensiData->zeroInflationCurveShiftData()["UKRPI"] = zinfData;
1737
1738 sensiData->yoyInflationCurveShiftData()["UKRPI"] = yinfData;
1739
1740 if (hasYYCapVols)
1741 sensiData->yoyInflationCapFloorVolShiftData()["UKRPI"] = yinfCfData;
1742
1743 return sensiData;
1744};
1745
1746
1747QuantLib::ext::shared_ptr<ore::analytics::ScenarioSimMarketParameters> TestConfigurationObjects::setupSimMarketData2() {
1748 QuantLib::ext::shared_ptr<ore::analytics::ScenarioSimMarketParameters> simMarketData(
1750 simMarketData->baseCcy() = "EUR";
1751 simMarketData->setDiscountCurveNames({"EUR", "GBP"});
1752 simMarketData->setYieldCurveNames({"BondCurve0"});
1753 simMarketData->setYieldCurveTenors("", {1 * Months, 6 * Months, 1 * Years, 2 * Years, 3 * Years, 4 * Years,
1754 5 * Years, 6 * Years, 7 * Years, 8 * Years, 9 * Years, 10 * Years,
1755 12 * Years, 15 * Years, 20 * Years, 25 * Years, 30 * Years});
1756 simMarketData->setIndices({"EUR-EURIBOR-6M", "GBP-LIBOR-6M"});
1757 simMarketData->setDefaultNames({"BondIssuer0"});
1758 simMarketData->setDefaultTenors(
1759 "", {6 * Months, 1 * Years, 2 * Years, 3 * Years, 5 * Years, 7 * Years, 10 * Years, 15 * Years, 20 * Years});
1760 simMarketData->setSecurities({"Bond0"});
1761 simMarketData->setSimulateSurvivalProbabilities(true);
1762 simMarketData->setDefaultCurveCalendars("", "TARGET");
1763 simMarketData->interpolation() = "LogLinear";
1764
1765 simMarketData->setSwapVolTerms(
1766 "", {1 * Years, 2 * Years, 3 * Years, 4 * Years, 5 * Years, 7 * Years, 10 * Years, 20 * Years});
1767 simMarketData->setSwapVolExpiries(
1768 "", {6 * Months, 1 * Years, 2 * Years, 3 * Years, 5 * Years, 7 * Years, 10 * Years, 20 * Years});
1769 simMarketData->setSwapVolKeys({"EUR", "GBP"});
1770 simMarketData->swapVolDecayMode() = "ForwardVariance";
1771 simMarketData->setSimulateSwapVols(true);
1772
1773 simMarketData->setFxVolExpiries("",
1774 vector<Period>{1 * Months, 3 * Months, 6 * Months, 2 * Years, 3 * Years, 4 * Years, 5 * Years});
1775 simMarketData->setFxVolDecayMode(string("ConstantVariance"));
1776 simMarketData->setSimulateFXVols(true);
1777 simMarketData->setFxVolCcyPairs({"EURGBP"});
1778 simMarketData->setFxVolIsSurface(true);
1779 simMarketData->setFxVolMoneyness(vector<Real>{0.1, 0.2, 0.3, 0.5, 1, 2, 3});
1780
1781 simMarketData->setFxCcyPairs({"EURGBP"});
1782
1783 simMarketData->setSimulateCapFloorVols(false);
1784
1785 return simMarketData;
1786}
1787
1788QuantLib::ext::shared_ptr<ore::analytics::ScenarioSimMarketParameters> TestConfigurationObjects::setupSimMarketData5() {
1789 QuantLib::ext::shared_ptr<ore::analytics::ScenarioSimMarketParameters> simMarketData(
1791
1792 simMarketData->baseCcy() = "EUR";
1793 simMarketData->setDiscountCurveNames({"EUR", "GBP", "USD", "CHF", "JPY"});
1794 simMarketData->setYieldCurveTenors("", {1 * Months, 6 * Months, 1 * Years, 2 * Years, 3 * Years, 4 * Years,
1795 5 * Years, 7 * Years, 10 * Years, 15 * Years, 20 * Years, 30 * Years});
1796 simMarketData->setIndices(
1797 {"EUR-EURIBOR-6M", "USD-LIBOR-3M", "USD-LIBOR-6M", "GBP-LIBOR-6M", "CHF-LIBOR-6M", "JPY-LIBOR-6M"});
1798 simMarketData->swapIndices()["EUR-CMS-2Y"] = "EUR-EURIBOR-6M";
1799 simMarketData->swapIndices()["EUR-CMS-30Y"] = "EUR-EURIBOR-6M";
1800
1801 simMarketData->setYieldCurveNames({"BondCurve0"});
1802 simMarketData->interpolation() = "LogLinear";
1803
1804 simMarketData->setSwapVolTerms("", {1 * Years, 2 * Years, 3 * Years, 5 * Years, 7 * Years, 10 * Years, 20 * Years});
1805 simMarketData->setSwapVolExpiries(
1806 "", {6 * Months, 1 * Years, 2 * Years, 3 * Years, 5 * Years, 7 * Years, 10 * Years, 20 * Years});
1807 simMarketData->setSwapVolKeys({"EUR", "GBP", "USD", "CHF", "JPY"});
1808 simMarketData->swapVolDecayMode() = "ForwardVariance";
1809 simMarketData->setSimulateSwapVols(true); // false;
1810
1811 simMarketData->setFxVolExpiries("",
1812 vector<Period>{1 * Months, 3 * Months, 6 * Months, 2 * Years, 3 * Years, 4 * Years, 5 * Years});
1813 simMarketData->setFxVolDecayMode(string("ConstantVariance"));
1814 simMarketData->setSimulateFXVols(true); // false;
1815 simMarketData->setFxVolCcyPairs({"EURUSD", "EURGBP", "EURCHF", "EURJPY", "GBPCHF"});
1816 simMarketData->setFxVolIsSurface(true);
1817 simMarketData->setFxVolMoneyness(vector<Real>{0.1, 0.2, 0.3, 0.5, 1, 2, 3});
1818
1819 simMarketData->setFxCcyPairs({"EURUSD", "EURGBP", "EURCHF", "EURJPY"});
1820
1821 simMarketData->setSimulateCapFloorVols(true);
1822 simMarketData->capFloorVolDecayMode() = "ForwardVariance";
1823 simMarketData->setCapFloorVolKeys({"EUR", "USD"});
1824 simMarketData->setCapFloorVolExpiries(
1825 "", {6 * Months, 1 * Years, 2 * Years, 3 * Years, 5 * Years, 7 * Years, 10 * Years, 15 * Years, 20 * Years});
1826 simMarketData->setCapFloorVolStrikes("", {0.00, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06});
1827
1828 simMarketData->setDefaultNames({"BondIssuer0"});
1829 simMarketData->setDefaultTenors(
1830 "", {6 * Months, 1 * Years, 2 * Years, 3 * Years, 5 * Years, 7 * Years, 10 * Years, 15 * Years, 20 * Years});
1831 simMarketData->setSimulateSurvivalProbabilities(true);
1832 simMarketData->setSecurities({"Bond0"});
1833 simMarketData->setDefaultCurveCalendars("", "TARGET");
1834
1835 simMarketData->setEquityNames({"SP5", "Lufthansa"});
1836 simMarketData->setEquityDividendTenors("SP5", {6 * Months, 1 * Years, 2 * Years});
1837 simMarketData->setEquityDividendTenors("Lufthansa", {6 * Months, 1 * Years, 2 * Years});
1838
1839 simMarketData->setSimulateEquityVols(true);
1840 simMarketData->setEquityVolDecayMode("ForwardVariance");
1841 simMarketData->setEquityVolNames({"SP5", "Lufthansa"});
1842 simMarketData->setEquityVolExpiries("", {6 * Months, 1 * Years, 2 * Years, 3 * Years,
1843 5 * Years, 7 * Years, 10 * Years, 20 * Years});
1844 simMarketData->setEquityVolIsSurface("", false);
1845 simMarketData->setSimulateEquityVolATMOnly(true);
1846 simMarketData->setEquityVolMoneyness("", {1});
1847
1848 simMarketData->setZeroInflationIndices({"UKRPI"});
1849 simMarketData->setZeroInflationTenors(
1850 "UKRPI", {1 * Years, 2 * Years, 3 * Years, 5 * Years, 7 * Years, 10 * Years, 15 * Years, 20 * Years});
1851 simMarketData->setYoyInflationIndices({"UKRPI"});
1852 simMarketData->setYoyInflationTenors(
1853 "UKRPI", {1 * Years, 2 * Years, 3 * Years, 5 * Years, 7 * Years, 10 * Years, 15 * Years, 20 * Years});
1854
1855 simMarketData->setCommodityCurveSimulate(true);
1856 simMarketData->setCommodityNames({"COMDTY_GOLD_USD", "COMDTY_WTI_USD"});
1857 simMarketData->setCommodityCurveTenors("", {0 * Days, 1 * Years, 2 * Years, 5 * Years});
1858
1859 simMarketData->setCommodityVolSimulate(true);
1860 simMarketData->commodityVolDecayMode() = "ForwardVariance";
1861 simMarketData->setCommodityVolNames({"COMDTY_GOLD_USD", "COMDTY_WTI_USD"});
1862 simMarketData->commodityVolExpiries("COMDTY_GOLD_USD") = {1 * Years, 2 * Years, 5 * Years};
1863 simMarketData->commodityVolMoneyness("COMDTY_GOLD_USD") = {1.0};
1864 simMarketData->commodityVolExpiries("COMDTY_WTI_USD") = {1 * Years, 5 * Years};
1865 simMarketData->commodityVolMoneyness("COMDTY_WTI_USD") = {0.9, 0.95, 1.0, 1.05, 1.1};
1866
1867 return simMarketData;
1868}
1869
1870QuantLib::ext::shared_ptr<ore::analytics::SensitivityScenarioData> TestConfigurationObjects::setupSensitivityScenarioData2() {
1871 QuantLib::ext::shared_ptr<ore::analytics::SensitivityScenarioData> sensiData =
1872 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData>();
1873
1875 cvsData.shiftTenors = {1 * Years, 2 * Years, 3 * Years, 5 * Years,
1876 7 * Years, 10 * Years, 15 * Years, 20 * Years}; // multiple tenors: triangular shifts
1877 cvsData.shiftType = ShiftType::Absolute;
1878 cvsData.shiftSize = 0.0001;
1879
1881 fxsData.shiftType = ShiftType::Relative;
1882 fxsData.shiftSize = 0.01;
1883
1885 fxvsData.shiftType = ShiftType::Relative;
1886 fxvsData.shiftSize = 1.0;
1887 fxvsData.shiftExpiries = {2 * Years, 5 * Years};
1888
1890 cfvsData.shiftType = ShiftType::Absolute;
1891 cfvsData.shiftSize = 0.0001;
1892 cfvsData.shiftExpiries = {1 * Years, 2 * Years, 3 * Years, 5 * Years, 10 * Years};
1893 cfvsData.shiftStrikes = {0.05};
1894
1896 swvsData.shiftType = ShiftType::Relative;
1897 swvsData.shiftSize = 0.01;
1898 swvsData.shiftExpiries = {3 * Years, 5 * Years, 10 * Years};
1899 swvsData.shiftTerms = {2 * Years, 5 * Years, 10 * Years};
1900
1901 sensiData->discountCurveShiftData()["EUR"] =
1902 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(cvsData);
1903
1904 sensiData->discountCurveShiftData()["GBP"] =
1905 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(cvsData);
1906
1907 sensiData->indexCurveShiftData()["EUR-EURIBOR-6M"] =
1908 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(cvsData);
1909 sensiData->indexCurveShiftData()["GBP-LIBOR-6M"] =
1910 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(cvsData);
1911
1912 sensiData->yieldCurveShiftData()["BondCurve0"] =
1913 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(cvsData);
1914
1915 sensiData->fxShiftData()["EURGBP"] = fxsData;
1916
1917 sensiData->fxVolShiftData()["EURGBP"] = fxvsData;
1918
1919 sensiData->swaptionVolShiftData()["EUR"] = swvsData;
1920 sensiData->swaptionVolShiftData()["GBP"] = swvsData;
1921
1922 sensiData->creditCurveShiftData()["BondIssuer0"] =
1923 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(cvsData);
1924
1925 // sensiData->capFloorVolLabel() = "VOL_CAPFLOOR";
1926 // sensiData->capFloorVolShiftData()["EUR"] = cfvsData;
1927 // sensiData->capFloorVolShiftData()["EUR"].indexName = "EUR-EURIBOR-6M";
1928 // sensiData->capFloorVolShiftData()["GBP"] = cfvsData;
1929 // sensiData->capFloorVolShiftData()["GBP"].indexName = "GBP-LIBOR-6M";
1930
1931 return sensiData;
1932}
1933
1934QuantLib::ext::shared_ptr<ore::analytics::SensitivityScenarioData> TestConfigurationObjects::setupSensitivityScenarioData2b() {
1935 QuantLib::ext::shared_ptr<ore::analytics::SensitivityScenarioData> sensiData =
1936 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData>();
1937
1938 // shift curve has more points than underlying curve, has tenor points where the underlying curve hasn't, skips some
1939 // tenor points that occur in the underlying curve (e.g. 2Y, 3Y, 4Y)
1941 cvsData.shiftTenors = {1 * Years, 15 * Months, 18 * Months, 21 * Months, 27 * Months, 30 * Months, 33 * Months,
1942 42 * Months, 54 * Months, 5 * Years, 6 * Years, 7 * Years, 8 * Years, 9 * Years,
1943 10 * Years, 11 * Years, 12 * Years, 13 * Years, 14 * Years, 15 * Years, 16 * Years,
1944 17 * Years, 18 * Years, 19 * Years, 20 * Years};
1945 cvsData.shiftType = ShiftType::Absolute;
1946 cvsData.shiftSize = 0.0001;
1947
1949 fxsData.shiftType = ShiftType::Relative;
1950 fxsData.shiftSize = 0.01;
1951
1953 fxvsData.shiftType = ShiftType::Relative;
1954 fxvsData.shiftSize = 1.0;
1955 fxvsData.shiftExpiries = {2 * Years, 5 * Years};
1956
1958 cfvsData.shiftType = ShiftType::Absolute;
1959 cfvsData.shiftSize = 0.0001;
1960 cfvsData.shiftExpiries = {1 * Years, 2 * Years, 3 * Years, 5 * Years, 10 * Years};
1961 cfvsData.shiftStrikes = {0.05};
1962
1964 swvsData.shiftType = ShiftType::Relative;
1965 swvsData.shiftSize = 0.01;
1966 swvsData.shiftExpiries = {3 * Years, 5 * Years, 10 * Years};
1967 swvsData.shiftTerms = {2 * Years, 5 * Years, 10 * Years};
1968
1969 sensiData->discountCurveShiftData()["EUR"] =
1970 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(cvsData);
1971
1972 sensiData->discountCurveShiftData()["GBP"] =
1973 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(cvsData);
1974
1975 sensiData->indexCurveShiftData()["EUR-EURIBOR-6M"] =
1976 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(cvsData);
1977 sensiData->indexCurveShiftData()["GBP-LIBOR-6M"] =
1978 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(cvsData);
1979
1980 sensiData->yieldCurveShiftData()["BondCurve0"] =
1981 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(cvsData);
1982
1983 sensiData->fxShiftData()["EURGBP"] = fxsData;
1984
1985 sensiData->fxVolShiftData()["EURGBP"] = fxvsData;
1986
1987 sensiData->swaptionVolShiftData()["EUR"] = swvsData;
1988 sensiData->swaptionVolShiftData()["GBP"] = swvsData;
1989
1990 sensiData->creditCurveShiftData()["BondIssuer0"] =
1991 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(cvsData);
1992
1993 // sensiData->capFloorVolLabel() = "VOL_CAPFLOOR";
1994 // sensiData->capFloorVolShiftData()["EUR"] = cfvsData;
1995 // sensiData->capFloorVolShiftData()["EUR"].indexName = "EUR-EURIBOR-6M";
1996 // sensiData->capFloorVolShiftData()["GBP"] = cfvsData;
1997 // sensiData->capFloorVolShiftData()["GBP"].indexName = "GBP-LIBOR-6M";
1998
1999 return sensiData;
2000}
2001
2002QuantLib::ext::shared_ptr<ore::analytics::SensitivityScenarioData> TestConfigurationObjects::setupSensitivityScenarioData5() {
2003 QuantLib::ext::shared_ptr<ore::analytics::SensitivityScenarioData> sensiData =
2004 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData>();
2005
2007 cvsData.shiftTenors = {6 * Months, 1 * Years, 2 * Years, 3 * Years, 5 * Years,
2008 7 * Years, 10 * Years, 15 * Years, 20 * Years}; // multiple tenors: triangular shifts
2009 cvsData.shiftType = ShiftType::Absolute;
2010 cvsData.shiftSize = 0.0001;
2011
2013 fxsData.shiftType = ShiftType::Relative;
2014 fxsData.shiftSize = 0.01;
2015
2017 fxvsData.shiftType = ShiftType::Relative;
2018 fxvsData.shiftSize = 1.0;
2019 fxvsData.shiftExpiries = {5 * Years};
2020
2022 cfvsData.shiftType = ShiftType::Absolute;
2023 cfvsData.shiftSize = 0.0001;
2024 cfvsData.shiftExpiries = {1 * Years, 2 * Years, 3 * Years, 5 * Years, 10 * Years};
2025 cfvsData.shiftStrikes = {0.01, 0.02, 0.03, 0.04, 0.05};
2026
2028 swvsData.shiftType = ShiftType::Relative;
2029 swvsData.shiftSize = 0.01;
2030 swvsData.shiftExpiries = {2 * Years, 5 * Years, 10 * Years};
2031 swvsData.shiftTerms = {5 * Years, 10 * Years};
2032
2034 eqsData.shiftType = ShiftType::Relative;
2035 eqsData.shiftSize = 0.01;
2036
2038 eqvsData.shiftType = ShiftType::Relative;
2039 eqvsData.shiftSize = 0.01;
2040 eqvsData.shiftExpiries = {5 * Years};
2041
2043 zinfData.shiftType = ShiftType::Absolute;
2044 zinfData.shiftSize = 0.0001;
2045 zinfData.shiftTenors = {1 * Years, 2 * Years, 3 * Years, 5 * Years, 7 * Years, 10 * Years, 15 * Years, 20 * Years};
2046
2047 auto commodityShiftData = QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>();
2048 commodityShiftData->shiftType = ShiftType::Relative;
2049 commodityShiftData->shiftSize = 0.01;
2050 commodityShiftData->shiftTenors = {0 * Days, 1 * Years, 2 * Years, 5 * Years};
2051
2053 commodityVolShiftData.shiftType = ShiftType::Relative;
2054 commodityVolShiftData.shiftSize = 0.01;
2055 commodityVolShiftData.shiftExpiries = {1 * Years, 2 * Years, 5 * Years};
2056 commodityVolShiftData.shiftStrikes = {0.9, 0.95, 1.0, 1.05, 1.1};
2057
2058 sensiData->discountCurveShiftData()["EUR"] =
2059 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(cvsData);
2060
2061 sensiData->discountCurveShiftData()["USD"] =
2062 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(cvsData);
2063
2064 sensiData->discountCurveShiftData()["GBP"] =
2065 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(cvsData);
2066
2067 sensiData->discountCurveShiftData()["JPY"] =
2068 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(cvsData);
2069
2070 sensiData->discountCurveShiftData()["CHF"] =
2071 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(cvsData);
2072
2073 sensiData->indexCurveShiftData()["EUR-EURIBOR-6M"] =
2074 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(cvsData);
2075
2076 sensiData->indexCurveShiftData()["USD-LIBOR-3M"] =
2077 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(cvsData);
2078
2079 sensiData->indexCurveShiftData()["GBP-LIBOR-6M"] =
2080 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(cvsData);
2081
2082 sensiData->indexCurveShiftData()["JPY-LIBOR-6M"] =
2083 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(cvsData);
2084
2085 sensiData->indexCurveShiftData()["CHF-LIBOR-6M"] =
2086 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(cvsData);
2087
2088 sensiData->yieldCurveShiftData()["BondCurve0"] =
2089 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(cvsData);
2090
2091 sensiData->creditCurveShiftData()["BondIssuer0"] =
2092 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(cvsData);
2093
2094 sensiData->fxShiftData()["EURUSD"] = fxsData;
2095 sensiData->fxShiftData()["EURGBP"] = fxsData;
2096 sensiData->fxShiftData()["EURJPY"] = fxsData;
2097 sensiData->fxShiftData()["EURCHF"] = fxsData;
2098
2099 sensiData->fxVolShiftData()["EURUSD"] = fxvsData;
2100 sensiData->fxVolShiftData()["EURGBP"] = fxvsData;
2101 sensiData->fxVolShiftData()["EURJPY"] = fxvsData;
2102 sensiData->fxVolShiftData()["EURCHF"] = fxvsData;
2103 sensiData->fxVolShiftData()["GBPCHF"] = fxvsData;
2104
2105 sensiData->swaptionVolShiftData()["EUR"] = swvsData;
2106 sensiData->swaptionVolShiftData()["GBP"] = swvsData;
2107 sensiData->swaptionVolShiftData()["USD"] = swvsData;
2108 sensiData->swaptionVolShiftData()["JPY"] = swvsData;
2109 sensiData->swaptionVolShiftData()["CHF"] = swvsData;
2110
2111 sensiData->capFloorVolShiftData()["EUR"] =
2112 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CapFloorVolShiftData>(cfvsData);
2113 sensiData->capFloorVolShiftData()["EUR"]->indexName = "EUR-EURIBOR-6M";
2114 sensiData->capFloorVolShiftData()["USD"] =
2115 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CapFloorVolShiftData>(cfvsData);
2116 sensiData->capFloorVolShiftData()["USD"]->indexName = "USD-LIBOR-3M";
2117
2118 sensiData->equityShiftData()["SP5"] = eqsData;
2119 sensiData->equityShiftData()["Lufthansa"] = eqsData;
2120
2121 sensiData->equityVolShiftData()["SP5"] = eqvsData;
2122 sensiData->equityVolShiftData()["Lufthansa"] = eqvsData;
2123
2124 sensiData->zeroInflationCurveShiftData()["UKRPI"] =
2125 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(zinfData);
2126
2127 sensiData->yoyInflationCurveShiftData()["UKRPI"] =
2128 QuantLib::ext::make_shared<ore::analytics::SensitivityScenarioData::CurveShiftData>(zinfData);
2129
2130 sensiData->commodityCurveShiftData()["COMDTY_GOLD_USD"] = commodityShiftData;
2131 sensiData->commodityCurrencies()["COMDTY_GOLD_USD"] = "USD";
2132 sensiData->commodityCurveShiftData()["COMDTY_WTI_USD"] = commodityShiftData;
2133 sensiData->commodityCurrencies()["COMDTY_WTI_USD"] = "USD";
2134
2135 sensiData->commodityVolShiftData()["COMDTY_GOLD_USD"] = commodityVolShiftData;
2136 sensiData->commodityVolShiftData()["COMDTY_WTI_USD"] = commodityVolShiftData;
2137
2138 return sensiData;
2139}
2140
2141} // namespace testsuite
Handle< Quote > fxSpot(const string &ccypair, const string &configuration=Market::defaultConfiguration) const
static const string defaultConfiguration
Handle< YieldTermStructure > discountCurve(const string &ccy, const string &configuration=Market::defaultConfiguration) const
map< pair< string, string >, Handle< OptionletVolatilityStructure > > capFloorCurves_
string shortSwapIndexBase(const string &key, const string &configuration=Market::defaultConfiguration) const override
string swapIndexBase(const string &key, const string &configuration=Market::defaultConfiguration) const override
map< tuple< string, string, string >, Handle< QuantExt::CorrelationTermStructure > > correlationCurves_
map< pair< string, string >, QuantLib::Handle< QuantExt::EquityIndex2 > > equityCurves_
map< pair< string, string >, Handle< CPIVolatilitySurface > > cpiInflationCapFloorVolatilitySurfaces_
map< pair< string, string >, Handle< BlackVolTermStructure > > fxVols_
QuantLib::ext::shared_ptr< FXTriangulation > fx_
map< tuple< string, YieldCurveType, string >, Handle< YieldTermStructure > > yieldCurves_
map< pair< string, string >, QuantLib::Handle< QuantExt::CommodityIndex > > commodityIndices_
map< pair< string, string >, Handle< QuantExt::CreditCurve > > defaultCurves_
map< pair< string, string >, Handle< IborIndex > > iborIndices_
map< pair< string, string >, Handle< YoYOptionletVolatilitySurface > > yoyCapFloorVolSurfaces_
map< pair< string, string >, Handle< YoYInflationIndex > > yoyInflationIndices_
map< pair< string, string >, Handle< QuantExt::CreditVolCurve > > cdsVols_
map< pair< string, string >, Handle< Quote > > equitySpots_
map< pair< string, string >, Handle< QuantLib::SwaptionVolatilityStructure > > swaptionCurves_
map< pair< string, string >, Handle< QuantExt::BaseCorrelationTermStructure > > baseCorrelations_
map< pair< string, string >, Handle< Quote > > recoveryRates_
Handle< Quote > equitySpot(const string &eqName, const string &configuration=Market::defaultConfiguration) const override
map< pair< string, string >, Handle< ZeroInflationIndex > > zeroInflationIndices_
Handle< SwapIndex > swapIndex(const string &indexName, const string &configuration=Market::defaultConfiguration) const override
map< pair< string, string >, pair< string, string > > swaptionIndexBases_
map< pair< string, string >, Handle< BlackVolTermStructure > > equityVols_
map< pair< string, string >, Handle< Quote > > securitySpreads_
Handle< YieldTermStructure > yieldCurve(const YieldCurveType &type, const string &ccy, const string &configuration=Market::defaultConfiguration) const override
map< pair< string, string >, QuantLib::Handle< QuantLib::BlackVolTermStructure > > commodityVols_
void addSwapIndex(const string &swapindex, const string &discountIndex, const string &configuration=Market::defaultConfiguration) const
static QuantLib::ext::shared_ptr< ore::analytics::SensitivityScenarioData > setupSensitivityScenarioData(bool hasSwapVolCube=false, bool hasYYCapVols=false, bool parConversion=false)
SensitivityScenarioData instance.
static QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarketParameters > setupSimMarketData2()
ScenarioSimMarketParameters instance, 2 currencies.
static QuantLib::ext::shared_ptr< ore::analytics::SensitivityScenarioData > setupSensitivityScenarioData2()
SensitivityScenarioData instance, 2 currencies.
static QuantLib::ext::shared_ptr< ore::analytics::SensitivityScenarioData > setupSensitivityScenarioData5()
SensitivityScenarioData instance, 5 currencies.
static void setConventions()
Set Conventions.
static QuantLib::ext::shared_ptr< ore::analytics::SensitivityScenarioData > setupSensitivityScenarioData2b()
SensitivityScenarioData instance, 2 currencies, shifts more granular than base curve.
static QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarketParameters > setupSimMarketData(bool hasSwapVolCube=false, bool hasYYCapVols=false)
ScenarioSimMarketParameters instance.
static QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarketParameters > setupSimMarketData5()
ScenarioSimMarketParameters instance, 5 currencies.
TestMarket(Date asof, bool swapVolCube=false)
Definition: testmarket.cpp:209
Handle< YoYInflationIndex > makeYoYInflationIndex(string index, vector< Date > dates, vector< Rate > rates, QuantLib::ext::shared_ptr< YoYInflationIndex > ii, Handle< YieldTermStructure > yts)
Definition: testmarket.cpp:588
Handle< CPICapFloorTermPriceSurface > flatRateCps(Handle< ZeroInflationIndex > infIndex, const std::vector< Rate > cStrikes, std::vector< Rate > fStrikes, std::vector< Period > cfMaturities, Matrix cPrice, Matrix fPrice)
Definition: testmarket.cpp:537
Handle< YoYInflationTermStructure > flatYoYInflationCurve(Real inflationRate, Rate nominalRate)
Definition: testmarket.cpp:626
Handle< YoYOptionletVolatilitySurface > flatYoYOptionletVolatilitySurface(Real normalVol)
Definition: testmarket.cpp:639
Handle< OptionletVolatilityStructure > flatRateCvs(Volatility vol, VolatilityType type=Normal, Real shift=0.0)
Definition: testmarket.cpp:524
Handle< ZeroInflationIndex > makeZeroInflationIndex(string index, vector< Date > dates, vector< Rate > rates, QuantLib::ext::shared_ptr< ZeroInflationIndex > ii, Handle< YieldTermStructure > yts)
Definition: testmarket.cpp:561
Handle< QuantLib::CPIVolatilitySurface > flatCpiVolSurface(Volatility v)
Definition: testmarket.cpp:548
Handle< QuantExt::CreditCurve > flatRateDcs(Volatility forward)
Definition: testmarket.cpp:518
Handle< QuantExt::CorrelationTermStructure > flatCorrelation(Real correlation=0.0)
Definition: testmarket.cpp:531
Handle< ZeroInflationTermStructure > flatZeroInflationCurve(Real inflationRate, Rate nominalRate)
Definition: testmarket.cpp:613
Handle< YieldTermStructure > flatRateYts(Real forward)
Definition: testmarket.cpp:492
Handle< BlackVolTermStructure > flatRateFxv(Volatility forward)
Definition: testmarket.cpp:498
Handle< QuantLib::SwaptionVolatilityStructure > flatRateSvs(Volatility forward, VolatilityType type=ShiftedLognormal, Real shift=0.0)
Definition: testmarket.cpp:511
Handle< YieldTermStructure > flatRateDiv(Real dividend)
Definition: testmarket.cpp:504
map< string, vector< Period > > swaptionVolRateHelperSwapTenorsMap_
Definition: testmarket.hpp:208
map< string, vector< Handle< Quote > > > discountRateHelperValuesMap_
Definition: testmarket.hpp:214
void createIborIndex(const string &idxName, const vector< string > &parInst, const vector< Period > &parTenor, const vector< Real > &parRates, bool singleCurve)
Definition: testmarket.cpp:909
map< string, vector< string > > baseCorrLossLevelsMap_
Definition: testmarket.hpp:210
map< string, vector< Handle< Quote > > > defaultRateHelperValuesMap_
Definition: testmarket.hpp:215
map< string, vector< Handle< Quote > > > baseCorrRateHelperValuesMap_
Definition: testmarket.hpp:216
map< string, vector< Period > > equityVolRateHelperTenorsMap_
Definition: testmarket.hpp:208
map< string, vector< Period > > zeroInflationRateHelperTenorsMap_
Definition: testmarket.hpp:209
map< string, vector< Handle< Quote > > > zeroInflationRateHelperValuesMap_
Definition: testmarket.hpp:217
void createDiscountCurve(const string &ccy, const vector< string > &parInst, const vector< Period > &parTenor, const vector< Real > &parRates)
Definition: testmarket.cpp:877
map< string, vector< QuantLib::ext::shared_ptr< QuantExt::DefaultProbabilityHelper > > > defaultRateHelpersMap_
Definition: testmarket.hpp:213
map< string, vector< string > > indexCurveRateHelperInstMap_
Definition: testmarket.hpp:204
map< string, vector< Handle< Quote > > > indexCurveRateHelperValuesMap_
Definition: testmarket.hpp:215
map< string, vector< Period > > baseCorrRateHelperTenorsMap_
Definition: testmarket.hpp:209
map< string, vector< string > > discountRateHelperInstMap_
Definition: testmarket.hpp:203
map< string, vector< Period > > swaptionVolRateHelperTenorsMap_
Definition: testmarket.hpp:208
Handle< OptionletVolatilityStructure > flatRateCvs(Volatility vol, VolatilityType type=Normal, Real shift=0.0)
void createCdsVolCurve(const string &name, const vector< Period > &parTenor, const vector< Real > &parRates)
Definition: testmarket.cpp:951
void createXccyDiscountCurve(const string &ccy, const string &baseCcy, const vector< string > &parInst, const vector< Period > &parTenor, const vector< Real > &parRates)
Definition: testmarket.cpp:890
map< string, vector< Period > > cdsVolRateHelperTenorsMap_
Definition: testmarket.hpp:207
map< string, vector< QuantLib::ext::shared_ptr< RateHelper > > > discountRateHelpersMap_
Definition: testmarket.hpp:211
Handle< YieldTermStructure > flatRateYts(Real forward)
TestMarketParCurves(const Date &asof)
Definition: testmarket.cpp:645
map< string, vector< string > > zeroInflationRateHelperInstMap_
Definition: testmarket.hpp:204
map< string, vector< Period > > defaultRateHelperTenorsMap_
Definition: testmarket.hpp:207
map< string, vector< Period > > discountRateHelperTenorsMap_
Definition: testmarket.hpp:206
map< string, vector< string > > defaultRateHelperInstMap_
Definition: testmarket.hpp:204
void createEquityVolCurve(const string &name, const string &ccy, const vector< Period > &parTenor, const vector< Real > &parRates)
Definition: testmarket.cpp:979
Handle< DefaultProbabilityTermStructure > flatRateDcs(Volatility forward)
map< string, vector< QuantLib::ext::shared_ptr< RateHelper > > > indexCurveRateHelpersMap_
Definition: testmarket.hpp:212
map< string, vector< Handle< Quote > > > equityVolRateHelperValuesMap_
Definition: testmarket.hpp:216
void createBaseCorrel(const string &name, const vector< Period > &tenors, const vector< string > &lossLevel, const vector< Real > quotes)
map< string, vector< Period > > indexCurveRateHelperTenorsMap_
Definition: testmarket.hpp:207
void createYoYInflationIndex(const string &idxName, const vector< string > &parInst, const vector< Period > &parTenor, const vector< Real > &parRates, bool singleCurve)
Handle< BlackVolTermStructure > flatRateFxv(Volatility forward)
map< string, vector< Period > > yoyInflationRateHelperTenorsMap_
Definition: testmarket.hpp:209
map< string, vector< Handle< Quote > > > cdsVolRateHelperValuesMap_
Definition: testmarket.hpp:215
map< string, vector< string > > yoyInflationRateHelperInstMap_
Definition: testmarket.hpp:205
void createDefaultCurve(const string &name, const string &ccy, const vector< string > &parInst, const vector< Period > &parTenor, const vector< Real > &parRates)
Definition: testmarket.cpp:933
Handle< QuantLib::SwaptionVolatilityStructure > flatRateSvs(Volatility forward, VolatilityType type=ShiftedLognormal, Real shift=0.0)
void createSwaptionVolCurve(const string &name, const vector< Period > &optionTenors, const vector< Period > &swapTenors, const vector< Real > &strikeSpreads, const vector< Real > &parRates)
map< string, vector< Handle< Quote > > > yoyInflationRateHelperValuesMap_
Definition: testmarket.hpp:217
void createZeroInflationIndex(const string &idxName, const vector< string > &parInst, const vector< Period > &parTenor, const vector< Real > &parRates, bool singleCurve)
map< string, vector< Handle< Quote > > > swaptionVolRateHelperValuesMap_
Definition: testmarket.hpp:216
QuantLib::ext::shared_ptr< ZeroInflationIndex > parseZeroInflationIndex(const string &s, const Handle< ZeroInflationTermStructure > &h=Handle< ZeroInflationTermStructure >())
Calendar parseCalendar(const string &s)
QuantLib::ext::shared_ptr< IborIndex > parseIborIndex(const string &s, const Handle< YieldTermStructure > &h=Handle< YieldTermStructure >())
Currency parseCurrency(const string &s)
Real parseReal(const string &s)
Calendar calendar
Filter close_enough(const RandomVariable &x, const RandomVariable &y)
ore::analytics::SensitivityScenarioData::CurveShiftParData createCurveData()
A class to hold the parametrisation for building sensitivity scenarios.
Date asof(14, Jun, 2018)
string name