Logo
Reference manual - version ored_version
Public Member Functions | List of all members
Portfolio Class Reference

Serializable portfolio. More...

#include <ored/portfolio/portfolio.hpp>

+ Inheritance diagram for Portfolio:

Public Member Functions

 Portfolio (bool buildFailedTrades=true)
 Default constructor.
 
void add (const boost::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.
 
boost::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.
 
XMLNodetoXML (XMLDocument &doc) 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 build (const boost::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.
 
QuantLib::Date maturity () const
 Calculates the maturity of the portfolio.
 
const std::map< std::string, boost::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?
 
std::map< std::string, std::set< QuantLib::Date > > fixings (const QuantLib::Date &settlementDate=QuantLib::Date()) const
 
std::map< AssetClass, std::set< std::string > > underlyingIndices (const boost::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr)
 
std::set< std::string > underlyingIndices (AssetClass assetClass, const boost::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr)
 
- Public Member Functions inherited from XMLSerializable
void fromFile (const std::string &filename)
 
void toFile (const std::string &filename)
 
void fromXMLString (const std::string &xml)
 Parse from XML string.
 
std::string toXMLString ()
 Parse from XML string.
 

Detailed Description

Serializable portfolio.

Member Function Documentation

◆ get()

boost::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

◆ fixings()

std::map<std::string, std::set<QuantLib::Date> > 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 boost::shared_ptr< ReferenceDataManager > &  referenceDataManager = nullptr)

Returns the names of the underlying instruments for each asset class