25#ifndef quantlib_binomial_convertible_engine_hpp
26#define quantlib_binomial_convertible_engine_hpp
28#include <ql/instruments/bonds/convertiblebonds.hpp>
29#include <ql/pricingengines/bond/discretizedconvertible.hpp>
30#include <ql/methods/lattices/tflattice.hpp>
31#include <ql/instruments/payoffs.hpp>
32#include <ql/processes/blackscholesprocess.hpp>
33#include <ql/termstructures/volatility/equityfx/blackconstantvol.hpp>
34#include <ql/termstructures/yield/flatforward.hpp>
55 QL_REQUIRE(timeSteps>0,
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));
129 QL_ENSURE(results_.
value < std::numeric_limits<Real>::max(),
130 "floating-point overflow on tree grid");
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.
@ 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