Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
marketdata.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2020 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/utilities/marketdata.hpp
20 \brief market data related utilties
21 \ingroup utilities
22*/
23
24#pragma once
25
27#include <string>
28
29namespace ore {
30namespace data {
31
32extern const std::string xccyCurveNamePrefix;
33
34/*! For a given currency code, \p ccyCode, return the internal name for the cross currency based yield curve.
35
36 For a given currency code, \p ccyCode, this function returns `__XCCY__-ccyCode`. This curve, if available, is
37 currently used in special cases to allow for separate discount curves when discounting the cashflows on cross
38 currency interest rate swaps.
39*/
40std::string xccyCurveName(const std::string& ccyCode);
41
42/*! Attempt to return a yield curve from the market using the name generated by `xccyCurveName(ccyCode)`. If no yield
43 curve is available, return the discount curve for the given currency code, \p ccyCode.
44*/
45QuantLib::Handle<QuantLib::YieldTermStructure>
46xccyYieldCurve(const QuantLib::ext::shared_ptr<Market>& market, const std::string& ccyCode,
47 const std::string& configuration = Market::defaultConfiguration);
48
49/*! Attempt to return a yield curve from the market using the name generated by `xccyCurveName(ccyCode)`. If no yield
50 curve is available, return the discount curve for the given currency code, \p ccyCode. The parameter
51 \p outXccyExists is populated with `true` if a yield curve was found under `xccyCurveName(ccyCode)` and it is
52 populated with `false` if there was no such yield curve.
53*/
54QuantLib::Handle<QuantLib::YieldTermStructure>
55xccyYieldCurve(const QuantLib::ext::shared_ptr<Market>& market, const std::string& ccyCode, bool& outXccyExists,
56 const std::string& configuration = Market::defaultConfiguration);
57
58/*! Get a yield curve by name, where name can refer to an index or a yield curve name */
59QuantLib::Handle<QuantLib::YieldTermStructure>
60indexOrYieldCurve(const QuantLib::ext::shared_ptr<Market>& market, const std::string& name,
61 const std::string& configuration = Market::defaultConfiguration);
62
63/*! For a given security id and credit curve id return the internal name for a security specific
64 copy of the credit curve. This is used to separate sensitivities on credit curves by securities. */
65std::string securitySpecificCreditCurveName(const std::string& securityId, const std::string& creditCurveId);
66
67/*! Return the credit curve id for a name generated with securitySpecificCreditCurveName(). If the name was not
68 generated with securitySpecificCreditCurveName(), return the input name unchanged. */
69std::string creditCurveNameFromSecuritySpecificCreditCurveName(const std::string& name);
70
71/*! Attempt to return a security specific default curve using the name generated by 'securitySpecificCreditCurveName()'.
72 If no such curve is available return the credit curve for the given creditCurveId. */
73QuantLib::Handle<QuantExt::CreditCurve>
74securitySpecificCreditCurve(const QuantLib::ext::shared_ptr<Market>& market, const std::string& securityId,
75 const std::string& creditCurveId,
76 const std::string& configuration = Market::defaultConfiguration);
77
78/*! Split curve name NAME_5Y into (NAME, 5Y), the period can be empty if not given */
79std::pair<std::string, QuantLib::Period> splitCurveIdWithTenor(const std::string& curveId);
80
81/*! Get default curve for index cds from market:
82 - if creditCurveId ends on _5Y (or any other term), use that to get the curve from the market
83 - if such a curve is not available, fall back to creditCurveId without that suffix
84*/
85QuantLib::Handle<QuantExt::CreditCurve> indexCdsDefaultCurve(const QuantLib::ext::shared_ptr<Market>& market,
86 const std::string& creditCurveId,
87 const std::string& config);
88
89/*! Pretty print an internal curve name occuring (once or several times) in a string (e.g. in a risk factor name). */
90std::string prettyPrintInternalCurveName(std::string name);
91
92/*! Build an Fx Index given a market. Note: sold==domestic, bought==foreign */
93QuantLib::ext::shared_ptr<QuantExt::FxIndex> buildFxIndex(const string& fxIndex, const string& domestic, const string& foreign,
94 const QuantLib::ext::shared_ptr<Market>& market, const string& configuration,
95 bool useXbsCurves = false);
96
97std::tuple<Natural, Calendar, BusinessDayConvention> getFxIndexConventions(const string& index);
98
99} // namespace data
100} // namespace ore
static const string defaultConfiguration
Default configuration label.
Definition: market.hpp:296
@ data
Definition: log.hpp:77
Base Market class.
Handle< YieldTermStructure > xccyYieldCurve(const QuantLib::ext::shared_ptr< Market > &market, const string &ccyCode, const string &configuration)
Definition: marketdata.cpp:41
std::string creditCurveNameFromSecuritySpecificCreditCurveName(const std::string &name)
Definition: marketdata.cpp:84
QuantLib::Handle< QuantExt::CreditCurve > indexCdsDefaultCurve(const QuantLib::ext::shared_ptr< Market > &market, const std::string &creditCurveId, const std::string &config)
Definition: marketdata.cpp:243
std::string prettyPrintInternalCurveName(std::string name)
Definition: marketdata.cpp:114
Handle< YieldTermStructure > indexOrYieldCurve(const QuantLib::ext::shared_ptr< Market > &market, const std::string &name, const std::string &configuration)
Definition: marketdata.cpp:65
string xccyCurveName(const string &ccyCode)
Definition: marketdata.cpp:39
std::tuple< Natural, Calendar, BusinessDayConvention > getFxIndexConventions(const string &index)
Definition: marketdata.cpp:160
std::pair< std::string, QuantLib::Period > splitCurveIdWithTenor(const std::string &creditCurveId)
Definition: marketdata.cpp:231
QuantLib::Handle< QuantExt::CreditCurve > securitySpecificCreditCurve(const QuantLib::ext::shared_ptr< Market > &market, const std::string &securityId, const std::string &creditCurveId, const std::string &configuration)
Definition: marketdata.cpp:98
QuantLib::ext::shared_ptr< QuantExt::FxIndex > buildFxIndex(const string &fxIndex, const string &domestic, const string &foreign, const QuantLib::ext::shared_ptr< Market > &market, const string &configuration, bool useXbsCurves)
Definition: marketdata.cpp:137
const string xccyCurveNamePrefix
Definition: marketdata.cpp:37
std::string securitySpecificCreditCurveName(const std::string &securityId, const std::string &creditCurveId)
Definition: marketdata.cpp:79
Serializable Credit Default Swap.
Definition: namespaces.docs:23
string name