Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
equitydoublebarrieroption.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2021 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7 ORE is free software: you can redistribute it and/or modify it
8 under the terms of the Modified BSD License. You should have received a
9 copy of the license along with this program.
10 The license is also available online at <http://opensourcerisk.org>
11 This program is distributed on the basis that it will form a useful
12 contribution to risk analytics and model standardisation, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
15*/
16
17/*! \file ored/portfolio/builders/equitydoublebarrieroption.hpp
18 \brief
19 \ingroup portfolio
20*/
21
22#pragma once
23
24#include <boost/make_shared.hpp>
29#include <ql/pricingengines//barrier/analyticdoublebarrierengine.hpp>
30#include <ql/pricingengines/barrier/fdblackscholesbarrierengine.hpp>
31#include <ql/processes/blackscholesprocess.hpp>
33
34namespace ore {
35namespace data {
36using namespace std;
37using namespace QuantLib;
38
39//! Engine Builder for Equity Double Barrier Options
40/*! Pricing engines are cached by asset name / currency
41
42 \ingroup portfolio
43 */
45 : public ore::data::CachingPricingEngineBuilder<string, const string&, const Currency&, const Date&> {
46
47protected:
49 : CachingEngineBuilder(model, engine, {"EquityDoubleBarrierOption"}) {}
50
51 virtual string keyImpl(const string& assetName, const Currency& ccy, const Date& expiryDate) override {
52 return assetName + "/" + ccy.code() + "/" + ore::data::to_string(expiryDate);
53 }
54
55 QuantLib::ext::shared_ptr<GeneralizedBlackScholesProcess> getBlackScholesProcess(const string& assetName, const Currency& ccy,
56 const std::vector<Time>& timePoints = {}) {
57
58 Handle<BlackVolTermStructure> vol = this->market_->equityVol(assetName, configuration(ore::data::MarketContext::pricing));
59 if (!timePoints.empty()) {
60 vol = Handle<BlackVolTermStructure>(
61 QuantLib::ext::make_shared<QuantExt::BlackMonotoneVarVolTermStructure>(vol, timePoints));
62 vol->enableExtrapolation();
63 }
64 return QuantLib::ext::make_shared<GeneralizedBlackScholesProcess>(
65 this->market_->equitySpot(assetName, configuration(ore::data::MarketContext::pricing)),
66 this->market_->equityDividendCurve(assetName, configuration(ore::data::MarketContext::pricing)),
67 this->market_->equityForecastCurve(assetName, configuration(ore::data::MarketContext::pricing)),
68 vol);
69 }
70};
71
74public:
76 : EquityDoubleBarrierOptionEngineBuilder("BlackScholesMerton", "AnalyticDoubleBarrierEngine") {}
77
78protected:
79
80 virtual QuantLib::ext::shared_ptr<PricingEngine> engineImpl(const string& assetName, const Currency& ccy, const Date& expiryDate) override {
81 QuantLib::ext::shared_ptr<GeneralizedBlackScholesProcess> gbsp = getBlackScholesProcess(assetName, ccy);
82 return QuantLib::ext::make_shared<QuantLib::AnalyticDoubleBarrierEngine>(gbsp);
83 }
84
85};
86
87} // namespace data
88} // namespace ore
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.
const string & configuration(const MarketContext &key)
Return a configuration (or the default one if key not found)
virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const string &assetName, const Currency &ccy, const Date &expiryDate) override
Engine Builder for Equity Double Barrier Options.
virtual string keyImpl(const string &assetName, const Currency &ccy, const Date &expiryDate) override
QuantLib::ext::shared_ptr< GeneralizedBlackScholesProcess > getBlackScholesProcess(const string &assetName, const Currency &ccy, const std::vector< Time > &timePoints={})
EquityDoubleBarrierOptionEngineBuilder(const string &model, const string &engine)
Pricing Engine Factory.
@ data
Definition: log.hpp:77
std::string to_string(const LocationInfo &l)
Definition: ast.cpp:28
Serializable Credit Default Swap.
Definition: namespaces.docs:23
Map text representations to QuantLib/QuantExt types.
string conversion utilities