22#include <ql/exercise.hpp>
23#include <ql/instruments/barrieroption.hpp>
24#include <ql/instruments/dividendbarrieroption.hpp>
25#include <ql/instruments/impliedvolatility.hpp>
26#include <ql/pricingengines/barrier/analyticbarrierengine.hpp>
27#include <ql/pricingengines/barrier/fdblackscholesbarrierengine.hpp>
36 const ext::shared_ptr<StrikedTypePayoff>& payoff,
37 const ext::shared_ptr<Exercise>& exercise)
39 barrierType_(barrierType), barrier_(barrier), rebate_(rebate) {}
46 QL_REQUIRE(moreArgs !=
nullptr,
"wrong argument type");
54 QL_DEPRECATED_DISABLE_WARNING
59 QL_DEPRECATED_ENABLE_WARNING
65 const ext::shared_ptr<GeneralizedBlackScholesProcess>& process,
71 accuracy, maxEvaluations, minVol, maxVol);
76 const ext::shared_ptr<GeneralizedBlackScholesProcess>& process,
82 QL_REQUIRE(!
isExpired(),
"option expired");
84 ext::shared_ptr<SimpleQuote> volQuote(
new SimpleQuote);
86 ext::shared_ptr<GeneralizedBlackScholesProcess> newProcess =
90 std::unique_ptr<PricingEngine>
engine;
93 if (dividends.empty())
94 engine = std::make_unique<AnalyticBarrierEngine>(newProcess);
96 engine = std::make_unique<FdBlackScholesBarrierEngine>(newProcess, dividends);
100 QL_FAIL(
"engine not available for non-European barrier option");
103 QL_FAIL(
"unknown exercise type");
121 OneAssetOption::arguments::validate();
123 switch (barrierType) {
130 QL_FAIL(
"unknown type");
133 QL_REQUIRE(barrier !=
Null<Real>(),
"no barrier given");
134 QL_REQUIRE(rebate !=
Null<Real>(),
"no rebate given");
138 switch (arguments_.barrierType) {
141 return underlying < arguments_.barrier;
144 return underlying > arguments_.barrier;
146 QL_FAIL(
"unknown type");
Arguments for barrier option calculation
void validate() const override
Barrier-option engine base class
bool triggered(Real underlying) const
Barrier::Type barrierType_
void setupArguments(PricingEngine::arguments *) const override
Volatility impliedVolatility(Real price, const ext::shared_ptr< GeneralizedBlackScholesProcess > &process, Real accuracy=1.0e-4, Size maxEvaluations=100, Volatility minVol=1.0e-7, Volatility maxVol=4.0) const
BarrierOption(Barrier::Type barrierType, Real barrier, Real rebate, const ext::shared_ptr< StrikedTypePayoff > &payoff, const ext::shared_ptr< Exercise > &exercise)
virtual void setupArguments(PricingEngine::arguments *) const
template class providing a null value for a given type.
Base class for options on a single asset.
bool isExpired() const override
returns whether the instrument might have value greater than zero.
ext::shared_ptr< Exercise > exercise_
market element returning a stored value
static ext::shared_ptr< GeneralizedBlackScholesProcess > clone(const ext::shared_ptr< GeneralizedBlackScholesProcess > &, const ext::shared_ptr< SimpleQuote > &)
static Volatility calculate(const Instrument &instrument, const PricingEngine &engine, SimpleQuote &volQuote, Real targetValue, Real accuracy, Natural maxEvaluations, Volatility minVol, Volatility maxVol)
Real Volatility
volatility
std::size_t Size
size of a container
std::vector< ext::shared_ptr< Dividend > > DividendSchedule
Placeholder for enumerated barrier types.