bayesline.api.equity.PortfolioHierarchyApi#

class bayesline.api.equity.PortfolioHierarchyApi#

Abstract base class for portfolio hierarchy APIs.

This class defines the interface for portfolio hierarchy APIs that provide access to portfolio hierarchy data and metadata.

__init__()#

Methods

__init__()

get(start_date, end_date[, id_type])

Get portfolio hierarchy data for the specified date range.

get_as_task(start_date, end_date[, id_type])

get_dates(*[, collapse])

Get the available dates for each portfolio.

get_id_types()

Get the available ID types for each portfolio.

Attributes

settings

Get the settings used to create this hierarchy.

abstract property settings: PortfolioHierarchySettings#

Get the settings used to create this hierarchy.

Returns#

PortfolioHierarchySettings

The settings used to create this hierarchy.

abstract get_id_types() dict[str, list[Literal['bayesid', 'bayesid_core', 'ticker', 'composite_figi', 'cik', 'cusip8', 'cusip9', 'isin', 'sedol6', 'sedol7', 'proxy', 'name']]]#

Get the available ID types for each portfolio.

Returns#

dict[str, list[IdType]]

The available ID types that at least a portion of assets can be mapped to for each portfolio. If a portfolio has a benchmark then the available id types are those that are available for both the portfolio and the benchmark.

abstract get_dates(*, collapse: bool = False) dict[str, list[date]]#

Get the available dates for each portfolio.

Parameters#

collapsebool, default=False

If True, will calculate aggregations any and all, indicating of for a given date, any (or all) portfolios have holdings.

Returns#

dict[str, list[dt.date]]

A dict of portfolio-id to dates for which this hierarchy can be produced. For a given portfolio and date, the hierarchy can be produced if the portfolio has holdings for that date. If a benchmark is given then this benchmark also must have holdings for the given date.

abstract get(start_date: str | date | datetime | None, end_date: str | date | datetime | None, id_type: Literal['bayesid', 'bayesid_core', 'ticker', 'composite_figi', 'cik', 'cusip8', 'cusip9', 'isin', 'sedol6', 'sedol7', 'proxy', 'name'] | None = None) DataFrame#

Get portfolio hierarchy data for the specified date range.

Parameters#

start_dateDateLike | None

The start date for the data.

end_dateDateLike | None

The end date for the data.

id_typeIdType | None, default=None

The ID type to use for the data.

Returns#

pl.DataFrame

The portfolio hierarchy data.

abstract get_as_task(start_date: str | date | datetime | None, end_date: str | date | datetime | None, id_type: Literal['bayesid', 'bayesid_core', 'ticker', 'composite_figi', 'cik', 'cusip8', 'cusip9', 'isin', 'sedol6', 'sedol7', 'proxy', 'name'] | None = None) Task[DataFrame]#