| 1 | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 | |
| 3 | /* |
| 4 | Copyright (C) 2006 Banca Profilo S.p.A. |
| 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 | /*! \file g2process.hpp |
| 21 | \brief G2 stochastic processes |
| 22 | */ |
| 23 | |
| 24 | #ifndef quantlib_g2_process_hpp |
| 25 | #define quantlib_g2_process_hpp |
| 26 | |
| 27 | #include <ql/processes/forwardmeasureprocess.hpp> |
| 28 | #include <ql/processes/ornsteinuhlenbeckprocess.hpp> |
| 29 | |
| 30 | namespace QuantLib { |
| 31 | |
| 32 | //! %G2 stochastic process |
| 33 | /*! \ingroup processes */ |
| 34 | class G2Process : public StochasticProcess { |
| 35 | public: |
| 36 | G2Process(Real a, Real sigma, Real b, Real eta, Real rho); |
| 37 | //! \name StochasticProcess interface |
| 38 | //@{ |
| 39 | Size size() const override; |
| 40 | Array initialValues() const override; |
| 41 | Array drift(Time t, const Array& x) const override; |
| 42 | Matrix diffusion(Time t, const Array& x) const override; |
| 43 | Array expectation(Time t0, const Array& x0, Time dt) const override; |
| 44 | Matrix stdDeviation(Time t0, const Array& x0, Time dt) const override; |
| 45 | Matrix covariance(Time t0, const Array& x0, Time dt) const override; |
| 46 | //@} |
| 47 | Real x0() const; |
| 48 | Real y0() const; |
| 49 | Real a() const; |
| 50 | Real sigma() const; |
| 51 | Real b() const; |
| 52 | Real eta() const; |
| 53 | Real rho() const; |
| 54 | private: |
| 55 | Real x0_ = 0.0, y0_ = 0.0, a_, sigma_, b_, eta_, rho_; |
| 56 | ext::shared_ptr<QuantLib::OrnsteinUhlenbeckProcess> xProcess_; |
| 57 | ext::shared_ptr<QuantLib::OrnsteinUhlenbeckProcess> yProcess_; |
| 58 | }; |
| 59 | |
| 60 | //! %Forward %G2 stochastic process |
| 61 | /*! \ingroup processes */ |
| 62 | class G2ForwardProcess : public ForwardMeasureProcess { |
| 63 | public: |
| 64 | G2ForwardProcess(Real a, Real sigma, Real b, Real eta, Real rho); |
| 65 | //! \name StochasticProcess interface |
| 66 | //@{ |
| 67 | Size size() const override; |
| 68 | Array initialValues() const override; |
| 69 | Array drift(Time t, const Array& x) const override; |
| 70 | Matrix diffusion(Time t, const Array& x) const override; |
| 71 | Array expectation(Time t0, const Array& x0, Time dt) const override; |
| 72 | Matrix stdDeviation(Time t0, const Array& x0, Time dt) const override; |
| 73 | Matrix covariance(Time t0, const Array& x0, Time dt) const override; |
| 74 | //@} |
| 75 | protected: |
| 76 | Real x0_ = 0.0, y0_ = 0.0, a_, sigma_, b_, eta_, rho_; |
| 77 | ext::shared_ptr<QuantLib::OrnsteinUhlenbeckProcess> xProcess_; |
| 78 | ext::shared_ptr<QuantLib::OrnsteinUhlenbeckProcess> yProcess_; |
| 79 | Real xForwardDrift(Time t, Time T) const; |
| 80 | Real yForwardDrift(Time t, Time T) const; |
| 81 | Real Mx_T(Real s, Real t, Real T) const; |
| 82 | Real My_T(Real s, Real t, Real T) const; |
| 83 | }; |
| 84 | |
| 85 | } |
| 86 | |
| 87 | |
| 88 | #endif |
| 89 | |
| 90 | |