1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2005, 2006 Theo Boafo
5 Copyright (C) 2006, 2007 StatPro Italia srl
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
21/*! \file discretizedconvertible.hpp
22 \brief discretized convertible
23*/
24
25#ifndef quantlib_discretized_convertible_hpp
26#define quantlib_discretized_convertible_hpp
27
28#include <ql/discretizedasset.hpp>
29#include <ql/instruments/bonds/convertiblebonds.hpp>
30#include <ql/processes/blackscholesprocess.hpp>
31
32namespace QuantLib {
33
34 class DiscretizedConvertible : public DiscretizedAsset {
35 public:
36 DiscretizedConvertible(ConvertibleBond::arguments,
37 ext::shared_ptr<GeneralizedBlackScholesProcess> process,
38 DividendSchedule dividends,
39 Handle<Quote> creditSpread,
40 const TimeGrid& grid = TimeGrid());
41
42 void reset(Size size) override;
43
44 const Array& conversionProbability() const {
45 return conversionProbability_;
46 }
47 Array& conversionProbability() { return conversionProbability_; }
48
49 const Array& spreadAdjustedRate() const { return spreadAdjustedRate_; }
50 Array& spreadAdjustedRate() { return spreadAdjustedRate_; }
51
52 const Array& dividendValues() const { return dividendValues_; }
53 Array& dividendValues() { return dividendValues_; }
54
55 std::vector<Time> mandatoryTimes() const override {
56 std::vector<Time> result;
57 std::copy(first: stoppingTimes_.begin(), last: stoppingTimes_.end(),
58 result: std::back_inserter(x&: result));
59 std::copy(first: callabilityTimes_.begin(), last: callabilityTimes_.end(),
60 result: std::back_inserter(x&: result));
61 std::copy(first: couponTimes_.begin(), last: couponTimes_.end(),
62 result: std::back_inserter(x&: result));
63 return result;
64 }
65
66 protected:
67 void postAdjustValuesImpl() override;
68 Array conversionProbability_, spreadAdjustedRate_, dividendValues_;
69
70 private:
71 Array adjustedGrid() const;
72 void applyConvertibility();
73 void applyCallability(Size, bool convertible);
74 void addCoupon(Size);
75 ConvertibleBond::arguments arguments_;
76 ext::shared_ptr<GeneralizedBlackScholesProcess> process_;
77 std::vector<Time> stoppingTimes_;
78 std::vector<Time> callabilityTimes_;
79 std::vector<Time> couponTimes_;
80 std::vector<Real> couponAmounts_;
81 std::vector<Time> dividendTimes_;
82 Handle<Quote> creditSpread_;
83 DividendSchedule dividends_;
84 std::vector<Date> dividendDates_;
85 };
86
87}
88
89
90#endif
91
92

source code of quantlib/ql/pricingengines/bond/discretizedconvertible.hpp