QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
nthtodefault.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2008 Roland Lichters
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
24#ifndef quantlib_nth_to_default_hpp
25#define quantlib_nth_to_default_hpp
26
27#include <ql/instrument.hpp>
28#include <ql/cashflow.hpp>
29#include <ql/default.hpp>
30#include <ql/termstructures/defaulttermstructure.hpp>
31#include <ql/experimental/credit/onefactorcopula.hpp>
32#include <ql/time/schedule.hpp>
33
34namespace QuantLib {
35
36 class YieldTermStructure;
37 class Claim;
38 class Basket;
39
40 //--------------------------------------------------------------------------
42
70 class NthToDefault : public Instrument {
71 public:
72 class arguments;
73 class results;
74 class engine;
75
77 // not relevant to it.
78 NthToDefault(const ext::shared_ptr<Basket>& basket,
79 Size n,
81 const Schedule& premiumSchedule,
82 Rate upfrontRate,
83 Rate premiumRate,
86 bool settlePremiumAccrual);
87
88 bool isExpired() const override;
89
90 // inspectors
91 Rate premium() const { return premiumRate_; }
92 Real nominal() const { return nominal_; }
93 DayCounter dayCounter() const { return dayCounter_; }
94 Protection::Side side() const { return side_; }
95 Size rank() const { return n_; }
96 Size basketSize() const;
97
98 const Date& maturity() const {return premiumSchedule_.endDate();}//???
99
100 const ext::shared_ptr<Basket>& basket() const {return basket_;}
101
102 // results
103 Rate fairPremium() const;
104 Real premiumLegNPV() const;
105 Real protectionLegNPV() const;
106 Real errorEstimate() const;
107
108 void setupArguments(PricingEngine::arguments*) const override;
109 void fetchResults(const PricingEngine::results*) const override;
110
111 private:
112 void setupExpired() const override;
113
114 ext::shared_ptr<Basket> basket_;
123
125
126 // results
132 };
133
134
135
137 public:
138 arguments() : side(Protection::Side(-1)),
140 upfrontRate(Null<Real>()) {}
141 void validate() const override;
142
143 ext::shared_ptr<Basket> basket;
146
149 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...
152 };
153
155 public:
156 void reset() override;
162 };
163
166 public GenericEngine<NthToDefault::arguments,
167 NthToDefault::results> { };
168
169}
170
171#endif
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
template base class for option pricing engines
Abstract instrument class.
Definition: instrument.hpp:44
ext::shared_ptr< Basket > basket
void validate() const override
N-th to default swap.
ext::shared_ptr< Basket > basket_
void setupArguments(PricingEngine::arguments *) const override
const ext::shared_ptr< Basket > & basket() const
bool isExpired() const override
returns whether the instrument might have value greater than zero.
const Date & maturity() const
Real errorEstimate() const
Protection::Side side_
Real protectionLegNPV() const
Real premiumLegNPV() const
Rate fairPremium() const
void setupExpired() const override
void fetchResults(const PricingEngine::results *) const override
DayCounter dayCounter() const
Protection::Side side() const
template class providing a null value for a given type.
Definition: null.hpp:76
Payment schedule.
Definition: schedule.hpp:40
const Date & endDate() const
Definition: schedule.hpp:184
QL_REAL Real
real number
Definition: types.hpp:50
Real Rate
interest rates
Definition: types.hpp:70
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
Definition: cashflow.hpp:78
information on a default-protection contract
Definition: default.hpp:32