Logo
Reference manual - version ored_version
Portfolio Class Reference

Serializable portfolio. More...

#include <ored/portfolio/portfolio.hpp>

Inheritance diagram for Portfolio:

Public Member Functions

 Portfolio (bool buildFailedTrades=true, bool ignoreTradeBuildFail=false)
 Default constructor.
void add (const QuantLib::ext::shared_ptr< Trade > &trade)
 Add a trade to the portfolio.
bool has (const string &id)
 Check if a trade id is already in the portfolio.
QuantLib::ext::shared_ptr< Tradeget (const std::string &id) const
void clear ()
 Clear the portfolio.
void reset ()
 Reset all trade data.
QuantLib::Size size () const
 Portfolio size.
bool empty () const
void fromXML (XMLNode *node) override
 XMLSerializable interface.
XMLNode * toXML (XMLDocument &doc) const override
bool remove (const std::string &tradeID)
 Remove specified trade from the portfolio.
void removeMatured (const QuantLib::Date &asof)
 Remove matured trades from portfolio for a given date, each removal is logged with an Alert.
void setBuildFailedTrades (const bool buildFailed)
 set if trades should build as a FailedTrade if they fail
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.
bool isBuilt () const
 if the portfolio has been built
QuantLib::Date maturity () const
 Calculates the maturity of the portfolio.
const std::map< std::string, QuantLib::ext::shared_ptr< Trade > > & trades () const
 Return the map tradeId -> trade.
std::set< std::string > ids () const
 Build a set of tradeIds.
std::map< std::string, std::string > nettingSetMap () const
 Build a map from trade Ids to NettingSet.
std::set< std::string > counterparties () const
 Build a set of all counterparties in the portfolio.
std::map< std::string, std::set< std::string > > counterpartyNettingSets () const
 Build a map from counterparty to NettingSet.
std::set< std::string > portfolioIds () const
 Compute set of portfolios.
bool hasNettingSetDetails () const
 Check if at least one trade in the portfolio uses the NettingSetDetails node, and not just NettingSetId.
bool buildFailedTrades () const
 Does this portfolio build failed trades?
bool ignoreTradeBuildFail () const
 Keep trade in the portfolio even after build fail.
std::map< std::string, RequiredFixings::FixingDatesfixings (const QuantLib::Date &settlementDate=QuantLib::Date()) const
std::map< AssetClass, std::set< std::string > > underlyingIndices (const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr, const bool useCache=true)
std::set< std::string > underlyingIndices (AssetClass assetClass, const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr, const bool useCache=true)
Public Member Functions inherited from XMLSerializable
void fromFile (const std::string &filename)
void toFile (const std::string &filename) const
void fromXMLString (const std::string &xml)
 Parse from XML string.
std::string toXMLString () const
 Parse from XML string.
std::string toXMLStringUnformatted () const

Detailed Description

Serializable portfolio.

Member Function Documentation

◆ get()

QuantLib::ext::shared_ptr< Trade > get ( const std::string & id) const

Get a Trade with the given id from the portfolio

Remarks
returns a nullptr if no trade found with the given id

◆ fromXML()

void fromXML ( XMLNode * node)
overridevirtual

XMLSerializable interface.

Implements XMLSerializable.

◆ toXML()

XMLNode * toXML ( XMLDocument & doc) const
overridevirtual

Implements XMLSerializable.

◆ fixings()

std::map< std::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.

Warning
This method will return an empty map if the Portfolio has not been built.

◆ underlyingIndices()

std::map< AssetClass, std::set< std::string > > underlyingIndices ( const QuantLib::ext::shared_ptr< ReferenceDataManager > & referenceDataManager = nullptr,
const bool useCache = true )

Returns the names of the underlying instruments for each asset class