This file is indexed.

/usr/include/ql/instruments/fixedratebondforward.hpp is in libquantlib0-dev 1.4-2.

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
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
 Copyright (C) 2006 Allen Kuo

 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 fixedratebondforward.hpp
    \brief forward contract on a fixed-rate bond
*/

#ifndef quantlib_fixed_rate_bond_forward_hpp
#define quantlib_fixed_rate_bond_forward_hpp

#include <ql/instruments/forward.hpp>
#include <ql/instruments/bonds/fixedratebond.hpp>

namespace QuantLib {

    //! %Forward contract on a fixed-rate bond
    /*! 1. valueDate refers to the settlement date of the bond forward
           contract.  maturityDate is the delivery (or repurchase)
           date for the underlying bond (not the bond's maturity
           date).

        2. Relevant formulas used in the calculations (\f$P\f$ refers
           to a price):

           a. \f$ P_{CleanFwd}(t) = P_{DirtyFwd}(t) -
              AI(t=deliveryDate) \f$ where \f$ AI \f$ refers to the
              accrued interest on the underlying bond.

           b. \f$ P_{DirtyFwd}(t) = \frac{P_{DirtySpot}(t) -
              SpotIncome(t)} {discountCurve->discount(t=deliveryDate)} \f$

           c. \f$ SpotIncome(t) = \sum_i \left( CF_i \times
              incomeDiscountCurve->discount(t_i) \right) \f$ where \f$
              CF_i \f$ represents the ith bond cash flow (coupon
              payment) associated with the underlying bond falling
              between the settlementDate and the deliveryDate. (Note
              the two different discount curves used in b. and c.)

        <b>Example: </b>
        \link Repo.cpp
        valuation of a repo on a fixed-rate bond
        \endlink

        \todo Add preconditions and tests

        \todo Create switch- if coupon goes to seller is toggled on,
              don't consider income in the \f$ P_{DirtyFwd}(t) \f$
              calculation.

        \todo Verify this works when the underlying is paper (in which
              case ignore all AI.)

        \warning This class still needs to be rigorously tested

        \ingroup instruments
    */
    class FixedRateBondForward : public Forward {
      public:
        //! \name Constructors
        /*! If strike is given in the constructor, can calculate the
            NPV of the contract via NPV().

            If strike/forward price is desired, it can be obtained via
            forwardPrice(). In this case, the strike variable in the
            constructor is irrelevant and will be ignored.
        */
        //@{
        FixedRateBondForward(
                    const Date& valueDate,
                    const Date& maturityDate,
                    Position::Type type,
                    Real strike,
                    Natural settlementDays,
                    const DayCounter& dayCounter,
                    const Calendar& calendar,
                    BusinessDayConvention businessDayConvention,
                    const boost::shared_ptr<FixedRateBond>& fixedCouponBond,
                    const Handle<YieldTermStructure>& discountCurve =
                                                Handle<YieldTermStructure>(),
                    const Handle<YieldTermStructure>& incomeDiscountCurve =
                                                Handle<YieldTermStructure>());
        //@}

        //! \name Calculations
        //@{

        //! (dirty) forward bond price
        Real forwardPrice() const;

        //! (dirty) forward bond price minus accrued on bond at delivery
        Real cleanForwardPrice() const;

        //!  NPV of bond coupons discounted using incomeDiscountCurve
        /*! Here only coupons between max(evaluation date,settlement
            date) and maturity date of bond forward contract are
            considered income.
        */
        Real spotIncome(const Handle<YieldTermStructure>& incomeDiscountCurve)
            const;

        //!  NPV of underlying bond
        Real spotValue() const;

        //@}

      protected:
        boost::shared_ptr<FixedRateBond> fixedCouponBond_;
        void performCalculations() const;
    };

}


#endif