bayesline.api.equity.AsyncUniverseApi#

class bayesline.api.equity.AsyncUniverseApi#

Provide access to universe data and operations.

A universe represents a filtered set of assets with specific properties.

__init__()#

Methods

__init__()

counts([dates, ...])

Get universe counts with optional grouping and aggregation.

counts_as_task([dates, ...])

coverage([id_type])

Get the list of all asset IDs this universe covers.

coverage_as_task([id_type])

dates(*[, range_only, trade_only])

Get the list of all dates this universe covers.

get(*[, start, end, id_type, filter_tradedays])

Get universe data for a specific date range.

get_as_task(*[, start, end, id_type, ...])

Attributes

id_types

Get the supported ID types for this universe.

settings

Get the settings used to create this universe.

abstract property settings: UniverseSettings#

Get the settings used to create this universe.

Returns#

UniverseSettings

The settings used to create this universe.

abstract property id_types: list[Literal['bayesid', 'bayesid_core', 'ticker', 'composite_figi', 'cik', 'cusip8', 'cusip9', 'isin', 'sedol6', 'sedol7', 'proxy', 'name']]#

Get the supported ID types for this universe.

Returns#

list[IdType]

Supported ID types for this universe.

abstract async coverage(id_type: Literal['bayesid', 'bayesid_core', 'ticker', 'composite_figi', 'cik', 'cusip8', 'cusip9', 'isin', 'sedol6', 'sedol7', 'proxy', 'name'] | None = None) list[str]#

Get the list of all asset IDs this universe covers.

Parameters#

id_typeIdType | None, default=None

The ID type to return asset IDs in, e.g. ticker.

Raises#

ValueError

If the given ID type is not supported.

Returns#

list[str]

List of all asset IDs this universe covers, in the given ID type.

abstract async coverage_as_task(id_type: Literal['bayesid', 'bayesid_core', 'ticker', 'composite_figi', 'cik', 'cusip8', 'cusip9', 'isin', 'sedol6', 'sedol7', 'proxy', 'name'] | None = None) AsyncTask[list[str]]#
abstract async dates(*, range_only: bool = False, trade_only: bool = False) list[date]#

Get the list of all dates this universe covers.

Parameters#

range_onlybool, default=False

If True, returns the first and last date only.

trade_onlybool, default=False

If True, filter down the dates to trade dates only.

Returns#

list[dt.date]

List of all dates this universe covers.

abstract async counts(dates: bool = True, categorical_hierarchy_levels: dict[str, int] | None = None, labels: bool = True) DataFrame#

Get universe counts with optional grouping and aggregation.

Parameters#

datesbool, default=True

If True, groups by dates.

categorical_hierarchy_levelsdict[str, int] | None, default=None

The level of categorical aggregation to group by. The key is the hierarchy name, the value is the level. If None, no categorical aggregation is done. A level of -1 means to use all levels.

labelsbool, default=True

If True, return labels for the counts, otherwise use the codes.

Returns#

pl.DataFrame

Universe counts. If grouped by dates then the count will be given. If not grouped by dates then the mean/min/max across all dates will be given.

abstract async counts_as_task(dates: bool = True, categorical_hierarchy_levels: dict[str, int] | None = None, labels: bool = True) AsyncTask[DataFrame]#
abstract async get(*, start: str | date | datetime | None = None, end: str | date | datetime | None = None, id_type: Literal['bayesid', 'bayesid_core', 'ticker', 'composite_figi', 'cik', 'cusip8', 'cusip9', 'isin', 'sedol6', 'sedol7', 'proxy', 'name'] | None = None, filter_tradedays: bool = False) DataFrame#

Get universe data for a specific date range.

Parameters#

startDateLike | None, default=None

The start date of the universe to return, inclusive.

endDateLike | None, default=None

The end date of the data to return, inclusive.

id_typeIdType | None, default=None

The ID type to return asset IDs in, e.g. ticker. The given ID type must be supported, i.e. in id_types.

filter_tradedaysbool, default=False

If True, filter down the data to trade dates only.

Raises#

ValueError

If the given ID type is not supported or date range is invalid.

Returns#

pl.DataFrame

The data for the given date range.

abstract async get_as_task(*, start: str | date | datetime | None = None, end: str | date | datetime | None = None, id_type: Literal['bayesid', 'bayesid_core', 'ticker', 'composite_figi', 'cik', 'cusip8', 'cusip9', 'isin', 'sedol6', 'sedol7', 'proxy', 'name'] | None = None, filter_tradedays: bool = False) AsyncTask[DataFrame]#