QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
cmsmarket.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2007 Ferdinando Ametrano
5 Copyright (C) 2007 Marco Bianchetti
6 Copyright (C) 2006, 2007 Giorgio Facchinetti
7
8 This file is part of QuantLib, a free-software/open-source library
9 for financial quantitative analysts and developers - http://quantlib.org/
10
11 QuantLib is free software: you can redistribute it and/or modify it
12 under the terms of the QuantLib license. You should have received a
13 copy of the license along with this program; if not, please email
14 <quantlib-dev@lists.sf.net>. The license is also available online at
15 <http://quantlib.org/license.shtml>.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the license for more details.
20*/
21
26#ifndef quantlib_cms_market_h
27#define quantlib_cms_market_h
28
29#include <ql/cashflows/conundrumpricer.hpp>
30#include <ql/math/matrix.hpp>
31#include <ql/quote.hpp>
32
33namespace QuantLib {
34
35 class CmsCouponPricer;
36 class Swap;
37 class SwapIndex;
38 class IborIndex;
39 class YieldTermStructure;
40
42 class CmsMarket: public LazyObject{
43 public:
44 CmsMarket(std::vector<Period> swapLengths,
45 std::vector<ext::shared_ptr<SwapIndex> > swapIndexes,
46 ext::shared_ptr<IborIndex> iborIndex,
47 const std::vector<std::vector<Handle<Quote> > >& bidAskSpreads,
48 const std::vector<ext::shared_ptr<CmsCouponPricer> >& pricers,
49 Handle<YieldTermStructure> discountingTS);
51
52 void update() override { LazyObject::update(); }
54 // called during calibration procedure
55 void reprice(const Handle<SwaptionVolatilityStructure>& volStructure,
56 Real meanReversion);
57 // inspectors ...
58 const std::vector<Period>& swapTenors() const { return swapTenors_;}
59 const std::vector<Period>& swapLengths() const { return swapLengths_;}
61 const Matrix& spreadErrors() { return errSpreads_; }
62 Matrix browse() const;
63
64 // cms market calibration methods (they haven't Lazy behaviour)
65 Real weightedSpreadError(const Matrix& weights);
66 Real weightedSpotNpvError(const Matrix& weights);
67 Real weightedFwdNpvError(const Matrix& weights);
68 Array weightedSpreadErrors(const Matrix& weights);
69 Array weightedSpotNpvErrors(const Matrix& weights);
70 Array weightedFwdNpvErrors(const Matrix& weights);
71
72 private:
73 void performCalculations() const override;
74 Real weightedMean(const Matrix& var, const Matrix& weights) const;
75 Array weightedMeans(const Matrix& var, const Matrix& weights) const;
76
77 std::vector<Period> swapLengths_;
78 std::vector<ext::shared_ptr<SwapIndex> > swapIndexes_;
79 ext::shared_ptr<IborIndex> iborIndex_;
80 std::vector<std::vector<Handle<Quote> > > bidAskSpreads_;
81 std::vector<ext::shared_ptr<CmsCouponPricer> > pricers_;
83
86 std::vector<Period> swapTenors_;
88
89 // market spreads
91 // model (mid) spreads
93 // differences between market and model mid spreads
95
96 // market mid prices of spot starting Cms Leg
98 // model mid prices of spot starting Cms Leg
100 // Differences between mdlSpotCmsLegNPV_ and mktSpotCmsLegNPV_
102
103 // market mid prices of forward starting Cms Leg
105 // model mid prices of forward starting Cms Leg
107 // Differences between mdlFwdCmsLegNPV_ and mktFwdCmsLegNPV_
109
110 std::vector<std::vector<ext::shared_ptr<Swap> > > spotSwaps_;
111 std::vector<std::vector<ext::shared_ptr<Swap> > > fwdSwaps_;
112
113 };
114
115}
116
117#endif
1-D array used in linear algebra.
Definition: array.hpp:52
set of CMS quotes
Definition: cmsmarket.hpp:42
Array weightedFwdNpvErrors(const Matrix &weights)
Definition: cmsmarket.cpp:191
void performCalculations() const override
Definition: cmsmarket.cpp:108
const Matrix & spreadErrors()
Definition: cmsmarket.hpp:61
Handle< YieldTermStructure > discTS_
Definition: cmsmarket.hpp:82
std::vector< std::vector< Handle< Quote > > > bidAskSpreads_
Definition: cmsmarket.hpp:80
Matrix browse() const
Definition: cmsmarket.cpp:227
std::vector< Period > swapTenors_
Definition: cmsmarket.hpp:86
Real weightedSpotNpvError(const Matrix &weights)
Definition: cmsmarket.cpp:179
Real weightedSpreadError(const Matrix &weights)
Definition: cmsmarket.cpp:184
std::vector< ext::shared_ptr< CmsCouponPricer > > pricers_
Definition: cmsmarket.hpp:81
void update() override
Definition: cmsmarket.hpp:52
const std::vector< Period > & swapTenors() const
Definition: cmsmarket.hpp:58
Array weightedSpotNpvErrors(const Matrix &weights)
Definition: cmsmarket.cpp:196
ext::shared_ptr< IborIndex > iborIndex_
Definition: cmsmarket.hpp:79
Matrix mdlSpotCmsLegNPV_
Definition: cmsmarket.hpp:99
Real weightedMean(const Matrix &var, const Matrix &weights) const
Definition: cmsmarket.cpp:206
std::vector< std::vector< ext::shared_ptr< Swap > > > fwdSwaps_
Definition: cmsmarket.hpp:111
std::vector< ext::shared_ptr< SwapIndex > > swapIndexes_
Definition: cmsmarket.hpp:78
const std::vector< Period > & swapLengths() const
Definition: cmsmarket.hpp:59
Matrix mktSpotCmsLegNPV_
Definition: cmsmarket.hpp:97
Array weightedMeans(const Matrix &var, const Matrix &weights) const
Definition: cmsmarket.cpp:217
void reprice(const Handle< SwaptionVolatilityStructure > &volStructure, Real meanReversion)
Definition: cmsmarket.cpp:155
Array weightedSpreadErrors(const Matrix &weights)
Definition: cmsmarket.cpp:201
Real weightedFwdNpvError(const Matrix &weights)
Definition: cmsmarket.cpp:174
const Matrix & impliedCmsSpreads()
Definition: cmsmarket.hpp:60
std::vector< std::vector< ext::shared_ptr< Swap > > > spotSwaps_
Definition: cmsmarket.hpp:110
std::vector< Period > swapLengths_
Definition: cmsmarket.hpp:77
Shared handle to an observable.
Definition: handle.hpp:41
Framework for calculation on demand and result caching.
Definition: lazyobject.hpp:35
void update() override
Definition: lazyobject.hpp:188
Matrix used in linear algebra.
Definition: matrix.hpp:41
QL_REAL Real
real number
Definition: types.hpp:50
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35