24#include <ql/pricingengines/vanilla/analyticbsmhullwhiteengine.hpp>
25#include <ql/pricingengines/vanilla/analyticeuropeanengine.hpp>
26#include <ql/termstructures/volatility/equityfx/blackvoltermstructure.hpp>
33 class ShiftedBlackVolTermStructure :
public BlackVolTermStructure {
35 ShiftedBlackVolTermStructure(
37 const Handle<BlackVolTermStructure> & volTS)
38 : BlackVolTermStructure(volTS->referenceDate(),
42 varianceOffset_(varianceOffset),
45 Real minStrike()
const override {
return volTS_->minStrike(); }
46 Real maxStrike()
const override {
return volTS_->maxStrike(); }
47 Date maxDate()
const override {
return volTS_->maxDate(); }
50 Real blackVarianceImpl(
Time t,
Real strike)
const override {
51 return volTS_->blackVariance(t, strike,
true)+varianceOffset_;
54 Time nonZeroMaturity = (t==0.0 ? 0.00001 : t);
55 Real var = blackVarianceImpl(nonZeroMaturity, strike);
56 return std::sqrt(var/nonZeroMaturity);
60 const Real varianceOffset_;
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)) {
71 QL_REQUIRE(
process_,
"no Black-Scholes process specified");
72 QL_REQUIRE(!
model_.
empty(),
"no Hull-White model specified");
78 QL_REQUIRE(
process_->x0() > 0.0,
"negative or null underlying given");
80 const ext::shared_ptr<StrikedTypePayoff> payoff =
81 ext::dynamic_pointer_cast<StrikedTypePayoff>(
arguments_.payoff);
82 QL_REQUIRE(payoff,
"non-striked payoff given");
84 const ext::shared_ptr<Exercise> exercise =
arguments_.exercise;
86 Time t =
process_->riskFreeRate()->dayCounter().yearFraction(
87 process_->riskFreeRate()->referenceDate(),
88 exercise->lastDate());
93 process_->blackVolatility()->blackVol(exercise->lastDate(),
98 const Real v = sigma*sigma/(a*a)
99 *(t + 2/a*std::exp(-a*t) - 1/(2*a)*std::exp(-2*a*t) - 3/(2*a));
100 const Real mu = 2*
rho_*sigma*eta/a*(t-1/a*(1-std::exp(-a*t)));
102 varianceOffset = v + mu;
106 const Real v = sigma*sigma*t*t*t*(1/3.0-0.25*a*t+7/60.0*a*a*t*t);
107 const Real mu =
rho_*sigma*eta*t*t*(1-a*t/3.0+a*a*t*t/12.0);
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());
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
Vanilla option (no discrete dividends, no barriers) on a single asset.
void setupArguments(PricingEngine::arguments *) const override
Real Time
continuous quantity with 1-year units
Real Volatility
volatility