Logo Search packages:      
Sourcecode: quantlib version File versions  Download package


/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

 Copyright (C) 2008 Jose Aparicio
 Copyright (C) 2008 Roland Lichters
 Copyright (C) 2008 StatPro Italia srl

 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 creditdefaultswap.hpp
    \brief Credit default swap

#ifndef quantlib_credit_default_swap_hpp
#define quantlib_credit_default_swap_hpp

#include <ql/instrument.hpp>
#include <ql/cashflow.hpp>
#include <ql/issuer.hpp>
#include <ql/time/schedule.hpp>

namespace QuantLib {

    class YieldTermStructure;
    class Claim;

    //! Credit default swap
    /*! \note This instrument currently assumes that the issuer did
              not default until today's date.

        \warning if QL_TODAYS_PAYMENTS was defined (in userconfig.hpp
                 or when calling ./configure; it is undefined by
                 default) payments occurring at the settlement date of
                 the swap are included in the NPV, and therefore
                 affect the fair-spread calculation. This might not be
                 what you want.

         \ingroup instruments
00052     class CreditDefaultSwap : public Instrument {
        class arguments;
        class results;
        class engine;
        //! \name Constructors
        CreditDefaultSwap(Protection::Side side,
                          Real notional,
                          Rate spread,
                          const Schedule& schedule,
                          BusinessDayConvention paymentConvention,
                          const DayCounter& dayCounter,
                          bool settlesAccrual = true,
                          bool paysAtDefaultTime = true,
                          const boost::shared_ptr<Claim>& =
        //! \name Instrument interface
        bool isExpired() const;
        void setupArguments(PricingEngine::arguments*) const;
        void fetchResults(const PricingEngine::results*) const;
        //! \name Inspectors
        Protection::Side side() const;
        Real notional() const;
        Rate spread() const;
        bool settlesAccrual() const;
        bool paysAtDefaultTime() const;
        const Leg& coupons() const;
        //! \name Results
        Rate fairSpread() const;
        Real couponLegBPS() const;
        Real couponLegNPV() const;
        Real defaultLegNPV() const;
        Rate impliedHazardRate(Real targetNPV,
                               const Handle<YieldTermStructure>& discountCurve,
                               const DayCounter& dayCounter,
                               Real recoveryRate = 0.4,
                               Real accuracy = 1.0e-6) const;
        //! \name Instrument interface
        void setupExpired() const;
        // data members
        Protection::Side side_;
        Real notional_;
        Rate spread_;
        bool settlesAccrual_, paysAtDefaultTime_;
        boost::shared_ptr<Claim> claim_;
        Leg leg_;
        // results
        mutable Rate fairSpread_;
        mutable Real couponLegBPS_, couponLegNPV_;
        mutable Real defaultLegNPV_;

    class CreditDefaultSwap::arguments
        : public virtual PricingEngine::arguments {
        Protection::Side side;
        Real notional;
        Rate spread;
        Leg leg;
        bool settlesAccrual;
        bool paysAtDefaultTime;
        boost::shared_ptr<Claim> claim;
        void validate() const;

    class CreditDefaultSwap::results : public Instrument::results {
        Rate fairSpread;
        Real couponLegBPS;
        Real couponLegNPV;
        Real defaultLegNPV;
        void reset();

    class CreditDefaultSwap::engine
        : public GenericEngine<CreditDefaultSwap::arguments,
                               CreditDefaultSwap::results> {};



Generated by  Doxygen 1.6.0   Back to index