QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
squarerootandersen.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2008 Mark Joshi
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#ifndef quantlib_square_root_andersen_hpp
21#define quantlib_square_root_andersen_hpp
22
23#include <ql/models/marketmodels/evolvers/marketmodelvolprocess.hpp>
24
25namespace QuantLib
26{
27
28
35 {
36 public:
37 SquareRootAndersen(Real meanLevel,
38 Real reversionSpeed,
39 Real volVar,
40 Real v0,
41 const std::vector<Real>& evolutionTimes,
43 Real w1,
44 Real w2,
45 Real cutPoint = 1.5);
46
47 Size variatesPerStep() override;
48 Size numberSteps() override;
49
50 void nextPath() override;
51 Real nextstep(const std::vector<Real>& variates) override;
52 Real stepSd() const override;
53
54 const std::vector<Real>& stateVariables() const override;
55 Size numberStateVariables() const override;
56
57 private:
58
59 void DoOneSubStep(Real& v, Real variate, Size j);
60
61 Real theta_; // mean level
62
63 Real k_; // reversion speed
64 Real epsilon_; // volvar
65
66 Real v0_; // initial value of instantaneous variance
67 Size numberSubSteps_; // sub steps per evolution time
68
69
70 std::vector<Real> dt_; // time step lengths
71 std::vector<Real> eMinuskDt_; // exp( - k * dt)
72
73 Real w1_; // weights to use for computing variance across step
75 Real PsiC_; // cut-off between two types of evolution
76
81 std::vector<Real> vPath_;
82
83 mutable std::vector<Real> state_;
84
85 };
86
87}
88
89#endif
Size numberStateVariables() const override
void DoOneSubStep(Real &v, Real variate, Size j)
const std::vector< Real > & stateVariables() const override
Real nextstep(const std::vector< Real > &variates) override
QL_REAL Real
real number
Definition: types.hpp:50
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35