20#include <ql/instruments/impliedvolatility.hpp>
21#include <ql/termstructures/volatility/equityfx/blackconstantvol.hpp>
22#include <ql/math/solvers1d/brent.hpp>
30 PriceError(
const PricingEngine& engine,
35 const PricingEngine& engine_;
38 const Instrument::results* results_;
41 PriceError::PriceError(
const PricingEngine& engine,
44 : engine_(engine), vol_(vol), targetValue_(targetValue) {
46 dynamic_cast<const Instrument::results*
>(engine_.getResults());
47 QL_REQUIRE(results_ !=
nullptr,
"pricing engine does not supply needed results");
50 Real PriceError::operator()(Volatility x)
const {
53 return results_->value-targetValue_;
74 PriceError f(engine, volQuote, targetValue);
83 ext::shared_ptr<GeneralizedBlackScholesProcess>
84 ImpliedVolatilityHelper::clone(
85 const ext::shared_ptr<GeneralizedBlackScholesProcess>& process,
86 const ext::shared_ptr<SimpleQuote>& volQuote) {
94 ext::shared_ptr<BlackVolTermStructure>(
98 blackVol->dayCounter())));
100 return ext::make_shared<GeneralizedBlackScholesProcess>(
101 stateVariable, dividendYield,
102 riskFreeRate, volatility);
Constant Black volatility, no time-strike dependence.
Shared handle to an observable.
Abstract instrument class.
virtual void setupArguments(PricingEngine::arguments *) const
virtual void validate() const =0
interface for pricing engines
virtual arguments * getArguments() const =0
market element returning a stored value
void setMaxEvaluations(Size evaluations)
Real solve(const F &f, Real accuracy, Real guess, Real step) const
unsigned QL_INTEGER Natural
positive integer
Real Volatility
volatility