Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
brlcdi.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2019 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
20
21using namespace QuantLib;
22using std::pow;
23
24namespace QuantExt {
25
26Rate BRLCdi::forecastFixing(const Date& fixingDate) const {
27
28 Date startDate = valueDate(fixingDate);
29 Date endDate = maturityDate(startDate);
30 Time dcf = dayCounter_.yearFraction(startDate, endDate);
31
32 // Some checks
33 QL_REQUIRE(dcf > 0.0, "Cannot calculate " << name() << " forward rate between " << startDate << " and " << endDate
34 << ": non positive time (" << dcf << ") using " << dayCounter_.name()
35 << " daycounter");
36
37 QL_REQUIRE(!termStructure_.empty(),
38 "Cannot calculate " << name() << " forward rate because term structure is empty");
39
40 // For BRL CDI, we want:
41 // DI(t, t_s, t_e) = \left[ \frac{P(t, t_s)}{P(t, t_e)} \right] ^ {\frac{1}{\tau(t_s, t_e)}} - 1
42 DiscountFactor discountStart = termStructure_->discount(startDate);
43 DiscountFactor discountEnd = termStructure_->discount(endDate);
44 return pow(discountStart / discountEnd, 1.0 / dcf) - 1.0;
45}
46
47QuantLib::ext::shared_ptr<IborIndex> BRLCdi::clone(const Handle<YieldTermStructure>& h) const {
48 return QuantLib::ext::make_shared<BRLCdi>(h);
49}
50
51} // namespace QuantExt
BRL-CDI index.
QuantLib::Rate forecastFixing(const QuantLib::Date &fixingDate) const override
Definition: brlcdi.cpp:26
QuantLib::ext::shared_ptr< IborIndex > clone(const QuantLib::Handle< QuantLib::YieldTermStructure > &h) const override
Definition: brlcdi.cpp:47
CompiledFormula pow(CompiledFormula x, const CompiledFormula &y)