26#include <boost/make_shared.hpp>
27#include <ql/shared_ptr.hpp>
30#include <ql/time/date.hpp>
31#include <ql/types.hpp>
37class ReferenceDataManager;
50 void add(
const QuantLib::ext::shared_ptr<Trade>& trade);
53 bool has(
const string&
id);
59 QuantLib::ext::shared_ptr<Trade>
get(
const std::string&
id)
const;
77 bool remove(
const std::string& tradeID);
83 void build(
const QuantLib::ext::shared_ptr<EngineFactory>&,
const std::string& context =
"unspecified",
84 const bool emitStructuredError =
true);
90 const std::map<std::string, QuantLib::ext::shared_ptr<Trade>>&
trades()
const;
93 std::set<std::string>
ids()
const;
121 std::map<std::string, RequiredFixings::FixingDates>
122 fixings(
const QuantLib::Date& settlementDate = QuantLib::Date())
const;
125 std::map<AssetClass, std::set<std::string>>
126 underlyingIndices(
const QuantLib::ext::shared_ptr<ReferenceDataManager>& referenceDataManager =
nullptr);
127 std::set<std::string>
129 const QuantLib::ext::shared_ptr<ReferenceDataManager>& referenceDataManager =
nullptr);
133 std::map<std::string, QuantLib::ext::shared_ptr<Trade>>
trades_;
137std::pair<QuantLib::ext::shared_ptr<Trade>,
bool>
buildTrade(
138 QuantLib::ext::shared_ptr<Trade>& trade,
139 const QuantLib::ext::shared_ptr<EngineFactory>& engineFactory,
140 const std::string& context,
const bool ignoreTradeBuildFail,
141 const bool buildFailedTrades,
const bool emitStructuredError);
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 > counterparties() const
Build a set of all counterparties in the portfolio.
void add(const QuantLib::ext::shared_ptr< Trade > &trade)
Add a trade to the portfolio.
std::map< std::string, RequiredFixings::FixingDates > fixings(const QuantLib::Date &settlementDate=QuantLib::Date()) const
bool ignoreTradeBuildFail_
QuantLib::Size size() const
Portfolio size.
void removeMatured(const QuantLib::Date &asof)
Remove matured trades from portfolio for a given date, each removal is logged with an Alert.
std::map< std::string, QuantLib::ext::shared_ptr< Trade > > trades_
std::map< std::string, std::string > nettingSetMap() const
Build a map from trade Ids to NettingSet.
bool ignoreTradeBuildFail() const
Keep trade in the portfolio even after build fail.
void fromXML(XMLNode *node) override
XMLSerializable interface.
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.
std::set< std::string > portfolioIds() const
Compute set of portfolios.
XMLNode * toXML(XMLDocument &doc) const override
std::map< AssetClass, std::set< std::string > > underlyingIndices(const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr)
bool hasNettingSetDetails() const
Check if at least one trade in the portfolio uses the NettingSetDetails node, and not just NettingSet...
bool remove(const std::string &tradeID)
Remove specified trade from the portfolio.
bool buildFailedTrades() const
Does this portfolio build failed trades?
std::map< AssetClass, std::set< std::string > > underlyingIndicesCache_
Portfolio(bool buildFailedTrades=true, bool ignoreTradeBuildFail=false)
Default constructor.
void clear()
Clear the portfolio.
void reset()
Reset all trade data.
std::map< std::string, std::set< std::string > > counterpartyNettingSets() const
Build a map from counterparty to NettingSet.
bool has(const string &id)
Check if a trade id is already in the portfolio.
QuantLib::ext::shared_ptr< Trade > get(const std::string &id) const
std::set< std::string > ids() const
Build a set of tradeIds.
Small XML Document wrapper class.
Base class for all serializable classes.
std::pair< QuantLib::ext::shared_ptr< Trade >, bool > buildTrade(QuantLib::ext::shared_ptr< Trade > &trade, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, const std::string &context, const bool ignoreTradeBuildFail, const bool buildFailedTrades, const bool emitStructuredError)
Serializable Credit Default Swap.