33 class ShiftedBlackVolTermStructure :
public BlackVolTermStructure {
35 ShiftedBlackVolTermStructure(
37 const Handle<BlackVolTermStructure> & volTS)
38 : BlackVolTermStructure(volTS->referenceDate(),
45 Real minStrike()
const override {
return volTS_->minStrike(); }
46 Real maxStrike()
const override {
return volTS_->maxStrike(); }
47 Date maxDate()
const override {
return volTS_->maxDate(); }
54 Time nonZeroMaturity = (
t==0.0 ? 0.00001 :
t);
55 Real var = blackVarianceImpl(nonZeroMaturity, strike);
56 return std::sqrt(var/nonZeroMaturity);
61 const Handle<BlackVolTermStructure>
volTS_;
66 Real equityShortRateCorrelation,
67 ext::shared_ptr<GeneralizedBlackScholesProcess> process,
68 const ext::shared_ptr<HullWhite>& model)
70 rho_(equityShortRateCorrelation), process_(
std::move(process)) {
80 const ext::shared_ptr<StrikedTypePayoff>
payoff =
81 ext::dynamic_pointer_cast<StrikedTypePayoff>(
arguments_.payoff);
84 const ext::shared_ptr<Exercise> exercise =
arguments_.exercise;
87 process_->riskFreeRate()->referenceDate(),
88 exercise->lastDate());
93 process_->blackVolatility()->blackVol(exercise->lastDate(),
99 *(
t + 2/a*std::exp(-a*
t) - 1/(2*a)*std::exp(-2*a*
t) - 3/(2*a));
102 varianceOffset =
v + mu;
109 varianceOffset =
v + mu;
113 ext::shared_ptr<BlackVolTermStructure>(
114 new ShiftedBlackVolTermStructure(varianceOffset,
117 ext::shared_ptr<GeneralizedBlackScholesProcess> adjProcess(
123 ext::shared_ptr<AnalyticEuropeanEngine> bsmEngine(
127 bsmEngine->getArguments());
128 bsmEngine->calculate();
131 bsmEngine->getResults());
const Real varianceOffset_
const Handle< BlackVolTermStructure > volTS_
analytic Black-Scholes engines including stochastic interest rates
Analytic European engine.
Black volatility term structure base classes.
void calculate() const override
ext::shared_ptr< GeneralizedBlackScholesProcess > process_
AnalyticBSMHullWhiteEngine(Real equityShortRateCorrelation, ext::shared_ptr< GeneralizedBlackScholesProcess >, const ext::shared_ptr< HullWhite > &)
Pricing engine for European vanilla options using analytical formulae.
Generalized Black-Scholes stochastic process.
Base class for some pricing engine on a particular model.
Handle< HullWhite > model_
Shared handle to an observable.
bool empty() const
checks if the contained shared pointer points to anything
Single-factor Hull-White (extended Vasicek) model class.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Results from single-asset option calculation
void setupArguments(PricingEngine::arguments *) const override
Vanilla option (no discrete dividends, no barriers) on a single asset.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Real Time
continuous quantity with 1-year units
Real Volatility
volatility
ext::shared_ptr< QuantLib::Payoff > payoff
ext::shared_ptr< BlackVolTermStructure > v