Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
trsunderlyingbuilder.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2021 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#pragma once
20
27
28namespace ore {
29namespace data {
30
33 virtual void
34 build(const std::string& parentId, const QuantLib::ext::shared_ptr<Trade>& underlying,
35 const std::vector<Date>& valuationDates, const std::vector<Date>& paymentDates,
36 const std::string& fundingCurrency, const QuantLib::ext::shared_ptr<EngineFactory>& engineFactory,
37 QuantLib::ext::shared_ptr<QuantLib::Index>& underlyingIndex, Real& underlyingMultiplier,
38 std::map<std::string, double>& indexQuantities, std::map<std::string, QuantLib::ext::shared_ptr<QuantExt::FxIndex>>& fxIndices,
39 Real& initialPrice, std::string& assetCurrency, std::string& creditRiskCurrency,
40 std::map<std::string, SimmCreditQualifierMapping>& creditQualifierMapping, Date& maturity,
41 const std::function<QuantLib::ext::shared_ptr<QuantExt::FxIndex>(
42 const QuantLib::ext::shared_ptr<Market> market, const std::string& configuration, const std::string& domestic,
43 const std::string& foreign, std::map<std::string, QuantLib::ext::shared_ptr<QuantExt::FxIndex>>& fxIndices)>&
44 getFxIndex,
45 const std::string& underlyingDerivativeId, RequiredFixings& fixings, std::vector<Leg>& returnLegs) const = 0;
46 virtual void updateUnderlying(const QuantLib::ext::shared_ptr<ReferenceDataManager>& refData,
47 QuantLib::ext::shared_ptr<Trade>& underlying, const std::string& parentId) const {}
48};
49
51 : public QuantLib::Singleton<TrsUnderlyingBuilderFactory, std::integral_constant<bool, true>> {
52 map<std::string, QuantLib::ext::shared_ptr<TrsUnderlyingBuilder>> builders_;
53 mutable boost::shared_mutex mutex_;
54
55public:
56 std::map<std::string, QuantLib::ext::shared_ptr<TrsUnderlyingBuilder>> getBuilders() const {
57 boost::shared_lock<boost::shared_mutex> lock(mutex_);
58 return builders_;
59 }
60 QuantLib::ext::shared_ptr<TrsUnderlyingBuilder> getBuilder(const std::string& tradeType) const;
61 void addBuilder(const std::string& tradeType, const QuantLib::ext::shared_ptr<TrsUnderlyingBuilder>& builder,
62 const bool allowOverwrite = false);
63};
64
66 void
67 build(const std::string& parentId, const QuantLib::ext::shared_ptr<Trade>& underlying,
68 const std::vector<Date>& valuationDates, const std::vector<Date>& paymentDates,
69 const std::string& fundingCurrency, const QuantLib::ext::shared_ptr<EngineFactory>& engineFactory,
70 QuantLib::ext::shared_ptr<QuantLib::Index>& underlyingIndex, Real& underlyingMultiplier,
71 std::map<std::string, double>& indexQuantities,
72 std::map<std::string, QuantLib::ext::shared_ptr<QuantExt::FxIndex>>& fxIndices,
73 Real& initialPrice, std::string& assetCurrency, std::string& creditRiskCurrency,
74 std::map<std::string, SimmCreditQualifierMapping>& creditQualifierMapping, Date& maturity,
75 const std::function<QuantLib::ext::shared_ptr<QuantExt::FxIndex>(
76 const QuantLib::ext::shared_ptr<Market> market, const std::string& configuration, const std::string& domestic,
77 const std::string& foreign, std::map<std::string, QuantLib::ext::shared_ptr<QuantExt::FxIndex>>& fxIndices)>&
78 getFxIndex,
79 const std::string& underlyingDerivativeId, RequiredFixings& fixings, std::vector<Leg>& returnLegs) const override;
80};
81
83 void
84 build(const std::string& parentId, const QuantLib::ext::shared_ptr<Trade>& underlying,
85 const std::vector<Date>& valuationDates, const std::vector<Date>& paymentDates,
86 const std::string& fundingCurrency, const QuantLib::ext::shared_ptr<EngineFactory>& engineFactory,
87 QuantLib::ext::shared_ptr<QuantLib::Index>& underlyingIndex, Real& underlyingMultiplier,
88 std::map<std::string, double>& indexQuantities,
89 std::map<std::string, QuantLib::ext::shared_ptr<QuantExt::FxIndex>>& fxIndices,
90 Real& initialPrice, std::string& assetCurrency, std::string& creditRiskCurrency,
91 std::map<std::string, SimmCreditQualifierMapping>& creditQualifierMapping, Date& maturity,
92 const std::function<QuantLib::ext::shared_ptr<QuantExt::FxIndex>(
93 const QuantLib::ext::shared_ptr<Market> market, const std::string& configuration, const std::string& domestic,
94 const std::string& foreign, std::map<std::string, QuantLib::ext::shared_ptr<QuantExt::FxIndex>>& fxIndices)>& getFxIndex,
95 const std::string& underlyingDerivativeId, RequiredFixings& fixings, std::vector<Leg>& returnLegs) const override;
96};
97
98template<class T>
100 void
101 build(const std::string& parentId, const QuantLib::ext::shared_ptr<Trade>& underlying,
102 const std::vector<Date>& valuationDates, const std::vector<Date>& paymentDates,
103 const std::string& fundingCurrency, const QuantLib::ext::shared_ptr<EngineFactory>& engineFactory,
104 QuantLib::ext::shared_ptr<QuantLib::Index>& underlyingIndex, Real& underlyingMultiplier,
105 std::map<std::string, double>& indexQuantities,
106 std::map<std::string, QuantLib::ext::shared_ptr<QuantExt::FxIndex>>& fxIndices,
107 Real& initialPrice, std::string& assetCurrency, std::string& creditRiskCurrency,
108 std::map<std::string, SimmCreditQualifierMapping>& creditQualifierMapping, Date& maturity,
109 const std::function<QuantLib::ext::shared_ptr<QuantExt::FxIndex>(
110 const QuantLib::ext::shared_ptr<Market> market, const std::string& configuration, const std::string& domestic,
111 const std::string& foreign, std::map<std::string, QuantLib::ext::shared_ptr<QuantExt::FxIndex>>& fxIndices)>& getFxIndex,
112 const std::string& underlyingDerivativeId, RequiredFixings& fixings, std::vector<Leg>& returnLegs) const override;
113
114 void updateQuantities(std::map<std::string, double>& indexQuantities, const std::string& indexName,
115 const double qty) const;
116
117 std::string getIndexCurrencyFromPosition(QuantLib::ext::shared_ptr<T> position, size_t i) const;
118
119};
120
123
125 void
126 build(const std::string& parentId, const QuantLib::ext::shared_ptr<Trade>& underlying,
127 const std::vector<Date>& valuationDates, const std::vector<Date>& paymentDates,
128 const std::string& fundingCurrency, const QuantLib::ext::shared_ptr<EngineFactory>& engineFactory,
129 QuantLib::ext::shared_ptr<QuantLib::Index>& underlyingIndex, Real& underlyingMultiplier,
130 std::map<std::string, double>& indexQuantities, std::map<std::string, QuantLib::ext::shared_ptr<QuantExt::FxIndex>>& fxIndices,
131 Real& initialPrice, std::string& assetCurrency, std::string& creditRiskCurrency,
132 std::map<std::string, SimmCreditQualifierMapping>& creditQualifierMapping, Date& maturity,
133 const std::function<QuantLib::ext::shared_ptr<QuantExt::FxIndex>(
134 const QuantLib::ext::shared_ptr<Market> market, const std::string& configuration, const std::string& domestic,
135 const std::string& foreign, std::map<std::string, QuantLib::ext::shared_ptr<QuantExt::FxIndex>>& fxIndices)>& getFxIndex,
136 const std::string& underlyingDerivativeId, RequiredFixings& fixings, std::vector<Leg>& returnLegs) const override;
137};
138
139
141 void
142 build(const std::string& parentId, const QuantLib::ext::shared_ptr<Trade>& underlying,
143 const std::vector<Date>& valuationDates, const std::vector<Date>& paymentDates,
144 const std::string& fundingCurrency, const QuantLib::ext::shared_ptr<EngineFactory>& engineFactory,
145 QuantLib::ext::shared_ptr<QuantLib::Index>& underlyingIndex, Real& underlyingMultiplier,
146 std::map<std::string, double>& indexQuantities, std::map<std::string, QuantLib::ext::shared_ptr<QuantExt::FxIndex>>& fxIndices,
147 Real& initialPrice, std::string& assetCurrency, std::string& creditRiskCurrency,
148 std::map<std::string, SimmCreditQualifierMapping>& creditQualifierMapping, Date& maturity,
149 const std::function<QuantLib::ext::shared_ptr<QuantExt::FxIndex>(
150 const QuantLib::ext::shared_ptr<Market> market, const std::string& configuration, const std::string& domestic,
151 const std::string& foreign, std::map<std::string, QuantLib::ext::shared_ptr<QuantExt::FxIndex>>& fxIndices)>& getFxIndex,
152 const std::string& underlyingDerivativeId, RequiredFixings& fixings, std::vector<Leg>& returnLegs) const override;
153};
154
156 void
157 build(const std::string& parentId, const QuantLib::ext::shared_ptr<Trade>& underlying,
158 const std::vector<Date>& valuationDates, const std::vector<Date>& paymentDates,
159 const std::string& fundingCurrency, const QuantLib::ext::shared_ptr<EngineFactory>& engineFactory,
160 QuantLib::ext::shared_ptr<QuantLib::Index>& underlyingIndex, Real& underlyingMultiplier,
161 std::map<std::string, double>& indexQuantities, std::map<std::string, QuantLib::ext::shared_ptr<QuantExt::FxIndex>>& fxIndices,
162 Real& initialPrice, std::string& assetCurrency, std::string& creditRiskCurrency,
163 std::map<std::string, SimmCreditQualifierMapping>& creditQualifierMapping, Date& maturity,
164 const std::function<QuantLib::ext::shared_ptr<QuantExt::FxIndex>(
165 const QuantLib::ext::shared_ptr<Market> market, const std::string& configuration, const std::string& domestic,
166 const std::string& foreign, std::map<std::string, QuantLib::ext::shared_ptr<QuantExt::FxIndex>>& fxIndices)>& getFxIndex,
167 const std::string& underlyingDerivativeId, RequiredFixings& fixings, std::vector<Leg>& returnLegs) const override;
168};
169
170// utility functions for bond TRS
171void modifyBondTRSLeg(QuantLib::Leg& leg, QuantLib::Date issueDate);
172Leg makeBondTRSLeg(const std::vector<Date>& valuationDates, const std::vector<Date>& paymentDates,
173 const BondIndexBuilder& bondIndexBuilder,
174 QuantLib::Real initialPrice = QuantLib::Null<QuantLib::Real>(),
175 QuantLib::ext::shared_ptr<QuantExt::FxIndex> fxIndex = nullptr);
176
177} // namespace data
178} // namespace ore
Interface for building a bond index.
std::map< std::string, QuantLib::ext::shared_ptr< TrsUnderlyingBuilder > > getBuilders() const
map< std::string, QuantLib::ext::shared_ptr< TrsUnderlyingBuilder > > builders_
void addBuilder(const std::string &tradeType, const QuantLib::ext::shared_ptr< TrsUnderlyingBuilder > &builder, const bool allowOverwrite=false)
QuantLib::ext::shared_ptr< TrsUnderlyingBuilder > getBuilder(const std::string &tradeType) const
Commodity Position trade data model and serialization.
Pricing Engine Factory.
Equity Position trade data model and serialization.
@ data
Definition: log.hpp:77
Time maturity
Definition: utilities.cpp:66
AssetPositionTrsUnderlyingBuilder< ore::data::CommodityPosition > CommodityPositionTrsUnderlyingBuilder
void modifyBondTRSLeg(QuantLib::Leg &leg, QuantLib::Date issueDate)
AssetPositionTrsUnderlyingBuilder< ore::data::EquityPosition > EquityPositionTrsUnderlyingBuilder
Leg makeBondTRSLeg(const std::vector< Date > &valuationDates, const std::vector< Date > &paymentDates, const BondIndexBuilder &bondIndexBuilder, Real initialPrice, QuantLib::ext::shared_ptr< QuantExt::FxIndex > fxIndex)
Serializable Credit Default Swap.
Definition: namespaces.docs:23
mapping of SIMM credit qualifiers
void updateQuantities(std::map< std::string, double > &indexQuantities, const std::string &indexName, const double qty) const
void build(const std::string &parentId, const QuantLib::ext::shared_ptr< Trade > &underlying, const std::vector< Date > &valuationDates, const std::vector< Date > &paymentDates, const std::string &fundingCurrency, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, QuantLib::ext::shared_ptr< QuantLib::Index > &underlyingIndex, Real &underlyingMultiplier, std::map< std::string, double > &indexQuantities, std::map< std::string, QuantLib::ext::shared_ptr< QuantExt::FxIndex > > &fxIndices, Real &initialPrice, std::string &assetCurrency, std::string &creditRiskCurrency, std::map< std::string, SimmCreditQualifierMapping > &creditQualifierMapping, Date &maturity, const std::function< QuantLib::ext::shared_ptr< QuantExt::FxIndex >(const QuantLib::ext::shared_ptr< Market > market, const std::string &configuration, const std::string &domestic, const std::string &foreign, std::map< std::string, QuantLib::ext::shared_ptr< QuantExt::FxIndex > > &fxIndices)> &getFxIndex, const std::string &underlyingDerivativeId, RequiredFixings &fixings, std::vector< Leg > &returnLegs) const override
std::string getIndexCurrencyFromPosition(QuantLib::ext::shared_ptr< T > position, size_t i) const
void build(const std::string &parentId, const QuantLib::ext::shared_ptr< Trade > &underlying, const std::vector< Date > &valuationDates, const std::vector< Date > &paymentDates, const std::string &fundingCurrency, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, QuantLib::ext::shared_ptr< QuantLib::Index > &underlyingIndex, Real &underlyingMultiplier, std::map< std::string, double > &indexQuantities, std::map< std::string, QuantLib::ext::shared_ptr< QuantExt::FxIndex > > &fxIndices, Real &initialPrice, std::string &assetCurrency, std::string &creditRiskCurrency, std::map< std::string, SimmCreditQualifierMapping > &creditQualifierMapping, Date &maturity, const std::function< QuantLib::ext::shared_ptr< QuantExt::FxIndex >(const QuantLib::ext::shared_ptr< Market > market, const std::string &configuration, const std::string &domestic, const std::string &foreign, std::map< std::string, QuantLib::ext::shared_ptr< QuantExt::FxIndex > > &fxIndices)> &getFxIndex, const std::string &underlyingDerivativeId, RequiredFixings &fixings, std::vector< Leg > &returnLegs) const override
void build(const std::string &parentId, const QuantLib::ext::shared_ptr< Trade > &underlying, const std::vector< Date > &valuationDates, const std::vector< Date > &paymentDates, const std::string &fundingCurrency, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, QuantLib::ext::shared_ptr< QuantLib::Index > &underlyingIndex, Real &underlyingMultiplier, std::map< std::string, double > &indexQuantities, std::map< std::string, QuantLib::ext::shared_ptr< QuantExt::FxIndex > > &fxIndices, Real &initialPrice, std::string &assetCurrency, std::string &creditRiskCurrency, std::map< std::string, SimmCreditQualifierMapping > &creditQualifierMapping, Date &maturity, const std::function< QuantLib::ext::shared_ptr< QuantExt::FxIndex >(const QuantLib::ext::shared_ptr< Market > market, const std::string &configuration, const std::string &domestic, const std::string &foreign, std::map< std::string, QuantLib::ext::shared_ptr< QuantExt::FxIndex > > &fxIndices)> &getFxIndex, const std::string &underlyingDerivativeId, RequiredFixings &fixings, std::vector< Leg > &returnLegs) const override
void build(const std::string &parentId, const QuantLib::ext::shared_ptr< Trade > &underlying, const std::vector< Date > &valuationDates, const std::vector< Date > &paymentDates, const std::string &fundingCurrency, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, QuantLib::ext::shared_ptr< QuantLib::Index > &underlyingIndex, Real &underlyingMultiplier, std::map< std::string, double > &indexQuantities, std::map< std::string, QuantLib::ext::shared_ptr< QuantExt::FxIndex > > &fxIndices, Real &initialPrice, std::string &assetCurrency, std::string &creditRiskCurrency, std::map< std::string, SimmCreditQualifierMapping > &creditQualifierMapping, Date &maturity, const std::function< QuantLib::ext::shared_ptr< QuantExt::FxIndex >(const QuantLib::ext::shared_ptr< Market > market, const std::string &configuration, const std::string &domestic, const std::string &foreign, std::map< std::string, QuantLib::ext::shared_ptr< QuantExt::FxIndex > > &fxIndices)> &getFxIndex, const std::string &underlyingDerivativeId, RequiredFixings &fixings, std::vector< Leg > &returnLegs) const override
void build(const std::string &parentId, const QuantLib::ext::shared_ptr< Trade > &underlying, const std::vector< Date > &valuationDates, const std::vector< Date > &paymentDates, const std::string &fundingCurrency, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, QuantLib::ext::shared_ptr< QuantLib::Index > &underlyingIndex, Real &underlyingMultiplier, std::map< std::string, double > &indexQuantities, std::map< std::string, QuantLib::ext::shared_ptr< QuantExt::FxIndex > > &fxIndices, Real &initialPrice, std::string &assetCurrency, std::string &creditRiskCurrency, std::map< std::string, SimmCreditQualifierMapping > &creditQualifierMapping, Date &maturity, const std::function< QuantLib::ext::shared_ptr< QuantExt::FxIndex >(const QuantLib::ext::shared_ptr< Market > market, const std::string &configuration, const std::string &domestic, const std::string &foreign, std::map< std::string, QuantLib::ext::shared_ptr< QuantExt::FxIndex > > &fxIndices)> &getFxIndex, const std::string &underlyingDerivativeId, RequiredFixings &fixings, std::vector< Leg > &returnLegs) const override
void build(const std::string &parentId, const QuantLib::ext::shared_ptr< Trade > &underlying, const std::vector< Date > &valuationDates, const std::vector< Date > &paymentDates, const std::string &fundingCurrency, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, QuantLib::ext::shared_ptr< QuantLib::Index > &underlyingIndex, Real &underlyingMultiplier, std::map< std::string, double > &indexQuantities, std::map< std::string, QuantLib::ext::shared_ptr< QuantExt::FxIndex > > &fxIndices, Real &initialPrice, std::string &assetCurrency, std::string &creditRiskCurrency, std::map< std::string, SimmCreditQualifierMapping > &creditQualifierMapping, Date &maturity, const std::function< QuantLib::ext::shared_ptr< QuantExt::FxIndex >(const QuantLib::ext::shared_ptr< Market > market, const std::string &configuration, const std::string &domestic, const std::string &foreign, std::map< std::string, QuantLib::ext::shared_ptr< QuantExt::FxIndex > > &fxIndices)> &getFxIndex, const std::string &underlyingDerivativeId, RequiredFixings &fixings, std::vector< Leg > &returnLegs) const override
virtual void updateUnderlying(const QuantLib::ext::shared_ptr< ReferenceDataManager > &refData, QuantLib::ext::shared_ptr< Trade > &underlying, const std::string &parentId) const
virtual void build(const std::string &parentId, const QuantLib::ext::shared_ptr< Trade > &underlying, const std::vector< Date > &valuationDates, const std::vector< Date > &paymentDates, const std::string &fundingCurrency, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, QuantLib::ext::shared_ptr< QuantLib::Index > &underlyingIndex, Real &underlyingMultiplier, std::map< std::string, double > &indexQuantities, std::map< std::string, QuantLib::ext::shared_ptr< QuantExt::FxIndex > > &fxIndices, Real &initialPrice, std::string &assetCurrency, std::string &creditRiskCurrency, std::map< std::string, SimmCreditQualifierMapping > &creditQualifierMapping, Date &maturity, const std::function< QuantLib::ext::shared_ptr< QuantExt::FxIndex >(const QuantLib::ext::shared_ptr< Market > market, const std::string &configuration, const std::string &domestic, const std::string &foreign, std::map< std::string, QuantLib::ext::shared_ptr< QuantExt::FxIndex > > &fxIndices)> &getFxIndex, const std::string &underlyingDerivativeId, RequiredFixings &fixings, std::vector< Leg > &returnLegs) const =0