Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
cmscaphelper.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2019 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 cmscaphelper.hpp
20 \brief Cms Option helper class
21*/
22
23#ifndef quantext_cms_calibration_helper_h
24#define quantext_cms_calibration_helper_h
25
26#include <list>
27#include <ql/indexes/swapindex.hpp>
28#include <ql/instruments/capfloor.hpp>
29#include <ql/models/calibrationhelper.hpp>
30#include <ql/patterns/lazyobject.hpp>
31#include <ql/quote.hpp>
32#include <ql/termstructures/yieldtermstructure.hpp>
34
35namespace QuantExt {
36using namespace QuantLib;
37class CmsCapHelper : public LazyObject, public CalibrationHelper {
38public:
39 CmsCapHelper(Date asof, QuantLib::ext::shared_ptr<SwapIndex>& index1, QuantLib::ext::shared_ptr<SwapIndex>& index2,
40 const Handle<YieldTermStructure>& yts, const Handle<Quote>& price, const Handle<Quote>& correlation,
41 const Period& length, const Period& forwardStart, const Period& spotDays, const Period& cmsTenor,
42 Natural fixingDays, const Calendar& calendar, const DayCounter& daycounter,
43 const BusinessDayConvention& convention, QuantLib::ext::shared_ptr<FloatingRateCouponPricer>& pricer,
44 QuantLib::ext::shared_ptr<QuantLib::CmsCouponPricer>& cmsPricer)
45 : asof_(asof), index1_(index1), index2_(index2), discountCurve_(yts), marketValue_(price->value()),
46 correlation_(correlation), length_(length), forwardStart_(forwardStart), spotDays_(spotDays),
47 cmsTenor_(cmsTenor), fixingDays_(fixingDays), calendar_(calendar), dayCounter_(daycounter),
48 convention_(convention), pricer_(pricer), cmsPricer_(cmsPricer) {
49
50 registerWith(correlation_);
51 }
52
53 void performCalculations() const override;
54
55 //! returns the actual price of the instrument (from volatility)
56 QuantLib::Real marketValue() const { return marketValue_; }
57
58 //! returns the price of the instrument according to the model
59 QuantLib::Real modelValue() const;
60
61 //! returns the error resulting from the model valuation
62 QuantLib::Real calibrationError() override { return marketValue() - modelValue(); }
63
64protected:
65 Date asof_;
66 QuantLib::ext::shared_ptr<SwapIndex> index1_;
67 QuantLib::ext::shared_ptr<SwapIndex> index2_;
68 Handle<YieldTermStructure> discountCurve_;
70 Handle<Quote> correlation_;
71 Period length_;
72
74 Period spotDays_;
75 Period cmsTenor_;
76 Natural fixingDays_;
77 Calendar calendar_;
78 DayCounter dayCounter_;
79 BusinessDayConvention convention_;
80
81 QuantLib::ext::shared_ptr<FloatingRateCouponPricer> pricer_;
82 QuantLib::ext::shared_ptr<QuantLib::CmsCouponPricer> cmsPricer_;
83
84private:
85 mutable QuantLib::ext::shared_ptr<QuantLib::Swap> cap_;
86};
87
88} // namespace QuantExt
89
90#endif
QuantLib::Real modelValue() const
returns the price of the instrument according to the model
Handle< Quote > correlation_
void performCalculations() const override
QuantLib::Real marketValue() const
returns the actual price of the instrument (from volatility)
Handle< YieldTermStructure > discountCurve_
CmsCapHelper(Date asof, QuantLib::ext::shared_ptr< SwapIndex > &index1, QuantLib::ext::shared_ptr< SwapIndex > &index2, const Handle< YieldTermStructure > &yts, const Handle< Quote > &price, const Handle< Quote > &correlation, const Period &length, const Period &forwardStart, const Period &spotDays, const Period &cmsTenor, Natural fixingDays, const Calendar &calendar, const DayCounter &daycounter, const BusinessDayConvention &convention, QuantLib::ext::shared_ptr< FloatingRateCouponPricer > &pricer, QuantLib::ext::shared_ptr< QuantLib::CmsCouponPricer > &cmsPricer)
QuantLib::ext::shared_ptr< FloatingRateCouponPricer > pricer_
BusinessDayConvention convention_
QuantLib::ext::shared_ptr< QuantLib::CmsCouponPricer > cmsPricer_
QuantLib::ext::shared_ptr< QuantLib::Swap > cap_
QuantLib::ext::shared_ptr< SwapIndex > index1_
QuantLib::ext::shared_ptr< SwapIndex > index2_
QuantLib::Real calibrationError() override
returns the error resulting from the model valuation
cms spread coupon pricer as in Brigo, Mercurio, 13.6.2, with extensions for shifted lognormal and nor...