bayesline.api.equity.AsyncRiskDatasetLoaderApi#

class bayesline.api.equity.AsyncRiskDatasetLoaderApi#

API for loading and managing risk datasets.

This class provides functionality for loading, creating, and managing risk datasets through a registry-based approach.

__init__()#

Methods

__init__()

create_dataset(name, settings)

Create a new dataset with the given name and settings.

create_dataset_as_task(name, settings)

create_or_replace_dataset(name, settings)

Create a new dataset or replace an existing one.

delete_dataset(name)

Delete the given dataset.

delete_dataset_if_exists(name)

Delete the given dataset if it exists.

get_dataset_names(*[, mode])

Get the names of all available datasets.

get_default_dataset_name()

Get the default dataset name.

list_riskdatasets([name, df])

List all available risk datasets.

load(ref_or_settings, *args, **kwargs)

Load an API instance from settings or reference.

Attributes

settings

Get the settings registry.

abstract async get_default_dataset_name() str#

Get the default dataset name.

Returns#

str

The default dataset name that will be populated into settings if no dataset name is provided.

abstract async get_dataset_names(*, mode: Literal['System', 'User'] | None = None) dict[str, Literal['ready', 'data_stale', 'needs_update', 'not_ready', 'corrupt']]#

Get the names of all available datasets.

Parameters#

modeLiteral[“System”, “User”] | None, default=None

System: only system wide datasets (available to all users and provided by the system). User: only user specific datasets (available to the current user). None: all datasets (system wide and user specific).

Returns#

dict[str, DatasetStatus]

The names of all available datasets and their status. “ready” means the dataset is ready to use. “data_stale” means the dataset is ready to use but newer data is available. “needs_update” means local data needs to be computed/updated. “not_ready” means the reference dataset is not in a usable state. “corrupt” means the underlying settings are corrupted and need to be repaired.

abstract async list_riskdatasets(name: str | None = None, *, df: bool = False) list[RiskDatasetMetadata] | DataFrame#

List all available risk datasets.

Parameters#

namestr | None, default=None

The name of the dataset to filter by. If not given, all datasets are returned.

dfbool, default=False

If True, return a polars DataFrame instead of a list of metadata objects.

Returns#

list[RiskDatasetMetadata] | pl.DataFrame

The metadata of all available datasets, either as a list of objects or as a DataFrame depending on the df parameter.

async create_or_replace_dataset(name: str, settings: RiskDatasetSettings) AsyncRiskDatasetApi#

Create a new dataset or replace an existing one.

Parameters#

namestr

The name of the dataset to create or replace.

settingsRiskDatasetSettings

The settings for the dataset.

Returns#

AsyncRiskDatasetApi

The API for the created or replaced dataset.

abstract async create_dataset(name: str, settings: RiskDatasetSettings) AsyncRiskDatasetApi#

Create a new dataset with the given name and settings.

Parameters#

namestr

The name of the dataset to create.

settingsRiskDatasetSettings

The settings for the dataset to create.

Raises#

DatasetError

If a dataset with the given name already exists or if the settings are otherwise invalid.

Returns#

AsyncRiskDatasetApi

The API of the newly created dataset.

abstract async create_dataset_as_task(name: str, settings: RiskDatasetSettings) AsyncTask[AsyncRiskDatasetApi]#
abstract async delete_dataset(name: str) RawSettings#

Delete the given dataset.

Parameters#

namestr

The name of the dataset to delete.

Raises#

KeyError

If the dataset does not exist.

DatasetError

If the dataset could not be deleted.

Returns#

RawSettings

The raw settings of the deleted dataset.

async delete_dataset_if_exists(name: str) RawSettings | None#

Delete the given dataset if it exists.

Parameters#

namestr

The name of the dataset to delete.

Raises#

DatasetError

If the dataset could not be deleted.

Returns#

RawSettings | None

The raw settings of the deleted dataset if dataset existed.