|
From: John M. <jwm...@ya...> - 2007-06-28 13:06:56
|
Luigi-
In DiscreteConvertible there is a protected array called dividendValues_.
It's used once to compute the present value of the dividends, but is not used
again. The code below goes into the constructor for DiscreteConvertible:
//existing code
dividendValues_ = Array(arguments_.dividends.size(), 0.0);
boost::shared_ptr<GeneralizedBlackScholesProcess> process =
boost::dynamic_pointer_cast<GeneralizedBlackScholesProcess>(
arguments_.stochasticProcess);
QL_REQUIRE(process, "Black-Scholes process required");
Date settlementDate = process->riskFreeRate()->referenceDate();
for (Size i=0; i<arguments_.dividends.size(); i++) {
if (arguments_.dividends[i]->date() >= settlementDate) {
dividendValues_[i] =
arguments_.dividends[i]->amount() *
process->riskFreeRate()->discount(
arguments_.dividends[i]->date());
}
}
//load in a schedule of dirty dividend prices
for (Size i=0; i<arguments_.dividends.size(); i++) {
dirtyDividends_.push_back(
boost::shared_ptr<Dividend>(new FixedDividend(dividendValues_[i],
arguments_.dividends[i]->date())));
}
|