QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
pathwiseproductcashrebate.cpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2009 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
23#include <utility>
24
25namespace QuantLib
26{
27
28
30 {
31 return false;
32 }
33
35 EvolutionDescription evolution,
36 const std::vector<Time>& paymentTimes,
37 Matrix amounts,
38 Size numberOfProducts)
39 : evolution_(std::move(evolution)), paymentTimes_(paymentTimes), amounts_(std::move(amounts)),
40 numberOfProducts_(numberOfProducts) {
41
42 checkIncreasingTimes(paymentTimes);
43
45 "the number of rows in the matrix must equal "
46 "the number of products");
48 "the number of columns in the matrix must equal "
49 "the number of payment times");
51 "the number of evolution times must equal "
52 "the number of payment times");
53 }
54
55
56 std::vector<Time>
58 {
59 return paymentTimes_;
60 }
61
63 {
64 return numberOfProducts_;
65 }
66
68 {
69 return 1;
70 }
71
73 {
75 }
76
77 std::vector<Size>
79 {
80 QL_FAIL("not implemented (yet?)");
81 }
82
84 {
85 return evolution_;
86 }
87
88
90 const CurveState&,
91 std::vector<Size>& numberCashFlowsThisStep,
92 std::vector<std::vector<MarketModelPathwiseMultiProduct::CashFlow> >& cashFlowsGenerated)
93 {
94 for (Size i=0; i<numberOfProducts_; ++i)
95 {
96 numberCashFlowsThisStep[i] = 1;
97 cashFlowsGenerated[i][0].timeIndex = currentIndex_;
98 cashFlowsGenerated[i][0].amount[0] = amounts_[i][currentIndex_];
99
100 for (Size k=1; k <= evolution_.numberOfRates(); ++k)
101 cashFlowsGenerated[i][0].amount[k] = 0.0;
102
103 }
105 return true;
106 }
107
108 std::unique_ptr<MarketModelPathwiseMultiProduct>
110 {
111 return std::unique_ptr<MarketModelPathwiseMultiProduct>(new MarketModelPathwiseCashRebate(*this));
112 }
113
114}
Curve state for market-model simulations
Definition: curvestate.hpp:41
Market-model evolution description.
const std::vector< Time > & evolutionTimes() const
std::vector< Size > suggestedNumeraires() const override
MarketModelPathwiseCashRebate(EvolutionDescription evolution, const std::vector< Time > &paymentTimes, Matrix amounts, Size numberOfProducts)
bool nextTimeStep(const CurveState &currentState, std::vector< Size > &numberCashFlowsThisStep, std::vector< std::vector< MarketModelPathwiseMultiProduct::CashFlow > > &cashFlowsGenerated) override
return value indicates whether path is finished, TRUE means done
std::unique_ptr< MarketModelPathwiseMultiProduct > clone() const override
returns a newly-allocated copy of itself
std::vector< Time > possibleCashFlowTimes() const override
const EvolutionDescription & evolution() const override
void reset() override
during simulation put product at start of path
Matrix used in linear algebra.
Definition: matrix.hpp:41
Size rows() const
Definition: matrix.hpp:504
Size columns() const
Definition: matrix.hpp:508
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Definition: errors.hpp:117
#define QL_FAIL(message)
throw an error (possibly with file and line information)
Definition: errors.hpp:92
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35
void checkIncreasingTimes(const std::vector< Time > &times)
check for strictly increasing times, first time greater than zero
Definition: utilities.cpp:92
STL namespace.