QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.38
Loading...
Searching...
No Matches
gjrgarchmodel.cpp
Go to the documentation of this file.
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
22#include <ql/shared_ptr.hpp>
23
24namespace QuantLib {
25
26 class GJRGARCHModel::VolatilityConstraint : public Constraint {
27 private:
28 class Impl final : public Constraint::Impl {
29 public:
30 bool test(const Array& params) const override {
31 const Real beta = params[2];
32 const Real gamma = params[3];
33
34 return (beta+gamma >= 0.0);
35 }
36 };
37 public:
38 VolatilityConstraint()
39 : Constraint(ext::shared_ptr<Constraint::Impl>(
40 new VolatilityConstraint::Impl)) {}
41 };
42
44 const ext::shared_ptr<GJRGARCHProcess> & process)
45 : CalibratedModel(6), process_(process) {
49 BoundaryConstraint( 0.0, 1.0));
51 BoundaryConstraint( 0.0, 1.0));
53 BoundaryConstraint(-1.0, 1.0));
57
58 constraint_ = ext::shared_ptr<Constraint>(
59 new CompositeConstraint(*constraint_, VolatilityConstraint()));
60
62
63 registerWith(process_->riskFreeRate());
64 registerWith(process_->dividendYield());
66 }
67
69 process_ = ext::make_shared<GJRGARCHProcess>(process_->riskFreeRate(),
70 process_->dividendYield(),
71 process_->s0(),
72 v0(), omega(),
73 alpha(), beta(),
74 gamma(), lambda(),
75 process_->daysPerYear());
76 }
77}
78
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_
No constraint.
Definition: constraint.hpp:79
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:226
Constraint imposing positivity to all arguments
Definition: constraint.hpp:92
GJR-GARCH model for the stochastic volatility of an asset.
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:37
Maps shared_ptr to either the boost or std implementation.
simple quote class