Logo Search packages:      
Sourcecode: quantlib version File versions


Go to the documentation of this file.
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

 Copyright (C) 2001, 2002, 2003 Sadruddin Rejeb

 This file is part of QuantLib, a free-software/open-source library
 for financial quantitative analysts and developers - http://quantlib.org/

 QuantLib is free software: you can redistribute it and/or modify it
 under the terms of the QuantLib license.  You should have received a
 copy of the license along with this program; if not, please email
 <quantlib-dev@lists.sf.net>. The license is also available online at

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.

/*! \file coxingersollross.hpp
    \brief Cox-Ingersoll-Ross model

#ifndef quantlib_one_factor_models_cox_ingersoll_ross_h
#define quantlib_one_factor_models_cox_ingersoll_ross_h

#include <ql/ShortRateModels/onefactormodel.hpp>

namespace QuantLib {

    //! Cox-Ingersoll-Ross model class.
    /*! This class implements the Cox-Ingersoll-Ross model defined by
            dr_t = k(\theta - r_t)dt + \sqrt{r_t}\sigma dW_t .

        \bug this class was not tested enough to guarantee
             its functionality.

        \ingroup shortrate
00042     class CoxIngersollRoss : public OneFactorAffineModel {
        CoxIngersollRoss(Rate r0 = 0.05,
                         Real theta = 0.1,
                         Real k = 0.1,
                         Real sigma = 0.1);

        virtual Real discountBondOption(Option::Type type,
                                        Real strike,
                                        Time maturity,
                                        Time bondMaturity) const;

        virtual boost::shared_ptr<ShortRateDynamics> dynamics() const;

        virtual boost::shared_ptr<Lattice> tree(const TimeGrid& grid) const;

        class Dynamics;
        Real A(Time t, Time T) const;
        Real B(Time t, Time T) const;

        Real theta() const { return theta_(0.0); }
        Real k() const { return k_(0.0); }
        Real sigma() const { return sigma_(0.0); }
        Real x0() const { return r0_(0.0); }

        class VolatilityConstraint;
        class HelperProcess;

        Parameter& theta_;
        Parameter& k_;
        Parameter& sigma_;
        Parameter& r0_;

    class CoxIngersollRoss::HelperProcess : public StochasticProcess {
        HelperProcess(Real theta, Real k, Real sigma, Real y0)
        : y0_(y0), theta_(theta), k_(k), sigma_(sigma) {}

        Real x0() const {
            return y0_;
        Real drift(Time, Real y) const {
            return (0.5*theta_*k_ - 0.125*sigma_*sigma_)/y
                - 0.5*k_*y;
        Real diffusion(Time, Real) const {
            return 0.5*sigma_;

        Real y0_, theta_, k_, sigma_;

    //! %Dynamics of the short-rate under the Cox-Ingersoll-Ross model
    /*! The state variable \f$ y_t \f$ will here be the square-root of the
        short-rate. It satisfies the following stochastic equation
                    (\frac{k\theta }{2}+\frac{\sigma ^2}{8})\frac{1}{y_t}-
                    \frac{k}{2}y_t \right] d_t+ \frac{\sigma }{2}dW_{t}
00107     class CoxIngersollRoss::Dynamics : public ShortRateDynamics {
        Dynamics(Real theta,
                 Real k,
                 Real sigma,
                 Real x0)
        : ShortRateDynamics(boost::shared_ptr<StochasticProcess>(
                        new HelperProcess(theta, k, sigma, std::sqrt(x0)))) {}

        virtual Real variable(Time, Rate r) const {
            return std::sqrt(r);
        virtual Real shortRate(Time, Real y) const {
            return y*y;



Generated by  Doxygen 1.6.0   Back to index