1 /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 3 /* 4 Copyright (C) 2006 Giorgio Facchinetti 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 #ifndef quantlib_multistep_inverse_floater_hpp 21 #define quantlib_multistep_inverse_floater_hpp 22 23 #include <ql/models/marketmodels/products/multiproductmultistep.hpp> 24 25 namespace QuantLib { 26 27 /* 28 Tested in MarketModels::testInverseFloater() 29 30 */ 31 32 class MultiStepInverseFloater : public MultiProductMultiStep { 33 public: 34 MultiStepInverseFloater(const std::vector<Time>& rateTimes, 35 const std::vector<Real>& fixedAccruals, 36 const std::vector<Real>& floatingAccruals, 37 const std::vector<Real>& fixedStrikes, 38 const std::vector<Real>& fixedMultipliers, 39 const std::vector<Real>& floatingSpreads, 40 const std::vector<Time>& paymentTimes, 41 bool payer = true); 42 //! \name MarketModelMultiProduct interface 43 //@{ 44 std::vector<Time> possibleCashFlowTimes() const; 45 Size numberOfProducts() const; 46 Size maxNumberOfCashFlowsPerProductPerStep() const; 47 void reset(); 48 bool nextTimeStep( 49 const CurveState& currentState, 50 std::vector<Size>& numberCashFlowsThisStep, 51 std::vector<std::vector<CashFlow> >& cashFlowsGenerated); 52 #if defined(QL_USE_STD_UNIQUE_PTR) 53 std::unique_ptr<MarketModelMultiProduct> clone() const; 54 #else 55 std::auto_ptr<MarketModelMultiProduct> clone() const; 56 #endif 57 //@} 58 private: 59 std::vector<Real> fixedAccruals_, floatingAccruals_,fixedStrikes_, fixedMultipliers_, floatingSpreads_; 60 std::vector<Time> paymentTimes_; 61 62 Real multiplier_; 63 Size lastIndex_; 64 // things that vary in a path 65 Size currentIndex_; 66 }; 67 68 69 // inline definitions 70 71 inline std::vector<Time> possibleCashFlowTimes() const72 MultiStepInverseFloater::possibleCashFlowTimes() const { 73 return paymentTimes_; 74 } 75 numberOfProducts() const76 inline Size MultiStepInverseFloater::numberOfProducts() const { 77 return 1; 78 } 79 80 inline Size maxNumberOfCashFlowsPerProductPerStep() const81 MultiStepInverseFloater::maxNumberOfCashFlowsPerProductPerStep() const { 82 return 1; 83 } 84 reset()85 inline void MultiStepInverseFloater::reset() { 86 currentIndex_=0; 87 } 88 89 } 90 91 #endif 92