| 1 | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|---|---|
| 2 | |
| 3 | /* |
| 4 | Copyright (C) 2007 Ferdinando Ametrano |
| 5 | Copyright (C) 2006 Mark Joshi |
| 6 | |
| 7 | This file is part of QuantLib, a free-software/open-source library |
| 8 | for financial quantitative analysts and developers - http://quantlib.org/ |
| 9 | |
| 10 | QuantLib is free software: you can redistribute it and/or modify it |
| 11 | under the terms of the QuantLib license. You should have received a |
| 12 | copy of the license along with this program; if not, please email |
| 13 | <quantlib-dev@lists.sf.net>. The license is also available online at |
| 14 | <http://quantlib.org/license.shtml>. |
| 15 | |
| 16 | This program is distributed in the hope that it will be useful, but WITHOUT |
| 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 18 | FOR A PARTICULAR PURPOSE. See the license for more details. |
| 19 | */ |
| 20 | |
| 21 | |
| 22 | #ifndef quantlib_accounting_engine_hpp |
| 23 | #define quantlib_accounting_engine_hpp |
| 24 | |
| 25 | // to be removed using forward declaration |
| 26 | #include <ql/models/marketmodels/multiproduct.hpp> |
| 27 | #include <ql/models/marketmodels/discounter.hpp> |
| 28 | #include <ql/math/statistics/sequencestatistics.hpp> |
| 29 | |
| 30 | #include <ql/utilities/clone.hpp> |
| 31 | #include <ql/types.hpp> |
| 32 | #include <vector> |
| 33 | |
| 34 | namespace QuantLib { |
| 35 | |
| 36 | class MarketModelEvolver; |
| 37 | |
| 38 | //class MarketModelDiscounter; |
| 39 | //class SequenceStatistics; |
| 40 | //class MarketModelMultiProduct; |
| 41 | //struct MarketModelMultiProduct::CashFlow; |
| 42 | |
| 43 | //! Engine collecting cash flows along a market-model simulation |
| 44 | class AccountingEngine { |
| 45 | public: |
| 46 | AccountingEngine(ext::shared_ptr<MarketModelEvolver> evolver, |
| 47 | const Clone<MarketModelMultiProduct>& product, |
| 48 | Real initialNumeraireValue); |
| 49 | void multiplePathValues(SequenceStatisticsInc& stats, |
| 50 | Size numberOfPaths); |
| 51 | private: |
| 52 | Real singlePathValues(std::vector<Real>& values); |
| 53 | |
| 54 | ext::shared_ptr<MarketModelEvolver> evolver_; |
| 55 | Clone<MarketModelMultiProduct> product_; |
| 56 | |
| 57 | Real initialNumeraireValue_; |
| 58 | Size numberProducts_; |
| 59 | |
| 60 | // workspace |
| 61 | std::vector<Real> numerairesHeld_; |
| 62 | std::vector<Size> numberCashFlowsThisStep_; |
| 63 | std::vector<std::vector<MarketModelMultiProduct::CashFlow> > |
| 64 | cashFlowsGenerated_; |
| 65 | std::vector<MarketModelDiscounter> discounters_; |
| 66 | |
| 67 | }; |
| 68 | |
| 69 | } |
| 70 | |
| 71 | #endif |
| 72 |
