/usr/include/ql/instruments/floatfloatswap.hpp is in libquantlib0-dev 1.12-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 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
Copyright (C) 2013 Peter Caspers
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 floatfloatswap.hpp
\brief swap exchanging capped floored Libor or CMS coupons with quite
general specification. If no payment convention is given, the
respective leg schedule convention is used. The interest rate
indices should be linked to valid forwarding and in case of
swap indices discounting curves
*/
#ifndef quantlib_floatfloat_swap_hpp
#define quantlib_floatfloat_swap_hpp
#include <ql/instruments/swap.hpp>
#include <ql/instruments/vanillaswap.hpp>
#include <ql/time/daycounter.hpp>
#include <ql/time/schedule.hpp>
#include <boost/optional.hpp>
namespace QuantLib {
class InterestRateIndex;
//! float float swap
class FloatFloatSwap : public Swap {
public:
class arguments;
class results;
class engine;
FloatFloatSwap(
const VanillaSwap::Type type, const Real nominal1,
const Real nominal2, const Schedule &schedule1,
const boost::shared_ptr<InterestRateIndex> &index1,
const DayCounter &dayCount1, const Schedule &schedule2,
const boost::shared_ptr<InterestRateIndex> &index2,
const DayCounter &dayCount2,
const bool intermediateCapitalExchange = false,
const bool finalCapitalExchange = false, const Real gearing1 = 1.0,
const Real spread1 = 0.0, const Real cappedRate1 = Null<Real>(),
const Real flooredRate1 = Null<Real>(), const Real gearing2 = 1.0,
const Real spread2 = 0.0, const Real cappedRate2 = Null<Real>(),
const Real flooredRate2 = Null<Real>(),
boost::optional<BusinessDayConvention> paymentConvention1 =
boost::none,
boost::optional<BusinessDayConvention> paymentConvention2 =
boost::none);
FloatFloatSwap(
const VanillaSwap::Type type, const std::vector<Real> &nominal1,
const std::vector<Real> &nominal2, const Schedule &schedule1,
const boost::shared_ptr<InterestRateIndex> &index1,
const DayCounter &dayCount1, const Schedule &schedule2,
const boost::shared_ptr<InterestRateIndex> &index2,
const DayCounter &dayCount2,
const bool intermediateCapitalExchange = false,
const bool finalCapitalExchange = false,
const std::vector<Real> &gearing1 = std::vector<Real>(),
const std::vector<Real> &spread1 = std::vector<Real>(),
const std::vector<Real> &cappedRate1 = std::vector<Real>(),
const std::vector<Real> &flooredRate1 = std::vector<Real>(),
const std::vector<Real> &gearing2 = std::vector<Real>(),
const std::vector<Real> &spread2 = std::vector<Real>(),
const std::vector<Real> &cappedRate2 = std::vector<Real>(),
const std::vector<Real> &flooredRate2 = std::vector<Real>(),
boost::optional<BusinessDayConvention> paymentConvention1 =
boost::none,
boost::optional<BusinessDayConvention> paymentConvention2 =
boost::none);
//! \name Inspectors
//@{
VanillaSwap::Type type() const;
const std::vector<Real> &nominal1() const;
const std::vector<Real> &nominal2() const;
const Schedule &schedule1() const;
const Schedule &schedule2() const;
const boost::shared_ptr<InterestRateIndex> &index1() const;
const boost::shared_ptr<InterestRateIndex> &index2() const;
const std::vector<Real> spread1() const;
const std::vector<Real> spread2() const;
const std::vector<Real> gearing1() const;
const std::vector<Real> gearing2() const;
const std::vector<Rate> cappedRate1() const;
const std::vector<Rate> flooredRate1() const;
const std::vector<Rate> cappedRate2() const;
const std::vector<Rate> flooredRate2() const;
const DayCounter &dayCount1() const;
const DayCounter &dayCount2() const;
BusinessDayConvention paymentConvention1() const;
BusinessDayConvention paymentConvention2() const;
const Leg &leg1() const;
const Leg &leg2() const;
//@}
//! \name Results
//@{
//@}
// other
void setupArguments(PricingEngine::arguments *args) const;
void fetchResults(const PricingEngine::results *) const;
private:
void init(boost::optional<BusinessDayConvention> paymentConvention1,
boost::optional<BusinessDayConvention> paymentConvention2);
void setupExpired() const;
VanillaSwap::Type type_;
std::vector<Real> nominal1_, nominal2_;
Schedule schedule1_, schedule2_;
boost::shared_ptr<InterestRateIndex> index1_, index2_;
std::vector<Real> gearing1_, gearing2_, spread1_, spread2_;
std::vector<Real> cappedRate1_, flooredRate1_, cappedRate2_,
flooredRate2_;
DayCounter dayCount1_, dayCount2_;
std::vector<bool> isRedemptionFlow1_, isRedemptionFlow2_;
BusinessDayConvention paymentConvention1_, paymentConvention2_;
const bool intermediateCapitalExchange_, finalCapitalExchange_;
};
//! %Arguments for float float swap calculation
class FloatFloatSwap::arguments : public Swap::arguments {
public:
arguments() : type(VanillaSwap::Receiver) {}
VanillaSwap::Type type;
std::vector<Real> nominal1, nominal2;
std::vector<Date> leg1ResetDates, leg1FixingDates, leg1PayDates;
std::vector<Date> leg2ResetDates, leg2FixingDates, leg2PayDates;
std::vector<Real> leg1Spreads, leg2Spreads, leg1Gearings, leg2Gearings;
std::vector<Real> leg1CappedRates, leg1FlooredRates, leg2CappedRates,
leg2FlooredRates;
std::vector<Real> leg1Coupons, leg2Coupons;
std::vector<Real> leg1AccrualTimes, leg2AccrualTimes;
boost::shared_ptr<InterestRateIndex> index1, index2;
std::vector<bool> leg1IsRedemptionFlow, leg2IsRedemptionFlow;
void validate() const;
};
//! %Results from float float swap calculation
class FloatFloatSwap::results : public Swap::results {
public:
void reset();
};
class FloatFloatSwap::engine
: public GenericEngine<FloatFloatSwap::arguments,
FloatFloatSwap::results> {};
// inline definitions
inline VanillaSwap::Type FloatFloatSwap::type() const { return type_; }
inline const std::vector<Real> &FloatFloatSwap::nominal1() const {
return nominal1_;
}
inline const std::vector<Real> &FloatFloatSwap::nominal2() const {
return nominal2_;
}
inline const Schedule &FloatFloatSwap::schedule1() const {
return schedule1_;
}
inline const Schedule &FloatFloatSwap::schedule2() const {
return schedule2_;
}
inline const boost::shared_ptr<InterestRateIndex> &
FloatFloatSwap::index1() const {
return index1_;
}
inline const boost::shared_ptr<InterestRateIndex> &
FloatFloatSwap::index2() const {
return index2_;
}
inline const std::vector<Real> FloatFloatSwap::spread1() const {
return spread1_;
}
inline const std::vector<Real> FloatFloatSwap::spread2() const {
return spread2_;
}
inline const std::vector<Real> FloatFloatSwap::gearing1() const {
return gearing1_;
}
inline const std::vector<Real> FloatFloatSwap::gearing2() const {
return gearing2_;
}
inline const std::vector<Real> FloatFloatSwap::cappedRate1() const {
return cappedRate1_;
}
inline const std::vector<Real> FloatFloatSwap::cappedRate2() const {
return cappedRate2_;
}
inline const std::vector<Real> FloatFloatSwap::flooredRate1() const {
return flooredRate1_;
}
inline const std::vector<Real> FloatFloatSwap::flooredRate2() const {
return flooredRate2_;
}
inline const DayCounter &FloatFloatSwap::dayCount1() const {
return dayCount1_;
}
inline const DayCounter &FloatFloatSwap::dayCount2() const {
return dayCount2_;
}
inline BusinessDayConvention FloatFloatSwap::paymentConvention1() const {
return paymentConvention1_;
}
inline BusinessDayConvention FloatFloatSwap::paymentConvention2() const {
return paymentConvention2_;
}
inline const Leg &FloatFloatSwap::leg1() const { return legs_[0]; }
inline const Leg &FloatFloatSwap::leg2() const { return legs_[1]; }
}
#endif
|