Portfolio Service#

Portfolio Service for loading portfolio and benchmark weight files.

Orchestrates the loading of portfolio weight files through a sequence of input handlers (CSV, Excel), returning a raw PyArrow table.

class PortfolioService[source]#

Bases: object

Loads portfolio/benchmark weight files using available input handlers.

static load_portfolio(portfolio_handlers: list[PortfolioInputHandlerInterface], file_name: str, start_date: date | Literal['auto'] | None = None, end_date: date | Literal['auto'] | None = None) → Table[source]#

Load a portfolio/benchmark weights file using the first handler able to read it.

Parameters:
  • portfolio_handlers (list[PortfolioInputHandlerInterface]) – Input handlers to try, in order, until one succeeds.

  • file_name (str) – File name (without extension) of the portfolio/benchmark weights file to load.

  • start_date (datetime.date or {"auto"} or None, optional) – Configured start of the analysis period, typically Configuration.start_date. When given (and not "auto"), the loaded table’s dates must include at least one date on or after start_date. Checked immediately after this (cheap) file loads, so a misconfigured date fails fast instead of after the heavier market data/factor files are loaded.

  • end_date (datetime.date or {"auto"} or None, optional) – Configured end of the analysis period, checked the same way as start_date.

Returns:

The raw table returned by the successful handler.

Return type:

pa.Table

Raises:
  • MissingPortfolioError – If every handler in portfolio_handlers fails to load file_name.

  • DateRangeError – If start_date/end_date don’t overlap any date in the loaded table.