1 /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 3 /* 4 Copyright (C) 2006 Mark Joshi 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 21 #ifndef quantlib_multistep_forwards_hpp 22 #define quantlib_multistep_forwards_hpp 23 24 #include <ql/models/marketmodels/products/multiproductmultistep.hpp> 25 26 namespace QuantLib { 27 28 class MultiStepForwards : public MultiProductMultiStep { 29 public: 30 MultiStepForwards(const std::vector<Time>& rateTimes, 31 const std::vector<Real>& accruals, 32 const std::vector<Time>& paymentTimes, 33 const std::vector<Rate>& strikes); 34 //! \name MarketModelMultiProduct interface 35 //@{ 36 std::vector<Time> possibleCashFlowTimes() const; 37 Size numberOfProducts() const; 38 Size maxNumberOfCashFlowsPerProductPerStep() const; 39 void reset(); 40 bool nextTimeStep( 41 const CurveState& currentState, 42 std::vector<Size>& numberCashFlowsThisStep, 43 std::vector<std::vector<CashFlow> >& cashFlowsGenerated); 44 #if defined(QL_USE_STD_UNIQUE_PTR) 45 std::unique_ptr<MarketModelMultiProduct> clone() const; 46 #else 47 std::auto_ptr<MarketModelMultiProduct> clone() const; 48 #endif 49 //@} 50 private: 51 std::vector<Real> accruals_; 52 std::vector<Time> paymentTimes_; 53 std::vector<Rate> strikes_; 54 // things that vary in a path 55 Size currentIndex_; 56 }; 57 58 // inline 59 60 inline std::vector<Time> possibleCashFlowTimes() const61 MultiStepForwards::possibleCashFlowTimes() const { 62 return paymentTimes_; 63 } 64 numberOfProducts() const65 inline Size MultiStepForwards::numberOfProducts() const { 66 return strikes_.size(); 67 } 68 69 inline Size maxNumberOfCashFlowsPerProductPerStep() const70 MultiStepForwards::maxNumberOfCashFlowsPerProductPerStep() const { 71 return 1; 72 } 73 reset()74 inline void MultiStepForwards::reset() { 75 currentIndex_=0; 76 } 77 78 } 79 80 #endif 81