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
81 ? Null<Real>()
83
84 Date settlement =
bond_->settlementDate();
85
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++) {
99 moreArgs->callabilityPrices.push_back(
bond_->
callability()[i]->price().amount() *
102 moreArgs->callabilityPrices.back() +=
bond_->accruedAmount(
bond_->
callability()[i]->date()) / 100.0 *
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
137 moreArgs->dividendDates.clear();
142 }
143 }
144
145 moreArgs->issueDate =
bond_->issueDate();
146 moreArgs->settlementDate =
bond_->settlementDate();
147 moreArgs->settlementDays =
bond_->settlementDays();
148 moreArgs->maturityDate =
bond_->maturityDate();
149}
Real conversionRatio() const
const CallabilitySchedule & callability() const
const DividendSchedule & dividends() const
Filter close_enough(const RandomVariable &x, const RandomVariable &y)