/usr/include/ql/instruments/capfloor.hpp is in libquantlib0-dev 1.7.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 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
Copyright (C) 2001, 2002, 2003 Sadruddin Rejeb
Copyright (C) 2006, 2014 Ferdinando Ametrano
Copyright (C) 2006 François du Vignaud
Copyright (C) 2006, 2007 StatPro Italia srl
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 capfloor.hpp
\brief cap and floor class
*/
#ifndef quantlib_instruments_capfloor_hpp
#define quantlib_instruments_capfloor_hpp
#include <ql/instrument.hpp>
#include <ql/cashflows/iborcoupon.hpp>
#include <ql/handle.hpp>
namespace QuantLib {
class YieldTermStructure;
//! Base class for cap-like instruments
/*! \ingroup instruments
\test
- the correctness of the returned value is tested by checking
that the price of a cap (resp. floor) decreases
(resp. increases) with the strike rate.
- the relationship between the values of caps, floors and the
resulting collars is checked.
- the put-call parity between the values of caps, floors and
swaps is checked.
- the correctness of the returned implied volatility is tested
by using it for reproducing the target value.
- the correctness of the returned value is tested by checking
it against a known good value.
*/
class CapFloor : public Instrument {
public:
enum Type { Cap, Floor, Collar };
class arguments;
class engine;
CapFloor(Type type,
const Leg& floatingLeg,
const std::vector<Rate>& capRates,
const std::vector<Rate>& floorRates);
CapFloor(Type type,
const Leg& floatingLeg,
const std::vector<Rate>& strikes);
//! \name Instrument interface
//@{
bool isExpired() const;
void setupArguments(PricingEngine::arguments*) const;
//@}
//! \name Inspectors
//@{
Type type() const { return type_; }
const std::vector<Rate>& capRates() const { return capRates_; }
const std::vector<Rate>& floorRates() const { return floorRates_; }
const Leg& floatingLeg() const { return floatingLeg_; }
Date startDate() const;
Date maturityDate() const;
boost::shared_ptr<FloatingRateCoupon> lastFloatingRateCoupon() const;
//! Returns the n-th optionlet as a new CapFloor with only one cash flow.
boost::shared_ptr<CapFloor> optionlet(const Size n) const;
//@}
Rate atmRate(const YieldTermStructure& discountCurve) const;
//! implied term volatility
Volatility impliedVolatility(Real price,
const Handle<YieldTermStructure>& disc,
Volatility guess,
Real accuracy = 1.0e-4,
Natural maxEvaluations = 100,
Volatility minVol = 1.0e-7,
Volatility maxVol = 4.0,
Real displacement = 0.0) const;
private:
Type type_;
Leg floatingLeg_;
std::vector<Rate> capRates_;
std::vector<Rate> floorRates_;
};
//! Concrete cap class
/*! \ingroup instruments */
class Cap : public CapFloor {
public:
Cap(const Leg& floatingLeg,
const std::vector<Rate>& exerciseRates)
: CapFloor(CapFloor::Cap, floatingLeg,
exerciseRates, std::vector<Rate>()) {}
};
//! Concrete floor class
/*! \ingroup instruments */
class Floor : public CapFloor {
public:
Floor(const Leg& floatingLeg,
const std::vector<Rate>& exerciseRates)
: CapFloor(CapFloor::Floor, floatingLeg,
std::vector<Rate>(), exerciseRates) {}
};
//! Concrete collar class
/*! \ingroup instruments */
class Collar : public CapFloor {
public:
Collar(const Leg& floatingLeg,
const std::vector<Rate>& capRates,
const std::vector<Rate>& floorRates)
: CapFloor(CapFloor::Collar, floatingLeg, capRates, floorRates) {}
};
//! %Arguments for cap/floor calculation
class CapFloor::arguments : public virtual PricingEngine::arguments {
public:
arguments() : type(CapFloor::Type(-1)) {}
CapFloor::Type type;
std::vector<Date> startDates;
std::vector<Date> fixingDates;
std::vector<Date> endDates;
std::vector<Time> accrualTimes;
std::vector<Rate> capRates;
std::vector<Rate> floorRates;
std::vector<Rate> forwards;
std::vector<Real> gearings;
std::vector<Real> spreads;
std::vector<Real> nominals;
std::vector<boost::shared_ptr<InterestRateIndex> > indexes;
void validate() const;
};
//! base class for cap/floor engines
class CapFloor::engine
: public GenericEngine<CapFloor::arguments, CapFloor::results> {};
std::ostream& operator<<(std::ostream&, CapFloor::Type);
}
#endif
|