QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
gjrgarchmodel.cpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2008 Yee Man Chan
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
20#include <ql/models/equity/gjrgarchmodel.hpp>
21#include <ql/quotes/simplequote.hpp>
22
23namespace QuantLib {
24
25 class GJRGARCHModel::VolatilityConstraint : public Constraint {
26 private:
27 class Impl final : public Constraint::Impl {
28 public:
29 bool test(const Array& params) const override {
30 const Real beta = params[2];
31 const Real gamma = params[3];
32
33 return (beta+gamma >= 0.0);
34 }
35 };
36 public:
37 VolatilityConstraint()
38 : Constraint(ext::shared_ptr<Constraint::Impl>(
39 new VolatilityConstraint::Impl)) {}
40 };
41
43 const ext::shared_ptr<GJRGARCHProcess> & process)
44 : CalibratedModel(6), process_(process) {
48 BoundaryConstraint( 0.0, 1.0));
50 BoundaryConstraint( 0.0, 1.0));
52 BoundaryConstraint(-1.0, 1.0));
56
57 constraint_ = ext::shared_ptr<Constraint>(
58 new CompositeConstraint(*constraint_, VolatilityConstraint()));
59
61
62 registerWith(process_->riskFreeRate());
63 registerWith(process_->dividendYield());
65 }
66
68 process_.reset(new GJRGARCHProcess(process_->riskFreeRate(),
69 process_->dividendYield(),
70 process_->s0(),
71 v0(), omega(),
72 alpha(), beta(),
73 gamma(), lambda(),
74 process_->daysPerYear()));
75 }
76}
77
Constraint imposing all arguments to be in [low,high]
Definition: constraint.hpp:114
Calibrated model class.
Definition: model.hpp:86
Array params() const
Returns array of arguments on which calibration is done.
Definition: model.cpp:126
ext::shared_ptr< Constraint > constraint_
Definition: model.hpp:127
std::vector< Parameter > arguments_
Definition: model.hpp:126
Constraint enforcing both given sub-constraints
Definition: constraint.hpp:140
Standard constant parameter .
Definition: parameter.hpp:71
Constraint(ext::shared_ptr< Impl > impl=ext::shared_ptr< Impl >())
Definition: constraint.cpp:25
void generateArguments() override
ext::shared_ptr< GJRGARCHProcess > process() const
GJRGARCHModel(const ext::shared_ptr< GJRGARCHProcess > &process)
ext::shared_ptr< GJRGARCHProcess > process_
Stochastic-volatility GJR-GARCH(1,1) process.
No constraint.
Definition: constraint.hpp:79
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:228
Constraint imposing positivity to all arguments
Definition: constraint.hpp:92
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:35