28#include <ql/methods/lattices/bsmlattice.hpp>
37 Spread
creditSpread, Volatility volatility, Spread divYield);
42 void stepback(Size i,
const Array& values,
const Array& conversionProbability,
const Array& spreadAdjustedRate,
43 Array& newValues, Array& newConversionProbability, Array& newSpreadAdjustedRate)
const;
55 Size
steps, Spread creditSpread, Volatility sigma,
58 QL_REQUIRE(this->pu_ <= 1.0,
"probability (" << this->pu_ <<
") higher than one");
59 QL_REQUIRE(this->pu_ >= 0.0,
"negative (" << this->pu_ <<
") probability");
64 const Array& spreadAdjustedRate, Array& newValues,
65 Array& newConversionProbability, Array& newSpreadAdjustedRate)
const {
67 for (Size j = 0; j < this->size(i); j++) {
73 newConversionProbability[j] = this->pd_ * conversionProbability[j] + this->pu_ * conversionProbability[j + 1];
76 newSpreadAdjustedRate[j] = newConversionProbability[j] * this->riskFreeRate_ +
77 (1 - newConversionProbability[j]) * (this->riskFreeRate_ + creditSpread_);
79 newValues[j] = (this->pd_ * values[j] / (1 + (spreadAdjustedRate[j] * this->dt_))) +
80 (this->pu_ * values[j + 1] / (1 + (spreadAdjustedRate[j + 1] * this->dt_)));
85 partialRollback(asset, to);
91 Time from = asset.time();
96 QL_REQUIRE(from > to,
"cannot roll the asset back to" << to <<
" (it is already at t = " << from <<
")");
100 Integer iFrom = Integer(this->t_.index(from));
101 Integer iTo = Integer(this->t_.index(to));
103 for (Integer i = iFrom - 1; i >= iTo; --i) {
105 Array newValues(this->size(i));
106 Array newSpreadAdjustedRate(this->size(i));
107 Array newConversionProbability(this->size(i));
110 newValues, newConversionProbability, newSpreadAdjustedRate);
112 convertible.time() = this->t_[i];
113 convertible.values() = newValues;
119 convertible.adjustValues();
const Array & spreadAdjustedRate() const
const Array & conversionProbability() const
Binomial lattice approximating the Tsiveriotis-Fernandes model.
void partialRollback(DiscretizedAsset &, Time to) const override
void rollback(DiscretizedAsset &, Time to) const override
Spread creditSpread() const
void stepback(Size i, const Array &values, const Array &conversionProbability, const Array &spreadAdjustedRate, Array &newValues, Array &newConversionProbability, Array &newSpreadAdjustedRate) const
TsiveriotisFernandesLattice(const ext::shared_ptr< T > &tree, Rate riskFreeRate, Time end, Size steps, Spread creditSpread, Volatility volatility, Spread divYield)
std::vector< Size > steps