28#include <boost/make_shared.hpp>
33#include <ql/pricingengines/barrier/analyticbinarybarrierengine.hpp>
34#include <ql/processes/blackscholesprocess.hpp>
51 :
CachingEngineBuilder(
"GarmanKohlhagen",
"FdBlackScholesBarrierEngine", {
"FxDigitalBarrierOption"}) {}
56 virtual string keyImpl(
const Currency& forCcy,
const Currency& domCcy,
const Date& expiryDate)
override {
60 virtual QuantLib::ext::shared_ptr<PricingEngine>
engineImpl(
const Currency& forCcy,
const Currency& domCcy,
61 const Date& expiryDate)
override {
63 Handle<YieldTermStructure> riskFreeRate =
65 Time expiry = riskFreeRate->dayCounter().yearFraction(riskFreeRate->referenceDate(),
66 std::max(riskFreeRate->referenceDate(), expiryDate));
74 const string pair = forCcy.code() + domCcy.code();
80 const Size totalSteps = tGrid + dampingSteps;
81 std::vector<Time> timePoints(totalSteps + 1);
82 Array timePointsArray(totalSteps, expiry, -expiry / totalSteps);
84 for (Size i = 0; i < totalSteps; i++)
85 timePoints[timePoints.size() - i - 1] = timePointsArray[i];
86 timePoints.insert(std::upper_bound(timePoints.begin(), timePoints.end(), 0.99 / 365), 0.99 / 365);
87 vol = Handle<BlackVolTermStructure>(
88 QuantLib::ext::make_shared<QuantExt::BlackMonotoneVarVolTermStructure>(vol, timePoints));
89 vol->enableExtrapolation();
91 QuantLib::ext::shared_ptr<GeneralizedBlackScholesProcess> gbsp = QuantLib::ext::make_shared<GeneralizedBlackScholesProcess>(
95 return QuantLib::ext::make_shared<FdBlackScholesBarrierEngine>(gbsp, tGrid, xGrid, dampingSteps, scheme);
Abstract template engine builder class.
Abstract template EngineBuilder class that can cache engines and coupon pricers.
QuantLib::ext::shared_ptr< Market > market_
const string & engine() const
Return the engine name.
const string & model() const
Return the model name.
std::string engineParameter(const std::string &p, const std::vector< std::string > &qualifiers={}, const bool mandatory=true, const std::string &defaultValue="") const
const string & configuration(const MarketContext &key)
Return a configuration (or the default one if key not found)
Engine Builder for European FX Digital Barrier Options.
virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const Currency &forCcy, const Currency &domCcy, const Date &expiryDate) override
FxDigitalBarrierOptionEngineBuilder()
FxDigitalBarrierOptionEngineBuilder(const string &model, const string &engine)
virtual string keyImpl(const Currency &forCcy, const Currency &domCcy, const Date &expiryDate) override
bool parseBool(const string &s)
Convert text to bool.
FdmSchemeDesc parseFdmSchemeDesc(const std::string &s)
Convert string to fdm scheme desc.
Integer parseInteger(const string &s)
Convert text to QuantLib::Integer.
std::string to_string(const LocationInfo &l)
Serializable Credit Default Swap.
Map text representations to QuantLib/QuantExt types.
string conversion utilities