22#include <ql/math/comparison.hpp>
23#include <ql/processes/blackscholesprocess.hpp>
28 const ext::shared_ptr<GeneralizedBlackScholesProcess>& process,
29 const Handle<Quote>& creditSpread,
const TimeGrid& grid)
30 :
arguments_(args), process_(process), creditSpread_(creditSpread) {
34 Date settlementDate =
process_->riskFreeRate()->referenceDate();
42 DayCounter dayCounter =
process_->riskFreeRate()->dayCounter();
76 notionalTimes_.push_back(grid.closestTime(dayCounter.yearFraction(bondSettlement, d)));
81 std::vector<Time> result;
95 values_ = Array(size, 0.0);
105 DayCounter rfdc =
process_->riskFreeRate()->dayCounter();
114 for (Size j = 0; j < values_.size(); j++) {
122 bool convertible =
false;
124 case Exercise::American:
128 case Exercise::European:
132 case Exercise::Bermudan:
139 QL_FAIL(
"invalid option type");
167 for (Size j = 0; j < values_.size(); j++) {
168 Real payoff = conversionRatio * grid[j];
169 if (values_[j] <= payoff) {
181 case Callability::Call:
184 for (j = 0; j < values_.size(); j++) {
186 if (grid[j] >= trigger) {
192 }
else if (convertible) {
193 for (j = 0; j < values_.size(); j++) {
198 for (j = 0; j < values_.size(); j++) {
203 case Callability::Put:
204 for (j = 0; j < values_.size(); j++) {
209 QL_FAIL(
"unknown callability type");
217 Array grid = method()->grid(t);
221 if (dividendTime >= t || close(dividendTime, t)) {
223 DiscountFactor dividendDiscount =
224 process_->riskFreeRate()->discount(dividendTime) /
process_->riskFreeRate()->discount(t);
225 for (Size j = 0; j < grid.size(); j++)
226 grid[j] += d->amount(grid[j]) * dividendDiscount;
std::vector< Date > dividendDates
std::vector< Date > callabilityDates
DividendSchedule dividends
std::vector< Date > cashflowDates
std::vector< Real > cashflowAmounts
std::vector< Real > notionals
std::vector< Real > callabilityTriggers
std::vector< Callability::Type > callabilityTypes
std::vector< Real > callabilityPrices
std::vector< Date > notionalDates
std::vector< Time > stoppingTimes_
DiscretizedConvertible(const ConvertibleBond::option::arguments &args, const ext::shared_ptr< GeneralizedBlackScholesProcess > &process, const Handle< Quote > &creditSpread, const TimeGrid &grid)
Array spreadAdjustedRate_
Array conversionProbability_
Array adjustedGrid() const
ConvertibleBond::option::arguments arguments_
std::vector< Time > cashflowTimes_
std::vector< Time > notionalTimes_
std::vector< Time > dividendTimes_
Real getConversionRatio(const Real t) const
void postAdjustValuesImpl() override
std::vector< Time > mandatoryTimes() const override
QuantLib::ext::shared_ptr< GeneralizedBlackScholesProcess > process_
void applyConvertibility()
std::vector< Time > callabilityTimes_
void applyCallability(Size, bool convertible)
Handle< Quote > creditSpread_
void reset(Size size) override
Filter close_enough(const RandomVariable &x, const RandomVariable &y)
Swap::arguments * arguments_