Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
fxbsbuilder.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 ored/model/fxbsbuilder.hpp
20 \brief Builder for a Lognormal FX model component
21 \ingroup models
22*/
23
24#pragma once
25
26#include <map>
27#include <ostream>
28#include <vector>
29
35
36namespace ore {
37namespace data {
38using namespace QuantLib;
39
40//! Builder for a Lognormal FX model component
41/*!
42 This class is a utility to turn an FX model component's description
43 into an FX model parametrization which can be used to ultimately
44 instantiate a CrossAssetModel.
45
46 \ingroup models
47 */
49public:
50 //! Constructor
51 FxBsBuilder( //! Market object
52 const QuantLib::ext::shared_ptr<ore::data::Market>& market,
53 //! FX model parameters/description
54 const QuantLib::ext::shared_ptr<FxBsData>& data,
55 //! Market configuration to use
56 const std::string& configuration = Market::defaultConfiguration,
57 //! the reference calibration grid
58 const std::string& referenceCalibrationGrid = "");
59
60 //! Return calibration error
61 Real error() const;
62
63 //! \name Inspectors
64 //@{
65 std::string foreignCurrency() { return data_->foreignCcy(); }
66 QuantLib::ext::shared_ptr<QuantExt::FxBsParametrization> parametrization() const;
67 std::vector<QuantLib::ext::shared_ptr<BlackCalibrationHelper>> optionBasket() const;
68 //@}
69
70 //! \name ModelBuilder interface
71 //@{
72 void forceRecalculate() override;
73 bool requiresRecalibration() const override;
74 //@}
75
76 void setCalibrationDone() const;
77
78private:
79 void performCalculations() const override;
80 Real optionStrike(const Size j) const;
81 Date optionExpiry(const Size j) const;
82 void buildOptionBasket() const;
83 // checks whether fx vols have changed compared to cache and updates the cache if requested
84 bool volSurfaceChanged(const bool updateCache) const;
85
86 // input data
87 const QuantLib::ext::shared_ptr<ore::data::Market> market_;
88 const std::string configuration_;
89 const QuantLib::ext::shared_ptr<FxBsData> data_;
90 const std::string referenceCalibrationGrid_;
91
92 // computed
93 mutable Real error_;
94 QuantLib::ext::shared_ptr<QuantExt::FxBsParametrization> parametrization_;
95
96 // which options in data->optionExpiries() are actually in the basket?
97 mutable std::vector<bool> optionActive_;
98 mutable std::vector<QuantLib::ext::shared_ptr<BlackCalibrationHelper>> optionBasket_;
99 mutable Array optionExpiries_;
100
101 // relevant market data
102 Handle<Quote> fxSpot_;
103 Handle<YieldTermStructure> ytsDom_, ytsFor_;
104 Handle<BlackVolTermStructure> fxVol_;
105
106 // Cache the fx volatilities
107 mutable std::vector<QuantLib::Real> fxVolCache_;
108
109 // helper flag to process forRecalculate()
110 bool forceCalibration_ = false;
111
112 // market observer
113 QuantLib::ext::shared_ptr<QuantExt::MarketObserver> marketObserver_;
114};
115
116} // namespace data
117} // namespace ore
Builder for a Lognormal FX model component.
Definition: fxbsbuilder.hpp:48
QuantLib::ext::shared_ptr< QuantExt::FxBsParametrization > parametrization_
Definition: fxbsbuilder.hpp:94
const std::string configuration_
Definition: fxbsbuilder.hpp:88
void forceRecalculate() override
void performCalculations() const override
bool volSurfaceChanged(const bool updateCache) const
Handle< YieldTermStructure > ytsFor_
QuantLib::ext::shared_ptr< QuantExt::MarketObserver > marketObserver_
std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > optionBasket() const
Handle< BlackVolTermStructure > fxVol_
const QuantLib::ext::shared_ptr< FxBsData > data_
Definition: fxbsbuilder.hpp:89
Real optionStrike(const Size j) const
std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > optionBasket_
Definition: fxbsbuilder.hpp:98
void setCalibrationDone() const
std::vector< QuantLib::Real > fxVolCache_
Handle< YieldTermStructure > ytsDom_
QuantLib::ext::shared_ptr< QuantExt::FxBsParametrization > parametrization() const
Date optionExpiry(const Size j) const
bool requiresRecalibration() const override
const QuantLib::ext::shared_ptr< ore::data::Market > market_
Definition: fxbsbuilder.hpp:87
std::string foreignCurrency()
Definition: fxbsbuilder.hpp:65
Handle< Quote > fxSpot_
const std::string referenceCalibrationGrid_
Definition: fxbsbuilder.hpp:90
Real error() const
Return calibration error.
void buildOptionBasket() const
std::vector< bool > optionActive_
Definition: fxbsbuilder.hpp:97
static const string defaultConfiguration
Default configuration label.
Definition: market.hpp:296
FX component data for the cross asset model.
@ data
Definition: log.hpp:77
Base Market class.
Serializable Credit Default Swap.
Definition: namespaces.docs:23