1 /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 3 /* 4 Copyright (C) 2018 Sebastian Schlenkrich 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 <http://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 swaptioncfs.hpp 21 \brief translate swaption into deterministic fixed and float cash flows 22 */ 23 24 #ifndef quantlib_swaptioncfs_hpp 25 #define quantlib_swaptioncfs_hpp 26 27 #include <ql/instruments/swaption.hpp> 28 #include <ql/option.hpp> 29 #include <ql/termstructures/yieldtermstructure.hpp> 30 #include <ql/time/date.hpp> 31 32 namespace QuantLib { 33 34 class IborLegCashFlows { 35 protected: 36 Date refDate_; // today, base for time calculations w.r.t. Act/365 (Fixed) 37 Leg floatLeg_; 38 std::vector<Real> floatTimes_; 39 std::vector<Real> floatWeights_; 40 41 public: floatLeg() const42 inline const Leg& floatLeg() const { return floatLeg_; } floatTimes() const43 inline const std::vector<Real>& floatTimes() const { return floatTimes_; } floatWeights() const44 inline const std::vector<Real>& floatWeights() const { return floatWeights_; } 45 IborLegCashFlows(const Leg& iborLeg, 46 const Handle<YieldTermStructure>& discountCurve, 47 bool contTenorSpread = true); IborLegCashFlows()48 IborLegCashFlows(){}; // allow default constructor which does nothing 49 }; 50 51 52 class SwapCashFlows : public IborLegCashFlows { 53 protected: 54 // resulting cash flows as leg 55 Leg fixedLeg_; 56 std::vector<Real> fixedTimes_; 57 std::vector<Real> fixedWeights_; 58 std::vector<Real> annuityWeights_; 59 60 public: 61 SwapCashFlows(const ext::shared_ptr<VanillaSwap>& swap, 62 const Handle<YieldTermStructure>& discountCurve, 63 bool contTenorSpread = true); SwapCashFlows()64 SwapCashFlows(){}; // allow default constructor which does nothing 65 // inspectors fixedLeg() const66 inline const Leg& fixedLeg() const { return fixedLeg_; } fixedTimes() const67 inline const std::vector<Real>& fixedTimes() const { return fixedTimes_; } fixedWeights() const68 inline const std::vector<Real>& fixedWeights() const { return fixedWeights_; } annuityWeights() const69 inline const std::vector<Real>& annuityWeights() const { return annuityWeights_; } 70 }; 71 72 73 class SwaptionCashFlows : public SwapCashFlows { 74 protected: 75 ext::shared_ptr<Swaption> swaption_; 76 std::vector<Real> exerciseTimes_; 77 78 public: 79 SwaptionCashFlows(const ext::shared_ptr<Swaption>& swaption, 80 const Handle<YieldTermStructure>& discountCurve, 81 bool contTenorSpread = true); SwaptionCashFlows()82 SwaptionCashFlows(){}; // allow default constructor which does nothing 83 // inspectors swaption() const84 inline ext::shared_ptr<Swaption> swaption() const { return swaption_; } exerciseTimes() const85 inline const std::vector<Real>& exerciseTimes() const { return exerciseTimes_; } 86 }; 87 88 89 } 90 91 #endif 92