36 const ext::shared_ptr<GeneralizedBlackScholesProcess>& process,
37 Time maturity,
const std::vector<Real>& strikes,
39 const std::pair<Real, Real>& cPoint)
42 const Real spot = process->x0();
43 QL_REQUIRE(spot > 0.0,
"negative or null underlying given");
46 / process->riskFreeRate()->discount(maturity);
47 const Real minStrike= *std::min_element(strikes.begin(), strikes.end());
48 const Real maxStrike= *std::max_element(strikes.begin(), strikes.end());
50 const Real Fmin = spot*spot/maxStrike*
d;
51 const Real Fmax = spot*spot/minStrike*
d;
53 QL_REQUIRE(Fmin > 0.0,
"negative forward given");
57 const Real sigmaSqrtTmin
58 = process->blackVolatility()->blackVol(maturity, minStrike)
60 const Real sigmaSqrtTmax
61 = process->blackVolatility()->blackVol(maturity, maxStrike)
65 = std::min(0.8*std::log(0.8*spot*spot/maxStrike),
66 std::log(Fmin) - sigmaSqrtTmin*normInvEps*scaleFactor
67 - sigmaSqrtTmin*sigmaSqrtTmin/2.0);
69 = std::max(1.2*std::log(0.8*spot*spot/minStrike),
70 std::log(Fmax) + sigmaSqrtTmax*normInvEps*scaleFactor
71 - sigmaSqrtTmax*sigmaSqrtTmax/2.0);
73 ext::shared_ptr<Fdm1dMesher> helper;
75 && std::log(cPoint.first) >=xMin && std::log(cPoint.first) <=xMax) {
77 helper = ext::shared_ptr<Fdm1dMesher>(
79 std::pair<Real,Real>(std::log(cPoint.first),cPoint.second)));
82 helper = ext::shared_ptr<Fdm1dMesher>(
89 dplus_[i] = helper->dplus(i);
Black constant volatility, no time dependence, no strike dependence.
std::vector< Real > locations_
std::vector< Real > dplus_
std::vector< Real > dminus_
FdmBlackScholesMultiStrikeMesher(Size size, const ext::shared_ptr< GeneralizedBlackScholesProcess > &process, Time maturity, const std::vector< Real > &strikes, Real eps=0.0001, Real scaleFactor=1.5, const std::pair< Real, Real > &cPoint=(std::pair< Real, Real >(Null< Real >(), Null< Real >())))
Inverse cumulative normal distribution function.
template class providing a null value for a given type.
One-dimensional grid mesher concentrating around critical points.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
1-d mesher for the Black-Scholes process (in ln(S))
Real Time
continuous quantity with 1-year units
Real DiscountFactor
discount factor between dates
std::size_t Size
size of a container
normal, cumulative and inverse cumulative distributions
Interest-rate term structure.