38 ext::shared_ptr<GeneralizedBlackScholesProcess> process,
44 Real illegalLocalVolOverwrite,
46 : process_(
std::move(process)), tGrid_(tGrid), xGrid_(xGrid),
47 dampingSteps_(dampingSteps), schemeDesc_(schemeDesc), localVol_(localVol),
48 illegalLocalVolOverwrite_(illegalLocalVolOverwrite), cashDividendModel_(cashDividendModel) {
53 ext::shared_ptr<GeneralizedBlackScholesProcess> process,
60 Real illegalLocalVolOverwrite,
62 : process_(
std::move(process)), dividends_(
std::move(dividends)),
63 tGrid_(tGrid), xGrid_(xGrid), dampingSteps_(dampingSteps), schemeDesc_(schemeDesc),
64 localVol_(localVol), illegalLocalVolOverwrite_(illegalLocalVolOverwrite),
65 cashDividendModel_(cashDividendModel) {
70 ext::shared_ptr<GeneralizedBlackScholesProcess> process,
71 ext::shared_ptr<FdmQuantoHelper> quantoHelper,
77 Real illegalLocalVolOverwrite,
79 : process_(
std::move(process)),
80 tGrid_(tGrid), xGrid_(xGrid), dampingSteps_(dampingSteps),
81 schemeDesc_(schemeDesc), localVol_(localVol),
82 illegalLocalVolOverwrite_(illegalLocalVolOverwrite), quantoHelper_(
std::move(quantoHelper)),
83 cashDividendModel_(cashDividendModel) {
89 ext::shared_ptr<GeneralizedBlackScholesProcess> process,
91 ext::shared_ptr<FdmQuantoHelper> quantoHelper,
97 Real illegalLocalVolOverwrite,
99 : process_(
std::move(process)), dividends_(
std::move(dividends)),
100 tGrid_(tGrid), xGrid_(xGrid), dampingSteps_(dampingSteps),
101 schemeDesc_(schemeDesc), localVol_(localVol),
102 illegalLocalVolOverwrite_(illegalLocalVolOverwrite), quantoHelper_(
std::move(quantoHelper)),
103 cashDividendModel_(cashDividendModel) {
112 const Date exerciseDate = arguments_.exercise->lastDate();
114 const Date settlementDate =
process_->riskFreeRate()->referenceDate();
116 Real spotAdjustment = 0.0;
119 ext::shared_ptr<EscrowedDividendAdjustment> escrowedDivAdj;
129 dividendSchedule.push_back(
130 ext::make_shared<FixedDividend>(0.0, cf->date()));
133 "Escrowed dividend model is not supported for Quanto-Options");
135 escrowedDivAdj = ext::make_shared<EscrowedDividendAdjustment>(
139 [&](
Date d){ return process_->time(d); },
144 escrowedDivAdj->dividendAdjustment(
process_->time(settlementDate));
147 "spot minus dividends becomes negative");
151 QL_FAIL(
"unknwon cash dividend model");
155 const ext::shared_ptr<StrikedTypePayoff>
payoff =
156 ext::dynamic_pointer_cast<StrikedTypePayoff>(arguments_.payoff);
158 const ext::shared_ptr<Fdm1dMesher> equityMesher =
159 ext::make_shared<FdmBlackScholesMesher>(
162 std::pair<Real, Real>(
payoff->strike(), 0.1),
166 const ext::shared_ptr<FdmMesher> mesher =
167 ext::make_shared<FdmMesherComposite>(equityMesher);
170 ext::shared_ptr<FdmInnerValueCalculator> calculator;
173 calculator = ext::make_shared<FdmLogInnerValue>(
177 calculator = ext::make_shared<FdmEscrowedLogInnerValueCalculator>(
178 escrowedDivAdj,
payoff, mesher, 0);
181 QL_FAIL(
"unknwon cash dividend model");
185 const ext::shared_ptr<FdmStepConditionComposite> conditions =
187 dividendSchedule, arguments_.exercise, mesher, calculator,
188 process_->riskFreeRate()->referenceDate(),
189 process_->riskFreeRate()->dayCounter());
195 FdmSolverDesc solverDesc = { mesher, boundaries, conditions, calculator,
198 const ext::shared_ptr<FdmBlackScholesSolver> solver(
199 ext::make_shared<FdmBlackScholesSolver>(
207 results_.value = solver->valueAt(spot);
208 results_.delta = solver->deltaAt(spot);
209 results_.gamma = solver->gammaAt(spot);
210 results_.theta = solver->thetaAt(spot);
214 ext::shared_ptr<GeneralizedBlackScholesProcess> process)
215 : process_(
std::move(process)),
217 illegalLocalVolOverwrite_(-
Null<
Real>()) {}
221 const ext::shared_ptr<FdmQuantoHelper>& quantoHelper) {
247 schemeDesc_ = ext::make_shared<FdmSchemeDesc>(schemeDesc);
259 Real illegalLocalVolOverwrite) {
266 const std::vector<Date>& dividendDates,
267 const std::vector<Real>& dividendAmounts) {
279 MakeFdBlackScholesVanillaEngine::operator
280 ext::shared_ptr<PricingEngine>()
const {
281 return ext::make_shared<FdBlackScholesVanillaEngine>(
285 tGrid_, xGrid_, dampingSteps_,
288 illegalLocalVolOverwrite_,
const Instrument::results * results_
Real illegalLocalVolOverwrite_
FdmSchemeDesc schemeDesc_
void calculate() const override
DividendSchedule dividends_
ext::shared_ptr< GeneralizedBlackScholesProcess > process_
ext::shared_ptr< FdmQuantoHelper > quantoHelper_
FdBlackScholesVanillaEngine(ext::shared_ptr< GeneralizedBlackScholesProcess >, Size tGrid=100, Size xGrid=100, Size dampingSteps=0, const FdmSchemeDesc &schemeDesc=FdmSchemeDesc::Douglas(), bool localVol=false, Real illegalLocalVolOverwrite=-Null< Real >(), CashDividendModel cashDividendModel=Spot)
CashDividendModel cashDividendModel_
static ext::shared_ptr< FdmStepConditionComposite > vanillaComposite(const DividendSchedule &schedule, const ext::shared_ptr< Exercise > &exercise, const ext::shared_ptr< FdmMesher > &mesher, const ext::shared_ptr< FdmInnerValueCalculator > &calculator, const Date &refDate, const DayCounter &dayCounter)
Shared handle to an observable.
MakeFdBlackScholesVanillaEngine & withIllegalLocalVolOverwrite(Real illegalLocalVolOverwrite)
MakeFdBlackScholesVanillaEngine & withLocalVol(bool localVol)
MakeFdBlackScholesVanillaEngine & withCashDividendModel(FdBlackScholesVanillaEngine::CashDividendModel cashDividendModel)
Real illegalLocalVolOverwrite_
MakeFdBlackScholesVanillaEngine & withTGrid(Size tGrid)
MakeFdBlackScholesVanillaEngine(ext::shared_ptr< GeneralizedBlackScholesProcess > process)
FdBlackScholesVanillaEngine::CashDividendModel cashDividendModel_
MakeFdBlackScholesVanillaEngine & withDampingSteps(Size dampingSteps)
MakeFdBlackScholesVanillaEngine & withQuantoHelper(const ext::shared_ptr< FdmQuantoHelper > &quantoHelper)
MakeFdBlackScholesVanillaEngine & withXGrid(Size xGrid)
MakeFdBlackScholesVanillaEngine & withCashDividends(const std::vector< Date > ÷ndDates, const std::vector< Real > ÷ndAmounts)
DividendSchedule dividends_
ext::shared_ptr< FdmQuantoHelper > quantoHelper_
MakeFdBlackScholesVanillaEngine & withFdmSchemeDesc(const FdmSchemeDesc &schemeDesc)
ext::shared_ptr< FdmSchemeDesc > schemeDesc_
template class providing a null value for a given type.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
Option exercise classes and payoff function.
Finite-differences Black Scholes vanilla option engine.
1-d mesher for the Black-Scholes process (in ln(S))
inner value for a escrowed dividend model
layer of abstraction to calculate the inner value
memory layout of a fdm linear operator
FdmMesher which is a composite of Fdm1dMesher.
helper class storing market data needed for the quanto adjustment.
composite of fdm step conditions
Real Time
continuous quantity with 1-year units
std::size_t Size
size of a container
ext::shared_ptr< QuantLib::Payoff > payoff
std::vector< ext::shared_ptr< Dividend > > DividendSchedule
std::vector< ext::shared_ptr< Dividend > > DividendVector(const std::vector< Date > ÷ndDates, const std::vector< Real > ÷nds)
helper function building a sequence of fixed dividends
OperatorTraits< FdmLinearOp >::bc_set FdmBoundaryConditionSet