/usr/include/ql/experimental/credit/nthtodefault.hpp is in libquantlib0-dev 1.7.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
Copyright (C) 2008 Roland Lichters
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
<http://quantlib.org/license.shtml>.
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 nthtodefault.hpp
\brief N-th to default swap
*/
#ifndef quantlib_nth_to_default_hpp
#define quantlib_nth_to_default_hpp
#include <ql/instrument.hpp>
#include <ql/cashflow.hpp>
#include <ql/default.hpp>
#include <ql/termstructures/defaulttermstructure.hpp>
#include <ql/experimental/credit/onefactorcopula.hpp>
#include <ql/time/schedule.hpp>
namespace QuantLib {
class YieldTermStructure;
class Claim;
class Basket;
//--------------------------------------------------------------------------
//! N-th to default swap
/*! A NTD instrument exchanges protection against the nth default
in a basket of underlying credits for premium payments based
on the protected notional amount.
The pricing is analogous to the pricing of a CDS instrument
which represents protection against default of a single
underlying credit. The only difference is the calculation of
the probability of default. In the CDS case, it is the
probabilty of single name default; in the NTD case the
probability of at least N defaults in the portfolio of
underlying credits.
This probability is computed using the algorithm in
John Hull and Alan White, "Valuation of a CDO and nth to
default CDS without Monte Carlo simulation", Journal of
Derivatives 12, 2, 2004.
The algorithm allows for varying probability of default across
the basket. Otherwise, for identical probabilities of default,
the probability of n defaults is given by the binomial
distribution.
Default correlation is modeled using a one-factor Gaussian copula
approach.
The class is tested against data in Hull-White (see reference
above.)
*/
class NthToDefault : public Instrument {
public:
class arguments;
class results;
class engine;
//! This product is 'digital'; the basket might be tranched but this is
// not relevant to it.
NthToDefault(const boost::shared_ptr<Basket>& basket,
Size n,
Protection::Side side,
const Schedule& premiumSchedule,
Rate upfrontRate,
Rate premiumRate,
const DayCounter& dayCounter,
Real nominal,
bool settlePremiumAccrual);
bool isExpired() const;
// inspectors
Rate premium() const { return premiumRate_; }
Real nominal() const { return nominal_; }
DayCounter dayCounter() const { return dayCounter_; }
Protection::Side side() const { return side_; }
Size rank() const { return n_; }
Size basketSize() const;
const Date& maturity() const {return premiumSchedule_.endDate();}//???
const boost::shared_ptr<Basket>& basket() const {return basket_;}
// results
Rate fairPremium() const;
Real premiumLegNPV() const;
Real protectionLegNPV() const;
Real errorEstimate() const;
void setupArguments(PricingEngine::arguments*) const;
void fetchResults(const PricingEngine::results*) const;
private:
void setupExpired() const;
boost::shared_ptr<Basket> basket_;
Size n_;
Protection::Side side_;
Real nominal_;
Schedule premiumSchedule_;
Rate premiumRate_;
Rate upfrontRate_;
DayCounter dayCounter_;
bool settlePremiumAccrual_;
Leg premiumLeg_;/////////////////// LEG AND SCHEDULE BOTH MEMBERS..... REVISE THIS!
// results
mutable Rate premiumValue_;
mutable Real protectionValue_;
mutable Real upfrontPremiumValue_;
mutable Real fairPremium_;
mutable Real errorEstimate_;
};
class NthToDefault::arguments : public virtual PricingEngine::arguments {
public:
arguments() : side(Protection::Side(-1)),
premiumRate(Null<Real>()),
upfrontRate(Null<Real>()) {}
void validate() const;
boost::shared_ptr<Basket> basket;
Protection::Side side;
Leg premiumLeg;
Size ntdOrder;
bool settlePremiumAccrual;
Real notional;// ALL NAMES WITH THE SAME WEIGHT, NOTIONAL IS NOT MAPPED TO THE BASKET HERE, this does not have to be that way, its perfectly possible to have irreg notionals...
Real premiumRate;
Rate upfrontRate;
};
class NthToDefault::results : public Instrument::results {
public:
void reset();
Real premiumValue;
Real protectionValue;
Real upfrontPremiumValue;
Real fairPremium;
Real errorEstimate;
};
//! NTD base engine
class NthToDefault::engine :
public GenericEngine<NthToDefault::arguments,
NthToDefault::results> { };
}
#endif
|