/usr/include/ql/experimental/credit/nthtodefault.hpp is in libquantlib0-dev 1.1-2build1.
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 | /* -*- 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;
//--------------------------------------------------------------------------
//! 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:
NthToDefault(
Size n,
const std::vector<Handle<DefaultProbabilityTermStructure> >&
probabilities,
Real recoveryRate,
const Handle<OneFactorCopula>& copula,
Protection::Side side,
Real nominal,
const Schedule& premiumSchedule,
Rate premiumRate,
const DayCounter& dayCounter,
bool settlePremiumAccrual,
const Handle<YieldTermStructure>& yieldTS,
const Period& integrationStepSize,
boost::shared_ptr<Claim> claim = boost::shared_ptr<Claim>());
bool isExpired() const;
Rate fairPremium() 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 { return probabilities_.size(); }
private:
Probability defaultProbability(const Date& d) const;
void setupExpired() const;
void performCalculations() const;
Size n_;
std::vector<Handle<DefaultProbabilityTermStructure> > probabilities_;
Real recoveryRate_;
Handle<OneFactorCopula> copula_;
Protection::Side side_;
Real nominal_;
Schedule premiumSchedule_;
Rate premiumRate_;
DayCounter dayCounter_;
bool settlePremiumAccrual_;
Handle<YieldTermStructure> yieldTS_;
Period integrationStepSize_;
boost::shared_ptr<Claim> claim_;
Leg premiumLeg_;
// results
mutable Rate fairPremium_;
};
}
#endif
|