Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
terminterpolateddefaultcurve.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2022 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 terminterpolateddefaultcurve.hpp
20 \brief default curve interpolating between two term curves
21*/
22
23#pragma once
24
25#include <ql/math/comparison.hpp>
26#include <ql/termstructures/credit/survivalprobabilitystructure.hpp>
27
28namespace QuantExt {
29
31public:
32 TermInterpolatedDefaultCurve(const Handle<DefaultProbabilityTermStructure>& c1,
33 const Handle<DefaultProbabilityTermStructure>& c2, const Real alpha)
34 : SurvivalProbabilityStructure(c1->dayCounter()), c1_(c1), c2_(c2), alpha_(alpha) {
35 registerWith(c1_);
36 registerWith(c2_);
37 }
38 Date maxDate() const override { return std::min(c1_->maxDate(), c2_->maxDate()); }
39 Time maxTime() const override { return std::min(c1_->maxTime(), c2_->maxTime()); }
40 const Date& referenceDate() const override { return c1_->referenceDate(); }
41 Calendar calendar() const override { return c1_->calendar(); }
42 Natural settlementDays() const override { return c1_->settlementDays(); }
43 Probability survivalProbabilityImpl(Time t) const override {
44 return std::pow(c1_->survivalProbability(t), alpha_) * std::pow(c2_->survivalProbability(t), 1.0 - alpha_);
45 }
46
47private:
48 Handle<DefaultProbabilityTermStructure> c1_, c2_;
49 Real alpha_;
50};
51
52} // namespace QuantExt
Handle< DefaultProbabilityTermStructure > c1_
TermInterpolatedDefaultCurve(const Handle< DefaultProbabilityTermStructure > &c1, const Handle< DefaultProbabilityTermStructure > &c2, const Real alpha)
Handle< DefaultProbabilityTermStructure > c2_
Probability survivalProbabilityImpl(Time t) const override