QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
lmmcurvestate.hpp
Go to the documentation of this file.
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_lmmcurvestate_hpp
23#define quantlib_lmmcurvestate_hpp
24
26
27namespace QuantLib {
28
29 //! %Curve state for %Libor market models
30 /*! This class stores the state of the yield curve associated to the
31 fixed calendar times within the simulation.
32 This is the workhorse discounting object associated to the rate times
33 of the simulation. It's important to pass the rates via an object like
34 this to the product rather than directly to make it easier to switch
35 to other engines such as a coterminal swap rate engine.
36 Many products will not need expired rates and others will only require
37 the first rate.
38 */
39 class LMMCurveState : public CurveState {
40 /* There will n+1 rate times expressing payment and reset times
41 of forward rates.
42
43 |-----|-----|-----|-----|-----| (size = 6)
44 t0 t1 t2 t3 t4 t5 rateTimes
45 f0 f1 f2 f3 f4 forwardRates
46 d0 d1 d2 d3 d4 d5 discountBonds
47 d0/d0 d1/d0 d2/d0 d3/d0 d4/d0 d5/d0 discountRatios
48 sr0 sr1 sr2 sr3 sr4 cotSwaps
49 */
50 public:
51 explicit LMMCurveState(const std::vector<Time>& rateTimes);
52 //! \name Modifiers
53 //@{
54 void setOnForwardRates(const std::vector<Rate>& fwdRates,
55 Size firstValidIndex = 0);
56
57 void setOnDiscountRatios(const std::vector<DiscountFactor>& discRatios,
58 Size firstValidIndex = 0);
59 //@}
60
61 //! \name Inspectors
62 //@{
63 Real discountRatio(Size i, Size j) const override;
64 Rate forwardRate(Size i) const override;
65
66 Rate coterminalSwapRate(Size i) const override;
67 Rate coterminalSwapAnnuity(Size numeraire, Size i) const override;
68
69 Rate cmSwapRate(Size i, Size spanningForwards) const override;
70 Rate cmSwapAnnuity(Size numeraire, Size i, Size spanningForwards) const override;
71 const std::vector<Rate>& forwardRates() const override;
72 const std::vector<Rate>& coterminalSwapRates() const override;
73 const std::vector<Rate>& cmSwapRates(Size spanningForwards) const override;
74 //@}
75 std::unique_ptr<CurveState> clone() const override;
76
77 private:
79 std::vector<DiscountFactor> discRatios_;
80 std::vector<Rate> forwardRates_;
81 mutable std::vector<Rate> cmSwapRates_;
82 mutable std::vector<Real> cmSwapAnnuities_;
83 mutable std::vector<Rate> cotSwapRates_;
84 mutable std::vector<Real> cotAnnuities_;
85
87 };
88
89}
90
91#endif
Curve state for market-model simulations
Definition: curvestate.hpp:41
const std::vector< Time > & rateTimes() const
Definition: curvestate.hpp:60
Curve state for Libor market models
const std::vector< Rate > & cmSwapRates(Size spanningForwards) const override
Real discountRatio(Size i, Size j) const override
std::vector< Rate > forwardRates_
void setOnForwardRates(const std::vector< Rate > &fwdRates, Size firstValidIndex=0)
void setOnDiscountRatios(const std::vector< DiscountFactor > &discRatios, Size firstValidIndex=0)
Rate cmSwapAnnuity(Size numeraire, Size i, Size spanningForwards) const override
Rate coterminalSwapRate(Size i) const override
Rate forwardRate(Size i) const override
Rate cmSwapRate(Size i, Size spanningForwards) const override
std::vector< Rate > cmSwapRates_
std::vector< Rate > cotSwapRates_
Rate coterminalSwapAnnuity(Size numeraire, Size i) const override
std::vector< Real > cmSwapAnnuities_
const std::vector< Rate > & forwardRates() const override
std::vector< DiscountFactor > discRatios_
std::unique_ptr< CurveState > clone() const override
std::vector< Real > cotAnnuities_
const std::vector< Rate > & coterminalSwapRates() const override
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