25#ifndef quantlib_binomial_convertible_engine_hpp
26#define quantlib_binomial_convertible_engine_hpp
56 "timeSteps must be positive, " << timeSteps <<
67 ext::shared_ptr<GeneralizedBlackScholesProcess>
process_;
77 DayCounter rfdc = process_->riskFreeRate()->dayCounter();
78 DayCounter divdc = process_->dividendYield()->dayCounter();
79 DayCounter voldc = process_->blackVolatility()->dayCounter();
80 Calendar volcal = process_->blackVolatility()->calendar();
82 Real s0 = process_->x0();
83 QL_REQUIRE(s0 > 0.0,
"negative or null underlying");
84 Volatility v = process_->blackVolatility()->blackVol(
85 arguments_.exercise->lastDate(), s0);
86 Date maturityDate = arguments_.exercise->lastDate();
87 Rate riskFreeRate = process_->riskFreeRate()->zeroRate(
89 Rate q = process_->dividendYield()->zeroRate(
91 Date referenceDate = process_->riskFreeRate()->referenceDate();
95 for (i=0; i<dividends_.size(); i++) {
96 if (dividends_[i]->date() >= referenceDate)
97 s0 -= dividends_[i]->amount() *
98 process_->riskFreeRate()->discount(dividends_[i]->date());
101 "negative value after subtracting dividends");
106 new FlatForward(referenceDate, riskFreeRate, rfdc)));
108 ext::shared_ptr<YieldTermStructure>(
new FlatForward(referenceDate,
q, divdc)));
113 Real strike = arguments_.redemption / arguments_.conversionRatio ;
115 ext::shared_ptr<GeneralizedBlackScholesProcess> bs(
117 ext::shared_ptr<T> tree(
new T(bs, maturity, timeSteps_, strike));
119 Real creditSpread = creditSpread_->value();
122 tree, riskFreeRate, maturity, timeSteps_, creditSpread,
v,
q));
130 "floating-point overflow on tree grid");
Black constant volatility, no time dependence, no strike dependence.
const Instrument::results * results_
Binomial Tsiveriotis-Fernandes engine for convertible bonds.
const Handle< Quote > & creditSpread() const
void calculate() const override
const DividendSchedule & dividends() const
BinomialConvertibleEngine(ext::shared_ptr< GeneralizedBlackScholesProcess > process, Size timeSteps, const Handle< Quote > &creditSpread, DividendSchedule dividends=DividendSchedule())
DividendSchedule dividends_
ext::shared_ptr< GeneralizedBlackScholesProcess > process_
Handle< Quote > creditSpread_
Constant Black volatility, no time-strike dependence.
Time yearFraction(const Date &, const Date &, const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date()) const
Returns the period between two dates as a fraction of year.
void initialize(const ext::shared_ptr< Lattice > &, Time t)
Flat interest-rate curve.
Generalized Black-Scholes stochastic process.
Shared handle to an observable.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
market element returning a stored value
Binomial lattice approximating the Tsiveriotis-Fernandes model.
#define QL_ENSURE(condition, message)
throw an error if the given post-condition is not verified
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
flat forward rate term structure
@ NoFrequency
null frequency
Real Time
continuous quantity with 1-year units
Real Volatility
volatility
std::size_t Size
size of a container
std::vector< ext::shared_ptr< Dividend > > DividendSchedule
Payoffs for various options.
ext::shared_ptr< YieldTermStructure > q
ext::shared_ptr< BlackVolTermStructure > v
Binomial Tsiveriotis-Fernandes tree model.