Coverage Report

Created: 2026-01-25 06:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/quantlib/ql/cashflows/cpicouponpricer.hpp
Line
Count
Source
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3
/*
4
 Copyright (C) 2009, 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
 <https://www.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 cpicouponpricer.hpp
21
    \brief zero inflation-coupon pricer
22
 */
23
24
#ifndef quantlib_cpicouponpricer_hpp
25
#define quantlib_cpicouponpricer_hpp
26
27
#include <ql/cashflow.hpp>
28
#include <ql/option.hpp>
29
#include <ql/cashflows/inflationcouponpricer.hpp>
30
#include <ql/cashflows/cpicoupon.hpp>
31
#include <ql/termstructures/volatility/inflation/cpivolatilitystructure.hpp>
32
33
namespace QuantLib {
34
35
    //! base pricer for capped/floored CPI coupons N.B. vol-dependent parts are a TODO
36
    /*! \note this pricer can already do swaplets but to get
37
              volatility-dependent coupons you need to implement the descendents.
38
    */
39
    class CPICouponPricer : public InflationCouponPricer {
40
      public:
41
        explicit CPICouponPricer(Handle<YieldTermStructure> nominalTermStructure = Handle<YieldTermStructure>());
42
43
        explicit CPICouponPricer(Handle<CPIVolatilitySurface> capletVol,
44
                                 Handle<YieldTermStructure> nominalTermStructure = Handle<YieldTermStructure>());
45
46
0
        virtual Handle<CPIVolatilitySurface> capletVolatility() const{
47
0
            return capletVol_;
48
0
        }
49
50
0
        virtual Handle<YieldTermStructure> nominalTermStructure() const{
51
0
            return nominalTermStructure_;
52
0
        }
53
54
        virtual void setCapletVolatility(
55
            const Handle<CPIVolatilitySurface>& capletVol);
56
57
58
        //! \name InflationCouponPricer interface
59
        //@{
60
        Real swapletPrice() const override;
61
        Rate swapletRate() const override;
62
        Real capletPrice(Rate effectiveCap) const override;
63
        Rate capletRate(Rate effectiveCap) const override;
64
        Real floorletPrice(Rate effectiveFloor) const override;
65
        Rate floorletRate(Rate effectiveFloor) const override;
66
        void initialize(const InflationCoupon&) override;
67
        //@}
68
69
        virtual Rate accruedRate(Date settlementDate) const;
70
71
      protected:
72
        virtual Real optionletPrice(Option::Type optionType,
73
                                    Real effStrike) const;
74
75
        virtual Real optionletRate(Option::Type optionType,
76
                                   Real effStrike) const;
77
78
        /*! Derived classes usually only need to implement this.
79
80
            The name of the method is misleading.  This actually
81
            returns the rate of the optionlet (so not discounted and
82
            not accrued).
83
        */
84
        virtual Real optionletPriceImp(Option::Type, Real strike,
85
                                       Real forward, Real stdDev) const;
86
87
        // data
88
        Handle<CPIVolatilitySurface> capletVol_;
89
        Handle<YieldTermStructure> nominalTermStructure_;
90
        const CPICoupon* coupon_;
91
        Real gearing_;
92
        Real discount_;
93
    };
94
    
95
}
96
97
#endif