QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
cpibond.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
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
30#include <ql/time/schedule.hpp>
31#include <utility>
32
33
34namespace QuantLib {
35
36 CPIBond::CPIBond(Natural settlementDays,
37 Real faceAmount,
38 bool growthOnly,
39 Real baseCPI,
40 const Period& observationLag,
41 ext::shared_ptr<ZeroInflationIndex> cpiIndex,
42 CPI::InterpolationType observationInterpolation,
43 Schedule schedule,
44 const std::vector<Rate>& fixedRate,
45 const DayCounter& accrualDayCounter,
46 BusinessDayConvention paymentConvention,
47 const Date& issueDate,
48 const Calendar& paymentCalendar,
49 const Period& exCouponPeriod,
50 const Calendar& exCouponCalendar,
51 const BusinessDayConvention exCouponConvention,
52 bool exCouponEndOfMonth)
53 : Bond(settlementDays,
54 paymentCalendar == Calendar() ? schedule.calendar() : paymentCalendar,
55 issueDate),
56 frequency_(schedule.tenor().frequency()), dayCounter_(accrualDayCounter),
57 growthOnly_(growthOnly), baseCPI_(baseCPI), observationLag_(observationLag),
58 cpiIndex_(std::move(cpiIndex)), observationInterpolation_(observationInterpolation) {
59
60 maturityDate_ = schedule.endDate();
61
62 // a CPIleg know about zero legs and inclusion of base inflation notional
63 cashflows_ = CPILeg(std::move(schedule), cpiIndex_,
65 .withNotionals(faceAmount)
66 .withFixedRates(fixedRate)
67 .withPaymentDayCounter(accrualDayCounter)
68 .withPaymentAdjustment(paymentConvention)
72 .withExCouponPeriod(exCouponPeriod,
73 exCouponCalendar,
74 exCouponConvention,
75 exCouponEndOfMonth);
76
77
79
80 redemptions_.push_back(cashflows_.back());
81
83 Leg::const_iterator i;
84 for (i = cashflows_.begin(); i < cashflows_.end(); ++i) {
85 registerWith(*i);
86 }
87 }
88}
Cash-flow analysis functions.
Cash flow vector builders.
Base bond class.
Definition: bond.hpp:59
Calendar calendar_
Definition: bond.hpp:299
Leg redemptions_
Definition: bond.hpp:303
Leg cashflows_
Definition: bond.hpp:302
Date maturityDate_
Definition: bond.hpp:305
void calculateNotionalsFromCashflows()
Definition: bond.cpp:374
Period observationLag_
Definition: cpibond.hpp:76
ext::shared_ptr< ZeroInflationIndex > cpiIndex_
Definition: cpibond.hpp:77
CPIBond(Natural settlementDays, Real faceAmount, bool growthOnly, Real baseCPI, const Period &observationLag, ext::shared_ptr< ZeroInflationIndex > cpiIndex, CPI::InterpolationType observationInterpolation, Schedule schedule, const std::vector< Rate > &coupons, const DayCounter &accrualDayCounter, BusinessDayConvention paymentConvention=ModifiedFollowing, const Date &issueDate=Date(), const Calendar &paymentCalendar=Calendar(), const Period &exCouponPeriod=Period(), const Calendar &exCouponCalendar=Calendar(), BusinessDayConvention exCouponConvention=Unadjusted, bool exCouponEndOfMonth=false)
Definition: cpibond.cpp:36
CPI::InterpolationType observationInterpolation_
Definition: cpibond.hpp:78
Helper class building a sequence of capped/floored CPI coupons.
Definition: cpicoupon.hpp:277
CPILeg & withNotionals(Real notional)
Definition: cpicoupon.cpp:284
CPILeg & withPaymentAdjustment(BusinessDayConvention)
Definition: cpicoupon.cpp:304
CPILeg & withSubtractInflationNominal(bool)
Definition: cpicoupon.cpp:294
CPILeg & withFixedRates(Real fixedRate)
Definition: cpicoupon.cpp:274
CPILeg & withExCouponPeriod(const Period &, const Calendar &, BusinessDayConvention, bool endOfMonth=false)
Definition: cpicoupon.cpp:344
CPILeg & withPaymentDayCounter(const DayCounter &)
Definition: cpicoupon.cpp:299
CPILeg & withPaymentCalendar(const Calendar &)
Definition: cpicoupon.cpp:309
CPILeg & withObservationInterpolation(CPI::InterpolationType)
Definition: cpicoupon.cpp:268
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:228
Payment schedule.
Definition: schedule.hpp:40
const Date & endDate() const
Definition: schedule.hpp:184
Coupon pricers.
zero-inflation-indexed-ratio-with-base bond
Coupon paying a zero-inflation index.
Coupon paying a fixed annual rate.
BusinessDayConvention
Business Day conventions.
QL_REAL Real
real number
Definition: types.hpp:50
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
Coupon paying a Libor-type index.
base classes for inflation indexes
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.