Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Classes | Functions
testsuite Namespace Reference

Classes

class  ParSensitivityAnalysisManualTest
 Par sensitivity analysis comparison against manual bump. More...
 
class  ParSensitivityAnalysisTest
 Sensitivity analysis tests. More...
 
class  SensitivityPerformancePlusTest
 Sensitivity Performance tests. More...
 
class  TestConfigurationObjects
 Static class to allow for easy construction of configuration objects for use within tests. More...
 
class  TestMarket
 Simple flat market setup to be used in the test suite. More...
 
class  TestMarketParCurves
 

Functions

void testParConversion (ObservationMode::Mode om)
 
 BOOST_AUTO_TEST_CASE (ZeroShifts1d)
 
 BOOST_AUTO_TEST_CASE (ZeroShifts2d)
 
 BOOST_AUTO_TEST_CASE (ZeroSensitivity)
 
 BOOST_AUTO_TEST_CASE (ParConversionNoneObs)
 
 BOOST_AUTO_TEST_CASE (ParConversionDisableObs)
 
 BOOST_AUTO_TEST_CASE (ParConversionDeferObs)
 
 BOOST_AUTO_TEST_CASE (ParConversionUnregisterObs)
 
 BOOST_AUTO_TEST_CASE (ParSwapBenchmarkTest)
 
 BOOST_AUTO_TEST_CASE (SensiPerformanceNoneObs)
 
 BOOST_AUTO_TEST_CASE (SensiPerformanceDisableObs)
 
 BOOST_AUTO_TEST_CASE (SensiPerformanceDeferObs)
 
 BOOST_AUTO_TEST_CASE (SensiPerformanceUnregisterObs)
 
 BOOST_AUTO_TEST_CASE (SensiPerformanceCrossGammaNoneObs)
 
 BOOST_AUTO_TEST_CASE (SensiPerformanceBigScenarioNoneObs)
 
 BOOST_AUTO_TEST_CASE (SensiPerformanceBigPortfolioObs)
 
 BOOST_AUTO_TEST_CASE (SensiPerformanceBigPortfolioBigScenarioNoneObs)
 
 BOOST_AUTO_TEST_CASE (SensiPerformanceBigPortfolioCrossGammaNoneObs)
 
 BOOST_AUTO_TEST_CASE (SensiPerformanceBigScenarioCrossGammaNoneObs)
 
 BOOST_AUTO_TEST_CASE (SensiPerformanceBigPortfolioBigScenarioCrossGammaNoneObs)
 
 BOOST_AUTO_TEST_CASE (SensiPerformanceBTSetupNoneObs)
 
ore::analytics::SensitivityScenarioData::CurveShiftParData createCurveData ()
 
QuantLib::ext::shared_ptr< TradebuildSwap (string id, string ccy, bool isPayer, Real notional, int start, Size term, Real rate, Real spread, string fixedFreq, string fixedDC, string floatFreq, string floatDC, string index, Calendar calendar, Natural spotDays, bool spotStartLag)
 
QuantLib::ext::shared_ptr< TradebuildEuropeanSwaption (string id, string longShort, string ccy, bool isPayer, Real notional, int start, Size term, Real rate, Real spread, string fixedFreq, string fixedDC, string floatFreq, string floatDC, string index, string cashPhysical, Real premium, string premiumCcy, string premiumDate)
 
QuantLib::ext::shared_ptr< TradebuildBermudanSwaption (string id, string longShort, string ccy, bool isPayer, Real notional, Size exercises, int start, Size term, Real rate, Real spread, string fixedFreq, string fixedDC, string floatFreq, string floatDC, string index, string cashPhysical, Real premium, string premiumCcy, string premiumDate)
 
QuantLib::ext::shared_ptr< TradebuildFxOption (string id, string longShort, string putCall, Size expiry, string boughtCcy, Real boughtAmount, string soldCcy, Real soldAmount, Real premium, string premiumCcy, string premiumDate)
 
QuantLib::ext::shared_ptr< TradebuildEquityOption (string id, string longShort, string putCall, Size expiry, string equityName, string currency, Real strike, Real quantity, Real premium, string premiumCcy, string premiumDate)
 
QuantLib::ext::shared_ptr< TradebuildEquityForward (string id, string longShort, Size expiry, string equityName, string currency, Real strike, Real quantity)
 
QuantLib::ext::shared_ptr< TradebuildCap (string id, string ccy, string longShort, Real capRate, Real notional, int start, Size term, string floatFreq, string floatDC, string index, Calendar calendar, Natural spotDays, bool spotStartLag)
 
QuantLib::ext::shared_ptr< TradebuildFloor (string id, string ccy, string longShort, Real floorRate, Real notional, int start, Size term, string floatFreq, string floatDC, string index, Calendar calendar, Natural spotDays, bool spotStartLag)
 
QuantLib::ext::shared_ptr< TradebuildCapFloor (string id, string ccy, string longShort, vector< Real > capRates, vector< Real > floorRates, Real notional, int start, Size term, string floatFreq, string floatDC, string index, Calendar calendar, Natural spotDays, bool spotStartLag)
 
QuantLib::ext::shared_ptr< TradebuildCrossCcyBasisSwap (string id, string recCcy, Real recNotional, string payCcy, Real payNotional, int start, Size term, Real recLegSpread, Real payLegSpread, string recFreq, string recDC, string recIndex, Calendar recCalendar, string payFreq, string payDC, string payIndex, Calendar payCalendar, Natural spotDays, bool spotStartLag, bool notionalInitialExchange, bool notionalFinalExchange, bool notionalAmortizingExchange, bool isRecLegFXResettable, bool isPayLegFXResettable)
 
QuantLib::ext::shared_ptr< TradebuildZeroBond (string id, string ccy, Real notional, Size term, string suffix)
 
QuantLib::ext::shared_ptr< TradebuildCreditDefaultSwap (string id, string ccy, string issuerId, string creditCurveId, bool isPayer, Real notional, int start, Size term, Real rate, Real spread, string fixedFreq, string fixedDC)
 
QuantLib::ext::shared_ptr< TradebuildSyntheticCDO (string id, string name, vector< string > names, string longShort, string ccy, vector< string > ccys, bool isPayer, vector< Real > notionals, Real notional, int start, Size term, Real rate, Real spread, string fixedFreq, string fixedDC)
 
QuantLib::ext::shared_ptr< TradebuildCmsCapFloor (string id, string ccy, string indexId, bool isPayer, Real notional, int start, Size term, Real capRate, Real floorRate, Real spread, string freq, string dc)
 
QuantLib::ext::shared_ptr< TradebuildCPIInflationSwap (string id, string ccy, bool isPayer, Real notional, int start, Size term, Real spread, string floatFreq, string floatDC, string index, string cpiFreq, string cpiDC, string cpiIndex, Real baseRate, string observationLag, bool interpolated, Real cpiRate)
 
QuantLib::ext::shared_ptr< TradebuildYYInflationSwap (string id, string ccy, bool isPayer, Real notional, int start, Size term, Real spread, string floatFreq, string floatDC, string index, string yyFreq, string yyDC, string yyIndex, string observationLag, Size fixDays)
 
QuantLib::ext::shared_ptr< TradebuildYYInflationCapFloor (string id, string ccy, Real notional, bool isCap, bool isLong, Real capFloorRate, int start, Size term, string yyFreq, string yyDC, string yyIndex, string observationLag, Size fixDays)
 
QuantLib::ext::shared_ptr< TradebuildCommodityForward (const std::string &id, const std::string &position, Size term, const std::string &commodityName, const std::string &currency, Real strike, Real quantity)
 
QuantLib::ext::shared_ptr< TradebuildCommodityOption (const string &id, const string &longShort, const string &putCall, Size term, const string &commodityName, const string &currency, Real strike, Real quantity, Real premium, const string &premiumCcy, const string &premiumDate)
 
string toString (Date d)
 Utilities to set up simple test trades. More...
 
QuantLib::ext::shared_ptr< TradebuildSwap (string id, string ccy, bool isPayer, Real notional, int start, Size term, Real rate, Real spread, string fixedFreq, string fixedDC, string floatFreq, string floatDC, string index, Calendar cal=TARGET(), QuantLib::Natural fixingDays=2, bool spotStartLag=false)
 
QuantLib::ext::shared_ptr< TradebuildCap (string id, string ccy, string longShort, Real capRate, Real notional, int start, Size term, string floatFreq, string floatDC, string index, Calendar cal=TARGET(), QuantLib::Natural fixingDays=2, bool spotStartLag=false)
 
QuantLib::ext::shared_ptr< TradebuildFloor (string id, string ccy, string longShort, Real floorRate, Real notional, int start, Size term, string floatFreq, string floatDC, string index, Calendar cal=TARGET(), QuantLib::Natural fixingDays=2, bool spotStartLag=false)
 
QuantLib::ext::shared_ptr< TradebuildCapFloor (string id, string ccy, string longShort, vector< Real > capRates, vector< Real > floorRates, Real notional, int start, Size term, string floatFreq, string floatDC, string index, Calendar cal=TARGET(), QuantLib::Natural fixingDays=2, bool spotStartLag=false)
 
QuantLib::ext::shared_ptr< TradebuildCrossCcyBasisSwap (string id, string recCcy, Real recNotional, string payCcy, Real payNotional, int start, Size term, Real recLegSpread, Real payLegSpread, string recFreq, string recDC, string recIndex, Calendar recCalendar, string payFreq, string payDC, string payIndex, Calendar payCalendar, QuantLib::Natural spotDays=2, bool spotStartLag=false, bool notionalInitialExchange=false, bool notionalFinalExchange=false, bool notionalAmortizingExchange=false, bool isRecLegFXResettable=false, bool isPayLegFXResettable=false)
 
QuantLib::ext::shared_ptr< TradebuildCommodityOption (const std::string &id, const std::string &longShort, const std::string &putCall, QuantLib::Size term, const std::string &commodityName, const std::string &currency, QuantLib::Real strike, QuantLib::Real quantity, QuantLib::Real premium=0.0, const std::string &premiumCcy="", const std::string &premiumDate="")
 

Function Documentation

◆ testParConversion()

void testParConversion ( ObservationMode::Mode  om)

Definition at line 1062 of file parsensitivityanalysis.cpp.

1062 {
1063
1064 SavedSettings backup;
1065
1066 ObservationMode::Mode backupMode = ObservationMode::instance().mode();
1067 ObservationMode::instance().setMode(om);
1068
1069 Date today = Date(14, April, 2016); // Settings::instance().evaluationDate();
1070 Settings::instance().evaluationDate() = today;
1071
1072 BOOST_TEST_MESSAGE("Today is " << today);
1073
1074 // build model
1075 string baseCcy = "EUR";
1076 vector<string> ccys;
1077 ccys.push_back(baseCcy);
1078 ccys.push_back("GBP");
1079 ccys.push_back("CHF");
1080 ccys.push_back("USD");
1081 ccys.push_back("JPY");
1082
1083 // Init market
1084 QuantLib::ext::shared_ptr<Market> initMarket = QuantLib::ext::make_shared<TestMarket>(today);
1085
1086 // build scenario sim market parameters
1087 QuantLib::ext::shared_ptr<analytics::ScenarioSimMarketParameters> simMarketData = setupSimMarketData5();
1088
1089 // sensitivity config
1090 QuantLib::ext::shared_ptr<SensitivityScenarioData> sensiData = setupSensitivityScenarioData5(true);
1091
1092 // build scenario sim market
1093 QuantLib::ext::shared_ptr<analytics::ScenarioSimMarket> simMarket =
1094 QuantLib::ext::make_shared<analytics::ScenarioSimMarket>(initMarket, simMarketData);
1095
1096 // build scenario factory
1097 QuantLib::ext::shared_ptr<Scenario> baseScenario = simMarket->baseScenario();
1098 QuantLib::ext::shared_ptr<ScenarioFactory> scenarioFactory =
1099 QuantLib::ext::make_shared<ore::analytics::DeltaScenarioFactory>(baseScenario);
1100
1101 // build scenario generator
1102 QuantLib::ext::shared_ptr<SensitivityScenarioGenerator> scenarioGenerator =
1103 QuantLib::ext::make_shared<SensitivityScenarioGenerator>(sensiData, baseScenario, simMarketData, simMarket,
1104 scenarioFactory, false);
1105 simMarket->scenarioGenerator() = scenarioGenerator;
1106
1107 // build porfolio
1108 QuantLib::ext::shared_ptr<EngineData> engineData = QuantLib::ext::make_shared<EngineData>();
1109 engineData->model("Swap") = "DiscountedCashflows";
1110 engineData->engine("Swap") = "DiscountingSwapEngine";
1111 engineData->model("CrossCurrencySwap") = "DiscountedCashflows";
1112 engineData->engine("CrossCurrencySwap") = "DiscountingCrossCurrencySwapEngine";
1113 engineData->model("EuropeanSwaption") = "BlackBachelier";
1114 engineData->engine("EuropeanSwaption") = "BlackBachelierSwaptionEngine";
1115 engineData->model("FxForward") = "DiscountedCashflows";
1116 engineData->engine("FxForward") = "DiscountingFxForwardEngine";
1117 engineData->model("FxOption") = "GarmanKohlhagen";
1118 engineData->engine("FxOption") = "AnalyticEuropeanEngine";
1119 engineData->model("CapFloor") = "IborCapModel";
1120 engineData->engine("CapFloor") = "IborCapEngine";
1121 engineData->model("CapFlooredIborLeg") = "BlackOrBachelier";
1122 engineData->engine("CapFlooredIborLeg") = "BlackIborCouponPricer";
1123 engineData->model("YYCapFloor") = "YYCapModel";
1124 engineData->engine("YYCapFloor") = "YYCapEngine";
1125 engineData->model("Bond") = "DiscountedCashflows";
1126 engineData->engine("Bond") = "DiscountingRiskyBondEngine";
1127 engineData->engineParameters("Bond")["TimestepPeriod"] = "6M";
1128 engineData->model("CreditDefaultSwap") = "DiscountedCashflows";
1129 engineData->engine("CreditDefaultSwap") = "MidPointCdsEngine";
1130 engineData->model("EquityOption") = "BlackScholesMerton";
1131 engineData->engine("EquityOption") = "AnalyticEuropeanEngine";
1132 QuantLib::ext::shared_ptr<EngineFactory> factory = QuantLib::ext::make_shared<EngineFactory>(engineData, simMarket);
1133
1134 // QuantLib::ext::shared_ptr<Portfolio> portfolio = buildSwapPortfolio(portfolioSize, factory);
1135 QuantLib::ext::shared_ptr<Portfolio> portfolio(new Portfolio());
1136 portfolio->add(buildSwap("1_Swap_EUR", "EUR", true, 10000000.0, 0, 10, 0.03, 0.00, "1Y",
1137 "30/360", "6M", "A360", "EUR-EURIBOR-6M"));
1138 portfolio->add(buildSwap("2_Swap_USD", "USD", true, 10000000.0, 0, 15, 0.02, 0.00, "6M",
1139 "30/360", "3M", "A360", "USD-LIBOR-3M"));
1140 portfolio->add(buildCap("9_Cap_EUR", "EUR", "Long", 0.05, 1000000.0, 0, 10, "6M", "A360",
1141 "EUR-EURIBOR-6M"));
1142 portfolio->add(buildFloor("10_Floor_USD", "USD", "Long", 0.01, 1000000.0, 0, 10, "3M", "A360",
1143 "USD-LIBOR-3M"));
1144 portfolio->add(buildZeroBond("11_ZeroBond_EUR", "EUR", 1000000.0, 10));
1145 portfolio->add(buildZeroBond("12_ZeroBond_USD", "USD", 1000000.0, 10));
1146 portfolio->add(
1147 buildEquityOption("13_EquityOption_SP5", "Long", "Call", 2, "SP5", "USD", 2147.56, 1000));
1148 portfolio->add(buildYYInflationCapFloor("14_YoYInflationCap_UKRPI", "GBP", 100000.0, true, true,
1149 0.02, 0, 10, "1Y", "ACT/ACT", "UKRP1", "2M", 2));
1150 portfolio->build(factory);
1151 BOOST_TEST_MESSAGE("Portfolio size after build: " << portfolio->size());
1152
1153 // build the sensitivity analysis object
1154 // first build the par analysis object, so that we can align the pillars for the zero sensi analysis
1155 ParSensitivityAnalysis parAnalysis(today, simMarketData, *sensiData, Market::defaultConfiguration);
1156 parAnalysis.alignPillars();
1157 QuantLib::ext::shared_ptr<SensitivityAnalysis> zeroAnalysis = QuantLib::ext::make_shared<SensitivityAnalysis>(
1158 portfolio, initMarket, Market::defaultConfiguration, engineData, simMarketData, sensiData, false);
1159 BOOST_TEST_MESSAGE("SensitivityAnalysis object built");
1160 zeroAnalysis->overrideTenors(true);
1161 zeroAnalysis->generateSensitivities();
1162 BOOST_TEST_MESSAGE("Raw sensitivity analsis done");
1163 BOOST_TEST_MESSAGE("Par sensitivity analsis object built");
1164
1165 // RL: CRITICAL CHANGE
1166 // // TODO: should the next two lines not come before call to zeroAnalysis->generateSensitivities();?
1167 // // PC, 30-07-2018, yes they should, cached results have to be updated then (postponed...)
1168 // parAnalysis.alignPillars();
1169 // zeroAnalysis->overrideTenors(true);
1170 parAnalysis.computeParInstrumentSensitivities(zeroAnalysis->simMarket());
1171 QuantLib::ext::shared_ptr<ParSensitivityConverter> parConverter =
1172 QuantLib::ext::make_shared<ParSensitivityConverter>(parAnalysis.parSensitivities(), parAnalysis.shiftSizes());
1173 QuantLib::ext::shared_ptr<SensitivityCube> sensiCube = zeroAnalysis->sensiCube();
1174 ZeroToParCube parCube(sensiCube, parConverter);
1175
1176 map<pair<string, string>, Real> parDelta;
1177 for (const auto& tradeId : portfolio->ids()) {
1178 // Fill the par deltas map
1179 auto temp = parCube.parDeltas(tradeId);
1180 for (const auto& kv : temp) {
1181 // We only care about the actual "converted" par deltas here
1182 if (ParSensitivityAnalysis::isParType(kv.first.keytype)) {
1183 string des = sensiCube->factorDescription(kv.first);
1184 parDelta[make_pair(tradeId, des)] = kv.second;
1185 }
1186 }
1187 }
1188
1189 struct Results {
1190 string id;
1191 string label;
1192 Real sensi;
1193 };
1194
1195 std::vector<Results> cachedResults = {
1196 {"10_Floor_USD", "DiscountCurve/USD/0/6M", -0.00112886},
1197 {"10_Floor_USD", "DiscountCurve/USD/1/1Y", 0.00675206},
1198 {"10_Floor_USD", "DiscountCurve/USD/2/2Y", 0.00900048},
1199 {"10_Floor_USD", "DiscountCurve/USD/3/3Y", -0.0302434},
1200 {"10_Floor_USD", "DiscountCurve/USD/4/5Y", -0.262464},
1201 {"10_Floor_USD", "DiscountCurve/USD/5/7Y", -1.07006},
1202 {"10_Floor_USD", "DiscountCurve/USD/6/10Y", -1.04325},
1203 {"10_Floor_USD", "IndexCurve/USD-LIBOR-3M/0/6M", 0.00386584},
1204 {"10_Floor_USD", "IndexCurve/USD-LIBOR-3M/1/1Y", 0.2381},
1205 {"10_Floor_USD", "IndexCurve/USD-LIBOR-3M/2/2Y", 2.2426},
1206 {"10_Floor_USD", "IndexCurve/USD-LIBOR-3M/3/3Y", 7.56822},
1207 {"10_Floor_USD", "IndexCurve/USD-LIBOR-3M/4/5Y", 15.9842},
1208 {"10_Floor_USD", "IndexCurve/USD-LIBOR-3M/5/7Y", 22.2464},
1209 {"10_Floor_USD", "IndexCurve/USD-LIBOR-3M/6/10Y", -89.3588},
1210 {"10_Floor_USD", "OptionletVolatility/USD/0/1Y/0.01", -0.622505},
1211 {"10_Floor_USD", "OptionletVolatility/USD/10/3Y/0.01", -2.20215},
1212 {"10_Floor_USD", "OptionletVolatility/USD/15/5Y/0.01", 1.77487},
1213 {"10_Floor_USD", "OptionletVolatility/USD/20/10Y/0.01", 207.854},
1214 {"10_Floor_USD", "OptionletVolatility/USD/5/2Y/0.01", 1.78417},
1215 {"11_ZeroBond_EUR", "SurvivalProbability/BondIssuer1/0/6M", 1.53634},
1216 {"11_ZeroBond_EUR", "SurvivalProbability/BondIssuer1/1/1Y", 3.53444},
1217 {"11_ZeroBond_EUR", "SurvivalProbability/BondIssuer1/2/2Y", 8.6117},
1218 {"11_ZeroBond_EUR", "SurvivalProbability/BondIssuer1/3/3Y", 18.5064},
1219 {"11_ZeroBond_EUR", "SurvivalProbability/BondIssuer1/4/5Y", 39.4197},
1220 {"11_ZeroBond_EUR", "SurvivalProbability/BondIssuer1/5/7Y", 36.4505},
1221 {"11_ZeroBond_EUR", "SurvivalProbability/BondIssuer1/6/10Y", -600.06},
1222 {"11_ZeroBond_EUR", "YieldCurve/BondCurve1/0/6M", -0.657215},
1223 {"11_ZeroBond_EUR", "YieldCurve/BondCurve1/1/1Y", 2.95782},
1224 {"11_ZeroBond_EUR", "YieldCurve/BondCurve1/2/2Y", 6.06677},
1225 {"11_ZeroBond_EUR", "YieldCurve/BondCurve1/3/3Y", 14.1153},
1226 {"11_ZeroBond_EUR", "YieldCurve/BondCurve1/4/5Y", 32.8224},
1227 {"11_ZeroBond_EUR", "YieldCurve/BondCurve1/5/7Y", 58.069},
1228 {"11_ZeroBond_EUR", "YieldCurve/BondCurve1/6/10Y", -690.301},
1229 {"12_ZeroBond_USD", "SurvivalProbability/BondIssuer1/0/6M", 1.28029},
1230 {"12_ZeroBond_USD", "SurvivalProbability/BondIssuer1/1/1Y", 2.94537},
1231 {"12_ZeroBond_USD", "SurvivalProbability/BondIssuer1/2/2Y", 7.17642},
1232 {"12_ZeroBond_USD", "SurvivalProbability/BondIssuer1/3/3Y", 15.422},
1233 {"12_ZeroBond_USD", "SurvivalProbability/BondIssuer1/4/5Y", 32.8498},
1234 {"12_ZeroBond_USD", "SurvivalProbability/BondIssuer1/5/7Y", 30.3754},
1235 {"12_ZeroBond_USD", "SurvivalProbability/BondIssuer1/6/10Y", -500.05},
1236 {"12_ZeroBond_USD", "YieldCurve/BondCurve1/0/6M", -0.547679},
1237 {"12_ZeroBond_USD", "YieldCurve/BondCurve1/1/1Y", 2.46485},
1238 {"12_ZeroBond_USD", "YieldCurve/BondCurve1/2/2Y", 5.05564},
1239 {"12_ZeroBond_USD", "YieldCurve/BondCurve1/3/3Y", 11.7627},
1240 {"12_ZeroBond_USD", "YieldCurve/BondCurve1/4/5Y", 27.352},
1241 {"12_ZeroBond_USD", "YieldCurve/BondCurve1/5/7Y", 48.3909},
1242 {"12_ZeroBond_USD", "YieldCurve/BondCurve1/6/10Y", -575.251},
1243 {"13_EquityOption_SP5", "DiscountCurve/USD/0/6M", 0.270388},
1244 {"13_EquityOption_SP5", "DiscountCurve/USD/1/1Y", -1.35418},
1245 {"13_EquityOption_SP5", "DiscountCurve/USD/2/2Y", 158.893},
1246 {"14_YoYInflationCap_UKRPI", "DiscountCurve/GBP/0/6M", 0.00347664},
1247 {"14_YoYInflationCap_UKRPI", "DiscountCurve/GBP/1/1Y", -0.00921372},
1248 {"14_YoYInflationCap_UKRPI", "DiscountCurve/GBP/2/2Y", -0.0271867},
1249 {"14_YoYInflationCap_UKRPI", "DiscountCurve/GBP/3/3Y", -0.0973079},
1250 {"14_YoYInflationCap_UKRPI", "DiscountCurve/GBP/4/5Y", -0.298947},
1251 {"14_YoYInflationCap_UKRPI", "DiscountCurve/GBP/5/7Y", -0.69657},
1252 {"14_YoYInflationCap_UKRPI", "DiscountCurve/GBP/6/10Y", -0.950666},
1253 {"14_YoYInflationCap_UKRPI", "YoYInflationCapFloorVolatility/UKRP1/10/2Y/0.02", 0.131713},
1254 {"14_YoYInflationCap_UKRPI", "YoYInflationCapFloorVolatility/UKRP1/16/3Y/0.02", -0.155071},
1255 {"14_YoYInflationCap_UKRPI", "YoYInflationCapFloorVolatility/UKRP1/22/5Y/0.02", 0.336249},
1256 {"14_YoYInflationCap_UKRPI", "YoYInflationCapFloorVolatility/UKRP1/28/7Y/0.02", -0.585254},
1257 {"14_YoYInflationCap_UKRPI", "YoYInflationCapFloorVolatility/UKRP1/34/10Y/0.02", 9.11852},
1258 {"14_YoYInflationCap_UKRPI", "YoYInflationCapFloorVolatility/UKRP1/4/1Y/0.02", -0.0981938},
1259 {"14_YoYInflationCap_UKRPI", "YoYInflationCurve/UKRP1/0/1Y", -0.501498},
1260 {"14_YoYInflationCap_UKRPI", "YoYInflationCurve/UKRP1/1/2Y", 0.104595},
1261 {"14_YoYInflationCap_UKRPI", "YoYInflationCurve/UKRP1/2/3Y", -0.258415},
1262 {"14_YoYInflationCap_UKRPI", "YoYInflationCurve/UKRP1/3/5Y", 1.13565},
1263 {"14_YoYInflationCap_UKRPI", "YoYInflationCurve/UKRP1/4/7Y", -2.64434},
1264 {"14_YoYInflationCap_UKRPI", "YoYInflationCurve/UKRP1/5/10Y", 52.8805},
1265 {"1_Swap_EUR", "DiscountCurve/EUR/0/6M", 3.55166},
1266 {"1_Swap_EUR", "DiscountCurve/EUR/1/1Y", 8.07755},
1267 {"1_Swap_EUR", "DiscountCurve/EUR/2/2Y", 15.787},
1268 {"1_Swap_EUR", "DiscountCurve/EUR/3/3Y", 36.2307},
1269 {"1_Swap_EUR", "DiscountCurve/EUR/4/5Y", 81.6737},
1270 {"1_Swap_EUR", "DiscountCurve/EUR/5/7Y", 146.97},
1271 {"1_Swap_EUR", "DiscountCurve/EUR/6/10Y", 170.249},
1272 {"1_Swap_EUR", "IndexCurve/EUR-EURIBOR-6M/0/6M", -492.385},
1273 {"1_Swap_EUR", "IndexCurve/EUR-EURIBOR-6M/1/1Y", 0.267094},
1274 {"1_Swap_EUR", "IndexCurve/EUR-EURIBOR-6M/2/2Y", -0.0571774},
1275 {"1_Swap_EUR", "IndexCurve/EUR-EURIBOR-6M/3/3Y", -0.00710812},
1276 {"1_Swap_EUR", "IndexCurve/EUR-EURIBOR-6M/4/5Y", -0.201881},
1277 {"1_Swap_EUR", "IndexCurve/EUR-EURIBOR-6M/5/7Y", 34.3404},
1278 {"1_Swap_EUR", "IndexCurve/EUR-EURIBOR-6M/6/10Y", 8928.34},
1279 {"2_Swap_USD", "DiscountCurve/USD/0/6M", -1.47948},
1280 {"2_Swap_USD", "DiscountCurve/USD/1/1Y", -3.99176},
1281 {"2_Swap_USD", "DiscountCurve/USD/2/2Y", -10.9621},
1282 {"2_Swap_USD", "DiscountCurve/USD/3/3Y", -25.1411},
1283 {"2_Swap_USD", "DiscountCurve/USD/4/5Y", -57.393},
1284 {"2_Swap_USD", "DiscountCurve/USD/5/7Y", -103.903},
1285 {"2_Swap_USD", "DiscountCurve/USD/6/10Y", -250.483},
1286 {"2_Swap_USD", "DiscountCurve/USD/7/15Y", -269.282},
1287 {"2_Swap_USD", "IndexCurve/USD-LIBOR-3M/0/6M", -198.455},
1288 {"2_Swap_USD", "IndexCurve/USD-LIBOR-3M/1/1Y", 0.163363},
1289 {"2_Swap_USD", "IndexCurve/USD-LIBOR-3M/2/2Y", -0.0310057},
1290 {"2_Swap_USD", "IndexCurve/USD-LIBOR-3M/3/3Y", -0.00237856},
1291 {"2_Swap_USD", "IndexCurve/USD-LIBOR-3M/4/5Y", -0.126057},
1292 {"2_Swap_USD", "IndexCurve/USD-LIBOR-3M/5/7Y", 0.117712},
1293 {"2_Swap_USD", "IndexCurve/USD-LIBOR-3M/6/10Y", 10.6825},
1294 {"2_Swap_USD", "IndexCurve/USD-LIBOR-3M/7/15Y", 9972.55},
1295 {"9_Cap_EUR", "DiscountCurve/EUR/0/6M", 0.000267715},
1296 {"9_Cap_EUR", "DiscountCurve/EUR/1/1Y", 1.93692e-06},
1297 {"9_Cap_EUR", "DiscountCurve/EUR/2/2Y", 0.00120582},
1298 {"9_Cap_EUR", "DiscountCurve/EUR/3/3Y", 0.0038175},
1299 {"9_Cap_EUR", "DiscountCurve/EUR/4/5Y", 0.00870478},
1300 {"9_Cap_EUR", "DiscountCurve/EUR/5/7Y", -0.0375854},
1301 {"9_Cap_EUR", "DiscountCurve/EUR/6/10Y", -0.25186},
1302 {"9_Cap_EUR", "IndexCurve/EUR-EURIBOR-6M/0/6M", 0.000685155},
1303 {"9_Cap_EUR", "IndexCurve/EUR-EURIBOR-6M/1/1Y", -0.00175651},
1304 {"9_Cap_EUR", "IndexCurve/EUR-EURIBOR-6M/2/2Y", -0.0118899},
1305 {"9_Cap_EUR", "IndexCurve/EUR-EURIBOR-6M/3/3Y", -0.301921},
1306 {"9_Cap_EUR", "IndexCurve/EUR-EURIBOR-6M/4/5Y", -2.28152},
1307 {"9_Cap_EUR", "IndexCurve/EUR-EURIBOR-6M/5/7Y", -7.16938},
1308 {"9_Cap_EUR", "IndexCurve/EUR-EURIBOR-6M/6/10Y", 16.3599},
1309 {"9_Cap_EUR", "OptionletVolatility/EUR/14/3Y/0.05", -0.0903623},
1310 {"9_Cap_EUR", "OptionletVolatility/EUR/19/5Y/0.05", 0.0577696},
1311 {"9_Cap_EUR", "OptionletVolatility/EUR/24/10Y/0.05", 41.9784},
1312 {"9_Cap_EUR", "OptionletVolatility/EUR/4/1Y/0.05", -0.0489527},
1313 {"9_Cap_EUR", "OptionletVolatility/EUR/9/2Y/0.05", 0.0995465}};
1314
1315 std::map<pair<string, string>, Real> sensiMap;
1316 for (Size i = 0; i < cachedResults.size(); ++i) {
1317 pair<string, string> p(cachedResults[i].id, cachedResults[i].label);
1318 sensiMap[p] = cachedResults[i].sensi;
1319 }
1320
1321 Real tolerance = 0.01;
1322 Size count = 0;
1323 for (auto data : parDelta) {
1324 pair<string, string> p = data.first;
1325 Real delta = data.second;
1326 if (fabs(delta) > 0.0) {
1327 count++;
1328 BOOST_CHECK_MESSAGE(sensiMap.find(p) != sensiMap.end(),
1329 "pair (" << p.first << ", " << p.second << ") not found in sensi map");
1330 if (sensiMap.find(p) != sensiMap.end()) {
1331 BOOST_CHECK_MESSAGE(fabs(delta - sensiMap[p]) < tolerance ||
1332 fabs((delta - sensiMap[p]) / delta) < tolerance,
1333 "sensitivity regression failed for pair ("
1334 << p.first << ", " << p.second << "): " << delta << " vs " << sensiMap[p]);
1335 }
1336 }
1337 }
1338 BOOST_CHECK_MESSAGE(count == cachedResults.size(), "number of non-zero par sensitivities ("
1339 << count << ") do not match regression data ("
1340 << cachedResults.size() << ")");
1341 ObservationMode::instance().setMode(backupMode);
1342 IndexManager::instance().clearHistories();
1343}
static bool isParType(ore::analytics::RiskFactorKey::KeyType type)
Returns true if risk factor type is applicable for par conversion.
static const string defaultConfiguration
data
QuantLib::ext::shared_ptr< Trade > buildCap(string id, string ccy, string longShort, Real capRate, Real notional, int start, Size term, string floatFreq, string floatDC, string index, Calendar calendar, Natural spotDays, bool spotStartLag)
QuantLib::ext::shared_ptr< Trade > buildSwap(string id, string ccy, bool isPayer, Real notional, int start, Size term, Real rate, Real spread, string fixedFreq, string fixedDC, string floatFreq, string floatDC, string index, Calendar calendar, Natural spotDays, bool spotStartLag)
QuantLib::ext::shared_ptr< Trade > buildZeroBond(string id, string ccy, Real notional, Size term, string suffix)
QuantLib::ext::shared_ptr< Trade > buildEquityOption(string id, string longShort, string putCall, Size expiry, string equityName, string currency, Real strike, Real quantity, Real premium, string premiumCcy, string premiumDate)
QuantLib::ext::shared_ptr< Trade > buildFloor(string id, string ccy, string longShort, Real floorRate, Real notional, int start, Size term, string floatFreq, string floatDC, string index, Calendar calendar, Natural spotDays, bool spotStartLag)
QuantLib::ext::shared_ptr< Trade > buildYYInflationCapFloor(string id, string ccy, Real notional, bool isCap, bool isLong, Real capFloorRate, int start, Size term, string yyFreq, string yyDC, string yyIndex, string observationLag, Size fixDays)
std::size_t count
QuantLib::ext::shared_ptr< SensitivityScenarioData > setupSensitivityScenarioData5(bool parConversion)
QuantLib::ext::shared_ptr< analytics::ScenarioSimMarketParameters > setupSimMarketData5()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BOOST_AUTO_TEST_CASE() [1/20]

BOOST_AUTO_TEST_CASE ( ZeroShifts1d  )

Definition at line 1574 of file parsensitivityanalysis.cpp.

1574 {
1575 BOOST_TEST_MESSAGE("Testing 1-d Zero Shifts");
1576 ParSensitivityAnalysisTest::test1dZeroShifts();
1577}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/20]

BOOST_AUTO_TEST_CASE ( ZeroShifts2d  )

Definition at line 1579 of file parsensitivityanalysis.cpp.

1579 {
1580 BOOST_TEST_MESSAGE("Testing 2-d Zero Shifts");
1581 ParSensitivityAnalysisTest::test2dZeroShifts();
1582}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [3/20]

BOOST_AUTO_TEST_CASE ( ZeroSensitivity  )

Definition at line 1584 of file parsensitivityanalysis.cpp.

1584 {
1585 BOOST_TEST_MESSAGE("Testing Portfolio Zero Sensitivity");
1586 ParSensitivityAnalysisTest::testPortfolioZeroSensitivity();
1587}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [4/20]

BOOST_AUTO_TEST_CASE ( ParConversionNoneObs  )

Definition at line 1589 of file parsensitivityanalysis.cpp.

1589 {
1590 BOOST_TEST_MESSAGE("Testing Par Conversion NoneObs");
1591 ParSensitivityAnalysisTest::testParConversionNoneObs();
1592}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [5/20]

BOOST_AUTO_TEST_CASE ( ParConversionDisableObs  )

Definition at line 1594 of file parsensitivityanalysis.cpp.

1594 {
1595 BOOST_TEST_MESSAGE("Testing Par Conversion DisableObs");
1596 ParSensitivityAnalysisTest::testParConversionDisableObs();
1597}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [6/20]

BOOST_AUTO_TEST_CASE ( ParConversionDeferObs  )

Definition at line 1599 of file parsensitivityanalysis.cpp.

1599 {
1600 BOOST_TEST_MESSAGE("Testing Par Conversion DeferObs");
1601 ParSensitivityAnalysisTest::testParConversionDeferObs();
1602}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [7/20]

BOOST_AUTO_TEST_CASE ( ParConversionUnregisterObs  )

Definition at line 1604 of file parsensitivityanalysis.cpp.

1604 {
1605 BOOST_TEST_MESSAGE("Testing Par Conversion UnregisterObs");
1606 ParSensitivityAnalysisTest::testParConversionUnregisterObs();
1607}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [8/20]

BOOST_AUTO_TEST_CASE ( ParSwapBenchmarkTest  )

Definition at line 631 of file parsensitivityanalysismanual.cpp.

631 {
632 BOOST_TEST_MESSAGE("Testing ParSwapBenchmark");
633 ParSensitivityAnalysisManualTest::testParSwapBenchmark();
634}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [9/20]

BOOST_AUTO_TEST_CASE ( SensiPerformanceNoneObs  )

Definition at line 929 of file sensitivityperformanceplus.cpp.

929 {
930 BOOST_TEST_MESSAGE("Testing Sensitivity Performance NoneObs");
931 SensitivityPerformancePlusTest::testSensiPerformanceNoneObs();
932}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [10/20]

BOOST_AUTO_TEST_CASE ( SensiPerformanceDisableObs  )

Definition at line 934 of file sensitivityperformanceplus.cpp.

934 {
935 BOOST_TEST_MESSAGE("Testing Sensitivity Performance DisableObs");
936 SensitivityPerformancePlusTest::testSensiPerformanceDisableObs();
937}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [11/20]

BOOST_AUTO_TEST_CASE ( SensiPerformanceDeferObs  )

Definition at line 939 of file sensitivityperformanceplus.cpp.

939 {
940 BOOST_TEST_MESSAGE("Testing Sensitivity Performance DeferObs");
941 SensitivityPerformancePlusTest::testSensiPerformanceDeferObs();
942}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [12/20]

BOOST_AUTO_TEST_CASE ( SensiPerformanceUnregisterObs  )

Definition at line 944 of file sensitivityperformanceplus.cpp.

944 {
945 BOOST_TEST_MESSAGE("Testing Sensitivity Performance UnregisterObs");
946 SensitivityPerformancePlusTest::testSensiPerformanceUnregisterObs();
947}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [13/20]

BOOST_AUTO_TEST_CASE ( SensiPerformanceCrossGammaNoneObs  )

Definition at line 949 of file sensitivityperformanceplus.cpp.

949 {
950 BOOST_TEST_MESSAGE("Testing Sensitivity Performance CrossGammaNoneObs");
951 SensitivityPerformancePlusTest::testSensiPerformanceCrossGammaNoneObs();
952}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [14/20]

BOOST_AUTO_TEST_CASE ( SensiPerformanceBigScenarioNoneObs  )

Definition at line 954 of file sensitivityperformanceplus.cpp.

954 {
955 BOOST_TEST_MESSAGE("Testing Sensitivity Performance BigScenarioNoneObs");
956 SensitivityPerformancePlusTest::testSensiPerformanceBigScenarioNoneObs();
957}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [15/20]

BOOST_AUTO_TEST_CASE ( SensiPerformanceBigPortfolioObs  )

Definition at line 965 of file sensitivityperformanceplus.cpp.

965 {
966 BOOST_TEST_MESSAGE("Testing Sensitivity Performance BigPortfolioNoneObs");
967 SensitivityPerformancePlusTest::testSensiPerformanceBigPortfolioNoneObs();
968}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [16/20]

BOOST_AUTO_TEST_CASE ( SensiPerformanceBigPortfolioBigScenarioNoneObs  )

Definition at line 970 of file sensitivityperformanceplus.cpp.

970 {
971 BOOST_TEST_MESSAGE("Testing Sensitivity Performance BigPortfolioBigScenarioNoneObs");
972 SensitivityPerformancePlusTest::testSensiPerformanceBigPortfolioBigScenarioNoneObs();
973}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [17/20]

BOOST_AUTO_TEST_CASE ( SensiPerformanceBigPortfolioCrossGammaNoneObs  )

Definition at line 975 of file sensitivityperformanceplus.cpp.

975 {
976 BOOST_TEST_MESSAGE("Testing Sensitivity Performance BigPortfolioCrossGammaNoneObs");
977 SensitivityPerformancePlusTest::testSensiPerformanceBigPortfolioCrossGammaNoneObs();
978}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [18/20]

BOOST_AUTO_TEST_CASE ( SensiPerformanceBigScenarioCrossGammaNoneObs  )

Definition at line 986 of file sensitivityperformanceplus.cpp.

986 {
987 BOOST_TEST_MESSAGE("Testing Sensitivity Performance BigScenarioCrossGammaNoneObs");
988 SensitivityPerformancePlusTest::testSensiPerformanceBigScenarioCrossGammaNoneObs();
989}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [19/20]

BOOST_AUTO_TEST_CASE ( SensiPerformanceBigPortfolioBigScenarioCrossGammaNoneObs  )

Definition at line 997 of file sensitivityperformanceplus.cpp.

997 {
998 BOOST_TEST_MESSAGE("Testing Sensitivity Performance BigPortfolioBigScenarioCrossGammaNoneObs");
999 SensitivityPerformancePlusTest::testSensiPerformanceBigPortfolioBigScenarioCrossGammaNoneObs();
1000}
+ Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [20/20]

BOOST_AUTO_TEST_CASE ( SensiPerformanceBTSetupNoneObs  )

Definition at line 1008 of file sensitivityperformanceplus.cpp.

1008 {
1009 BOOST_TEST_MESSAGE("Testing Sensitivity Performance BTSetupNoneObs");
1010 SensitivityPerformancePlusTest::testSensiPerformanceBTSetupNoneObs();
1011}
+ Here is the call graph for this function:

◆ createCurveData()

Definition at line 1344 of file testmarket.cpp.

1344 {
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}
+ Here is the caller graph for this function:

◆ buildSwap() [1/2]

QuantLib::ext::shared_ptr< Trade > buildSwap ( string  id,
string  ccy,
bool  isPayer,
Real  notional,
int  start,
Size  term,
Real  rate,
Real  spread,
string  fixedFreq,
string  fixedDC,
string  floatFreq,
string  floatDC,
string  index,
Calendar  calendar,
Natural  spotDays,
bool  spotStartLag 
)

Definition at line 48 of file testportfolio.cpp.

50 {
51 Date today = Settings::instance().evaluationDate();
52 ostringstream o;
53 o << calendar;
54 string cal = o.str();
55 string conv = "MF";
56 string rule = "Forward";
57
58 vector<Real> notionals(1, notional);
59 vector<Real> rates(1, rate);
60 vector<Real> spreads(1, spread);
61
62 Period spotStartLagTenor = spotStartLag ? spotDays * Days : 0 * Days;
63
64 Date qlStartDate = calendar.adjust(today + spotStartLagTenor + start * Years);
65 Date qlEndDate = calendar.adjust(qlStartDate + term * Years);
66 string startDate = ore::data::to_string(qlStartDate);
67 string endDate = ore::data::to_string(qlEndDate);
68
69 // envelope
70 Envelope env("CP");
71 // schedules
72 ScheduleData floatSchedule(ScheduleRules(startDate, endDate, floatFreq, cal, conv, conv, rule));
73 ScheduleData fixedSchedule(ScheduleRules(startDate, endDate, fixedFreq, cal, conv, conv, rule));
74 // fixed leg
75 LegData fixedLeg(QuantLib::ext::make_shared<FixedLegData>(rates), isPayer, ccy, fixedSchedule, fixedDC, notionals);
76 // float leg
77 LegData floatingLeg(QuantLib::ext::make_shared<FloatingLegData>(index, spotDays, false, spreads), !isPayer, ccy,
78 floatSchedule, floatDC, notionals);
79 // trade
80 QuantLib::ext::shared_ptr<Trade> trade(new ore::data::Swap(env, floatingLeg, fixedLeg));
81 trade->id() = id;
82
83 return trade;
84
85}
Calendar calendar
std::string to_string(const LocationInfo &l)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildEuropeanSwaption()

QuantLib::ext::shared_ptr< Trade > buildEuropeanSwaption ( string  id,
string  longShort,
string  ccy,
bool  isPayer,
Real  notional,
int  start,
Size  term,
Real  rate,
Real  spread,
string  fixedFreq,
string  fixedDC,
string  floatFreq,
string  floatDC,
string  index,
string  cashPhysical,
Real  premium,
string  premiumCcy,
string  premiumDate 
)

Definition at line 87 of file testportfolio.cpp.

91 {
92
93 Date today = Settings::instance().evaluationDate();
94 Calendar calendar = TARGET();
95 int days = 2;
96 string cal = "TARGET";
97 string conv = "MF";
98 string rule = "Forward";
99
100 vector<Real> notionals(1, notional);
101 vector<Real> rates(1, rate);
102 vector<Real> spreads(1, spread);
103
104 Date qlStartDate = calendar.adjust(today + start * Years);
105 Date qlEndDate = calendar.adjust(qlStartDate + term * Years);
106 string startDate = ore::data::to_string(qlStartDate);
107 string endDate = ore::data::to_string(qlEndDate);
108
109 // envelope
110 Envelope env("CP");
111 // schedules
112 ScheduleData floatSchedule(ScheduleRules(startDate, endDate, floatFreq, cal, conv, conv, rule));
113 ScheduleData fixedSchedule(ScheduleRules(startDate, endDate, fixedFreq, cal, conv, conv, rule));
114 // fixed leg
115 LegData fixedLeg(QuantLib::ext::make_shared<FixedLegData>(rates), isPayer, ccy, fixedSchedule, fixedDC, notionals);
116 // float leg
117 LegData floatingLeg(QuantLib::ext::make_shared<FloatingLegData>(index, days, false, spreads), !isPayer, ccy, floatSchedule,
118 floatDC, notionals);
119 // leg vector
120 vector<LegData> legs;
121 legs.push_back(fixedLeg);
122 legs.push_back(floatingLeg);
123 // option data
124 OptionData option(longShort, "Call", "European", false, vector<string>(1, startDate), cashPhysical, "",
125 premiumDate.empty() ? PremiumData() : PremiumData(premium, premiumCcy, parseDate(premiumDate)));
126 // trade
127 QuantLib::ext::shared_ptr<Trade> trade(new ore::data::Swaption(env, option, legs));
128 trade->id() = id;
129
130 return trade;
131}
Date parseDate(const string &s)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildBermudanSwaption()

QuantLib::ext::shared_ptr< Trade > buildBermudanSwaption ( string  id,
string  longShort,
string  ccy,
bool  isPayer,
Real  notional,
Size  exercises,
int  start,
Size  term,
Real  rate,
Real  spread,
string  fixedFreq,
string  fixedDC,
string  floatFreq,
string  floatDC,
string  index,
string  cashPhysical,
Real  premium,
string  premiumCcy,
string  premiumDate 
)

Definition at line 133 of file testportfolio.cpp.

137 {
138
139 Date today = Settings::instance().evaluationDate();
140 Calendar calendar = TARGET();
141 int days = 2;
142 string cal = "TARGET";
143 string conv = "MF";
144 string rule = "Forward";
145
146 vector<Real> notionals(1, notional);
147 vector<Real> rates(1, rate);
148 vector<Real> spreads(1, spread);
149
150 Date qlStartDate = calendar.adjust(today + start * Years);
151 Date qlEndDate = calendar.adjust(qlStartDate + term * Years);
152 string startDate = ore::data::to_string(qlStartDate);
153 string endDate = ore::data::to_string(qlEndDate);
154
155 vector<string> exerciseDates;
156 for (Size i = 0; i < exercises; ++i) {
157 Date exerciseDate = qlStartDate + i * Years;
158 exerciseDates.push_back(ore::data::to_string(exerciseDate));
159 }
160
161 // envelope
162 Envelope env("CP");
163 // schedules
164 ScheduleData floatSchedule(ScheduleRules(startDate, endDate, floatFreq, cal, conv, conv, rule));
165 ScheduleData fixedSchedule(ScheduleRules(startDate, endDate, fixedFreq, cal, conv, conv, rule));
166 // fixed leg
167 LegData fixedLeg(QuantLib::ext::make_shared<FixedLegData>(rates), isPayer, ccy, fixedSchedule, fixedDC, notionals);
168 // float leg
169 LegData floatingLeg(QuantLib::ext::make_shared<FloatingLegData>(index, days, false, spreads), !isPayer, ccy, floatSchedule,
170 floatDC, notionals);
171 // leg vector
172 vector<LegData> legs;
173 legs.push_back(fixedLeg);
174 legs.push_back(floatingLeg);
175 // option data
176 OptionData option(longShort, "Call", "Bermudan", false, exerciseDates, cashPhysical, "",
177 premiumDate.empty() ? PremiumData() : PremiumData(premium, premiumCcy, parseDate(premiumDate)));
178 // trade
179 QuantLib::ext::shared_ptr<Trade> trade(new ore::data::Swaption(env, option, legs));
180 trade->id() = id;
181
182 return trade;
183}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildFxOption()

QuantLib::ext::shared_ptr< Trade > buildFxOption ( string  id,
string  longShort,
string  putCall,
Size  expiry,
string  boughtCcy,
Real  boughtAmount,
string  soldCcy,
Real  soldAmount,
Real  premium,
string  premiumCcy,
string  premiumDate 
)

Definition at line 185 of file testportfolio.cpp.

187 {
188 Date today = Settings::instance().evaluationDate();
189 Calendar calendar = TARGET();
190 string cal = "TARGET";
191 string conv = "MF";
192 string rule = "Forward";
193
194 Date qlExpiry = calendar.adjust(today + expiry * Years);
195 string expiryDate = ore::data::to_string(qlExpiry);
196
197 // envelope
198 Envelope env("CP");
199 // option data
200 OptionData option(longShort, putCall, "European", false, vector<string>(1, expiryDate), "Cash", "",
201 premiumDate.empty() ? PremiumData() : PremiumData(premium, premiumCcy, parseDate(premiumDate)));
202 // trade
203 QuantLib::ext::shared_ptr<Trade> trade(new ore::data::FxOption(env, option, boughtCcy, boughtAmount, soldCcy, soldAmount));
204 trade->id() = id;
205
206 return trade;
207}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildEquityOption()

QuantLib::ext::shared_ptr< Trade > buildEquityOption ( string  id,
string  longShort,
string  putCall,
Size  expiry,
string  equityName,
string  currency,
Real  strike,
Real  quantity,
Real  premium,
string  premiumCcy,
string  premiumDate 
)

Definition at line 209 of file testportfolio.cpp.

211 {
212 Date today = Settings::instance().evaluationDate();
213 Calendar calendar = TARGET();
214 string cal = "TARGET";
215 string conv = "MF";
216 string rule = "Forward";
217
218 Date qlExpiry = calendar.adjust(today + expiry * Years);
219 string expiryDate = ore::data::to_string(qlExpiry);
220
221 TradeStrike tradeStrike(strike, currency);
222
223 // envelope
224 Envelope env("CP");
225 // option data
226 OptionData option(longShort, putCall, "European", false, vector<string>(1, expiryDate), "Cash", "",
227 premiumDate.empty() ? PremiumData() : PremiumData(premium, premiumCcy, parseDate(premiumDate)));
228 // trade
229 QuantLib::ext::shared_ptr<Trade> trade(
230 new ore::data::EquityOption(env, option, EquityUnderlying(equityName), currency, quantity, tradeStrike));
231 trade->id() = id;
232
233 return trade;
234}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildEquityForward()

QuantLib::ext::shared_ptr< Trade > buildEquityForward ( string  id,
string  longShort,
Size  expiry,
string  equityName,
string  currency,
Real  strike,
Real  quantity 
)

Definition at line 236 of file testportfolio.cpp.

237 {
238 Date today = Settings::instance().evaluationDate();
239 Calendar calendar = TARGET();
240
241 Date qlExpiry = calendar.adjust(today + expiry * Years);
242 string expiryDate = ore::data::to_string(qlExpiry);
243
244 // envelope
245 Envelope env("CP");
246 // trade
247 QuantLib::ext::shared_ptr<Trade> trade(new ore::data::EquityForward(env, longShort, EquityUnderlying(equityName), currency,
248 quantity, expiryDate, strike));
249 trade->id() = id;
250
251 return trade;
252}
+ Here is the call graph for this function:

◆ buildCap() [1/2]

QuantLib::ext::shared_ptr< Trade > buildCap ( string  id,
string  ccy,
string  longShort,
Real  capRate,
Real  notional,
int  start,
Size  term,
string  floatFreq,
string  floatDC,
string  index,
Calendar  calendar,
Natural  spotDays,
bool  spotStartLag 
)

Definition at line 254 of file testportfolio.cpp.

256 {
257 return buildCapFloor(id, ccy, longShort, vector<Real>(1, capRate), vector<Real>(), notional, start, term, floatFreq,
258 floatDC, index, calendar, spotDays, spotStartLag);
259}
QuantLib::ext::shared_ptr< Trade > buildCapFloor(string id, string ccy, string longShort, vector< Real > capRates, vector< Real > floorRates, Real notional, int start, Size term, string floatFreq, string floatDC, string index, Calendar calendar, Natural spotDays, bool spotStartLag)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildFloor() [1/2]

QuantLib::ext::shared_ptr< Trade > buildFloor ( string  id,
string  ccy,
string  longShort,
Real  floorRate,
Real  notional,
int  start,
Size  term,
string  floatFreq,
string  floatDC,
string  index,
Calendar  calendar,
Natural  spotDays,
bool  spotStartLag 
)

Definition at line 261 of file testportfolio.cpp.

263 {
264 return buildCapFloor(id, ccy, longShort, vector<Real>(), vector<Real>(1, floorRate), notional, start, term,
265 floatFreq, floatDC, index, calendar, spotDays, spotStartLag);
266}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildCapFloor() [1/2]

QuantLib::ext::shared_ptr< Trade > buildCapFloor ( string  id,
string  ccy,
string  longShort,
vector< Real >  capRates,
vector< Real >  floorRates,
Real  notional,
int  start,
Size  term,
string  floatFreq,
string  floatDC,
string  index,
Calendar  calendar,
Natural  spotDays,
bool  spotStartLag 
)

Definition at line 268 of file testportfolio.cpp.

271 {
272 Date today = Settings::instance().evaluationDate();
273 // Calendar calendar = TARGET();
274 // Size days = 2;
275 // string cal = "TARGET";
276 ostringstream o;
277 o << calendar;
278 string cal = o.str();
279 string conv = "MF";
280 string rule = "Forward";
281
282 vector<Real> notionals(1, notional);
283 vector<Real> spreads(1, 0.0);
284
285 Period spotStartLagTenor = spotStartLag ? spotDays * Days : 0 * Days;
286
287 Date qlStartDate = calendar.adjust(today + spotStartLagTenor + start * Years);
288 Date qlEndDate = calendar.adjust(qlStartDate + term * Years);
289 string startDate = ore::data::to_string(qlStartDate);
290 string endDate = ore::data::to_string(qlEndDate);
291
292 // envelope
293 Envelope env("CP");
294 // schedules
295 ScheduleData floatSchedule(ScheduleRules(startDate, endDate, floatFreq, cal, conv, conv, rule));
296 // float leg
297 LegData floatingLeg(QuantLib::ext::make_shared<FloatingLegData>(index, spotDays, false, spreads), false, ccy, floatSchedule,
298 floatDC, notionals);
299 // trade
300 QuantLib::ext::shared_ptr<Trade> trade(new ore::data::CapFloor(env, longShort, floatingLeg, capRates, floorRates));
301 trade->id() = id;
302
303 return trade;
304}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildCrossCcyBasisSwap() [1/2]

QuantLib::ext::shared_ptr< Trade > buildCrossCcyBasisSwap ( string  id,
string  recCcy,
Real  recNotional,
string  payCcy,
Real  payNotional,
int  start,
Size  term,
Real  recLegSpread,
Real  payLegSpread,
string  recFreq,
string  recDC,
string  recIndex,
Calendar  recCalendar,
string  payFreq,
string  payDC,
string  payIndex,
Calendar  payCalendar,
Natural  spotDays,
bool  spotStartLag,
bool  notionalInitialExchange,
bool  notionalFinalExchange,
bool  notionalAmortizingExchange,
bool  isRecLegFXResettable,
bool  isPayLegFXResettable 
)

Definition at line 306 of file testportfolio.cpp.

311 {
312 Date today = Settings::instance().evaluationDate();
313
314 string payCal = to_string(payCalendar);
315 string recCal = to_string(recCalendar);
316 string conv = "MF";
317 string rule = "Forward";
318
319 vector<Real> recNotionals(1, recNotional);
320 vector<Real> recSpreads(1, recLegSpread);
321 vector<Real> payNotionals(1, payNotional);
322 vector<Real> paySpreads(1, payLegSpread);
323
324 Period spotStartLagTenor = spotStartLag ? spotDays * Days : 0 * Days;
325
326 Date qlStartDate = recCalendar.adjust(today + spotStartLagTenor + start * Years);
327 Date qlEndDate = recCalendar.adjust(qlStartDate + term * Years);
328 string startDate = ore::data::to_string(qlStartDate);
329 string endDate = ore::data::to_string(qlEndDate);
330
331 // envelope
332 Envelope env("CP");
333 // schedules
334 ScheduleData recSchedule(ScheduleRules(startDate, endDate, recFreq, recCal, conv, conv, rule));
335 ScheduleData paySchedule(ScheduleRules(startDate, endDate, payFreq, payCal, conv, conv, rule));
336 // rec float leg
337 auto recFloatingLegData = QuantLib::ext::make_shared<FloatingLegData>(recIndex, spotDays, false, recSpreads);
338 LegData recFloatingLeg;
339 if (isRecLegFXResettable) {
340 string fxIndex = "FX-ECB-" + recCcy + "-" + payCcy;
341 recFloatingLeg = LegData(recFloatingLegData, false, recCcy, recSchedule, recDC, recNotionals, vector<string>(),
342 conv, notionalInitialExchange, notionalFinalExchange, notionalAmortizingExchange,
343 isRecLegFXResettable, payCcy, payNotional, fxIndex);
344 } else {
345 recFloatingLeg = LegData(recFloatingLegData, false, recCcy, recSchedule, recDC, recNotionals, vector<string>(),
346 conv, notionalInitialExchange, notionalFinalExchange, notionalAmortizingExchange);
347 }
348 // pay float leg
349 auto payFloatingLegData = QuantLib::ext::make_shared<FloatingLegData>(payIndex, spotDays, false, recSpreads);
350 LegData payFloatingLeg;
351 if (isPayLegFXResettable) {
352 string fxIndex = "FX-ECB-" + payCcy + "-" + recCcy;
353 payFloatingLeg = LegData(payFloatingLegData, true, payCcy, paySchedule, payDC, payNotionals, vector<string>(),
354 conv, notionalInitialExchange, notionalFinalExchange, notionalAmortizingExchange,
355 !isPayLegFXResettable, recCcy, recNotional, fxIndex);
356 } else {
357 payFloatingLeg = LegData(payFloatingLegData, true, payCcy, paySchedule, payDC, payNotionals, vector<string>(),
358 conv, notionalInitialExchange, notionalFinalExchange, notionalAmortizingExchange);
359 }
360 // trade
361 QuantLib::ext::shared_ptr<Trade> trade(new ore::data::Swap(env, recFloatingLeg, payFloatingLeg));
362 trade->id() = id;
363
364 return trade;
365}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildZeroBond()

QuantLib::ext::shared_ptr< Trade > buildZeroBond ( string  id,
string  ccy,
Real  notional,
Size  term,
string  suffix 
)

Definition at line 367 of file testportfolio.cpp.

367 {
368 Date today = Settings::instance().evaluationDate();
369 Date qlEndDate = today + term * Years;
370 string maturityDate = ore::data::to_string(qlEndDate);
371 string issueDate = ore::data::to_string(today);
372
373 string settlementDays = "2";
374 string calendar = "TARGET";
375 string issuerId = "BondIssuer" + suffix;
376 string creditCurveId = "BondIssuer" + suffix;
377 string securityId = "Bond" + suffix;
378 string referenceCurveId = "BondCurve" + suffix;
379 // envelope
380 Envelope env("CP");
381 QuantLib::ext::shared_ptr<Trade> trade(
382 new ore::data::Bond(env, BondData(issuerId, creditCurveId, securityId, referenceCurveId, settlementDays,
383 calendar, notional, maturityDate, ccy, issueDate)));
384 trade->id() = id;
385
386 return trade;
387}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildCreditDefaultSwap()

QuantLib::ext::shared_ptr< Trade > buildCreditDefaultSwap ( string  id,
string  ccy,
string  issuerId,
string  creditCurveId,
bool  isPayer,
Real  notional,
int  start,
Size  term,
Real  rate,
Real  spread,
string  fixedFreq,
string  fixedDC 
)

Definition at line 389 of file testportfolio.cpp.

392 {
393 Date today = Settings::instance().evaluationDate();
394
395 string settlementDays = "1";
396 Calendar calendar = WeekendsOnly();
397 string cal = "WeekendsOnly";
398 string conv = "F";
399 string convEnd = "U";
400 string rule = "CDS2015";
401
402 vector<Real> notionals(1, notional);
403 vector<Real> rates(1, rate);
404 vector<Real> spreads(1, spread);
405
406 Date qlStartDate = calendar.adjust(today + start * Years);
407 Date qlEndDate = calendar.adjust(qlStartDate + term * Years);
408 string startDate = ore::data::to_string(qlStartDate);
409 string endDate = ore::data::to_string(qlEndDate);
410
411 // envelope
412 Envelope env("CP");
413 ScheduleData fixedSchedule(ScheduleRules(startDate, endDate, fixedFreq, cal, conv, convEnd, rule));
414 // fixed leg
415 LegData fixedLeg(QuantLib::ext::make_shared<FixedLegData>(spreads), isPayer, ccy, fixedSchedule, fixedDC, notionals);
416
417 ore::data::CreditDefaultSwapData swap(issuerId, creditCurveId, fixedLeg, true,
418 QuantExt::CreditDefaultSwap::ProtectionPaymentTime::atDefault, today + 1);
419 QuantLib::ext::shared_ptr<Trade> trade(new ore::data::CreditDefaultSwap(env, swap));
420
421 trade->id() = id;
422
423 return trade;
424}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildSyntheticCDO()

QuantLib::ext::shared_ptr< Trade > buildSyntheticCDO ( string  id,
string  name,
vector< string >  names,
string  longShort,
string  ccy,
vector< string >  ccys,
bool  isPayer,
vector< Real >  notionals,
Real  notional,
int  start,
Size  term,
Real  rate,
Real  spread,
string  fixedFreq,
string  fixedDC 
)

Definition at line 426 of file testportfolio.cpp.

430 {
431 Date today = Settings::instance().evaluationDate();
432 Calendar calendar = WeekendsOnly();
433 string cal = "WeekendsOnly";
434 string conv = "F";
435 string rule = "CDS2015";
436 string issuerId = name;
437 string creditCurveId = name;
438 string qualifier = "Tranch1";
439
440 Real attachmentPoint = 0.0;
441 Real detachmentPoint = 0.1;
442 bool settlesAccrual = true;
443 QuantExt::CreditDefaultSwap::ProtectionPaymentTime protectionPaymentTime =
444 QuantExt::CreditDefaultSwap::ProtectionPaymentTime::atDefault;
445
446 Real upfrontFee = 0.0;
447
448 vector<Real> notionalTotal(names.size(), notional);
449 vector<Real> rates(names.size(), rate);
450 vector<Real> spreads(names.size(), spread);
451
452 Date qlStartDate = calendar.adjust(today + start * Years);
453 Date qlProtectionStartDate = calendar.advance(qlStartDate, 1 * Days);
454 Date qlEndDate = calendar.adjust(qlStartDate + term * Years);
455 Date qlUpfrontDate = calendar.advance(qlStartDate, 3 * Days);
456 string startDate = ore::data::to_string(qlStartDate);
457 string protectionStart = ore::data::to_string(qlProtectionStartDate);
458 string endDate = ore::data::to_string(qlEndDate);
459 string upfrontDate = ore::data::to_string(qlUpfrontDate);
460
461 // envelope
462 Envelope env("CP");
463 // schedules
464 ScheduleData fixedSchedule(ScheduleRules(startDate, endDate, fixedFreq, cal, conv, conv, rule));
465 // fixed leg
466 LegData fixedLeg(QuantLib::ext::make_shared<FixedLegData>(rates), isPayer, ccy, fixedSchedule, fixedDC, notionalTotal);
467 // basket data
469 vector<BasketConstituent> constituents;
470 for (Size i = 0; i < names.size(); ++i) {
471 constituents.emplace_back(names[i], names[i], notionals[i], ccys[i], qualifier);
472 }
473 ore::data::BasketData basket(constituents);
474 // swap data
475 ore::data::IndexCreditDefaultSwapData swap(creditCurveId, basket, fixedLeg);
476
477 QuantLib::ext::shared_ptr<Trade> trade(new ore::data::SyntheticCDO(
478 env, fixedLeg, qualifier, basket, attachmentPoint, detachmentPoint, settlesAccrual, protectionPaymentTime,
479 protectionStart, upfrontDate, upfrontFee));
480 if (trade == NULL)
481 std::cout << "failed to build" << std::endl;
482
483 trade->id() = id;
484
485 return trade;
486}
string name
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildCmsCapFloor()

QuantLib::ext::shared_ptr< Trade > buildCmsCapFloor ( string  id,
string  ccy,
string  indexId,
bool  isPayer,
Real  notional,
int  start,
Size  term,
Real  capRate,
Real  floorRate,
Real  spread,
string  freq,
string  dc 
)

Definition at line 488 of file testportfolio.cpp.

490 {
491 Date today = Settings::instance().evaluationDate();
492
493 string settlementDays = "2";
494 Calendar calendar = TARGET();
495 string cal = "TARGET";
496 string qualifier = "";
497 string conv = "MF";
498 string rule = "Forward";
499
500 Date qlStartDate = calendar.adjust(today + start * Years);
501 Date qlEndDate = calendar.adjust(qlStartDate + term * Years);
502 string startDate = ore::data::to_string(qlStartDate);
503 string endDate = ore::data::to_string(qlEndDate);
504
505 string longShort = "Long";
506
507 vector<Real> notionals(1, notional);
508 vector<Real> caps(1, capRate);
509 vector<Real> floors(1, floorRate);
510 vector<Real> spreads(1, spread);
511 bool isInArrears = false;
512
513 // envelope
514 Envelope env("CP");
515 ScheduleData schedule(ScheduleRules(startDate, endDate, freq, cal, conv, conv, rule));
516 // fixed leg
517
518 LegData cmsLeg(QuantLib::ext::make_shared<CMSLegData>(indexId, 0, isInArrears, spreads, vector<string>(1, startDate)),
519 isPayer, ccy, schedule, dc, notionals, vector<string>(1, startDate));
520
521 QuantLib::ext::shared_ptr<Trade> trade(new ore::data::CapFloor(env, longShort, cmsLeg, vector<double>(), floors));
522
523 trade->id() = id;
524
525 return trade;
526}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildCPIInflationSwap()

QuantLib::ext::shared_ptr< Trade > buildCPIInflationSwap ( string  id,
string  ccy,
bool  isPayer,
Real  notional,
int  start,
Size  term,
Real  spread,
string  floatFreq,
string  floatDC,
string  index,
string  cpiFreq,
string  cpiDC,
string  cpiIndex,
Real  baseRate,
string  observationLag,
bool  interpolated,
Real  cpiRate 
)

Definition at line 528 of file testportfolio.cpp.

531 {
532
533 Date today = Settings::instance().evaluationDate();
534 Calendar calendar = TARGET();
535 int days = 2;
536 string cal = "TARGET";
537 string conv = "MF";
538 string rule = "Forward";
539
540 vector<Real> notionals(1, notional);
541 vector<Real> cpiRates(1, cpiRate);
542 vector<Real> spreads(1, spread);
543
544 Date qlStartDate = calendar.adjust(today + start * Years);
545 Date qlEndDate = calendar.adjust(qlStartDate + term * Years);
546 string startDate = ore::data::to_string(qlStartDate);
547 string endDate = ore::data::to_string(qlEndDate);
548
549 // envelope
550 Envelope env("CP");
551 // schedules
552 ScheduleData floatSchedule(ScheduleRules(startDate, endDate, floatFreq, cal, conv, conv, rule));
553 ScheduleData cpiSchedule(ScheduleRules(startDate, endDate, cpiFreq, cal, conv, conv, rule));
554 // float leg
555 LegData floatingLeg(QuantLib::ext::make_shared<FloatingLegData>(index, days, false, spreads), !isPayer, ccy, floatSchedule,
556 floatDC, notionals);
557 // fixed leg
558 LegData cpiLeg(QuantLib::ext::make_shared<CPILegData>(cpiIndex, startDate, baseRate, observationLag,
559 (interpolated ? "Linear" : "Flat"), cpiRates),
560 isPayer, ccy, cpiSchedule, cpiDC, notionals, vector<string>(), "F", false, true);
561
562 // trade
563 QuantLib::ext::shared_ptr<Trade> trade(new ore::data::Swap(env, floatingLeg, cpiLeg));
564 trade->id() = id;
565
566 return trade;
567}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildYYInflationSwap()

QuantLib::ext::shared_ptr< Trade > buildYYInflationSwap ( string  id,
string  ccy,
bool  isPayer,
Real  notional,
int  start,
Size  term,
Real  spread,
string  floatFreq,
string  floatDC,
string  index,
string  yyFreq,
string  yyDC,
string  yyIndex,
string  observationLag,
Size  fixDays 
)

Definition at line 569 of file testportfolio.cpp.

572 {
573
574 Date today = Settings::instance().evaluationDate();
575 Calendar calendar = TARGET();
576 int days = 2;
577 string cal = "TARGET";
578 string conv = "MF";
579 string rule = "Forward";
580
581 vector<Real> notionals(1, notional);
582 vector<Real> spreads(1, spread);
583
584 Date qlStartDate = calendar.adjust(today + start * Years);
585 Date qlEndDate = calendar.adjust(qlStartDate + term * Years);
586 string startDate = ore::data::to_string(qlStartDate);
587 string endDate = ore::data::to_string(qlEndDate);
588
589 // envelope
590 Envelope env("CP");
591 // schedules
592 ScheduleData floatSchedule(ScheduleRules(startDate, endDate, floatFreq, cal, conv, conv, rule));
593 ScheduleData yySchedule(ScheduleRules(startDate, endDate, yyFreq, cal, conv, conv, rule));
594 // float leg
595 LegData floatingLeg(QuantLib::ext::make_shared<FloatingLegData>(index, days, false, spreads), !isPayer, ccy, floatSchedule,
596 floatDC, notionals);
597 // fixed leg
598 LegData yyLeg(QuantLib::ext::make_shared<YoYLegData>(yyIndex, observationLag, fixDays), isPayer, ccy, yySchedule, yyDC,
599 notionals);
600
601 // trade
602 QuantLib::ext::shared_ptr<Trade> trade(new ore::data::Swap(env, floatingLeg, yyLeg));
603 trade->id() = id;
604
605 return trade;
606}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildYYInflationCapFloor()

QuantLib::ext::shared_ptr< Trade > buildYYInflationCapFloor ( string  id,
string  ccy,
Real  notional,
bool  isCap,
bool  isLong,
Real  capFloorRate,
int  start,
Size  term,
string  yyFreq,
string  yyDC,
string  yyIndex,
string  observationLag,
Size  fixDays 
)

Definition at line 608 of file testportfolio.cpp.

612 {
613
614 Date today = Settings::instance().evaluationDate();
615 Calendar calendar = TARGET();
616 string cal = "TARGET";
617 string conv = "MF";
618 string rule = "Forward";
619
620 vector<Real> notionals(1, notional);
621 vector<Real> caps, floors;
622 if (isCap)
623 caps.resize(1, capFloorRate);
624 else
625 floors.resize(1, capFloorRate);
626
627 Date qlStartDate = calendar.adjust(today + start * Years);
628 Date qlEndDate = calendar.adjust(qlStartDate + term * Years);
629 string startDate = ore::data::to_string(qlStartDate);
630 string endDate = ore::data::to_string(qlEndDate);
631
632 ScheduleData yySchedule(ScheduleRules(startDate, endDate, yyFreq, cal, conv, conv, rule));
633
634 LegData yyLeg(QuantLib::ext::make_shared<YoYLegData>(yyIndex, observationLag, fixDays), true, ccy, yySchedule, yyDC,
635 notionals);
636
637 Envelope env("CP");
638
639 auto trade = QuantLib::ext::make_shared<ore::data::CapFloor>(env, isLong ? "Long" : "Short", yyLeg, caps, floors);
640 trade->id() = id;
641 return trade;
642}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildCommodityForward()

QuantLib::ext::shared_ptr< Trade > buildCommodityForward ( const std::string &  id,
const std::string &  position,
Size  term,
const std::string &  commodityName,
const std::string &  currency,
Real  strike,
Real  quantity 
)

Definition at line 644 of file testportfolio.cpp.

646 {
647
648 Date today = Settings::instance().evaluationDate();
649 string maturity = ore::data::to_string(today + term * Years);
650
651 Envelope env("CP");
652 QuantLib::ext::shared_ptr<Trade> trade = QuantLib::ext::make_shared<ore::data::CommodityForward>(
653 env, position, commodityName, currency, quantity, maturity, strike);
654 trade->id() = id;
655
656 return trade;
657}
Time maturity
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildCommodityOption() [1/2]

QuantLib::ext::shared_ptr< Trade > buildCommodityOption ( const string &  id,
const string &  longShort,
const string &  putCall,
Size  term,
const string &  commodityName,
const string &  currency,
Real  strike,
Real  quantity,
Real  premium,
const string &  premiumCcy,
const string &  premiumDate 
)

Definition at line 659 of file testportfolio.cpp.

662 {
663
664 Date today = Settings::instance().evaluationDate();
665 vector<string> expiryDate{ore::data::to_string(today + term * Years)};
666
667 Envelope env("CP");
668 OptionData option(longShort, putCall, "European", false, expiryDate, "Cash", "",
669 premiumDate.empty() ? PremiumData() : PremiumData(premium, premiumCcy, parseDate(premiumDate)));
670 TradeStrike trStrike(TradeStrike::Type::Price, strike);
671 QuantLib::ext::shared_ptr<Trade> trade =
672 QuantLib::ext::make_shared<ore::data::CommodityOption>(env, option, commodityName, currency, quantity, trStrike);
673 trade->id() = id;
674
675 return trade;
676}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toString()

string toString ( Date  d)

Utilities to set up simple test trades.

◆ buildSwap() [2/2]

QuantLib::ext::shared_ptr< Trade > buildSwap ( string  id,
string  ccy,
bool  isPayer,
Real  notional,
int  start,
Size  term,
Real  rate,
Real  spread,
string  fixedFreq,
string  fixedDC,
string  floatFreq,
string  floatDC,
string  index,
Calendar  cal = TARGET(),
QuantLib::Natural  fixingDays = 2,
bool  spotStartLag = false 
)
+ Here is the call graph for this function:

◆ buildCap() [2/2]

QuantLib::ext::shared_ptr< Trade > buildCap ( string  id,
string  ccy,
string  longShort,
Real  capRate,
Real  notional,
int  start,
Size  term,
string  floatFreq,
string  floatDC,
string  index,
Calendar  cal = TARGET(),
QuantLib::Natural  fixingDays = 2,
bool  spotStartLag = false 
)
+ Here is the call graph for this function:

◆ buildFloor() [2/2]

QuantLib::ext::shared_ptr< Trade > buildFloor ( string  id,
string  ccy,
string  longShort,
Real  floorRate,
Real  notional,
int  start,
Size  term,
string  floatFreq,
string  floatDC,
string  index,
Calendar  cal = TARGET(),
QuantLib::Natural  fixingDays = 2,
bool  spotStartLag = false 
)
+ Here is the call graph for this function:

◆ buildCapFloor() [2/2]

QuantLib::ext::shared_ptr< Trade > buildCapFloor ( string  id,
string  ccy,
string  longShort,
vector< Real >  capRates,
vector< Real >  floorRates,
Real  notional,
int  start,
Size  term,
string  floatFreq,
string  floatDC,
string  index,
Calendar  cal = TARGET(),
QuantLib::Natural  fixingDays = 2,
bool  spotStartLag = false 
)

◆ buildCrossCcyBasisSwap() [2/2]

QuantLib::ext::shared_ptr< Trade > buildCrossCcyBasisSwap ( string  id,
string  recCcy,
Real  recNotional,
string  payCcy,
Real  payNotional,
int  start,
Size  term,
Real  recLegSpread,
Real  payLegSpread,
string  recFreq,
string  recDC,
string  recIndex,
Calendar  recCalendar,
string  payFreq,
string  payDC,
string  payIndex,
Calendar  payCalendar,
QuantLib::Natural  spotDays = 2,
bool  spotStartLag = false,
bool  notionalInitialExchange = false,
bool  notionalFinalExchange = false,
bool  notionalAmortizingExchange = false,
bool  isRecLegFXResettable = false,
bool  isPayLegFXResettable = false 
)
+ Here is the call graph for this function:

◆ buildCommodityOption() [2/2]

QuantLib::ext::shared_ptr< Trade > buildCommodityOption ( const std::string &  id,
const std::string &  longShort,
const std::string &  putCall,
QuantLib::Size  term,
const std::string &  commodityName,
const std::string &  currency,
QuantLib::Real  strike,
QuantLib::Real  quantity,
QuantLib::Real  premium = 0.0,
const std::string &  premiumCcy = "",
const std::string &  premiumDate = "" 
)
+ Here is the call graph for this function: