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