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
20#include <ql/rebatedexercise.hpp>
21#include <utility>
22
23namespace QuantLib {
24
25 RebatedExercise::RebatedExercise(const Exercise& exercise,
26 const Real rebate,
27 const Natural rebateSettlementDays,
28 Calendar rebatePaymentCalendar,
29 const BusinessDayConvention rebatePaymentConvention)
30 : Exercise(exercise), rebates_(std::vector<Real>(dates().size(), rebate)),
31 rebateSettlementDays_(rebateSettlementDays),
32 rebatePaymentCalendar_(std::move(rebatePaymentCalendar)),
33 rebatePaymentConvention_(rebatePaymentConvention) {}
34
35 RebatedExercise::RebatedExercise(const Exercise& exercise,
36 const std::vector<Real>& rebates,
37 const Natural rebateSettlementDays,
38 Calendar rebatePaymentCalendar,
39 const BusinessDayConvention rebatePaymentConvention)
40 : Exercise(exercise), rebates_(rebates), rebateSettlementDays_(rebateSettlementDays),
41 rebatePaymentCalendar_(std::move(rebatePaymentCalendar)),
42 rebatePaymentConvention_(rebatePaymentConvention) {
43
44 QL_REQUIRE(
45 type_ == Bermudan,
46 "a rebate vector is allowed only for a bermudan style exercise");
47
48 QL_REQUIRE(rebates.size() == dates().size(),
49 "the number of rebates ("
50 << rebates.size()
51 << ") must be equal to the number of exercise dates ("
52 << dates().size());
53 }
54}
55

source code of quantlib/ql/rebatedexercise.cpp