bayesline.api.equity.AsyncPortfolioReturnsReportAccessor#
- class bayesline.api.equity.AsyncPortfolioReturnsReportAccessor(accessor: AsyncReportAccessorApi)#
Specific accessor for a portfolio returns report.
- abstract __init__(accessor: AsyncReportAccessorApi)#
Methods
__init__(accessor)get_asset_returns(portfolio_id[, ...])Get the asset level returns for the portfolio id between start and end dates.
get_portfolio_returns([portfolio_names, ...])Get the portfolio returns for the portfolio names between start and end dates.
with_scenario(scenario_settings)Return a new accessor with the given scenario settings applied.
Attributes
accessorThe underlying report accessor API.
- scenario_types: ClassVar[list[type[AnyScenarioSettings]]] = [<class 'bayesline.api._src.equity.report.scenarios.PortfolioHoldingsScenario'>]#
- abstract async get_portfolio_returns(portfolio_names: list[str] | None = None, start_date: str | date | datetime | None = None, end_date: str | date | datetime | None = None, aggregation_type: Literal['D', 'M', 'Y'] | None = 'D', value_cols: list[str] | None = None) DataFrame#
Get the portfolio returns for the portfolio names between start and end dates.
Parameters#
- portfolio_nameslist[str] | None, default=None
The names of the portfolios to calculate the report for. If None, all portfolios will be calculated.
- start_dateDateLike | None, default=None
The start date of the report.
- end_dateDateLike | None, default=None
The end date of the report.
- aggregation_typeLiteral[“D”, “M”, “Y”] | None, default=”D”
The aggregation type to use for the returns. If None, dates will be completely collapsed and the returns for the entire period will be returned.
- value_colslist[str] | None, default=None
The value columns to return. If None, all value columns will be returned.
Returns#
- pl.DataFrame
A dataframe with the portfolio returns.
- abstract async get_asset_returns(portfolio_id: str, start_date: str | date | datetime | None = None, end_date: str | date | datetime | None = None, aggregation_type: Literal['D', 'M', 'Y'] | None = 'D', value_cols: list[str] | None = None) DataFrame#
Get the asset level returns for the portfolio id between start and end dates.
Parameters#
- portfolio_idstr
The id of the portfolio to calculate the report for.
- start_dateDateLike | None, default=None
The start date of the report.
- end_dateDateLike | None, default=None
The end date of the report.
- aggregation_typeLiteral[“D”, “M”, “Y”] | None, default=”D”
The aggregation type to use for the returns. If None, dates will be completely collapsed and the returns for the entire period will be returned.
- value_colslist[str] | None, default=None
The value columns to return. If None, all value columns will be returned.
Returns#
- pl.DataFrame
A dataframe with the asset level returns.