bayesline.api.equity.PortfolioHierarchySettings

bayesline.api.equity.PortfolioHierarchySettings#

model PortfolioHierarchySettings#

Specifies portfolio hierarchies with arbitrary groupings (e.g. manager, etc.).

Fields#

Field

Type

Required

Default

Constraints

auto_decompose_levels

list[str] | None

No

None

max_length=100

benchmark_ids

list[str | None]

Yes

groupings

dict[str, dict[str, str]]

No

factory

portfolio_ids

list[str]

Yes

portfolio_schema

str | int | PortfolioOrganizerSettings

Yes

field auto_decompose_levels: list[str] | None [Optional]#

When provided, each portfolio_id that is a FoF parent is automatically expanded at load time into one entry per descendant path (parent:child:...:leaf) plus a parent_path:{REST} entry at each non-leaf level capturing what wasn’t decomposed there. Path-typed inputs (containing :) are left unchanged for idempotence. Only len(auto_decompose_levels) is meaningful — it sets the maximum recursion depth; the cascade emits exactly that many system grouping columns named bayesline/level_N, and the element values themselves are not consumed. Deeper branches stop expanding and are emitted as bare leaves (no :{REST} sibling is added below a truncated node for its own un-emitted children); NAV is still conserved because the lookthrough math at query time descends through the full subtree. So auto_decompose_levels=['fund', 'strategy'] decomposes up to two levels and emits bayesline/level_1 and bayesline/level_2 columns in groupings carrying the parent ids at each level; a row whose path is shorter than that carries an empty string at the tiers it does not reach. Compatible with hand-rolled groupings: their label maps are resolved onto the expanded rows, residual entries included. None disables auto-decompose; an empty list is rejected. Capped at 100 to keep recursion well below Python’s default limit; real FoF hierarchies rarely exceed a handful of levels.

Constraints:
  • max_length = 100

field benchmark_ids: list[str | None] [Required]#
field groupings: dict[str, dict[str, str]] [Optional]#

Per-fund grouping labels keyed by grouping name, as {grouping: {portfolio_id: label}}. Keys may be bare portfolio ids ('P4') or :-qualified subpaths ('P3:P4') that label a fund only where it appears under that parent chain. A fund’s label also applies to everything held inside it: when several keys apply to a row, the outermost labeled fund wins, and among keys for that fund the most qualified one wins. Empty-string labels are treated as unset, except on a key equal to a full row id, which explicitly leaves that row unlabeled. The legacy positional form ({grouping: [one label per portfolio_ids entry]}) is also accepted.

field portfolio_ids: list[str] [Required]#
field portfolio_schema: str | int | PortfolioOrganizerSettings [Required]#

The portfolio organizer settings to use as an underlying schema of portfolios. The ‘Default’ schema is used by default.