bayesline.api.equity.AsyncUniverseImpl#
- class bayesline.api.equity.AsyncUniverseImpl(settings: DatasetAwareSettings[UniverseSettings], report_loader: AsyncReportLoaderApi) None#
- __init__(settings: DatasetAwareSettings[UniverseSettings], report_loader: AsyncReportLoaderApi) None#
Methods
__init__(settings, report_loader)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
Get the dataset used to create this universe.
Get the supported ID types for this universe.
Get the settings used to create this universe.
- __init__(settings: DatasetAwareSettings[UniverseSettings], report_loader: AsyncReportLoaderApi) None#
- property dataset: str#
Get the dataset used to create this universe.
Returns#
- str
The dataset used to create this universe.
- property settings: UniverseSettings#
Get the settings used to create this universe.
Returns#
- UniverseSettings
The settings used to create this universe.
- property id_types: list[str]#
Get the supported ID types for this universe.
Returns#
- list[IdType]
Supported ID types for this universe.
- async coverage(id_type: str | 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.
- 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.
- 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.
- async counts_as_task(dates: bool = True, categorical_hierarchy_levels: dict[str, int] | None = None, labels: bool = True) AsyncTask[DataFrame]#
- async get(*, start: str | date | datetime | None = None, end: str | date | datetime | None = None, id_type: str | 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.