Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
convertiblebond2.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2021 Quaternion Risk Management Ltd.
3
4 This file is part of ORE, a free-software/open-source library
5 for transparent pricing and risk analysis - http://opensourcerisk.org
6
7 ORE is free software: you can redistribute it and/or modify it
8 under the terms of the Modified BSD License. You should have received a
9 copy of the license along with this program.
10 The license is also available online at <http://opensourcerisk.org>
11
12 This program is distributed on the basis that it will form a useful
13 contribution to risk analytics and model standardisation, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
16*/
17
18/*! \file qle/instruments/convertiblebond2.hpp */
19
20#pragma once
21
22#include <ql/instruments/bond.hpp>
23#include <ql/pricingengine.hpp>
24#include <ql/time/daycounter.hpp>
25
26namespace QuantExt {
27
28using QuantLib::Bond;
29using QuantLib::Calendar;
30using QuantLib::Date;
31using QuantLib::GenericEngine;
32using QuantLib::Leg;
33using QuantLib::PricingEngine;
34using QuantLib::Real;
35using QuantLib::Size;
36
37class ConvertibleBond2 : public QuantLib::Bond {
38public:
39 class arguments;
40 class results;
41 class engine;
42
46 };
47
50 enum class PriceType { Clean, Dirty };
53 Real price;
56 bool isSoft;
58 };
59
62 Real cap;
63 std::vector<Real> stockPrices;
64 std::vector<Date> effectiveDates;
65 std::vector<std::vector<Real>> crIncrease;
66 };
67 boost::optional<CrIncreaseData> crIncreaseData;
68 };
69
73 };
74
79 enum class CocoType { None, Spot, StartOfPeriod };
82 };
83
90 };
91
98 };
99
108 };
109
110 /* callData, putData, conversionData and conversionReset data must be sorted w.r.t. their event dates */
111 ConvertibleBond2(Size settlementDays, const Calendar& calendar, const Date& issueDate, const Leg& coupons,
112 const ExchangeableData& exchangeableData = ExchangeableData{false, false},
113 const std::vector<CallabilityData>& callData = {}, const MakeWholeData& makeWholeData = {},
114 const std::vector<CallabilityData>& putData = {},
115 const std::vector<ConversionRatioData>& conversionRatioData = {},
116 const std::vector<ConversionData>& conversionData = {},
117 const std::vector<MandatoryConversionData>& mandatoryConversionData = {},
118 const std::vector<ConversionResetData>& conversionResetData = {},
119 const std::vector<DividendProtectionData>& dividendProtectionData = {},
120 const bool detachable = false, const bool perpetual = false);
121
122private:
123 void setupArguments(PricingEngine::arguments*) const override;
124 void fetchResults(const PricingEngine::results*) const override;
125
126 // convertible data
128 std::vector<CallabilityData> callData_;
130 std::vector<CallabilityData> putData_;
131 std::vector<ConversionData> conversionData_;
132 std::vector<ConversionRatioData> conversionRatioData_;
133 std::vector<MandatoryConversionData> mandatoryConversionData_;
134 std::vector<ConversionResetData> conversionResetData_;
135 std::vector<DividendProtectionData> dividendProtectionData_;
138};
139
141public:
142 void validate() const override;
144 std::vector<Real> notionals;
146 std::vector<CallabilityData> callData;
148 std::vector<CallabilityData> putData;
149 std::vector<ConversionData> conversionData;
150 std::vector<ConversionRatioData> conversionRatioData;
151 std::vector<MandatoryConversionData> mandatoryConversionData;
152 std::vector<ConversionResetData> conversionResetData;
153 std::vector<DividendProtectionData> dividendProtectionData;
156};
157
159public:
160 void reset() override;
161};
162
163class ConvertibleBond2::engine : public GenericEngine<ConvertibleBond2::arguments, ConvertibleBond2::results> {};
164
165} // namespace QuantExt
std::vector< CallabilityData > putData
std::vector< DividendProtectionData > dividendProtectionData
std::vector< ConversionResetData > conversionResetData
std::vector< CallabilityData > callData
std::vector< ConversionRatioData > conversionRatioData
std::vector< ConversionData > conversionData
std::vector< MandatoryConversionData > mandatoryConversionData
void setupArguments(PricingEngine::arguments *) const override
std::vector< DividendProtectionData > dividendProtectionData_
std::vector< ConversionData > conversionData_
std::vector< MandatoryConversionData > mandatoryConversionData_
std::vector< ConversionResetData > conversionResetData_
void fetchResults(const PricingEngine::results *) const override
std::vector< ConversionRatioData > conversionRatioData_
std::vector< CallabilityData > putData_
std::vector< CallabilityData > callData_
ExchangeableData exchangeableData_
boost::optional< CrIncreaseData > crIncreaseData