QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
bermudanswaptionexercisevalue.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
23#include <ql/payoff.hpp>
24#include <utility>
25
26namespace QuantLib {
27
29 const std::vector<Time>& rateTimes, std::vector<ext::shared_ptr<Payoff> > payoffs)
30 : numberOfExercises_(rateTimes.empty() ? 0 : rateTimes.size() - 1), rateTimes_(rateTimes),
31 payoffs_(std::move(payoffs)) {
32
33 checkIncreasingTimes(rateTimes);
35 "Rate times must contain at least two values");
36 std::vector<Time> evolveTimes(rateTimes_);
37 evolveTimes.pop_back();
39 }
40
42 return numberOfExercises_;
43 }
44
47 return evolution_;
48 }
49
50 std::vector<Time>
52 return rateTimes_;
53 }
54
57 }
58
60 const Payoff& p = (*payoffs_[currentIndex_]);
63
64 // value /= state.discountRatios()[currentIndex_];
65 value = std::max(value, 0.0);
69 }
70
71
73 return std::valarray<bool>(true,numberOfExercises_);
74 }
75
78 return cf_;
79 }
80
81 std::unique_ptr<MarketModelExerciseValue>
83 return std::unique_ptr<MarketModelExerciseValue>(new BermudanSwaptionExerciseValue(*this));
84 }
85
86}
MarketModelMultiProduct::CashFlow value(const CurveState &) const override
std::valarray< bool > isExerciseTime() const override
std::vector< ext::shared_ptr< Payoff > > payoffs_
std::unique_ptr< MarketModelExerciseValue > clone() const override
std::vector< Time > possibleCashFlowTimes() const override
const EvolutionDescription & evolution() const override
BermudanSwaptionExerciseValue(const std::vector< Time > &rateTimes, std::vector< ext::shared_ptr< Payoff > >)
Curve state for market-model simulations
Definition: curvestate.hpp:41
virtual Rate coterminalSwapAnnuity(Size numeraire, Size i) const =0
virtual Rate coterminalSwapRate(Size i) const =0
Market-model evolution description.
Abstract base class for option payoffs.
Definition: payoff.hpp:36
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Definition: errors.hpp:117
QL_REAL Real
real number
Definition: types.hpp:50
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.
Option payoff classes.