/src/quantlib/ql/pricingengines/futures/discountingperpetualfuturesengine.hpp
Line | Count | Source |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2025 Hiroto Ogawa |
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 | | <https://www.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 | | |
20 | | /*! \file discountingperpetualfuturesengine.hpp |
21 | | \brief discounting perpetual futures engine |
22 | | */ |
23 | | |
24 | | #ifndef quantlib_discounting_perpetual_futures_engine_hpp |
25 | | #define quantlib_discounting_perpetual_futures_engine_hpp |
26 | | |
27 | | #include <ql/instruments/perpetualfutures.hpp> |
28 | | #include <ql/termstructures/yieldtermstructure.hpp> |
29 | | #include <ql/handle.hpp> |
30 | | #include <ql/optional.hpp> |
31 | | #include <ql/math/interpolation.hpp> |
32 | | |
33 | | namespace QuantLib { |
34 | | |
35 | | //! Discounting engine for perpetual futures |
36 | | /*! This engine discounts perpetual futures cashflows |
37 | | to the reference date. |
38 | | */ |
39 | | class DiscountingPerpetualFuturesEngine : public PerpetualFutures::engine { |
40 | | public: |
41 | | enum InterpolationType { PiecewiseConstant, Linear, CubicSpline }; |
42 | | DiscountingPerpetualFuturesEngine( |
43 | | const Handle<YieldTermStructure>& domesticDiscountCurve, |
44 | | const Handle<YieldTermStructure>& foreignDiscountCurve, |
45 | | const Handle<Quote>& assetSpot, |
46 | | const std::vector<Time>& fundingTimes, |
47 | | const std::vector<Rate>& fundingRates, |
48 | | const std::vector<Spread>& interestRateDiffs, |
49 | | InterpolationType fundingInterpType = PiecewiseConstant, |
50 | | Real maxT = 60.); |
51 | | void calculate() const override; |
52 | 0 | Handle<YieldTermStructure> domesticDiscountCurve() const { return domesticDiscountCurve_; } |
53 | 0 | Handle<YieldTermStructure> foreignDiscountCurve() const { return foreignDiscountCurve_; } |
54 | 0 | Handle<Quote> assetSpot() const { return assetSpot_; } |
55 | 0 | const std::vector<Time>& fundingTimes() const { return fundingTimes_; } |
56 | 0 | const std::vector<Rate>& fundingRates() const { return fundingRates_; } |
57 | 0 | const std::vector<Spread>& interestRateDiffs() const { return interestRateDiffs_; } |
58 | | |
59 | | private: |
60 | | Interpolation selectInterpolation(const std::vector<Time>& times, const std::vector<Real>& values) const; |
61 | | Handle<YieldTermStructure> domesticDiscountCurve_, foreignDiscountCurve_; |
62 | | Handle<Quote> assetSpot_; |
63 | | std::vector<Time> fundingTimes_; |
64 | | std::vector<Rate> fundingRates_; |
65 | | std::vector<Spread> interestRateDiffs_; |
66 | | InterpolationType fundingInterpType_; |
67 | | Real maxT_; |
68 | | }; |
69 | | |
70 | | } |
71 | | |
72 | | #endif |