bayesline.api.equity.ReportAccessorApi#

class bayesline.api.equity.ReportAccessorApi#

Abstract base class for report accessor APIs.

This class extends BaseReportAccessorApi with additional abstract methods for getting level values and data from portfolio reports.

__init__()#

Methods

__init__()

get_data(path, *[, expand, pivot_cols, ...])

Get data for the specified path.

get_data_as_task(path, *[, expand, ...])

get_level_values([levels, include_totals, ...])

Get level values for the specified levels.

is_path_valid(path_levels, *[, expand])

Check if a path is valid.

persist(name)

Persist the given report for the given name.

validate_path(path_levels[, expand])

Validate a path and expand tuple.

Attributes

axes

Get the axes configuration for the report.

axis_lookup

Get the axis lookup mapping.

metric_cols

Get the metric column names for the report.

pivot_cols

Get the pivot column names for the report.

abstract get_level_values(levels: tuple[str, ...] = (), include_totals: bool = False, filters: list[tuple[str, str, Any] | Sequence[tuple[str, str, Any]]] | None = None) DataFrame#

Get level values for the specified levels.

Parameters#

levelstuple[str, …], default=()

The levels to get values for.

include_totalsbool, default=False

Whether to include totals in the results.

filtersDNFFilterExpressions | None, default=None

Optional filters to apply.

Returns#

pl.DataFrame

A DataFrame containing the level values.

abstract get_data(path: list[tuple[str, str]], *, expand: tuple[str, ...] = (), pivot_cols: tuple[str, ...] = (), value_cols: tuple[str, ...] = (), filters: list[tuple[str, str, Any] | Sequence[tuple[str, str, Any]]] | None = None, pivot_total: bool = False) DataFrame#

Get data for the specified path.

Parameters#

pathlist[tuple[str, str]]

The path to get data for.

expandtuple[str, …], default=()

The expand tuple for the path.

pivot_colstuple[str, …], default=()

The columns to pivot on.

value_colstuple[str, …], default=()

The value columns.

filtersDNFFilterExpressions | None, default=None

Optional filters to apply.

pivot_totalbool, default=False

Whether to include pivot totals.

Returns#

pl.DataFrame

A DataFrame containing the requested data.

abstract get_data_as_task(path: list[tuple[str, str]], *, expand: tuple[str, ...] = (), pivot_cols: tuple[str, ...] = (), value_cols: tuple[str, ...] = (), filters: list[tuple[str, str, Any] | Sequence[tuple[str, str, Any]]] | None = None, pivot_total: bool = False) Task[DataFrame]#
abstract persist(name: str) int#

Persist the given report for the given name.

Parameters#

namestr

The name to persist the report under. Will throw if the name already exists.

Returns#

int

A globally unique identifier of the persisted report.