QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
cpicapfloor.cpp
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 Copyright (C) 2021 Ralf Konrad Eckel
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
31#include <ql/time/schedule.hpp>
32#include <utility>
33
34
35namespace QuantLib {
36
38 Real nominal,
39 const Date& startDate, // start date of contract (only)
40 Real baseCPI,
41 const Date& maturity, // this is pre-adjustment!
42 Calendar fixCalendar,
43 BusinessDayConvention fixConvention,
44 Calendar payCalendar,
45 BusinessDayConvention payConvention,
46 Rate strike,
47 ext::shared_ptr<ZeroInflationIndex> index,
48 const Period& observationLag,
49 CPI::InterpolationType observationInterpolation)
50 : type_(type), nominal_(nominal), startDate_(startDate), baseCPI_(baseCPI), maturity_(maturity),
51 fixCalendar_(std::move(fixCalendar)), fixConvention_(fixConvention),
52 payCalendar_(std::move(payCalendar)), payConvention_(payConvention), strike_(strike),
53 index_(std::move(index)), observationLag_(observationLag),
54 observationInterpolation_(observationInterpolation) {
55 QL_REQUIRE(index_, "no inflation index passed");
56 QL_REQUIRE(fixCalendar_ != Calendar(), "no fixing calendar passed");
57 QL_REQUIRE(payCalendar_ != Calendar(), "no payment calendar passed");
58
60 QL_REQUIRE(observationLag_ >= index_->availabilityLag(),
61 "CPIcapfloor's observationLag must be at least availabilityLag of inflation index: "
62 <<"when the observation is effectively flat"
63 << observationLag_ << " vs " << index_->availabilityLag());
64 } else {
65 QL_REQUIRE(observationLag_ > index_->availabilityLag(),
66 "CPIcapfloor's observationLag must be greater than availabilityLag of inflation index: "
67 <<"when the observation is effectively linear"
68 << observationLag_ << " vs " << index_->availabilityLag());
69 }
70 }
71
72
73 // when you fix - but remember that there is an observation interpolation factor as well
76 }
77
78
81 }
82
83
85 return (Settings::instance().evaluationDate() > maturity_);
86 }
87
88
90 // nothing yet
91 }
92
93
95
96 // correct PricingEngine?
97 auto* arguments = dynamic_cast<CPICapFloor::arguments*>(args);
98 QL_REQUIRE(arguments != nullptr, "wrong argument type, not CPICapFloor::arguments*");
99
100 // data move
116 }
117
118}
Cash-flow analysis functions.
Cash flow vector builders.
BusinessDayConvention payConvention
CPI::InterpolationType observationInterpolation
ext::shared_ptr< ZeroInflationIndex > index
BusinessDayConvention fixConvention
void validate() const override
Definition: cpicapfloor.cpp:89
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_
Date payDate() const
Definition: cpicapfloor.cpp:79
CPI::InterpolationType observationInterpolation_
BusinessDayConvention payConvention_
BusinessDayConvention fixConvention_
CPICapFloor(Option::Type type, Real nominal, const Date &startDate, Real baseCPI, const Date &maturity, Calendar fixCalendar, BusinessDayConvention fixConvention, Calendar payCalendar, BusinessDayConvention payConvention, Rate strike, ext::shared_ptr< ZeroInflationIndex > inflationIndex, const Period &observationLag, CPI::InterpolationType observationInterpolation=CPI::AsIndex)
Definition: cpicapfloor.cpp:37
calendar class
Definition: calendar.hpp:61
Date adjust(const Date &, BusinessDayConvention convention=Following) const
Definition: calendar.cpp:84
Concrete date class.
Definition: date.hpp:125
static Settings & instance()
access to the unique instance
Definition: singleton.hpp:104
Coupon pricers.
zero-inflation-indexed-ratio-with-base option
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Definition: errors.hpp:117
Coupon paying a fixed annual rate.
BusinessDayConvention
Business Day conventions.
QL_REAL Real
real number
Definition: types.hpp:50
Real Rate
interest rates
Definition: types.hpp:70
Coupon paying a Libor-type index.
base classes for inflation indexes
bool isInterpolated(const QuantLib::CPI::InterpolationType &type=QuantLib::CPI::AsIndex)
Definition: any.hpp:35
STL namespace.
date schedule
Predetermined cash flow.
InterpolationType
when you observe an index, how do you interpolate between fixings?
Interest-rate term structure.