Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
equitydoubletouchoption.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2019 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
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17 */
18
19/*! \file ored/portfolio/builders/equitydoubletouchoption.hpp
20 \brief
21 \ingroup portfolio
22*/
23
24#pragma once
25
26#include <boost/make_shared.hpp>
30#include <ql/pricingengines/barrier/analyticdoublebarrierbinaryengine.hpp>
31#include <ql/processes/blackscholesprocess.hpp>
33
34namespace ore {
35namespace data {
36using namespace std;
37using namespace QuantLib;
38
39//! Abstract Engine Builder for EQ Double Touch 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&> {
46public:
48 : CachingEngineBuilder(model, engine, {"EquityDoubleTouchOption"}) {}
49
50protected:
51 virtual string keyImpl(const string& assetName, const Currency& ccy) override {
52 return assetName + ccy.code();
53 }
54
55 QuantLib::ext::shared_ptr<GeneralizedBlackScholesProcess>
56 getBlackScholesProcess(const string& assetName, const Currency& ccy, const std::vector<Time>& timePoints = {}) {
57 Handle<BlackVolTermStructure> vol =
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>(
66 market_->equityDividendCurve(assetName,configuration(ore::data::MarketContext::pricing)),
67 market_->equityForecastCurve(assetName, configuration(ore::data::MarketContext::pricing)), vol);
68 }
69};
70
71//! Analytical Engine Builder for EQ Double Touch Options
72/*! Pricing engines are cached by asset name / currency
73
74 \ingroup portfolio
75 */
77public:
79 : EquityDoubleTouchOptionEngineBuilder("GarmanKohlhagen", "AnalyticDoubleBarrierBinaryEngine") {}
80
81protected:
82 virtual QuantLib::ext::shared_ptr<PricingEngine> engineImpl(const string& assetName, const Currency& ccy) override {
83 QuantLib::ext::shared_ptr<GeneralizedBlackScholesProcess> gbsp = getBlackScholesProcess(assetName, ccy);
84
85 engine_ = "AnalyticDoubleBarrierBinaryEngine";
86 return QuantLib::ext::make_shared<QuantLib::AnalyticDoubleBarrierBinaryEngine>(gbsp);
87 }
88};
89
90} // namespace data
91} // namespace oreplus
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)
Analytical Engine Builder for EQ Double Touch Options.
virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const string &assetName, const Currency &ccy) override
Abstract Engine Builder for EQ Double Touch Options.
EquityDoubleTouchOptionEngineBuilder(const string &model, const string &engine)
QuantLib::ext::shared_ptr< GeneralizedBlackScholesProcess > getBlackScholesProcess(const string &assetName, const Currency &ccy, const std::vector< Time > &timePoints={})
virtual string keyImpl(const string &assetName, const Currency &ccy) override
Pricing Engine Factory.
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23
Map text representations to QuantLib/QuantExt types.