QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
rebatedexercise.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2013 Peter Caspers
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
24#ifndef quantlib_rebatedexercise_hpp
25#define quantlib_rebatedexercise_hpp
26
27#include <ql/exercise.hpp>
28#include <ql/time/calendars/nullcalendar.hpp>
29#include <ql/errors.hpp>
30
31namespace QuantLib {
32
34
38 class RebatedExercise : public Exercise {
39 public:
40 // in case of exercise the holder receives the rebate
41 // (if positive) or pays it (if negative) on the rebate
42 // settlement date
43 RebatedExercise(const Exercise& exercise,
44 Real rebate = 0.0,
45 Natural rebateSettlementDays = 0,
46 Calendar rebatePaymentCalendar = NullCalendar(),
47 BusinessDayConvention rebatePaymentConvention = Following);
48 RebatedExercise(const Exercise& exercise,
49 const std::vector<Real>& rebates,
50 Natural rebateSettlementDays = 0,
51 Calendar rebatePaymentCalendar = NullCalendar(),
52 BusinessDayConvention rebatePaymentConvention = Following);
53 Real rebate(Size index) const;
54 Date rebatePaymentDate(Size index) const;
55 const std::vector<Real> &rebates() const { return rebates_; }
56
57 private:
58 const std::vector<Real> rebates_;
62 };
63
64 inline Real RebatedExercise::rebate(Size index) const {
65 QL_REQUIRE(index < rebates_.size(),
66 "rebate with index " << index << " does not exist (0..."
67 << (rebates_.size()-1) << ")");
68 return rebates_[index];
69 }
70
72 QL_REQUIRE(type_ == European || type_ == Bermudan,
73 "for american style exercises the rebate payment date "
74 << "has to be calculted in the client code");
78 }
79
80}
81
82#endif
calendar class
Definition: calendar.hpp:61
Date advance(const Date &, Integer n, TimeUnit unit, BusinessDayConvention convention=Following, bool endOfMonth=false) const
Definition: calendar.cpp:130
Concrete date class.
Definition: date.hpp:125
Base exercise class.
Definition: exercise.hpp:35
std::vector< Date > dates_
Definition: exercise.hpp:51
Calendar for reproducing theoretical calculations.
const std::vector< Real > & rebates() const
const BusinessDayConvention rebatePaymentConvention_
const Natural rebateSettlementDays_
const Calendar rebatePaymentCalendar_
Real rebate(Size index) const
const std::vector< Real > rebates_
Date rebatePaymentDate(Size index) const
BusinessDayConvention
Business Day conventions.
QL_REAL Real
real number
Definition: types.hpp:50
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35