Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Attributes | List of all members
ConvertibleBond::option Class Reference

#include <qle/instruments/convertiblebond.hpp>

+ Inheritance diagram for ConvertibleBond::option:
+ Collaboration diagram for ConvertibleBond::option:

Classes

class  arguments
 
class  engine
 

Public Member Functions

 option (const ConvertibleBond *bond)
 
void setupArguments (PricingEngine::arguments *) const override
 
bool isExpired () const override
 

Private Attributes

const ConvertibleBondbond_
 

Detailed Description

Definition at line 79 of file convertiblebond.hpp.

Constructor & Destructor Documentation

◆ option()

option ( const ConvertibleBond bond)

Definition at line 62 of file convertiblebond.cpp.

63 : OneAssetOption(QuantLib::ext::shared_ptr<StrikedTypePayoff>(
64 new PlainVanillaPayoff(Option::Call, bond->notionals().front() / bond->conversionRatio())),
65 bond->exercise()),
66 bond_(bond) {
67 registerWith(QuantLib::ext::shared_ptr<ConvertibleBond>(const_cast<ConvertibleBond*>(bond), null_deleter()));
68}

Member Function Documentation

◆ setupArguments()

void setupArguments ( PricingEngine::arguments *  args) const
override

Definition at line 72 of file convertiblebond.cpp.

72 {
73
74 OneAssetOption::setupArguments(args);
75
76 ConvertibleBond::option::arguments* moreArgs = dynamic_cast<ConvertibleBond::option::arguments*>(args);
77 QL_REQUIRE(moreArgs != 0, "wrong argument type");
78
79 moreArgs->conversionRatio = bond_->conversionRatio();
80 moreArgs->conversionValue = close_enough(bond_->conversionRatio(), 0.0)
81 ? Null<Real>()
82 : bond_->notionals().front() / bond_->conversionRatio();
83
84 Date settlement = bond_->settlementDate();
85
86 Size n = bond_->callability().size();
87 moreArgs->callabilityDates.clear();
88 moreArgs->callabilityTypes.clear();
89 moreArgs->callabilityPrices.clear();
90 moreArgs->callabilityTriggers.clear();
91 moreArgs->callabilityDates.reserve(n);
92 moreArgs->callabilityTypes.reserve(n);
93 moreArgs->callabilityPrices.reserve(n);
94 moreArgs->callabilityTriggers.reserve(n);
95 for (Size i = 0; i < n; i++) {
96 if (!bond_->callability()[i]->hasOccurred(settlement, false)) {
97 moreArgs->callabilityTypes.push_back(bond_->callability()[i]->type());
98 moreArgs->callabilityDates.push_back(bond_->callability()[i]->date());
99 moreArgs->callabilityPrices.push_back(bond_->callability()[i]->price().amount() *
100 bond_->notional(bond_->callability()[i]->date()));
101 if (bond_->callability()[i]->price().type() == Bond::Price::Clean)
102 moreArgs->callabilityPrices.back() += bond_->accruedAmount(bond_->callability()[i]->date()) / 100.0 *
103 bond_->notional(bond_->callability()[i]->date());
104 QuantLib::ext::shared_ptr<SoftCallability> softCall =
105 QuantLib::ext::dynamic_pointer_cast<SoftCallability>(bond_->callability()[i]);
106 if (softCall)
107 moreArgs->callabilityTriggers.push_back(softCall->trigger());
108 else
109 moreArgs->callabilityTriggers.push_back(Null<Real>());
110 }
111 }
112
113 const Leg& cashflows = bond_->cashflows();
114
115 moreArgs->cashflowDates.clear();
116 moreArgs->cashflowAmounts.clear();
117 for (Size i = 0; i < cashflows.size(); i++) {
118 if (!cashflows[i]->hasOccurred(settlement, false)) {
119 moreArgs->cashflowDates.push_back(cashflows[i]->date());
120 moreArgs->cashflowAmounts.push_back(cashflows[i]->amount());
121 }
122 }
123
124 moreArgs->notionals.clear();
125 moreArgs->notionalDates.clear();
126 Real currentNotional = 0.0;
127 for (std::vector<QuantLib::ext::shared_ptr<CashFlow>>::const_reverse_iterator r = bond_->redemptions().rbegin();
128 r != bond_->redemptions().rend(); ++r) {
129 moreArgs->notionals.insert(moreArgs->notionals.begin(), currentNotional);
130 moreArgs->notionalDates.insert(moreArgs->notionalDates.begin(), (*r)->date());
131 currentNotional += (*r)->amount();
132 }
133 moreArgs->notionals.insert(moreArgs->notionals.begin(), currentNotional);
134 moreArgs->notionalDates.insert(moreArgs->notionalDates.begin(), settlement);
135
136 moreArgs->dividends.clear();
137 moreArgs->dividendDates.clear();
138 for (Size i = 0; i < bond_->dividends().size(); i++) {
139 if (!bond_->dividends()[i]->hasOccurred(settlement, false)) {
140 moreArgs->dividends.push_back(bond_->dividends()[i]);
141 moreArgs->dividendDates.push_back(bond_->dividends()[i]->date());
142 }
143 }
144
145 moreArgs->issueDate = bond_->issueDate();
146 moreArgs->settlementDate = bond_->settlementDate();
147 moreArgs->settlementDays = bond_->settlementDays();
148 moreArgs->maturityDate = bond_->maturityDate();
149}
const CallabilitySchedule & callability() const
const DividendSchedule & dividends() const
Filter close_enough(const RandomVariable &x, const RandomVariable &y)
+ Here is the call graph for this function:

◆ isExpired()

bool isExpired ( ) const
override

Definition at line 70 of file convertiblebond.cpp.

70{ return bond_->isExpired(); }

Member Data Documentation

◆ bond_

const ConvertibleBond* bond_
private

Definition at line 90 of file convertiblebond.hpp.