Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
fxforward.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 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 portfolio/builders/fxforward.hpp
20 \brief Engine builder for FX Forwards
21 \ingroup builders
22*/
23
24#pragma once
25
26#include <boost/make_shared.hpp>
30
31namespace ore {
32namespace data {
33
34//! Engine Builder base class for FX Forwards
35/*! Pricing engines are cached by currency1 and currency2
36 \ingroup builders
37*/
39 : public CachingPricingEngineBuilder<string, const Currency&, const Currency&> {
40public:
41 FxForwardEngineBuilderBase(const std::string& model, const std::string& engine)
42 : CachingEngineBuilder(model, engine, {"FxForward"}) {}
43
44protected:
45 virtual string keyImpl(const Currency& forCcy, const Currency& domCcy) override {
46 return forCcy.code() + domCcy.code();
47 }
48};
49
50//! Engine Builder for FX Forwards
51/*! Pricing engines are cached by currency pair
52 \ingroup builders
53*/
55public:
56 FxForwardEngineBuilder() : FxForwardEngineBuilderBase("DiscountedCashflows", "DiscountingFxForwardEngine") {}
57
58protected:
59 virtual QuantLib::ext::shared_ptr<PricingEngine> engineImpl(const Currency& forCcy, const Currency& domCcy) override {
60 string pair = keyImpl(forCcy, domCcy);
61 string tmp = engineParameter("includeSettlementDateFlows", {}, false, "");
62 bool includeSettlementDateFlows = tmp == "" ? false : parseBool(tmp);
63 return QuantLib::ext::make_shared<QuantExt::DiscountingFxForwardEngine>(
64 domCcy, market_->discountCurve(domCcy.code(), configuration(MarketContext::pricing)), forCcy,
65 market_->discountCurve(forCcy.code(), configuration(MarketContext::pricing)),
67 includeSettlementDateFlows);
68 }
69};
70
71//! FX forward engine builder for external cam, with additional simulation dates (AMC)
73public:
74 // for external cam, with additional simulation dates (AMC)
75 CamAmcFxForwardEngineBuilder(const QuantLib::ext::shared_ptr<QuantExt::CrossAssetModel>& cam,
76 const std::vector<Date>& simulationDates)
77 : FxForwardEngineBuilderBase("CrossAssetModel", "AMC"), cam_(cam), simulationDates_(simulationDates) {}
78
79protected:
80 virtual QuantLib::ext::shared_ptr<PricingEngine> engineImpl(const Currency& forCcy, const Currency& domCcy) override;
81
82private:
83 const QuantLib::ext::shared_ptr<QuantExt::CrossAssetModel> cam_;
84 const std::vector<Date> simulationDates_;
85};
86
87} // namespace data
88} // namespace ore
Abstract template engine builder class.
Abstract template EngineBuilder class that can cache engines and coupon pricers.
FX forward engine builder for external cam, with additional simulation dates (AMC)
Definition: fxforward.hpp:72
const std::vector< Date > simulationDates_
Definition: fxforward.hpp:84
virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const Currency &forCcy, const Currency &domCcy) override
Definition: fxforward.cpp:29
const QuantLib::ext::shared_ptr< QuantExt::CrossAssetModel > cam_
Definition: fxforward.hpp:83
CamAmcFxForwardEngineBuilder(const QuantLib::ext::shared_ptr< QuantExt::CrossAssetModel > &cam, const std::vector< Date > &simulationDates)
Definition: fxforward.hpp:75
QuantLib::ext::shared_ptr< Market > market_
const string & engine() const
Return the engine name.
const string & model() const
Return the model name.
std::string engineParameter(const std::string &p, const std::vector< std::string > &qualifiers={}, const bool mandatory=true, const std::string &defaultValue="") const
const string & configuration(const MarketContext &key)
Return a configuration (or the default one if key not found)
Engine Builder base class for FX Forwards.
Definition: fxforward.hpp:39
FxForwardEngineBuilderBase(const std::string &model, const std::string &engine)
Definition: fxforward.hpp:41
virtual string keyImpl(const Currency &forCcy, const Currency &domCcy) override
Definition: fxforward.hpp:45
Engine Builder for FX Forwards.
Definition: fxforward.hpp:54
virtual QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const Currency &forCcy, const Currency &domCcy) override
Definition: fxforward.hpp:59
Pricing Engine Factory.
bool parseBool(const string &s)
Convert text to bool.
Definition: parsers.cpp:144
@ data
Definition: log.hpp:77
Serializable Credit Default Swap.
Definition: namespaces.docs:23