21#include <boost/make_shared.hpp>
22#include <boost/test/unit_test.hpp>
24#include <ql/indexes/inflation/ukrpi.hpp>
25#include <ql/termstructures/inflation/inflationhelpers.hpp>
26#include <ql/termstructures/inflation/piecewiseyoyinflationcurve.hpp>
27#include <ql/termstructures/inflation/piecewisezeroinflationcurve.hpp>
28#include <ql/termstructures/volatility/equityfx/blackconstantvol.hpp>
29#include <ql/termstructures/volatility/equityfx/blackvariancecurve.hpp>
30#include <ql/termstructures/volatility/optionlet/constantoptionletvol.hpp>
31#include <ql/termstructures/volatility/swaption/swaptionconstantvol.hpp>
32#include <ql/termstructures/volatility/swaption/swaptionvolcube.hpp>
33#include <ql/termstructures/volatility/swaption/swaptionvolmatrix.hpp>
43using QuantExt::DefaultProbabilityHelper;
50 QuantLib::ext::shared_ptr<Conventions> conventions = QuantLib::ext::make_shared<Conventions>();
53 QuantLib::ext::shared_ptr<ore::data::Convention> swapIndexEURConv(
55 QuantLib::ext::shared_ptr<ore::data::Convention> swapIndexEURLongConv(
57 QuantLib::ext::shared_ptr<ore::data::Convention> swapIndexUSDConv(
59 QuantLib::ext::shared_ptr<ore::data::Convention> swapIndexUSDLongConv(
61 QuantLib::ext::shared_ptr<ore::data::Convention> swapIndexGBPConv(
63 QuantLib::ext::shared_ptr<ore::data::Convention> swapIndexGBPLongConv(
65 QuantLib::ext::shared_ptr<ore::data::Convention> swapIndexCHFConv(
67 QuantLib::ext::shared_ptr<ore::data::Convention> swapIndexCHFLongConv(
69 QuantLib::ext::shared_ptr<ore::data::Convention> swapIndexJPYConv(
71 QuantLib::ext::shared_ptr<ore::data::Convention> swapIndexJPYLongConv(
74 conventions->add(swapIndexEURConv);
75 conventions->add(swapIndexEURLongConv);
76 conventions->add(swapIndexUSDConv);
77 conventions->add(swapIndexUSDLongConv);
78 conventions->add(swapIndexGBPConv);
79 conventions->add(swapIndexGBPLongConv);
80 conventions->add(swapIndexCHFConv);
81 conventions->add(swapIndexCHFLongConv);
82 conventions->add(swapIndexJPYConv);
83 conventions->add(swapIndexJPYLongConv);
86 "EUR-6M-SWAP-CONVENTIONS",
"TARGET",
"Annual",
"MF",
"30/360",
"EUR-EURIBOR-6M"));
87 QuantLib::ext::shared_ptr<ore::data::Convention> swapUSDConv(
89 QuantLib::ext::shared_ptr<ore::data::Convention> swapGBPConv(
91 QuantLib::ext::shared_ptr<ore::data::Convention> swapGBPLongConv(
93 QuantLib::ext::shared_ptr<ore::data::Convention> swapCHFConv(
95 QuantLib::ext::shared_ptr<ore::data::Convention> swapCHFLongConv(
98 "JPY-LIBOR-6M-SWAP-CONVENTIONS",
"JP",
"Semiannual",
"MF",
"A365",
"JPY-LIBOR-6M"));
100 conventions->add(swapEURConv);
101 conventions->add(swapUSDConv);
102 conventions->add(swapGBPConv);
103 conventions->add(swapGBPLongConv);
104 conventions->add(swapCHFConv);
105 conventions->add(swapCHFLongConv);
106 conventions->add(swapJPYConv);
108 InstrumentConventions::instance().setConventions(conventions);
120 vector<pair<string, Real>> indexData = {
121 {
"EUR-EONIA", 0.01}, {
"EUR-EURIBOR-3M", 0.015}, {
"EUR-EURIBOR-6M", 0.02}, {
"USD-FedFunds", 0.01},
122 {
"USD-LIBOR-1M", 0.02}, {
"USD-LIBOR-3M", 0.03}, {
"USD-LIBOR-6M", 0.05}, {
"GBP-SONIA", 0.01},
123 {
"GBP-LIBOR-3M", 0.03}, {
"GBP-LIBOR-6M", 0.04}, {
"CHF-LIBOR-3M", 0.01}, {
"CHF-TOIS", 0.02},
124 {
"CHF-LIBOR-6M", 0.02}, {
"JPY-LIBOR-6M", 0.01}, {
"JPY-TONAR", 0.01}, {
"JPY-LIBOR-3M", 0.01},
125 {
"CAD-CDOR-3M", 0.02}, {
"CAD-CORRA", 0.01}, {
"SEK-STIBOR-3M", 0.02}};
127 for (
auto id : indexData) {
132 for (Date d = asof - 400; d < asof; d++) {
133 if (h->isValidFixingDate(d))
134 h->addFixing(d, 0.01);
151 std::map<std::string, QuantLib::Handle<QuantLib::Quote>> quotes;
152 quotes[
"EURUSD"] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(1.2));
153 quotes[
"EURGBP"] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.8));
154 quotes[
"EURCHF"] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(1.0));
155 quotes[
"EURCAD"] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(1.0));
156 quotes[
"EURSEK"] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(1.0));
157 quotes[
"EURJPY"] = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(128.0));
158 fx_ = QuantLib::ext::make_shared<FXTriangulation>(quotes);
168 Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(2147.56));
170 Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(12.75));
181 yieldCurve(YieldCurveType::EquityDividend,
"SP5")));
183 Handle<EquityIndex2>(QuantLib::ext::make_shared<EquityIndex2>(
185 yieldCurve(YieldCurveType::Discount,
"EUR"),
yieldCurve(YieldCurveType::EquityDividend,
"Lufthansa")));
196 vector<Real> shiftStrikes = {-0.02, -0.01, -0.005, -0.0025, 0.0, 0.0025, 0.005, 0.01, 0.02};
197 vector<Period> optionTenors = {2 * Weeks, 1 * Months, 3 * Months, 6 * Months, 1 * Years, 2 * Years,
198 3 * Years, 5 * Years, 10 * Years, 15 * Years, 20 * Years, 30 * Years};
199 vector<Period> swapTenors = {1 * Years, 2 * Years, 3 * Years, 4 * Years, 5 * Years,
200 7 * Years, 10 * Years, 15 * Years, 20 * Years, 30 * Years};
201 DayCounter dc = Actual365Fixed();
202 Calendar cal = TARGET();
203 BusinessDayConvention bdc = Following;
204 vector<vector<Handle<Quote>>> parQuotes(
206 vector<Handle<Quote>>(swapTenors.size(), Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.02))));
208 vector<vector<Real>> shift(optionTenors.size(), vector<Real>(swapTenors.size(), 0.0));
209 vector<string> ccys = {
"USD",
"JPY"};
210 QuantLib::ext::shared_ptr<SwaptionVolatilityStructure> atm(
new SwaptionVolatilityMatrix(
211 asof_, cal, bdc, optionTenors, swapTenors, parQuotes, dc,
true, QuantLib::Normal, shift));
213 Handle<SwaptionVolatilityStructure> hATM(atm);
214 vector<vector<Handle<Quote>>> cubeQuotes(
215 optionTenors.size() * swapTenors.size(),
216 vector<Handle<Quote>>(shiftStrikes.size(), Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.02))));
218 for (
auto name : ccys) {
223 hATM, optionTenors, swapTenors, shiftStrikes, cubeQuotes, *si, *ssi,
false,
true,
false));
224 tmp->enableExtrapolation();
226 Handle<SwaptionVolatilityStructure> svp =
227 Handle<SwaptionVolatilityStructure>(QuantLib::ext::make_shared<SwaptionVolCubeWithATM>(tmp));
253 Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.4));
255 Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.4));
260 Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.0));
263 Handle<QuantExt::CreditVolCurve>(QuantLib::ext::make_shared<QuantExt::CreditVolCurveWrapper>(
flatRateFxv(0.12)));
267 QuantLib::ext::shared_ptr<YieldTermStructure> yts(
268 new FlatForward(Settings::instance().evaluationDate(), forward, ActualActual(ActualActual::ISDA)));
269 return Handle<YieldTermStructure>(yts);
273 QuantLib::ext::shared_ptr<YieldTermStructure> yts(
274 new FlatForward(Settings::instance().evaluationDate(), dividend, ActualActual(ActualActual::ISDA)));
275 return Handle<YieldTermStructure>(yts);
279 QuantLib::ext::shared_ptr<BlackVolTermStructure> fxv(
280 new BlackConstantVol(Settings::instance().evaluationDate(), NullCalendar(), forward, Actual365Fixed()));
281 return Handle<BlackVolTermStructure>(fxv);
286 QuantLib::ext::shared_ptr<QuantLib::SwaptionVolatilityStructure> svs(
287 new QuantLib::ConstantSwaptionVolatility(Settings::instance().evaluationDate(), NullCalendar(),
288 ModifiedFollowing, forward, Actual365Fixed(), type, shift));
289 return Handle<QuantLib::SwaptionVolatilityStructure>(svs);
293 QuantLib::ext::shared_ptr<DefaultProbabilityTermStructure> dcs(
new FlatHazardRate(
asof_, forward, ActualActual(ActualActual::ISDA)));
294 return Handle<QuantExt::CreditCurve>(
295 QuantLib::ext::make_shared<QuantExt::CreditCurve>(Handle<DefaultProbabilityTermStructure>(dcs)));
299 QuantLib::ext::shared_ptr<OptionletVolatilityStructure> ts(
new QuantLib::ConstantOptionletVolatility(
300 Settings::instance().evaluationDate(), NullCalendar(), ModifiedFollowing, vol, ActualActual(ActualActual::ISDA), type, shift));
301 return Handle<OptionletVolatilityStructure>(ts);
Handle< OptionletVolatilityStructure > flatRateCvs(Volatility vol, VolatilityType type=Normal, Real shift=0.0)
Handle< QuantExt::CreditCurve > flatRateDcs(Volatility forward)
Handle< YieldTermStructure > flatRateYts(Real forward)
OredTestMarket(Date asof, bool swapVolCube=false)
Handle< BlackVolTermStructure > flatRateFxv(Volatility forward)
Handle< QuantLib::SwaptionVolatilityStructure > flatRateSvs(Volatility forward, VolatilityType type=ShiftedLognormal, Real shift=0.0)
Handle< YieldTermStructure > flatRateDiv(Real dividend)
Container for storing Interest Rate Swap conventions.
static const string defaultConfiguration
Default configuration label.
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< pair< string, string >, QuantLib::Handle< QuantExt::EquityIndex2 > > equityCurves_
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 >, Handle< QuantExt::CreditCurve > > defaultCurves_
map< pair< string, string >, Handle< IborIndex > > iborIndices_
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< Quote > > recoveryRates_
Handle< Quote > equitySpot(const string &eqName, const string &configuration=Market::defaultConfiguration) const override
Equity curves.
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
Yield Curves.
void addSwapIndex(const string &swapindex, const string &discountIndex, const string &configuration=Market::defaultConfiguration) const
add a swap index to the market
Container for storing Swap Index conventions.
QuantLib::ext::shared_ptr< IborIndex > parseIborIndex(const string &s, const Handle< YieldTermStructure > &h)
Convert std::string to QuantLib::IborIndex.
Currency parseCurrency(const string &s)
Convert text to QuantLib::Currency.