Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
equitytouchoption.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2020 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/equitytouchoption.hpp
20 \brief
21 \ingroup portfolio
22*/
23
24#pragma once
25
26#include <boost/make_shared.hpp>
30#include <ql/pricingengines/vanilla/analyticdigitalamericanengine.hpp>
31#include <ql/processes/blackscholesprocess.hpp>
32
33namespace ore {
34namespace data {
35using namespace std;
36using namespace QuantLib;
37
38//! Engine Builder for EQ Touch Options
39/*! Pricing engines are cached by asset name / currency
40
41 \ingroup portfolio
42 */
44 : public ore::data::CachingPricingEngineBuilder<string, const string&, const Currency&, const string&> {
45public:
47 : CachingEngineBuilder("BlackScholesMerton", "AnalyticDigitalAmericanEngine", {"EquityTouchOption"}) {}
48 EquityTouchOptionEngineBuilder(const string& model, const string& engine)
49 : CachingEngineBuilder(model, engine, {"EquityTouchOption"}) {}
50
51protected:
52 virtual string keyImpl(const string& assetName, const Currency& ccy, const string& type) override {
53 return assetName + ccy.code() + type;
54 }
55
56 virtual QuantLib::ext::shared_ptr<PricingEngine> engineImpl(const string& assetName, const Currency& ccy,
57 const string& type) override {
58 QuantLib::ext::shared_ptr<GeneralizedBlackScholesProcess> gbsp = QuantLib::ext::make_shared<GeneralizedBlackScholesProcess>(
60 market_->equityDividendCurve(assetName, configuration(ore::data::MarketContext::pricing)),
61 market_->equityForecastCurve(assetName, configuration(ore::data::MarketContext::pricing)),
63
64 if (type == "One-Touch") {
65 engine_ = "AnalyticDigitalAmericanEngine";
66 return QuantLib::ext::make_shared<QuantLib::AnalyticDigitalAmericanEngine>(gbsp);
67 } else if (type == "No-Touch") {
68 engine_ = "AnalyticDigitalAmericanKOEngine";
69 return QuantLib::ext::make_shared<QuantLib::AnalyticDigitalAmericanKOEngine>(gbsp);
70 } else {
71 QL_FAIL("Unknwon EQ touch option type: " << type);
72 }
73 }
74};
75
76} // namespace data
77} // 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)
Engine Builder for EQ Touch Options.
EquityTouchOptionEngineBuilder(const string &model, const string &engine)
virtual string keyImpl(const string &assetName, const Currency &ccy, const string &type) override
virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const string &assetName, const Currency &ccy, const string &type) override
Pricing Engine Factory.
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23
Map text representations to QuantLib/QuantExt types.