QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
curvestate.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2006, 2007 Ferdinando Ametrano
5 Copyright (C) 2006, 2007 Mark Joshi
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
21
22#ifndef quantlib_curve_state_hpp
23#define quantlib_curve_state_hpp
24
25#include <ql/math/array.hpp>
26#include <vector>
27#include <memory>
28
29namespace QuantLib {
30
32
41 class CurveState {
42 /* There will n+1 rate times expressing payment and reset times
43 of forward rates.
44
45 |-----|-----|-----|-----|-----| (size = 6)
46 t0 t1 t2 t3 t4 t5 rateTimes
47 f0 f1 f2 f3 f4 forwardRates
48 d0 d1 d2 d3 d4 d5 discountBonds
49 d0/d0 d1/d0 d2/d0 d3/d0 d4/d0 d5/d0 discountRatios
50 sr0 sr1 sr2 sr3 sr4 cotSwaps
51 */
52 public:
53 CurveState(const std::vector<Time>& rateTimes);
54 virtual ~CurveState() = default;
55
57
58 Size numberOfRates() const { return numberOfRates_; }
59
60 const std::vector<Time>& rateTimes() const { return rateTimes_; }
61 const std::vector<Time>& rateTaus() const { return rateTaus_; }
62
64 Size j) const = 0;
65 virtual Rate forwardRate(Size i) const = 0;
66 virtual Rate coterminalSwapAnnuity(Size numeraire,
67 Size i) const = 0;
68 virtual Rate coterminalSwapRate(Size i) const = 0;
69 virtual Rate cmSwapAnnuity(Size numeraire,
70 Size i,
71 Size spanningForwards) const = 0;
72 virtual Rate cmSwapRate(Size i,
73 Size spanningForwards) const = 0;
74
75 virtual const std::vector<Rate>& forwardRates() const = 0;
76 virtual const std::vector<Rate>& coterminalSwapRates() const = 0;
77 virtual const std::vector<Rate>& cmSwapRates(Size spanningForwards) const = 0;
78 Rate swapRate(Size begin,
79 Size end) const;
80
81 virtual std::unique_ptr<CurveState> clone() const = 0;
83 protected:
85 std::vector<Time> rateTimes_, rateTaus_;
86 };
87
88 void forwardsFromDiscountRatios(Size firstValidIndex,
89 const std::vector<DiscountFactor>& ds,
90 const std::vector<Time>& taus,
91 std::vector<Rate>& fwds);
92
93 void coterminalFromDiscountRatios(Size firstValidIndex,
94 const std::vector<DiscountFactor>& ds,
95 const std::vector<Time>& taus,
96 std::vector<Rate>& cotSwapRates,
97 std::vector<Real>& cotSwapAnnuities);
98
99 void constantMaturityFromDiscountRatios( // Size i, // to be added later
100 Size spanningForwards,
101 Size firstValidIndex,
102 const std::vector<DiscountFactor>& ds,
103 const std::vector<Time>& taus,
104 std::vector<Rate>& cotSwapRates,
105 std::vector<Real>& cotSwapAnnuities);
106}
107
108#endif
Curve state for market-model simulations
Definition: curvestate.hpp:41
Size numberOfRates() const
Definition: curvestate.hpp:58
virtual Rate coterminalSwapAnnuity(Size numeraire, Size i) const =0
virtual const std::vector< Rate > & cmSwapRates(Size spanningForwards) const =0
virtual Rate cmSwapRate(Size i, Size spanningForwards) const =0
virtual Rate forwardRate(Size i) const =0
const std::vector< Time > & rateTimes() const
Definition: curvestate.hpp:60
virtual const std::vector< Rate > & coterminalSwapRates() const =0
Rate swapRate(Size begin, Size end) const
Definition: curvestate.cpp:32
std::vector< Time > rateTimes_
Definition: curvestate.hpp:85
virtual const std::vector< Rate > & forwardRates() const =0
const std::vector< Time > & rateTaus() const
Definition: curvestate.hpp:61
virtual Rate coterminalSwapRate(Size i) const =0
std::vector< Time > rateTaus_
Definition: curvestate.hpp:85
virtual Rate cmSwapAnnuity(Size numeraire, Size i, Size spanningForwards) const =0
virtual ~CurveState()=default
virtual Real discountRatio(Size i, Size j) const =0
virtual std::unique_ptr< CurveState > clone() const =0
QL_REAL Real
real number
Definition: types.hpp:50
Real Rate
interest rates
Definition: types.hpp:70
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35
void forwardsFromDiscountRatios(const Size firstValidIndex, const std::vector< DiscountFactor > &ds, const std::vector< Time > &taus, std::vector< Rate > &fwds)
Definition: curvestate.cpp:45
void coterminalFromDiscountRatios(const Size firstValidIndex, const std::vector< DiscountFactor > &discountFactors, const std::vector< Time > &taus, std::vector< Rate > &cotSwapRates, std::vector< Real > &cotSwapAnnuities)
Definition: curvestate.cpp:58
void constantMaturityFromDiscountRatios(const Size spanningForwards, const Size firstValidIndex, const std::vector< DiscountFactor > &ds, const std::vector< Time > &taus, std::vector< Rate > &constMatSwapRates, std::vector< Real > &constMatSwapAnnuities)
Definition: curvestate.cpp:88