20#include <ql/exercise.hpp>
21#include <ql/instruments/doublebarrieroption.hpp>
22#include <ql/instruments/impliedvolatility.hpp>
23#include <ql/pricingengines/barrier/analyticdoublebarrierengine.hpp>
33 const ext::shared_ptr<StrikedTypePayoff>& payoff,
34 const ext::shared_ptr<Exercise>& exercise)
36 barrierType_(barrierType), barrier_lo_(barrier_lo),
37 barrier_hi_(barrier_hi), rebate_(rebate) {}
44 QL_REQUIRE(moreArgs !=
nullptr,
"wrong argument type");
54 const ext::shared_ptr<GeneralizedBlackScholesProcess>& process,
60 QL_REQUIRE(!
isExpired(),
"option expired");
62 ext::shared_ptr<SimpleQuote> volQuote(
new SimpleQuote);
64 ext::shared_ptr<GeneralizedBlackScholesProcess> newProcess =
68 std::unique_ptr<PricingEngine>
engine;
71 engine = std::make_unique<AnalyticDoubleBarrierEngine>(newProcess);
75 QL_FAIL(
"engine not available for non-European barrier option");
78 QL_FAIL(
"unknown exercise type");
96 OneAssetOption::arguments::validate();
102 "Invalid barrier type");
104 QL_REQUIRE(barrier_lo !=
Null<Real>(),
"no low barrier given");
105 QL_REQUIRE(barrier_hi !=
Null<Real>(),
"no high barrier given");
106 QL_REQUIRE(rebate !=
Null<Real>(),
"no rebate given");
110 return underlying <= arguments_.barrier_lo || underlying >= arguments_.barrier_hi;
Arguments for double barrier option calculation
void validate() const override
Double-Barrier-option engine base class
bool triggered(Real underlying) const
DoubleBarrierOption(DoubleBarrier::Type barrierType, Real barrier_lo, Real barrier_hi, Real rebate, const ext::shared_ptr< StrikedTypePayoff > &payoff, const ext::shared_ptr< Exercise > &exercise)
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
DoubleBarrier::Type barrierType_
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
Placeholder for enumerated barrier types.
@ KOKI
lower barrier KI, upper KO