Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
formulabasedindex.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2018 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 qle/indexes/formulabasedindex.hpp
20 \brief formula based index
21 \ingroup indexes
22*/
23
24#pragma once
25
27
28#include <ql/indexes/interestrateindex.hpp>
29
30namespace QuantExt {
31using namespace QuantLib;
32
33//! formula based index class
34/*! The variables in the given formula must correspond to index vector, both w.r.t.
35 size and position.
36
37 Warning:
38 - tenor is set to 0d for this index, since it doesn't have a meaningful interpretation
39 - fixingDays are set to the value of the first index, because Null<Size> could be interpreted
40 as the actual (big) number of fixing days by client code
41 - currency is set to Currency()
42 - dayCounter is set to SimpleDayCounter(), because it's used in InterestRateIndex to set the name,
43 which is overwritten here though
44 - fixingCalendar should be explicitly given, since it is used to derive the fixing date in
45 formula based coupons (and to determine valid fixing dates)
46*/
47
48class FormulaBasedIndex : public QuantLib::InterestRateIndex {
49public:
50 FormulaBasedIndex(const std::string& familyName, const std::vector<QuantLib::ext::shared_ptr<InterestRateIndex>>& indices,
51 const CompiledFormula& formula, const Calendar& fixingCalendar);
52
53 // InterestRateIndex interface
54 Date maturityDate(const Date& valueDate) const override {
55 QL_FAIL("FormulaBasedIndex does not provide a single maturity date");
56 }
57 Rate forecastFixing(const Date& fixingDate) const override;
58 Rate pastFixing(const Date& fixingDate) const override;
59 bool allowsNativeFixings() override { return false; }
60
61 // Inspectors
62 const std::vector<QuantLib::ext::shared_ptr<InterestRateIndex>>& indices() const { return indices_; }
63 const CompiledFormula& formula() const { return formula_; }
64
65private:
66 const std::vector<QuantLib::ext::shared_ptr<InterestRateIndex>> indices_;
68};
69
70} // namespace QuantExt
helper class representing a formula with variables given by an id v
formula based index class
const std::vector< QuantLib::ext::shared_ptr< InterestRateIndex > > & indices() const
Rate pastFixing(const Date &fixingDate) const override
const CompiledFormula formula_
Date maturityDate(const Date &valueDate) const override
const CompiledFormula & formula() const
const std::vector< QuantLib::ext::shared_ptr< InterestRateIndex > > indices_
Rate forecastFixing(const Date &fixingDate) const override
compiled formula