Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
fxtouchoption.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/fxtouchoption.hpp
20 \brief
21 \ingroup portfolio
22*/
23
24#pragma once
25
26#include <boost/make_shared.hpp>
32#include <ql/processes/blackscholesprocess.hpp>
33
34namespace ore {
35namespace data {
36using namespace std;
37using namespace QuantLib;
38
39//! Engine Builder for FX Touch Options
40/*! Pricing engines are cached by currency pair
41
42 \ingroup portfolio
43 */
45 : public ore::data::CachingPricingEngineBuilder<string, const Currency&, const Currency&, const string&,
46 const Date&, const bool> {
47public:
49 : CachingEngineBuilder("GarmanKohlhagen", "AnalyticDigitalAmericanEngine", {"FxTouchOption"}) {}
50 FxTouchOptionEngineBuilder(const string& model, const string& engine)
51 : CachingEngineBuilder(model, engine, {"FxTouchOption"}) {}
52
53protected:
54 virtual string keyImpl(const Currency& forCcy, const Currency& domCcy, const string& type, const Date& payDate,
55 const bool flipResults) override {
56 return forCcy.code() + domCcy.code() + type + ore::data::to_string(payDate) + (flipResults ? "_1" : "_0");
57 }
58
59 virtual QuantLib::ext::shared_ptr<PricingEngine> engineImpl(const Currency& forCcy, const Currency& domCcy,
60 const string& type, const Date& payDate,
61 const bool flipResults) override {
62 string pair = forCcy.code() + domCcy.code();
63 QuantLib::ext::shared_ptr<GeneralizedBlackScholesProcess> gbsp = QuantLib::ext::make_shared<GeneralizedBlackScholesProcess>(
65 market_->discountCurve(forCcy.code(),
66 configuration(ore::data::MarketContext::pricing)), // dividend yield ~ foreign yield
67 market_->discountCurve(domCcy.code(), configuration(ore::data::MarketContext::pricing)),
69
70 if (type == "One-Touch") {
71 return QuantLib::ext::make_shared<QuantExt::AnalyticDigitalAmericanEngine>(gbsp, payDate, flipResults);
72 } else if (type == "No-Touch") {
73 return QuantLib::ext::make_shared<QuantExt::AnalyticDigitalAmericanKOEngine>(gbsp, payDate, flipResults);
74 } else {
75 QL_FAIL("Unknown FX touch option type: " << type);
76 }
77 }
78};
79
80} // namespace data
81} // 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 FX Touch Options.
virtual string keyImpl(const Currency &forCcy, const Currency &domCcy, const string &type, const Date &payDate, const bool flipResults) override
virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const Currency &forCcy, const Currency &domCcy, const string &type, const Date &payDate, const bool flipResults) override
FxTouchOptionEngineBuilder(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