/usr/include/ql/cashflows/inflationcoupon.hpp is in libquantlib0-dev 1.9.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
Copyright (C) 2009 Chris Kenyon
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
QuantLib is free software: you can redistribute it and/or modify it
under the terms of the QuantLib license. You should have received a
copy of the license along with this program; if not, please email
<quantlib-dev@lists.sf.net>. The license is also available online at
<http://quantlib.org/license.shtml>.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the license for more details.
*/
/*! \file floatingratecoupon.hpp
\brief Coupon paying a variable index-based rate
*/
#ifndef quantlib_inflation_coupon_hpp
#define quantlib_inflation_coupon_hpp
#include <ql/cashflows/coupon.hpp>
#include <ql/patterns/visitor.hpp>
#include <ql/time/daycounter.hpp>
#include <ql/handle.hpp>
namespace QuantLib {
class InflationIndex;
class YieldTermStructure;
class InflationCouponPricer;
//! Base inflation-coupon class
/*! The day counter is usually obtained from the inflation term
structure that the inflation index uses for forecasting.
There is no gearing or spread because these are relevant for
YoY coupons but not zero inflation coupons.
\note inflation indices do not contain day counters or calendars.
*/
class InflationCoupon : public Coupon,
public Observer {
public:
InflationCoupon(const Date& paymentDate,
Real nominal,
const Date& startDate,
const Date& endDate,
Natural fixingDays,
const boost::shared_ptr<InflationIndex>& index,
const Period& observationLag,
const DayCounter& dayCounter,
const Date& refPeriodStart = Date(),
const Date& refPeriodEnd = Date(),
const Date& exCouponDate = Date()
);
//! \name CashFlow interface
//@{
Real amount() const { return rate() * accrualPeriod() * nominal(); }
//@}
//! \name Coupon interface
//@{
Real price(const Handle<YieldTermStructure>& discountingCurve) const;
DayCounter dayCounter() const { return dayCounter_; }
Real accruedAmount(const Date&) const;
Rate rate() const;
//@}
//! \name Inspectors
//@{
//! yoy inflation index
const boost::shared_ptr<InflationIndex>& index() const { return index_; }
//! how the coupon observes the index
Period observationLag() const { return observationLag_; }
//! fixing days
Natural fixingDays() const { return fixingDays_; }
//! fixing date
virtual Date fixingDate() const;
//! fixing of the underlying index, as observed by the coupon
virtual Rate indexFixing() const;
//@}
//! \name Observer interface
//@{
void update() { notifyObservers(); }
//@}
//! \name Visitability
//@{
virtual void accept(AcyclicVisitor&);
//@}
void setPricer(const boost::shared_ptr<InflationCouponPricer>&);
boost::shared_ptr<InflationCouponPricer> pricer() const;
protected:
boost::shared_ptr<InflationCouponPricer> pricer_;
boost::shared_ptr<InflationIndex> index_;
Period observationLag_;
DayCounter dayCounter_;
Natural fixingDays_;
//! makes sure you were given the correct type of pricer
// this can also done in external pricer setter classes via
// accept/visit mechanism
virtual bool checkPricerImpl(const
boost::shared_ptr<InflationCouponPricer>&) const = 0;
};
// inline definitions
inline void InflationCoupon::accept(AcyclicVisitor& v) {
Visitor<InflationCoupon>* v1 =
dynamic_cast<Visitor<InflationCoupon>*>(&v);
if (v1 != 0)
v1->visit(*this);
else
Coupon::accept(v);
}
inline boost::shared_ptr<InflationCouponPricer>
InflationCoupon::pricer() const {
return pricer_;
}
}
#endif
|