Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
hwparametrization.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2022 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 hwparametrization.hpp
20 \brief Hull White n factor parametrization
21 \ingroup models
22*/
23
24#pragma once
25
27#include <ql/handle.hpp>
28#include <ql/termstructures/yieldtermstructure.hpp>
29#include <ql/math/array.hpp>
30#include <ql/math/matrix.hpp>
31
32namespace QuantExt {
33
34//! HW nF Parametrization with m driving Brownian motions
35/*! \ingroup models
36 */
37template <class TS> class HwParametrization : public Parametrization {
38public:
39 HwParametrization(const QuantLib::Size n, const QuantLib::Size m, const QuantLib::Currency& currency,
40 const QuantLib::Handle<TS>& termStructure,
41 const std::string& name = std::string());
42
43 /*! sigma_x, 1.12, this is a m x n matrix */
44 virtual QuantLib::Matrix sigma_x(const QuantLib::Time t) const = 0;
45 /* kappa(t), this is an n-array representing the diag matrix in 1.8 */
46 virtual QuantLib::Array kappa(const QuantLib::Time t) const = 0;
47
48 /*! y(t), 1.19, this is an n x n matrix */
49 virtual QuantLib::Matrix y(const QuantLib::Time t) const;
50 /*! g(t,T), 1.21, this is an n-array */
51 virtual QuantLib::Array g(const QuantLib::Time t, const QuantLib::Time T) const;
52
53 /*! the underlying term structure */
54 const QuantLib::Handle<TS> termStructure() const { return termStructure_; }
55
56 /*! we have m x n (from g) + n (from kappa) parameters */
57 QuantLib::Size numberOfParameters() const override { return m_ * n_ + n_; }
58
59 QuantLib::Size n() const { return n_; }
60 QuantLib::Size m() const { return m_; }
61
62 void update() const override;
63
64protected:
65 QuantLib::Size n_, m_;
66
67private:
68 const QuantLib::Handle<TS> termStructure_;
69};
70
71// implementation
72
73template <class TS>
74HwParametrization<TS>::HwParametrization(const QuantLib::Size n, const QuantLib::Size m,
75 const QuantLib::Currency& currency, const QuantLib::Handle<TS>& termStructure,
76 const std::string& name)
77 : Parametrization(currency, name.empty() ? currency.code() : name), n_(n), m_(m), termStructure_(termStructure) {}
78
79template <class TS> QuantLib::Matrix HwParametrization<TS>::y(const Time t) const {
80 QL_FAIL("HwParametrization::y(t) not implemented");
81}
82
83template <class TS> QuantLib::Array HwParametrization<TS>::g(const QuantLib::Time t, const QuantLib::Time T) const {
84 QL_FAIL("HwParametrization::g(t, T) not implemented");
85}
86
87template <class TS> void HwParametrization<TS>::update() const { Parametrization::update(); }
88
89// typedef
90
92
93} // namespace QuantExt
HW nF Parametrization with m driving Brownian motions.
const QuantLib::Handle< TS > termStructure_
QuantLib::Size n() const
HwParametrization(const QuantLib::Size n, const QuantLib::Size m, const QuantLib::Currency &currency, const QuantLib::Handle< TS > &termStructure, const std::string &name=std::string())
QuantLib::Size numberOfParameters() const override
void update() const override
const QuantLib::Handle< TS > termStructure() const
virtual QuantLib::Matrix sigma_x(const QuantLib::Time t) const =0
virtual QuantLib::Array g(const QuantLib::Time t, const QuantLib::Time T) const
virtual QuantLib::Matrix y(const QuantLib::Time t) const
virtual QuantLib::Array kappa(const QuantLib::Time t) const =0
QuantLib::Size m() const
const std::string & name() const
virtual const Currency & currency() const
virtual void update() const
HwParametrization< YieldTermStructure > IrHwParametrization
base class for model parametrizations