QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
cashrebate.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) 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
22#include <utility>
23
24namespace QuantLib {
25
27 const std::vector<Time>& paymentTimes,
28 Matrix amounts,
29 Size numberOfProducts)
30 : evolution_(std::move(evolution)), paymentTimes_(paymentTimes), amounts_(std::move(amounts)),
31 numberOfProducts_(numberOfProducts) {
32
33 checkIncreasingTimes(paymentTimes);
34
36 "the number of rows in the matrix must equal "
37 "the number of products");
39 "the number of columns in the matrix must equal "
40 "the number of payment times");
42 "the number of evolution times must equal "
43 "the number of payment times");
44 }
45
46
47 std::vector<Time>
49 {
50 return paymentTimes_;
51 }
52
54 {
55 return numberOfProducts_;
56 }
57
59 {
60 return 1;
61 }
62
64 {
66 }
67
68 std::vector<Size>
70 {
71 QL_FAIL("not implemented (yet?)");
72 }
73
75 {
76 return evolution_;
77 }
78
79
81 const CurveState&,
82 std::vector<Size>& numberCashFlowsThisStep,
83 std::vector<std::vector<MarketModelMultiProduct::CashFlow> >&
84 genCashFlows)
85 {
86 for (Size i=0; i<numberOfProducts_; ++i)
87 {
88 numberCashFlowsThisStep[i] = 1;
89 genCashFlows[i][0].timeIndex = currentIndex_;
90 genCashFlows[i][0].amount = amounts_[i][currentIndex_];
91 }
93 return true;
94 }
95
96 std::unique_ptr<MarketModelMultiProduct>
98 {
99 return std::unique_ptr<MarketModelMultiProduct>(new MarketModelCashRebate(*this));
100 }
101
102}
103
Curve state for market-model simulations
Definition: curvestate.hpp:41
Market-model evolution description.
const std::vector< Time > & evolutionTimes() const
std::vector< Time > paymentTimes_
Definition: cashrebate.hpp:58
std::vector< Size > suggestedNumeraires() const override
Definition: cashrebate.cpp:69
std::unique_ptr< MarketModelMultiProduct > clone() const override
returns a newly-allocated copy of itself
Definition: cashrebate.cpp:97
bool nextTimeStep(const CurveState &currentState, std::vector< Size > &numberCashFlowsThisStep, std::vector< std::vector< CashFlow > > &cashFlowsGenerated) override
return value indicates whether path is finished, TRUE means done
Definition: cashrebate.cpp:80
MarketModelCashRebate(EvolutionDescription evolution, const std::vector< Time > &paymentTimes, Matrix amounts, Size numberOfProducts)
Definition: cashrebate.cpp:26
std::vector< Time > possibleCashFlowTimes() const override
Definition: cashrebate.cpp:48
const EvolutionDescription & evolution() const override
Definition: cashrebate.cpp:74
Size maxNumberOfCashFlowsPerProductPerStep() const override
Definition: cashrebate.cpp:58
EvolutionDescription evolution_
Definition: cashrebate.hpp:57
Size numberOfProducts() const override
Definition: cashrebate.cpp:53
void reset() override
during simulation put product at start of path
Definition: cashrebate.cpp:63
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.