QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
coterminalswapcurvestate.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_coterminalswapcurvestate_hpp
23#define quantlib_coterminalswapcurvestate_hpp
24
26
27namespace QuantLib {
28
29 //! %Curve state for coterminal-swap 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 */
40 /* There will n+1 rate times expressing payment and reset times
41 of coterminal swap rates.
42
43 |-----|-----|-----|-----|-----| (size = 6)
44 0 1 2 3 4 5 index (i) (i = 0, ..., 5)
45 t0 t1 t2 t3 t4 t5 rateTimes (i = 0, ..., 5; dim = 6)
46 tau0 tau1 tau2 tau3 tau4 rateTaus (i = 0, ..., 4; dim = 5)
47 f0 f1 f2 f3 f4 forwardRates (i = 0, ..., 4; dim = 5)
48 d0 d1 d2 d3 d4 d5 discountBonds (i = 0, ..., 5; dim = 6)
49 d0/d0 d1/d0 d2/d0 d3/d0 d4/d0 d5/d0 discountRatios (i = 0, ..., 5; dim = 6)
50 sr0 sr1 sr2 sr3 sr4 cotSwapsRates (i = 0, ..., 4; dim = 5)
51 a0 a1 a2 a3 a4 cotAnnuities (i = 0, ..., 4; dim = 5)
52 */
53 public:
54 explicit CoterminalSwapCurveState(const std::vector<Time>& rateTimes);
55 //! \name Modifiers
56 //@{
57 void setOnCoterminalSwapRates(const std::vector<Rate>& swapRates,
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 Rate coterminalSwapRate(Size i) const override;
66 Rate coterminalSwapAnnuity(Size numeraire, Size i) const override;
67 Rate cmSwapRate(Size i, Size spanningForwards) const override;
68 Rate cmSwapAnnuity(Size numeraire, Size i, Size spanningForwards) const override;
69 const std::vector<Rate>& forwardRates() const override;
70 const std::vector<Rate>& coterminalSwapRates() const override;
71 const std::vector<Rate>& cmSwapRates(Size spanningForwards) const override;
72 //@}
73 std::unique_ptr<CurveState> clone() const override;
74 private:
76 std::vector<DiscountFactor> discRatios_;
77 mutable std::vector<Rate> forwardRates_;
78 mutable std::vector<Rate> cmSwapRates_;
79 mutable std::vector<Real> cmSwapAnnuities_;
80 std::vector<Rate> cotSwapRates_;
81 std::vector<Real> cotAnnuities_;
82 };
83
84}
85
86#endif
Curve state for coterminal-swap market models
const std::vector< Rate > & cmSwapRates(Size spanningForwards) const override
void setOnCoterminalSwapRates(const std::vector< Rate > &swapRates, Size firstValidIndex=0)
Real discountRatio(Size i, Size j) const override
Rate cmSwapAnnuity(Size numeraire, Size i, Size spanningForwards) const override
Rate coterminalSwapRate(Size i) const override
Rate cmSwapRate(Size i, Size spanningForwards) const override
Rate coterminalSwapAnnuity(Size numeraire, Size i) const override
const std::vector< Rate > & forwardRates() const override
std::vector< DiscountFactor > discRatios_
std::unique_ptr< CurveState > clone() const override
const std::vector< Rate > & coterminalSwapRates() const override
Curve state for market-model simulations
Definition: curvestate.hpp:41
const std::vector< Time > & rateTimes() const
Definition: curvestate.hpp:60
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