27std::string getCurveName(
const std::string& spec) {
28 auto pos = spec.rfind(
"/");
29 if (pos != std::string::npos) {
30 return spec.substr(pos + 1);
45 const QuantLib::ext::shared_ptr<TodaysMarketParameters>& todaysMarketParams,
46 const std::string& label) {
48 if (market ==
nullptr)
50 auto t = QuantLib::ext::dynamic_pointer_cast<TodaysMarket>(market);
52 DLOG(
"MarketCalibrationReportBase::populateReport() expected TodaysMarket");
56 auto calibrationInfo = t->calibrationInfo();
64 if (todaysMarketParams->hasMarketObject(MarketObject::DiscountCurve)) {
66 auto yts = calibrationInfo->yieldCurveCalibrationInfo.find(it.second);
67 if (yts != calibrationInfo->yieldCurveCalibrationInfo.end())
68 addYieldCurve(calibrationInfo->asof, yts->second, getCurveName(it.second),
true, label);
71 if (todaysMarketParams->hasMarketObject(MarketObject::YieldCurve)) {
73 auto yts = calibrationInfo->yieldCurveCalibrationInfo.find(it.second);
74 if (yts != calibrationInfo->yieldCurveCalibrationInfo.end())
75 addYieldCurve(calibrationInfo->asof, yts->second, getCurveName(it.second),
false, label);
78 if (todaysMarketParams->hasMarketObject(MarketObject::EquityCurve)) {
80 auto yts = calibrationInfo->dividendCurveCalibrationInfo.find(it.second);
81 if (yts != calibrationInfo->dividendCurveCalibrationInfo.end())
82 addYieldCurve(calibrationInfo->asof, yts->second, getCurveName(it.second),
false, label);
85 if (todaysMarketParams->hasMarketObject(MarketObject::IndexCurve)) {
87 auto yts = calibrationInfo->yieldCurveCalibrationInfo.find(it.second);
88 if (yts != calibrationInfo->yieldCurveCalibrationInfo.end())
89 addYieldCurve(calibrationInfo->asof, yts->second, getCurveName(it.second),
false, label);
96 for (
auto const& c : calibrationInfo->inflationCurveCalibrationInfo) {
103 for (
auto const& c : calibrationInfo->commodityCurveCalibrationInfo) {
104 addCommodityCurve(calibrationInfo->asof, c.second, getCurveName(c.first), label);
110 for (
auto const& c : calibrationInfo->fxVolCalibrationInfo) {
111 addFxVol(calibrationInfo->asof, c.second, getCurveName(c.first), label);
117 for (
auto const& c : calibrationInfo->eqVolCalibrationInfo) {
118 addEqVol(calibrationInfo->asof, c.second, getCurveName(c.first), label);
124 for (
auto const& c: calibrationInfo->commVolCalibrationInfo){
125 addCommVol(calibrationInfo->asof, c.second, getCurveName(c.first), label);
131 for (
auto const& c : calibrationInfo->irVolCalibrationInfo) {
132 addIrVol(calibrationInfo->asof, c.second, c.first, label);
138 const QuantLib::ext::shared_ptr<ore::data::Report>& report)
140 report_->addColumn(
"MarketObjectType",
string())
141 .addColumn(
"MarketObjectId",
string())
142 .addColumn(
"ResultId",
string())
143 .addColumn(
"ResultKey1",
string())
144 .addColumn(
"ResultKey2",
string())
145 .addColumn(
"ResultKey3",
string())
146 .addColumn(
"ResultType",
string())
147 .addColumn(
"ResultValue",
string());
156 const std::string& resId,
const std::string& key1,
const std::string& key2,
157 const std::string& key3,
const boost::any& value) {
159 report_->next().add(moType).add(moId).add(resId).add(key1).add(key2).add(key3).add(p.first).add(p.second);
163 bool hasCalibration =
false;
166 if (curves.find(
id) != curves.end())
167 hasCalibration =
true;
169 return hasCalibration;
173 QuantLib::ext::shared_ptr<ore::data::YieldCurveCalibrationInfo> info,
174 const std::string&
id,
bool isDiscount,
const std::string& label) {
178 string yieldStr =
"yieldCurve";
182 DLOG(
"Skipping curve " <<
id <<
" for label " << label <<
" as it has already been added");
187 addRowReport(yieldStr,
id,
"dayCounter",
"",
"",
"", info->dayCounter);
188 addRowReport(yieldStr,
id,
"currency",
"",
"",
"", info->currency);
190 for (Size i = 0; i < info->pillarDates.size(); ++i) {
191 std::string key1 =
to_string(info->pillarDates[i]);
192 addRowReport(yieldStr,
id,
"time", key1,
"",
"", info->times.at(i));
193 addRowReport(yieldStr,
id,
"zeroRate", key1,
"",
"", info->zeroRates.at(i));
194 addRowReport(yieldStr,
id,
"discountFactor", key1,
"",
"", info->discountFactors.at(i));
198 auto y = QuantLib::ext::dynamic_pointer_cast<FittedBondCurveCalibrationInfo>(info);
200 addRowReport(yieldStr,
id,
"fittedBondCurve.fittingMethod",
"",
"",
"", y->fittingMethod);
201 for (Size k = 0; k < y->solution.size(); ++k) {
202 addRowReport(yieldStr,
id,
"fittedBondCurve.solution", std::to_string(k),
"",
"",
205 addRowReport(yieldStr,
id,
"fittedBondCurve.iterations",
"",
"",
"", y->iterations);
206 addRowReport(yieldStr,
id,
"fittedBondCurve.costValue",
"",
"",
"", y->costValue);
207 for (Size i = 0; i < y->securities.size(); ++i) {
208 addRowReport(yieldStr,
id,
"fittedBondCurve.bondMaturity", y->securities.at(i),
"",
"",
209 y->securityMaturityDates.at(i));
210 addRowReport(yieldStr,
id,
"fittedBondCurve.marketPrice", y->securities.at(i),
"",
"",
211 y->marketPrices.at(i));
212 addRowReport(yieldStr,
id,
"fittedBondCurve.modelPrice", y->securities.at(i),
"",
"",
213 y->modelPrices.at(i));
214 addRowReport(yieldStr,
id,
"fittedBondCurve.marketYield", y->securities.at(i),
"",
"",
215 y->marketYields.at(i));
216 addRowReport(yieldStr,
id,
"fittedBondCurve.modelYield", y->securities.at(i),
"",
"",
217 y->modelYields.at(i));
225 QuantLib::ext::shared_ptr<ore::data::InflationCurveCalibrationInfo> info,
226 const std::string&
id,
const std::string& label) {
230 const string inflationStr =
"inflationCuve";
234 DLOG(
"Skipping curve " <<
id <<
" for label " << label <<
" as it has already been added");
239 addRowReport(inflationStr,
id,
"dayCounter",
"",
"",
"", info->dayCounter);
240 addRowReport(inflationStr,
id,
"calendar",
"",
"",
"", info->calendar);
241 addRowReport(inflationStr,
id,
"baseDate",
"",
"",
"", info->baseDate);
244 auto z = QuantLib::ext::dynamic_pointer_cast<ZeroInflationCurveCalibrationInfo>(info);
246 addRowReport(inflationStr,
id,
"baseCpi",
"",
"",
"", z->baseCpi);
247 for (Size i = 0; i < z->pillarDates.size(); ++i) {
249 addRowReport(inflationStr,
id,
"time", key1,
"",
"", z->times.at(i));
250 addRowReport(inflationStr,
id,
"zeroRate", key1,
"",
"", z->zeroRates.at(i));
251 addRowReport(inflationStr,
id,
"cpi", key1,
"",
"", z->forwardCpis.at(i));
256 auto y = QuantLib::ext::dynamic_pointer_cast<YoYInflationCurveCalibrationInfo>(info);
258 for (Size i = 0; i < y->pillarDates.size(); ++i) {
260 addRowReport(inflationStr,
id,
"time", key1,
"",
"", y->times.at(i));
261 addRowReport(inflationStr,
id,
"yoyRate", key1,
"",
"", y->yoyRates.at(i));
269 QuantLib::ext::shared_ptr<ore::data::CommodityCurveCalibrationInfo> info,
270 const std::string&
id,
const std::string& label) {
274 const string commodityStr =
"commodityCuve";
278 DLOG(
"Skipping curve " <<
id <<
" for label " << label <<
" as it has already been added");
282 addRowReport(commodityStr,
id,
"calendar",
"",
"",
"", info->calendar);
283 addRowReport(commodityStr,
id,
"currenct",
"",
"",
"", info->currency);
284 addRowReport(commodityStr,
id,
"interpolationMethod",
"",
"",
"", info->interpolationMethod);
286 for (Size i = 0; i < info->pillarDates.size(); ++i) {
287 auto date =
to_string(info->pillarDates.at(i));
288 addRowReport(commodityStr,
id,
"time", date,
"",
"", info->times.at(i));
289 addRowReport(commodityStr,
id,
"price", date,
"",
"", info->futurePrices.at(i));
295 QuantLib::ext::shared_ptr<ore::data::FxEqCommVolCalibrationInfo> info,
296 const string&
id,
const string& label) {
302 DLOG(
"Skipping curve " <<
id <<
" for label " << label <<
" as it has already been added");
306 addRowReport(type,
id,
"dayCounter",
"",
"",
"", info->dayCounter);
307 addRowReport(type,
id,
"calendar",
"",
"",
"", info->calendar);
308 addRowReport(type,
id,
"atmType",
"",
"",
"", info->atmType);
309 addRowReport(type,
id,
"deltaType",
"",
"",
"", info->deltaType);
310 addRowReport(type,
id,
"longTermAtmType",
"",
"",
"", info->longTermAtmType);
311 addRowReport(type,
id,
"longTermDeltaType",
"",
"",
"", info->longTermDeltaType);
312 addRowReport(type,
id,
"switchTenor",
"",
"",
"", info->switchTenor);
313 addRowReport(type,
id,
"riskReversalInFavorOf",
"",
"",
"", info->riskReversalInFavorOf);
314 addRowReport(type,
id,
"butterflyStyle",
"",
"",
"", info->butterflyStyle);
315 addRowReport(type,
id,
"isArbitrageFree",
"",
"",
"", info->isArbitrageFree);
316 for (Size i = 0; i < info->messages.size(); ++i)
317 addRowReport(type,
id,
"message_" + std::to_string(i),
"",
"",
"", info->messages[i]);
319 for (Size i = 0; i < info->times.size(); ++i) {
320 std::string tStr = std::to_string(info->times.at(i));
321 addRowReport(type,
id,
"expiry", tStr,
"",
"", info->expiryDates.at(i));
324 for (Size i = 0; i < info->times.size(); ++i) {
325 std::string tStr = std::to_string(info->times.at(i));
326 for (Size j = 0; j < info->deltas.size(); ++j) {
327 std::string dStr = info->deltas.at(j);
328 addRowReport(type,
id,
"forward", tStr, dStr,
"", info->forwards.at(i));
329 addRowReport(type,
id,
"strike", tStr, dStr,
"", info->deltaGridStrikes.at(i).at(j));
330 addRowReport(type,
id,
"vol", tStr, dStr,
"", info->deltaGridImpliedVolatility.at(i).at(j));
331 addRowReport(type,
id,
"prob", tStr, dStr,
"", info->deltaGridProb.at(i).at(j));
332 addRowReport(type,
id,
"call_premium", tStr, dStr,
"", info->deltaCallPrices.at(i).at(j));
333 addRowReport(type,
id,
"put_premium", tStr, dStr,
"", info->deltaPutPrices.at(i).at(j));
335 static_cast<bool>(info->deltaGridCallSpreadArbitrage.at(i).at(j)));
337 static_cast<bool>(info->deltaGridButterflyArbitrage.at(i).at(j)));
341 for (Size i = 0; i < info->times.size(); ++i) {
342 std::string tStr = std::to_string(info->times.at(i));
343 for (Size j = 0; j < info->moneyness.size(); ++j) {
344 std::string mStr = std::to_string(info->moneyness.at(j));
345 addRowReport(type,
id,
"forward", tStr, mStr,
"", info->forwards.at(i));
346 addRowReport(type,
id,
"strike", tStr, mStr,
"", info->moneynessGridStrikes.at(i).at(j));
348 info->moneynessGridImpliedVolatility.at(i).at(j));
349 addRowReport(type,
id,
"call_premium", tStr, mStr,
"", info->moneynessCallPrices.at(i).at(j));
350 addRowReport( type,
id,
"put_premium", tStr, mStr,
"", info->moneynessPutPrices.at(i).at(j));
351 addRowReport(type,
id,
"prob", tStr, mStr,
"", info->moneynessGridProb.at(i).at(j));
353 static_cast<bool>(info->moneynessGridCallSpreadArbitrage.at(i).at(j)));
355 static_cast<bool>(info->moneynessGridButterflyArbitrage.at(i).at(j)));
357 static_cast<bool>(info->moneynessGridCalendarArbitrage.at(i).at(j)));
364 QuantLib::ext::shared_ptr<ore::data::FxEqCommVolCalibrationInfo> info,
365 const std::string&
id,
const std::string& label) {
371 QuantLib::ext::shared_ptr<ore::data::FxEqCommVolCalibrationInfo> info,
372 const std::string&
id,
const std::string& label) {
378 QuantLib::ext::shared_ptr<ore::data::FxEqCommVolCalibrationInfo> info,
379 const std::string&
id,
const std::string& label) {
386 QuantLib::ext::shared_ptr<ore::data::IrVolCalibrationInfo> info,
387 const std::string&
id,
const std::string& label) {
391 string type =
"irVol";
395 DLOG(
"Skipping curve " <<
id <<
" for label " << label <<
" as it has already been added");
399 addRowReport(type,
id,
"dayCounter",
"",
"",
"", info->dayCounter);
400 addRowReport(type,
id,
"calendar",
"",
"",
"", info->calendar);
401 addRowReport(type,
id,
"isArbitrageFree",
"",
"",
"", info->isArbitrageFree);
402 addRowReport(type,
id,
"volatilityType",
"",
"",
"", info->volatilityType);
403 for (Size i = 0; i < info->messages.size(); ++i)
404 addRowReport(type,
id,
"message_" + std::to_string(i),
"",
"",
"", info->messages[i]);
406 for (Size i = 0; i < info->times.size(); ++i) {
407 std::string tStr = std::to_string(info->times.at(i));
408 addRowReport(type,
id,
"expiry", tStr,
"",
"", info->expiryDates.at(i));
411 for (Size i = 0; i < info->underlyingTenors.size(); ++i) {
412 addRowReport(type,
id,
"tenor", std::to_string(i),
"",
"",
416 for (Size i = 0; i < info->times.size(); ++i) {
417 std::string tStr = std::to_string(info->times.at(i));
418 for (Size u = 0; u < info->underlyingTenors.size(); ++u) {
420 for (Size j = 0; j < info->strikes.size(); ++j) {
421 std::string kStr = std::to_string(info->strikes.at(j));
422 addRowReport(type,
id,
"forward", tStr, kStr, uStr, info->forwards.at(i).at(u));
424 info->strikeGridStrikes.at(i).at(u).at(j));
426 info->strikeGridImpliedVolatility.at(i).at(u).at(j));
427 addRowReport(type,
id,
"prob", tStr, kStr, uStr, info->strikeGridProb.at(i).at(u).at(j));
428 addRowReport(type,
id,
"callSpreadArb", tStr, kStr, uStr,
429 static_cast<bool>(info->strikeGridCallSpreadArbitrage.at(i).at(u).at(j)));
430 addRowReport(type,
id,
"butterflyArb", tStr, kStr, uStr,
431 static_cast<bool>(info->strikeGridButterflyArbitrage.at(i).at(u).at(j)));
436 for (Size i = 0; i < info->times.size(); ++i) {
437 std::string tStr = std::to_string(info->times.at(i));
438 for (Size u = 0; u < info->underlyingTenors.size(); ++u) {
440 for (Size j = 0; j < info->strikeSpreads.size(); ++j) {
441 std::string kStr = std::to_string(info->strikeSpreads.at(j));
442 addRowReport(type,
id,
"forward", tStr, kStr, uStr, info->forwards.at(i).at(u));
444 info->strikeSpreadGridStrikes.at(i).at(u).at(j));
446 info->strikeSpreadGridImpliedVolatility.at(i).at(u).at(j));
448 info->strikeSpreadGridProb.at(i).at(u).at(j));
449 addRowReport(type,
id,
"callSpreadArb", tStr, kStr, uStr,
450 static_cast<bool>(info->strikeSpreadGridCallSpreadArbitrage.at(i).at(u).at(j)));
451 addRowReport(type,
id,
"butterflyArb", tStr, kStr, uStr,
452 static_cast<bool>(info->strikeSpreadGridButterflyArbitrage.at(i).at(u).at(j)));
virtual void addInflationCurve(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::InflationCurveCalibrationInfo > yts, const std::string &name, const std::string &label)=0
virtual void addFxVol(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::FxEqCommVolCalibrationInfo > vol, const std::string &name, const std::string &label)=0
virtual void populateReport(const QuantLib::ext::shared_ptr< ore::data::Market > &market, const QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameters > &todaysMarketParams, const std::string &label=std::string())
virtual void addCommVol(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::FxEqCommVolCalibrationInfo > vol, const std::string &name, const std::string &label)=0
virtual void addCommodityCurve(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::CommodityCurveCalibrationInfo > yts, std::string const &name, std::string const &label)=0
CalibrationFilters calibrationFilters_
virtual void addYieldCurve(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::YieldCurveCalibrationInfo > yts, const std::string &name, bool isDiscount, const std::string &label)=0
virtual void addIrVol(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::IrVolCalibrationInfo > vol, const std::string &name, const std::string &label)=0
MarketCalibrationReportBase(const std::string &calibrationFilter)
virtual void addEqVol(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::FxEqCommVolCalibrationInfo > vol, const std::string &name, const std::string &label)=0
virtual void initialise(const std::string &label)
void addYieldCurve(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::YieldCurveCalibrationInfo > yts, const std::string &name, bool isDiscount, const std::string &label) override
void addEqFxVol(const std::string &type, QuantLib::ext::shared_ptr< ore::data::FxEqCommVolCalibrationInfo > vol, const std::string &id, const std::string &label)
void addCommVol(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::FxEqCommVolCalibrationInfo > vol, const std::string &name, const std::string &label) override
MarketCalibrationReport(const std::string &calibrationFilter, const QuantLib::ext::shared_ptr< ore::data::Report > &report)
void addCommodityCurve(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::CommodityCurveCalibrationInfo > yts, const std::string &name, const std::string &label) override
const bool checkCalibrations(std::string label, std::string type, std::string id) const
std::map< std::string, std::map< std::string, std::set< std::string > > > calibrations_
QuantLib::ext::shared_ptr< ore::data::Report > outputCalibrationReport() override
void addInflationCurve(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::InflationCurveCalibrationInfo > yts, const std::string &name, const std::string &label) override
void addEqVol(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::FxEqCommVolCalibrationInfo > vol, const std::string &name, const std::string &label) override
void addIrVol(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::IrVolCalibrationInfo > vol, const std::string &name, const std::string &label) override
void addFxVol(const QuantLib::Date &refdate, QuantLib::ext::shared_ptr< ore::data::FxEqCommVolCalibrationInfo > vol, const std::string &name, const std::string &label) override
QuantLib::ext::shared_ptr< ore::data::Report > report_
void addRowReport(const std::string &moType, const std::string &moId, const std::string &resId, const std::string &key1, const std::string &key2, const std::string &key3, const boost::any &value)
static const string defaultConfiguration
SafeStack< ValueType > value
pair< string, string > parseBoostAny(const boost::any &anyType, Size precision)
std::string to_string(const LocationInfo &l)