QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
cpicapfloor.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) 2010, 2011 Chris Kenyon
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18 */
19
20/*! \file cpicapfloor.hpp
21 \brief zero-inflation-indexed-ratio-with-base option
22 */
23
24
25#ifndef quantlib_cpicapfloor_hpp
26#define quantlib_cpicapfloor_hpp
27
28#include <ql/instrument.hpp>
29#include <ql/option.hpp>
30#include <ql/time/calendar.hpp>
34
35namespace QuantLib {
36
37 //! CPI cap or floor
38 /*! Quoted as a fixed strike rate \f$ K \f$. Payoff:
39 \f[
40 P_n(0,T) \max(y (N [(1+K)^{T}-1] -
41 N \left[ \frac{I(T)}{I(0)} -1 \right]), 0)
42 \f]
43 where \f$ T \f$ is the maturity time, \f$ P_n(0,t) \f$ is the
44 nominal discount factor at time \f$ t \f$, \f$ N \f$ is the
45 notional, and \f$ I(t) \f$ is the inflation index value at
46 time \f$ t \f$.
47
48 Inflation is generally available on every day, including
49 holidays and weekends. Hence there is a variable to state
50 whether the observe/fix dates for inflation are adjusted or
51 not. The default is not to adjust.
52
53 N.B. a cpi cap or floor is an option, not a cap or floor on a coupon.
54 Thus this is very similar to a ZCIIS and has a single flow, this is
55 as usual for cpi because it is cumulative up to option maturity from base
56 date.
57
58 We do not inherit from Option, although this would be reasonable,
59 because we do not have that degree of generality.
60
61 */
62 class CPICapFloor : public Instrument {
63 public:
64 class arguments;
65 class engine;
66
69 const Date& startDate, // start date of contract (only)
70 Real baseCPI,
71 const Date& maturity, // this is pre-adjustment!
72 Calendar fixCalendar,
73 BusinessDayConvention fixConvention,
74 Calendar payCalendar,
75 BusinessDayConvention payConvention,
77 ext::shared_ptr<ZeroInflationIndex> inflationIndex,
79 CPI::InterpolationType observationInterpolation = CPI::AsIndex);
80
81 //! \name Inspectors
82 //@{
83 Option::Type type() const { return type_; }
84 Real nominal() const { return nominal_; }
85 //! \f$ K \f$ in the above formula.
86 Rate strike() const { return strike_; }
87 Date fixingDate() const;
88 Date payDate() const;
89 const ext::shared_ptr<ZeroInflationIndex>& index() const { return index_; }
91 //@}
92
93 //! \name Instrument interface
94 //@{
95 bool isExpired() const override;
96 void setupArguments(PricingEngine::arguments*) const override;
97 //@}
98
99 protected:
110 ext::shared_ptr<ZeroInflationIndex> index_;
113 };
114
115
117 public:
126 ext::shared_ptr<ZeroInflationIndex> index;
129
130 void validate() const override;
131 };
132
133 class CPICapFloor::engine : public GenericEngine<CPICapFloor::arguments,
134 CPICapFloor::results> {};
135
136}
137
138
139#endif
140
calendar class
BusinessDayConvention payConvention
CPI::InterpolationType observationInterpolation
ext::shared_ptr< ZeroInflationIndex > index
BusinessDayConvention fixConvention
void validate() const override
Definition: cpicapfloor.cpp:89
CPI cap or floor.
Definition: cpicapfloor.hpp:62
Date fixingDate() const
Definition: cpicapfloor.cpp:74
void setupArguments(PricingEngine::arguments *) const override
Definition: cpicapfloor.cpp:94
bool isExpired() const override
returns whether the instrument might have value greater than zero.
Definition: cpicapfloor.cpp:84
ext::shared_ptr< ZeroInflationIndex > index_
Period observationLag() const
Definition: cpicapfloor.hpp:90
Real nominal() const
Definition: cpicapfloor.hpp:84
Option::Type type() const
Definition: cpicapfloor.hpp:83
Date payDate() const
Definition: cpicapfloor.cpp:79
CPI::InterpolationType observationInterpolation_
BusinessDayConvention payConvention_
Rate strike() const
in the above formula.
Definition: cpicapfloor.hpp:86
BusinessDayConvention fixConvention_
const ext::shared_ptr< ZeroInflationIndex > & index() const
Definition: cpicapfloor.hpp:89
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
template base class for option pricing engines
Abstract instrument class.
Definition: instrument.hpp:44
Coupon paying a zero-inflation index.
day counter class
BusinessDayConvention
Business Day conventions.
QL_REAL Real
real number
Definition: types.hpp:50
Real Rate
interest rates
Definition: types.hpp:70
base classes for inflation indexes
Abstract instrument class.
Definition: any.hpp:35
Base option class.
InterpolationType
when you observe an index, how do you interpolate between fixings?
@ AsIndex
same interpolation as index