/src/quantlib/ql/indexes/ibor/cdi.cpp
Line | Count | Source |
1 | | /* |
2 | | Copyright (C) 2025 Sotirios Papathanasopoulos |
3 | | |
4 | | This file is part of QuantLib, a free-software/open-source library |
5 | | for financial quantitative analysts and developers - http://quantlib.org/ |
6 | | QuantLib is free software: you can redistribute it and/or modify it |
7 | | under the terms of the QuantLib license. You should have received a |
8 | | copy of the license along with this program; if not, please email |
9 | | <quantlib-dev@lists.sf.net>. The license is also available online at |
10 | | <https://www.quantlib.org/license.shtml>. |
11 | | This program is distributed in the hope that it will be useful, but WITHOUT |
12 | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
13 | | FOR A PARTICULAR PURPOSE. See the license for more details. |
14 | | */ |
15 | | |
16 | | #include <ql/indexes/ibor/cdi.hpp> |
17 | | |
18 | | namespace QuantLib { |
19 | | // Reference: Zine-eddine, Arroub. "OpenGamma Quantitative research Brazilian Swaps", London, December 2013. paragraph 5 |
20 | 0 | Rate Cdi::forecastFixing(const Date& fixingDate) const { |
21 | |
|
22 | 0 | Date startDate = valueDate(fixingDate); |
23 | 0 | Date endDate = maturityDate(startDate); |
24 | 0 | Time yf = dayCounter_.yearFraction(startDate, endDate); |
25 | |
|
26 | 0 | QL_REQUIRE(yf > 0.0, "year fraction (" << yf << ") must be positive"); |
27 | | |
28 | 0 | QL_REQUIRE(!termStructure_.empty(), "null term structure set to this instance of " << name()); |
29 | | |
30 | 0 | DiscountFactor discountStart = termStructure_->discount(startDate); |
31 | 0 | DiscountFactor discountEnd = termStructure_->discount(endDate); |
32 | 0 | return std::pow(discountStart / discountEnd, 1.0 / yf) - 1.0; |
33 | 0 | } |
34 | | |
35 | | } |