bayesline.api.equity.ExposureApi#

class bayesline.api.equity.ExposureApi#

Abstract base class for exposure API operations.

__init__()#

Methods

__init__()

coverage_stats(universe, *[, id_type, by])

Get coverage statistics for the exposure data.

coverage_stats_as_task(universe, *[, ...])

Get coverage statistics as a task.

dates(universe, *[, range_only])

Get the dates covered by the exposure data.

get(universe, *, standardize_universe[, ...])

Get exposure data for the specified universe and date range.

get_as_task(universe, *, standardize_universe)

Get exposure data as a task.

Attributes

settings

Get the settings used to create these exposures.

abstract property settings: ExposureSettings#

Get the settings used to create these exposures.

Returns#

ExposureSettings

The settings used to create these exposures.

abstract dates(universe: str | int | UniverseSettings | UniverseApi, *, range_only: bool = False) list[date]#

Get the dates covered by the exposure data.

Parameters#

universestr | int | UniverseSettings | UniverseApi

The universe to use for the exposure calculation.

range_onlybool, default=False

If True, returns the first and last date only.

Returns#

list[dt.date]

List of all covered dates.

abstract coverage_stats(universe: str | int | UniverseSettings | UniverseApi, *, id_type: Literal['bayesid', 'bayesid_core', 'ticker', 'composite_figi', 'cik', 'cusip8', 'cusip9', 'isin', 'sedol6', 'sedol7', 'proxy', 'name'] | None = None, by: Literal['date', 'asset'] = 'date') DataFrame#

Get coverage statistics for the exposure data.

Parameters#

universestr | int | UniverseSettings | UniverseApi

The universe to use for the exposure calculation.

id_typeIdType | None, default=None

The id type to return asset ids in, e.g. ticker. The given id type must be supported by the linked universe.

byLiteral[“date”, “asset”], default=”date”

The aggregation, either by date or by asset.

Returns#

pl.DataFrame

A dataframe with date as the first column, where the remaining columns names are the styles and substyles (concatenated with a dot). The values are the counts of the underlying data before it was imputed.

abstract coverage_stats_as_task(universe: str | int | UniverseSettings | UniverseApi, *, id_type: Literal['bayesid', 'bayesid_core', 'ticker', 'composite_figi', 'cik', 'cusip8', 'cusip9', 'isin', 'sedol6', 'sedol7', 'proxy', 'name'] | None = None, by: Literal['date', 'asset'] = 'date') Task[DataFrame]#

Get coverage statistics as a task.

Parameters#

universestr | int | UniverseSettings | UniverseApi

The universe to use for the exposure calculation.

id_typeIdType | None, default=None

The id type to return asset ids in, e.g. ticker. The given id type must be supported by the linked universe.

byLiteral[“date”, “asset”], default=”date”

The aggregation, either by date or by asset.

Returns#

Task[pl.DataFrame]

A task that returns coverage statistics.

abstract get(universe: str | int | UniverseSettings | UniverseApi, *, standardize_universe: str | int | UniverseSettings | UniverseApi | None, 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 exposure data for the specified universe and date range.

Parameters#

universestr | int | UniverseSettings | UniverseApi

The universe to use for the exposure calculation.

standardize_universestr | int | UniverseSettings | UniverseApi | None

The universe to use for the standardization of the exposure data. If None, the standardization is uses the entire universe.

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 by the linked universe.

filter_tradedaysbool, default=False

If True, only returns data for tradedays.

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 with a where the date is the first column and the asset id is the second column. The remaining columns are the individual styles.

abstract get_as_task(universe: str | int | UniverseSettings | UniverseApi, *, standardize_universe: str | int | UniverseSettings | UniverseApi | None, 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) Task[DataFrame]#

Get exposure data as a task.

Parameters#

universestr | int | UniverseSettings | UniverseApi

The universe to use for the exposure calculation.

standardize_universestr | int | UniverseSettings | UniverseApi | None

The universe to use for the standardization of the exposure data. If None, the standardization is uses the entire universe.

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 by the linked universe.

filter_tradedaysbool, default=False

If True, only returns data for tradedays.

Returns#

Task[pl.DataFrame]

A task that returns exposure data.