Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
lgmcalibrationinfo.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2021 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
20
21namespace QuantExt {
22
23std::map<std::string, boost::any> getAdditionalResultsMap(const LgmCalibrationInfo& info) {
24 std::map<std::string, boost::any> result;
25 if (info.valid) {
26 result["lgmCalibrationError"] = info.rmse;
27 std::vector<Real> timeToExpiry, swapLength, strike, atmForward, annuity, vega, vols;
28 std::vector<Real> modelTime, modelVol, marketVol, modelValue, marketValue, modelAlpha, modelKappa, modelHwSigma;
29 std::vector<Real> volDiff, valueDiff;
30 for (auto const& d : info.swaptionData) {
31 timeToExpiry.push_back(d.timeToExpiry);
32 swapLength.push_back(d.swapLength);
33 strike.push_back(d.strike);
34 atmForward.push_back(d.atmForward);
35 annuity.push_back(d.annuity);
36 vega.push_back(d.vega);
37 vols.push_back(d.stdDev / std::sqrt(d.timeToExpiry));
38 }
39 for (auto const& d : info.lgmCalibrationData) {
40 modelTime.push_back(d.modelTime);
41 modelVol.push_back(d.modelVol);
42 marketVol.push_back(d.marketVol);
43 modelValue.push_back(d.modelValue);
44 marketValue.push_back(d.marketValue);
45 modelAlpha.push_back(d.modelAlpha);
46 modelKappa.push_back(d.modelKappa);
47 modelHwSigma.push_back(d.modelHwSigma);
48 volDiff.push_back(d.modelVol - d.marketVol);
49 valueDiff.push_back(d.modelValue - d.marketValue);
50 }
51 result["lgmCalibrationBasketExpiryTimes"] = timeToExpiry;
52 result["lgmCalibrationBasketSwapLengths"] = swapLength;
53 result["lgmCalibrationBasketStrikes"] = strike;
54 result["lgmCalibrationBasketAtmForwards"] = atmForward;
55 result["lgmCalibrationBasketAnnuities"] = annuity;
56 result["lgmCalibrationBasketVegas"] = vega;
57 result["lgmCalibrationBasketVols"] = vols;
58 result["lgmCalibrationTimes"] = modelTime;
59 result["lgmCalibrationModelVols"] = modelVol;
60 result["lgmCalibrationMarketVols"] = marketVol;
61 result["lgmCalibrationModelValues"] = modelValue;
62 result["lgmCalibrationMarketValues"] = marketValue;
63 result["lgmCalibrationModelAlphas"] = modelAlpha;
64 result["lgmCalibrationModelKappas"] = modelKappa;
65 result["lgmCalibrationModelHwSigmas"] = modelHwSigma;
66 result["lgmCalibrationModelMarketVolDiffs"] = volDiff;
67 result["lgmCalibrationModelMarketValueDiffs"] = valueDiff;
68 }
69 return result;
70}
71
72} // namespace QuantExt
info data on how a lgm model was calibrated
std::map< std::string, boost::any > getAdditionalResultsMap(const LgmCalibrationInfo &info)
std::vector< LgmCalibrationData > lgmCalibrationData
std::vector< SwaptionData > swaptionData