Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
todaysmarket.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 marketdata/todaysmarket.hpp
20 \brief An concrete implementation of the Market class that loads todays market and builds the required curves
21 \ingroup marketdata
22*/
23
24#pragma once
25
34
35#include <boost/graph/adjacency_list.hpp>
36#include <boost/graph/directed_graph.hpp>
37#include <boost/graph/graph_traits.hpp>
38#include <ql/shared_ptr.hpp>
39#include <boost/enable_shared_from_this.hpp>
40
41#include <map>
42
43namespace ore {
44namespace data {
45
46class ReferenceDataManager;
47class YieldCurve;
48class FXSpot;
49class FXVolCurve;
50class GenericYieldVolCurve;
51class YieldVolCurve;
52class CapFloorVolCurve;
53class DefaultCurve;
54class CDSVolCurve;
55class BaseCorrelationCurve;
56class InflationCurve;
57class InflationCapFloorVolCurve;
58class EquityCurve;
59class EquityVolCurve;
60class Security;
61class CommodityCurve;
62class CommodityVolCurve;
63class CorrelationCurve;
64
65// TODO: rename class
66//! Today's Market
67/*!
68 Today's Market differs from MarketImpl in that it actually loads market data
69 and builds term structure objects.
70
71 We label this object Today's Market in contrast to the Simulation Market which can
72 differ in composition and granularity. The Simulation Market is initialised using a Today's Market
73 object.
74
75 Today's market's purpose is t0 pricing, the Simulation Market's purpose is
76 pricing under future scenarios.
77
78 \ingroup marketdata
79 */
80class TodaysMarket : public MarketImpl {
81public:
82 //! Constructor taking pointers and allowing for a lazy build of the market objects
83 TodaysMarket( //! Valuation date
84 const Date& asof,
85 //! Description of the market composition
86 const QuantLib::ext::shared_ptr<TodaysMarketParameters>& params,
87 //! Market data loader
88 const QuantLib::ext::shared_ptr<Loader>& loader,
89 //! Description of curve compositions
90 const QuantLib::ext::shared_ptr<CurveConfigurations>& curveConfigs,
91 //! Continue even if build errors occur
92 const bool continueOnError = false,
93 //! Optional Load Fixings
94 const bool loadFixings = true,
95 //! If yes, build market objects lazily
96 const bool lazyBuild = false,
97 //! Optional reference data manager, needed to build fitted bond curves
98 const QuantLib::ext::shared_ptr<ReferenceDataManager>& referenceData = nullptr,
99 //! If true, preserve link to loader quotes, this might heavily interfere with XVA simulations!
100 const bool preserveQuoteLinkage = false,
101 //! the ibor fallback config
102 const IborFallbackConfig& iborFallbackConfig = IborFallbackConfig::defaultConfig(),
103 //! build calibration info?
104 const bool buildCalibrationInfo = true,
105 //! support pseudo currencies
106 const bool handlePseudoCurrencies = true);
107
108 QuantLib::ext::shared_ptr<TodaysMarketCalibrationInfo> calibrationInfo() const { return calibrationInfo_; }
109
110private:
111 // MarketImpl interface
112 void require(const MarketObject o, const string& name, const string& configuration,
113 const bool forceBuild = false) const override;
114
115 // input parameters
116
117 const QuantLib::ext::shared_ptr<TodaysMarketParameters> params_;
118 const QuantLib::ext::shared_ptr<Loader> loader_;
119 const QuantLib::ext::shared_ptr<const CurveConfigurations> curveConfigs_;
120
122 const bool loadFixings_;
123 const bool lazyBuild_;
125 const QuantLib::ext::shared_ptr<ReferenceDataManager> referenceData_;
128
129 // initialise market
130 void initialise(const Date& asof);
131
132 // some typedefs for graph related data types
134 using Graph = boost::directed_graph<Node>;
135 using IndexMap = boost::property_map<Graph, boost::vertex_index_t>::type;
136 using Vertex = boost::graph_traits<Graph>::vertex_descriptor;
137 using VertexIterator = boost::graph_traits<Graph>::vertex_iterator;
138
139 // the dependency graphs for each configuration
140 mutable std::map<std::string, Graph> dependencies_;
141
142 // build a single market object
143 void buildNode(const std::string& configuration, Node& node) const;
144
145 // calibration results
146 QuantLib::ext::shared_ptr<TodaysMarketCalibrationInfo> calibrationInfo_;
147
148 // cached market objects, the key of the maps is the curve spec name, except for swap indices, see below
149 mutable map<string, QuantLib::ext::shared_ptr<YieldCurve>> requiredYieldCurves_;
150 mutable map<string, QuantLib::ext::shared_ptr<FXVolCurve>> requiredFxVolCurves_;
151 mutable map<string, QuantLib::ext::shared_ptr<GenericYieldVolCurve>> requiredGenericYieldVolCurves_;
152 mutable map<string, std::pair<QuantLib::ext::shared_ptr<CapFloorVolCurve>, std::pair<std::string, QuantLib::Period>>>
154 mutable map<string, QuantLib::ext::shared_ptr<DefaultCurve>> requiredDefaultCurves_;
155 mutable map<string, QuantLib::ext::shared_ptr<CDSVolCurve>> requiredCDSVolCurves_;
156 mutable map<string, QuantLib::ext::shared_ptr<BaseCorrelationCurve>> requiredBaseCorrelationCurves_;
157 mutable map<string, QuantLib::ext::shared_ptr<InflationCurve>> requiredInflationCurves_;
158 mutable map<string, QuantLib::ext::shared_ptr<InflationCapFloorVolCurve>> requiredInflationCapFloorVolCurves_;
159 mutable map<string, QuantLib::ext::shared_ptr<EquityCurve>> requiredEquityCurves_;
160 mutable map<string, QuantLib::ext::shared_ptr<EquityVolCurve>> requiredEquityVolCurves_;
161 mutable map<string, QuantLib::ext::shared_ptr<Security>> requiredSecurities_;
162 mutable map<string, QuantLib::ext::shared_ptr<CommodityCurve>> requiredCommodityCurves_;
163 mutable map<string, QuantLib::ext::shared_ptr<CommodityVolCurve>> requiredCommodityVolCurves_;
164 mutable map<string, QuantLib::ext::shared_ptr<CorrelationCurve>> requiredCorrelationCurves_;
165 // for swap indices we map the configuration name to a map (swap index name => index)
166 mutable map<string, map<string, QuantLib::ext::shared_ptr<SwapIndex>>> requiredSwapIndices_;
167};
168
169std::ostream& operator<<(std::ostream& o, const DependencyGraph::Node& n);
170
171} // namespace data
172} // namespace ore
static IborFallbackConfig defaultConfig()
bool handlePseudoCurrencies() const
Definition: market.hpp:339
Market Implementation.
Definition: marketimpl.hpp:53
map< string, QuantLib::ext::shared_ptr< GenericYieldVolCurve > > requiredGenericYieldVolCurves_
void initialise(const Date &asof)
map< string, std::pair< QuantLib::ext::shared_ptr< CapFloorVolCurve >, std::pair< std::string, QuantLib::Period > > > requiredCapFloorVolCurves_
const bool preserveQuoteLinkage_
const bool buildCalibrationInfo_
void require(const MarketObject o, const string &name, const string &configuration, const bool forceBuild=false) const override
map< string, QuantLib::ext::shared_ptr< DefaultCurve > > requiredDefaultCurves_
boost::graph_traits< Graph >::vertex_iterator VertexIterator
const QuantLib::ext::shared_ptr< const CurveConfigurations > curveConfigs_
boost::property_map< Graph, boost::vertex_index_t >::type IndexMap
QuantLib::ext::shared_ptr< TodaysMarketCalibrationInfo > calibrationInfo() const
map< string, QuantLib::ext::shared_ptr< FXVolCurve > > requiredFxVolCurves_
const QuantLib::ext::shared_ptr< TodaysMarketParameters > params_
map< string, QuantLib::ext::shared_ptr< CommodityCurve > > requiredCommodityCurves_
const QuantLib::ext::shared_ptr< ReferenceDataManager > referenceData_
map< string, map< string, QuantLib::ext::shared_ptr< SwapIndex > > > requiredSwapIndices_
map< string, QuantLib::ext::shared_ptr< CommodityVolCurve > > requiredCommodityVolCurves_
const QuantLib::ext::shared_ptr< Loader > loader_
map< string, QuantLib::ext::shared_ptr< InflationCurve > > requiredInflationCurves_
map< string, QuantLib::ext::shared_ptr< BaseCorrelationCurve > > requiredBaseCorrelationCurves_
map< string, QuantLib::ext::shared_ptr< CorrelationCurve > > requiredCorrelationCurves_
map< string, QuantLib::ext::shared_ptr< EquityCurve > > requiredEquityCurves_
boost::directed_graph< Node > Graph
std::map< std::string, Graph > dependencies_
map< string, QuantLib::ext::shared_ptr< YieldCurve > > requiredYieldCurves_
map< string, QuantLib::ext::shared_ptr< CDSVolCurve > > requiredCDSVolCurves_
boost::graph_traits< Graph >::vertex_descriptor Vertex
map< string, QuantLib::ext::shared_ptr< Security > > requiredSecurities_
const IborFallbackConfig iborFallbackConfig_
map< string, QuantLib::ext::shared_ptr< InflationCapFloorVolCurve > > requiredInflationCapFloorVolCurves_
QuantLib::ext::shared_ptr< TodaysMarketCalibrationInfo > calibrationInfo_
void buildNode(const std::string &configuration, Node &node) const
map< string, QuantLib::ext::shared_ptr< EquityVolCurve > > requiredEquityVolCurves_
Currency and instrument specific conventions/defaults.
Curve configuration repository.
Curve requirements specification.
DependencyGraph class to establish build order of marketObjects and its dependency.
Market Datum Loader Interface.
@ data
Definition: log.hpp:77
An implementation of the Market class that stores the required objects in maps.
std::ostream & operator<<(std::ostream &out, EquityReturnType t)
MarketObject
Definition: market.hpp:65
Serializable Credit Default Swap.
Definition: namespaces.docs:23
vector< string > curveConfigs
a container holding information on calibration results during the t0 market build
string name
A class to hold todays market configuration(s)