Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
utilities.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file model/utilities.hpp
20 \brief Shared utilities for model building and calibration
21 \ingroup models
22*/
23
24#pragma once
25
27
35
36#include <ql/models/calibrationhelper.hpp>
37
38#include <boost/variant.hpp>
39
40#include <vector>
41
42namespace ore {
43namespace data {
44using namespace QuantExt;
45using namespace QuantLib;
46
47template <typename Helper> Real getCalibrationError(const std::vector<QuantLib::ext::shared_ptr<Helper>>& basket) {
48 Real rmse = 0.0;
49 for (auto const& h : basket) {
50 Real tmp = h->calibrationError();
51 rmse += tmp * tmp;
52 }
53 return std::sqrt(rmse / static_cast<Real>(basket.size()));
54}
55
56std::string getCalibrationDetails(
57 LgmCalibrationInfo& info, const std::vector<QuantLib::ext::shared_ptr<BlackCalibrationHelper>>& basket,
58 const QuantLib::ext::shared_ptr<IrLgm1fParametrization>& parametrization = QuantLib::ext::shared_ptr<IrLgm1fParametrization>());
59
60std::string getCalibrationDetails(
61 const std::vector<QuantLib::ext::shared_ptr<BlackCalibrationHelper>>& basket,
62 const QuantLib::ext::shared_ptr<FxBsParametrization>& parametrization = QuantLib::ext::shared_ptr<FxBsParametrization>(),
63 const QuantLib::ext::shared_ptr<Parametrization>& domesticLgm = QuantLib::ext::shared_ptr<IrLgm1fParametrization>());
64
65std::string getCalibrationDetails(
66 const std::vector<QuantLib::ext::shared_ptr<BlackCalibrationHelper>>& basket,
67 const QuantLib::ext::shared_ptr<FxBsParametrization>& parametrization = QuantLib::ext::shared_ptr<FxBsParametrization>(),
68 const QuantLib::ext::shared_ptr<IrLgm1fParametrization>& domesticLgm = QuantLib::ext::shared_ptr<IrLgm1fParametrization>());
69
70std::string getCalibrationDetails(
71 const std::vector<QuantLib::ext::shared_ptr<BlackCalibrationHelper>>& basket,
72 const QuantLib::ext::shared_ptr<EqBsParametrization>& parametrization = QuantLib::ext::shared_ptr<EqBsParametrization>(),
73 const QuantLib::ext::shared_ptr<Parametrization>& domesticLgm = QuantLib::ext::shared_ptr<IrLgm1fParametrization>());
74
75std::string getCalibrationDetails(
76 const std::vector<QuantLib::ext::shared_ptr<BlackCalibrationHelper>>& basket,
77 const QuantLib::ext::shared_ptr<EqBsParametrization>& parametrization = QuantLib::ext::shared_ptr<EqBsParametrization>(),
78 const QuantLib::ext::shared_ptr<IrLgm1fParametrization>& domesticLgm = QuantLib::ext::shared_ptr<IrLgm1fParametrization>());
79
80std::string getCalibrationDetails(
81 const std::vector<QuantLib::ext::shared_ptr<BlackCalibrationHelper>>& basket,
82 const QuantLib::ext::shared_ptr<InfDkParametrization>& parametrization = QuantLib::ext::shared_ptr<InfDkParametrization>(),
83 bool indexIsInterpolated = true);
84
85std::string getCalibrationDetails(
86 const std::vector<QuantLib::ext::shared_ptr<BlackCalibrationHelper>>& basket,
87 const QuantLib::ext::shared_ptr<CommoditySchwartzParametrization>& parametrization = QuantLib::ext::shared_ptr<CommoditySchwartzParametrization>());
88
89std::string getCalibrationDetails(const std::vector<QuantLib::ext::shared_ptr<CalibrationHelper>>& realRateBasket,
90 const std::vector<QuantLib::ext::shared_ptr<CalibrationHelper>>& indexBasket,
91 const QuantLib::ext::shared_ptr<InfJyParameterization>& parameterization,
92 bool calibrateRealRateVol = false);
93
94std::string getCalibrationDetails(const QuantLib::ext::shared_ptr<IrLgm1fParametrization>& parametrization);
95
96//! Return an option's maturity date, given an explicit date or a period.
97QuantLib::Date optionMaturity(const boost::variant<QuantLib::Date, QuantLib::Period>& maturity,
99 const QuantLib::Date& referenceDate = Settings::instance().evaluationDate());
100
101//! Return a cpi cap/floor strike value, the input strike can be of type absolute or atm forward
102Real cpiCapFloorStrikeValue(const QuantLib::ext::shared_ptr<BaseStrike>& strike,
103 const QuantLib::ext::shared_ptr<ZeroInflationTermStructure>& curve,
104 const QuantLib::Date& optionMaturityDate);
105
106//! Return a yoy cap/floor strike value, the input strike can be of type absolute or atm forward
107Real yoyCapFloorStrikeValue(const QuantLib::ext::shared_ptr<BaseStrike>& strike,
108 const QuantLib::ext::shared_ptr<YoYInflationTermStructure>& curve,
109 const QuantLib::Date& optionMaturityDate);
110
111//! helper function that computes the atm forward
112Real atmForward(const Real s0, const Handle<YieldTermStructure>& r, const Handle<YieldTermStructure>& q, const Real t);
113
114} // namespace data
115} // namespace ore
@ data
Definition: log.hpp:77
Classes for representing a strike using various conventions.
Time maturity
Definition: utilities.cpp:66
Date referenceDate
Definition: utilities.cpp:442
Calendar calendar
Definition: utilities.cpp:441
Real yoyCapFloorStrikeValue(const QuantLib::ext::shared_ptr< BaseStrike > &strike, const QuantLib::ext::shared_ptr< YoYInflationTermStructure > &curve, const QuantLib::Date &optionMaturityDate)
Return a yoy cap/floor strike value, the input strike can be of type absolute or atm forward.
Definition: utilities.cpp:468
Real getCalibrationError(const std::vector< QuantLib::ext::shared_ptr< Helper > > &basket)
Definition: utilities.hpp:47
Real atmForward(const Real s0, const Handle< YieldTermStructure > &r, const Handle< YieldTermStructure > &q, const Real t)
helper function that computes the atm forward
Definition: utilities.cpp:483
Date optionMaturity(const boost::variant< Date, Period > &maturity, const QuantLib::Calendar &calendar, const QuantLib::Date &referenceDate)
Definition: utilities.cpp:447
std::string getCalibrationDetails(LgmCalibrationInfo &info, const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &basket, const QuantLib::ext::shared_ptr< IrLgm1fParametrization > &parametrization)
Definition: utilities.cpp:125
Real cpiCapFloorStrikeValue(const QuantLib::ext::shared_ptr< BaseStrike > &strike, const QuantLib::ext::shared_ptr< ZeroInflationTermStructure > &curve, const QuantLib::Date &optionMaturityDate)
Return a cpi cap/floor strike value, the input strike can be of type absolute or atm forward.
Definition: utilities.cpp:453
Serializable Credit Default Swap.
Definition: namespaces.docs:23