Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
spreadeddiscountcurve.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2020 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 spreadeddiscountcurve.hpp
20 \brief spreaded discount term structure
21 \ingroup termstructures
22*/
23
24#pragma once
25
26#include <ql/math/interpolation.hpp>
27#include <ql/patterns/lazyobject.hpp>
28#include <ql/termstructures/yieldtermstructure.hpp>
29
30#include <boost/make_shared.hpp>
31
32namespace QuantExt {
33using namespace QuantLib;
34
35/*! Curve taking a reference curve and discount factor quotes, that are used to overlay the reference
36 curve with a spread. The quotes are interpolated loglinearly. The spread curve is given in terms of
37 times relative to the reference date, which means that the spread will float with a changing reference
38 date in the reference curve. */
39class SpreadedDiscountCurve : public YieldTermStructure, public LazyObject {
40public:
43 //! times should be consistent with reference ts day counter
44 SpreadedDiscountCurve(const Handle<YieldTermStructure>& referenceCurve, const std::vector<Time>& times,
45 const std::vector<Handle<Quote>>& quotes,
46 const Interpolation interpolation = Interpolation::logLinear,
47 const Extrapolation extrapolation = Extrapolation::flatFwd);
48
49 Date maxDate() const override;
50 void update() override;
51 const Date& referenceDate() const override;
52
53 Calendar calendar() const override;
54 Natural settlementDays() const override;
55
56protected:
57 void performCalculations() const override;
58 DiscountFactor discountImpl(Time t) const override;
59
60private:
61 Handle<YieldTermStructure> referenceCurve_;
62 std::vector<Time> times_;
63 std::vector<Handle<Quote>> quotes_;
66 mutable std::vector<Real> data_;
67 QuantLib::ext::shared_ptr<QuantLib::Interpolation> dataInterpolation_;
68};
69
70} // namespace QuantExt
Calendar calendar() const override
Handle< YieldTermStructure > referenceCurve_
DiscountFactor discountImpl(Time t) const override
const Date & referenceDate() const override
Natural settlementDays() const override
std::vector< Handle< Quote > > quotes_
QuantLib::ext::shared_ptr< QuantLib::Interpolation > dataInterpolation_