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 vasicek.hpp
    \brief Vasicek model class

#ifndef quantlib_one_factor_models_vasicek_h
#define quantlib_one_factor_models_vasicek_h

#include <ql/ShortRateModels/onefactormodel.hpp>
#include <ql/Processes/ornsteinuhlenbeckprocess.hpp>

namespace QuantLib {

    //! %Vasicek model class
    /*! This class implements the Vasicek model defined by
            dr_t = a(b - r_t)dt + \sigma dW_t ,
        where \f$ a \f$, \f$ b \f$ and \f$ \sigma \f$ are constants.

        \ingroup shortrate
00041     class Vasicek : public OneFactorAffineModel {
        Vasicek(Rate r0 = 0.05,
                Real a = 0.1, Real b = 0.05, Real sigma = 0.01);

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

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

        virtual Real A(Time t, Time T) const;
        virtual Real B(Time t, Time T) const;

        Real a() const { return a_(0.0); }
        Real b() const { return b_(0.0); }
        Real sigma() const { return sigma_(0.0); }

        class Dynamics;

        Real r0_;
        Parameter& a_;
        Parameter& b_;
        Parameter& sigma_;

    //! Short-rate dynamics in the %Vasicek model
    /*! The short-rate follows an Ornstein-Uhlenbeck process with mean
        \f$ b \f$.
00074     class Vasicek::Dynamics : public ShortRateDynamics {
        Dynamics(Real a,
                 Real b,
                 Real sigma,
                 Real r0)
        : ShortRateDynamics(boost::shared_ptr<StochasticProcess>(
                             new OrnsteinUhlenbeckProcess(a, sigma, r0 - b))),
          a_(a), b_(b), r0_(r0) {}

        virtual Real variable(Time, Rate r) const {
            return r - b_;
        virtual Real shortRate(Time, Real x) const {
            return x + b_;
        Real a_, b_, r0_;

    // inline definitions

    inline boost::shared_ptr<OneFactorModel::ShortRateDynamics>
00098     Vasicek::dynamics() const {
        return boost::shared_ptr<ShortRateDynamics>(
                                     new Dynamics(a(), b() , sigma(), r0_));



Generated by  Doxygen 1.6.0   Back to index