Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
hazardspreadeddefaulttermstructure.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file qle/termstructures/hazardspreadeddefaulttermstructure.hpp
20 \brief adds a constant hazard rate spread to a default term structure
21 \ingroup termstructures
22*/
23
24#ifndef quantext_hazard_spreaded__defaulttermstructure_hpp
25#define quantext_hazard_spreaded__defaulttermstructure_hpp
26
27#include <ql/quote.hpp>
28#include <ql/termstructures/credit/hazardratestructure.hpp>
29
30namespace QuantExt {
31using namespace QuantLib;
32
33// FIXME: why do we need this?
34//! Hazard Spreaded Default Term Structure
35/*! \ingroup termstructures
36 */
38public:
39 //! \name Constructors
40 //@{
41 HazardSpreadedDefaultTermStructure(const Handle<DefaultProbabilityTermStructure>& source,
42 const Handle<Quote>& spread);
43 //@}
44 //! \name TermStructure interface
45 //@{
46 virtual DayCounter dayCounter() const override;
47 virtual Date maxDate() const override;
48 virtual Time maxTime() const override;
49 virtual const Date& referenceDate() const override;
50 virtual Calendar calendar() const override;
51 virtual Natural settlementDays() const override;
52 //@}
53private:
54 //! \name HazardRateStructure interface
55 //@{
56 Rate hazardRateImpl(Time) const override;
57 //@}
58
59 //! \name DefaultProbabilityTermStructure interface
60 //@{
61 Probability survivalProbabilityImpl(Time) const override;
62 //@}
63
64 Handle<DefaultProbabilityTermStructure> source_;
65 Handle<Quote> spread_;
66};
67
68// inline definitions
69
71 return source_->hazardRate(t) + spread_->value();
72}
73
75 return source_->survivalProbability(t) * std::exp(-spread_->value() * t);
76}
77
78inline DayCounter HazardSpreadedDefaultTermStructure::dayCounter() const { return source_->dayCounter(); }
79
80inline Date HazardSpreadedDefaultTermStructure::maxDate() const { return source_->maxDate(); }
81
82inline Time HazardSpreadedDefaultTermStructure::maxTime() const { return source_->maxTime(); }
83
84inline const Date& HazardSpreadedDefaultTermStructure::referenceDate() const { return source_->referenceDate(); }
85
86inline Calendar HazardSpreadedDefaultTermStructure::calendar() const { return source_->calendar(); }
87
88inline Natural HazardSpreadedDefaultTermStructure::settlementDays() const { return source_->settlementDays(); }
89
90} // namespace QuantExt
91
92#endif