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_proxy_greek_engine_hpp 22 #define quantlib_proxy_greek_engine_hpp 23 24 // to be removed using forward declaration 25 #include <ql/models/marketmodels/multiproduct.hpp> 26 27 #include <ql/math/statistics/sequencestatistics.hpp> 28 #include <ql/utilities/clone.hpp> 29 #include <valarray> 30 31 namespace QuantLib { 32 33 class MarketModelEvolver; 34 class ConstrainedEvolver; 35 class MarketModelDiscounter; 36 37 class ProxyGreekEngine { 38 public: 39 ProxyGreekEngine( 40 const ext::shared_ptr<MarketModelEvolver>& evolver, 41 const std::vector< 42 std::vector<ext::shared_ptr<ConstrainedEvolver> > >& 43 constrainedEvolvers, 44 const std::vector<std::vector<std::vector<Real> > >& diffWeights, 45 const std::vector<Size>& startIndexOfConstraint, 46 const std::vector<Size>& endIndexOfConstraint, 47 const Clone<MarketModelMultiProduct>& product, 48 Real initialNumeraireValue); 49 void multiplePathValues( 50 SequenceStatisticsInc& stats, 51 std::vector<std::vector<SequenceStatisticsInc> >& modifiedStats, 52 Size numberOfPaths); 53 void singlePathValues( 54 std::vector<Real>& values, 55 std::vector<std::vector<std::vector<Real> > >& modifiedValues); 56 private: 57 void singleEvolverValues(MarketModelEvolver& evolver, 58 std::vector<Real>& values, 59 bool storeRates = false); 60 ext::shared_ptr<MarketModelEvolver> originalEvolver_; 61 std::vector<std::vector<ext::shared_ptr<ConstrainedEvolver> > > 62 constrainedEvolvers_; 63 std::vector<std::vector<std::vector<Real> > > diffWeights_; 64 std::vector<Size> startIndexOfConstraint_; 65 std::vector<Size> endIndexOfConstraint_; 66 Clone<MarketModelMultiProduct> product_; 67 68 Real initialNumeraireValue_; 69 Size numberProducts_; 70 71 // workspace 72 std::vector<Rate> constraints_; 73 std::valarray<bool> constraintsActive_; 74 std::vector<Real> numerairesHeld_; 75 std::vector<Size> numberCashFlowsThisStep_; 76 std::vector<std::vector<MarketModelMultiProduct::CashFlow> > 77 cashFlowsGenerated_; 78 std::vector<MarketModelDiscounter> discounters_; 79 80 }; 81 82 } 83 84 #endif 85