Coverage Report

Created: 2026-08-14 07:10

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/quantlib/ql/pricingengines/bond/discretizedconvertible.hpp
Line
Count
Source
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
 <https://www.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
32
namespace QuantLib {
33
34
    class DiscretizedConvertible : public DiscretizedAsset {
35
      public:
36
        DiscretizedConvertible(ConvertibleBond::arguments,
37
                               ext::shared_ptr<GeneralizedBlackScholesProcess> process,
38
                               const DividendSchedule& dividends,
39
                               Handle<Quote> creditSpread,
40
                               const TimeGrid& grid = TimeGrid());
41
42
        void reset(Size size) override;
43
44
0
        const Array& conversionProbability() const {
45
0
            return conversionProbability_;
46
0
        }
47
0
        Array& conversionProbability() { return conversionProbability_; }
48
49
0
        const Array& spreadAdjustedRate() const { return spreadAdjustedRate_; }
50
0
        Array& spreadAdjustedRate() { return spreadAdjustedRate_; }
51
52
0
        const Array& dividendValues() const { return dividendValues_; }
53
0
        Array& dividendValues() { return dividendValues_; }
54
55
0
        std::vector<Time> mandatoryTimes() const override {
56
0
            std::vector<Time> result;
57
0
            std::copy(stoppingTimes_.begin(), stoppingTimes_.end(),
58
0
                      std::back_inserter(result));
59
0
            std::copy(callabilityTimes_.begin(), callabilityTimes_.end(),
60
0
                      std::back_inserter(result));
61
0
            std::copy(couponTimes_.begin(), couponTimes_.end(),
62
0
                      std::back_inserter(result));
63
0
            return result;
64
0
        }
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