Serializable portfolio. More...
#include <ored/portfolio/portfolio.hpp>
Public Member Functions | |
Portfolio (bool buildFailedTrades=true, bool ignoreTradeBuildFail=false) | |
Default constructor. More... | |
void | add (const QuantLib::ext::shared_ptr< Trade > &trade) |
Add a trade to the portfolio. More... | |
bool | has (const string &id) |
Check if a trade id is already in the portfolio. More... | |
QuantLib::ext::shared_ptr< Trade > | get (const std::string &id) const |
void | clear () |
Clear the portfolio. More... | |
void | reset () |
Reset all trade data. More... | |
QuantLib::Size | size () const |
Portfolio size. More... | |
bool | empty () const |
void | fromXML (XMLNode *node) override |
XMLSerializable interface. More... | |
XMLNode * | toXML (XMLDocument &doc) const override |
bool | remove (const std::string &tradeID) |
Remove specified trade from the portfolio. More... | |
void | removeMatured (const QuantLib::Date &asof) |
Remove matured trades from portfolio for a given date, each removal is logged with an Alert. More... | |
void | build (const QuantLib::ext::shared_ptr< EngineFactory > &, const std::string &context="unspecified", const bool emitStructuredError=true) |
Call build on all trades in the portfolio, the context is included in error messages. More... | |
QuantLib::Date | maturity () const |
Calculates the maturity of the portfolio. More... | |
const std::map< std::string, QuantLib::ext::shared_ptr< Trade > > & | trades () const |
Return the map tradeId -> trade. More... | |
std::set< std::string > | ids () const |
Build a set of tradeIds. More... | |
std::map< std::string, std::string > | nettingSetMap () const |
Build a map from trade Ids to NettingSet. More... | |
std::set< std::string > | counterparties () const |
Build a set of all counterparties in the portfolio. More... | |
std::map< std::string, std::set< std::string > > | counterpartyNettingSets () const |
Build a map from counterparty to NettingSet. More... | |
std::set< std::string > | portfolioIds () const |
Compute set of portfolios. More... | |
bool | hasNettingSetDetails () const |
Check if at least one trade in the portfolio uses the NettingSetDetails node, and not just NettingSetId. More... | |
bool | buildFailedTrades () const |
Does this portfolio build failed trades? More... | |
bool | ignoreTradeBuildFail () const |
Keep trade in the portfolio even after build fail. More... | |
std::map< std::string, RequiredFixings::FixingDates > | fixings (const QuantLib::Date &settlementDate=QuantLib::Date()) const |
std::map< AssetClass, std::set< std::string > > | underlyingIndices (const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr) |
std::set< std::string > | underlyingIndices (AssetClass assetClass, const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr) |
Public Member Functions inherited from XMLSerializable | |
virtual | ~XMLSerializable () |
virtual void | fromXML (XMLNode *node)=0 |
virtual XMLNode * | toXML (XMLDocument &doc) const =0 |
void | fromFile (const std::string &filename) |
void | toFile (const std::string &filename) const |
void | fromXMLString (const std::string &xml) |
Parse from XML string. More... | |
std::string | toXMLString () const |
Parse from XML string. More... | |
Private Attributes | |
bool | buildFailedTrades_ |
bool | ignoreTradeBuildFail_ |
std::map< std::string, QuantLib::ext::shared_ptr< Trade > > | trades_ |
std::map< AssetClass, std::set< std::string > > | underlyingIndicesCache_ |
Serializable portfolio.
Definition at line 43 of file portfolio.hpp.
Default constructor.
Definition at line 46 of file portfolio.hpp.
void add | ( | const QuantLib::ext::shared_ptr< Trade > & | trade | ) |
Add a trade to the portfolio.
Definition at line 186 of file portfolio.cpp.
bool has | ( | const string & | id | ) |
Check if a trade id is already in the portfolio.
Definition at line 192 of file portfolio.cpp.
QuantLib::ext::shared_ptr< Trade > get | ( | const std::string & | id | ) | const |
Get a Trade with the given id
from the portfolio
nullptr
if no trade found with the given id
Definition at line 194 of file portfolio.cpp.
void clear | ( | ) |
Clear the portfolio.
Definition at line 39 of file portfolio.cpp.
void reset | ( | ) |
QuantLib::Size size | ( | ) | const |
Portfolio size.
Definition at line 68 of file portfolio.hpp.
bool empty | ( | ) | const |
Definition at line 70 of file portfolio.hpp.
|
overridevirtual |
XMLSerializable interface.
Implements XMLSerializable.
Definition at line 50 of file portfolio.cpp.
|
overridevirtual |
Implements XMLSerializable.
Definition at line 99 of file portfolio.cpp.
bool remove | ( | const std::string & | tradeID | ) |
Remove specified trade from the portfolio.
Definition at line 106 of file portfolio.cpp.
void removeMatured | ( | const QuantLib::Date & | asof | ) |
Remove matured trades from portfolio for a given date, each removal is logged with an Alert.
Definition at line 111 of file portfolio.cpp.
void build | ( | const QuantLib::ext::shared_ptr< EngineFactory > & | engineFactory, |
const std::string & | context = "unspecified" , |
||
const bool | emitStructuredError = true |
||
) |
Call build on all trades in the portfolio, the context is included in error messages.
Definition at line 122 of file portfolio.cpp.
Date maturity | ( | ) | const |
Calculates the maturity of the portfolio.
Definition at line 147 of file portfolio.cpp.
const std::map< std::string, QuantLib::ext::shared_ptr< Trade > > & trades | ( | ) | const |
Return the map tradeId -> trade.
Definition at line 162 of file portfolio.cpp.
set< string > ids | ( | ) | const |
Build a set of tradeIds.
Definition at line 155 of file portfolio.cpp.
map< string, string > nettingSetMap | ( | ) | const |
Build a map from trade Ids to NettingSet.
Definition at line 164 of file portfolio.cpp.
std::set< std::string > counterparties | ( | ) | const |
Build a set of all counterparties in the portfolio.
Definition at line 171 of file portfolio.cpp.
map< string, set< string > > counterpartyNettingSets | ( | ) | const |
Build a map from counterparty to NettingSet.
Definition at line 178 of file portfolio.cpp.
std::set< std::string > portfolioIds | ( | ) | const |
Compute set of portfolios.
Definition at line 202 of file portfolio.cpp.
bool hasNettingSetDetails | ( | ) | const |
Check if at least one trade in the portfolio uses the NettingSetDetails node, and not just NettingSetId.
Definition at line 210 of file portfolio.cpp.
bool buildFailedTrades | ( | ) | const |
Does this portfolio build failed trades?
Definition at line 111 of file portfolio.hpp.
bool ignoreTradeBuildFail | ( | ) | const |
Keep trade in the portfolio even after build fail.
Definition at line 114 of file portfolio.hpp.
map< string, RequiredFixings::FixingDates > fixings | ( | const QuantLib::Date & | settlementDate = QuantLib::Date() | ) | const |
Return the fixings that will be requested in order to price every Trade in this Portfolio given the settlementDate
. The map key is the ORE name of the index and the map value is the set of fixing dates.
Definition at line 220 of file portfolio.cpp.
std::map< AssetClass, std::set< std::string > > underlyingIndices | ( | const QuantLib::ext::shared_ptr< ReferenceDataManager > & | referenceDataManager = nullptr | ) |
Returns the names of the underlying instruments for each asset class
Definition at line 234 of file portfolio.cpp.
std::set< std::string > underlyingIndices | ( | AssetClass | assetClass, |
const QuantLib::ext::shared_ptr< ReferenceDataManager > & | referenceDataManager = nullptr |
||
) |
Definition at line 258 of file portfolio.cpp.
|
private |
Definition at line 132 of file portfolio.hpp.
|
private |
Definition at line 132 of file portfolio.hpp.
|
private |
Definition at line 133 of file portfolio.hpp.
|
private |
Definition at line 134 of file portfolio.hpp.