bayesline.api.equity.ModelConstructionSettings

bayesline.api.equity.ModelConstructionSettings#

model ModelConstructionSettings#

Defines settings to build a factor risk model.

Fields#

Field

Type

Required

Default

currency

str

No

'USD'

estimation_universe

str | int | UniverseSettings | None

No

None

fx_convert_returns

bool

No

True

known_factor_map

Mapping[tuple[str, str], str]

No

factory

return_clip_bounds

tuple[Annotated[float, Le(le=0)] | None, Annotated[float, Ge(ge=0)] | None]

No

(-0.1, 0.1)

thin_category_shrinkage

Mapping[str, Annotated[float, Ge(ge=0)]]

No

factory

thin_category_shrinkage_overrides

Mapping[tuple[str, str], Annotated[float, Ge(ge=0)]]

No

factory

weights

Literal[‘SqrtCap’, ‘InvIdioVar’, ‘Cap’]

No

'SqrtCap'

zero_sum_constraints

Mapping[str, Literal[‘none’, ‘equal_weights’, ‘mcap_weighted’]]

No

factory

Validators#

Validator

Mode

Fields

check_valid_weights

after

weights

field currency: str [Optional]#

The currency of the factor risk model.

field estimation_universe: str | int | UniverseSettings | None [Optional]#

The universe settings to use for the estimation universe.

field fx_convert_returns: bool [Optional]#

Whether to convert the asset returns to the currency of the factor model.

field known_factor_map: Mapping[tuple[str, str], str] [Optional]#

A mapping from tuple of factor groups and factor names (labels) to known series. These factors will have fixed returns derived from the series.

field return_clip_bounds: tuple[Annotated[float, Le(le=0)] | None, Annotated[float, Ge(ge=0)] | None] [Optional]#

The bounds for the return clipping.

field thin_category_shrinkage: Mapping[str, Annotated[float, Ge(ge=0)]] [Optional]#

Minimum effective number of assets (n_eff) for categorical factor groups. Factors with n_eff below this threshold get L2 shrinkage toward zero, with strength proportional to (threshold - n_eff). n_eff is the inverse HHI of regression-weight-scaled exposures. Keys are factor group names, values are n_eff thresholds. Interaction groups automatically inherit the threshold from their categorical parent component.

field thin_category_shrinkage_overrides: Mapping[tuple[str, str], Annotated[float, Ge(ge=0)]] [Optional]#

The shrinkage strength override for the factor risk model. The keys are the tuples of (categorical) factor groups and factor names and the values are the shrinkage penalty overrides.

field weights: Literal['SqrtCap', 'InvIdioVar', 'Cap'] [Optional]#

The regression weights used for the factor risk model.

Validated by:

check_valid_weights

field zero_sum_constraints: Mapping[str, Literal['none', 'equal_weights', 'mcap_weighted']] [Optional]#

Whether to apply a zero-sum constraint to the categorical exposures. If the category exposures are exhaustive and sum to one, then implicitly a dummy variable trap is present. This can be avoided by creating a constraint on the factor returns. This means the interpretation of the categorical factor returns is ‘in excess of’ the market. If ‘none’, no constraint is applied (for example if we do not have a market factor). If ‘equal_weights’ or ‘mcap_weighted’, then the categorical factor returns are constrained to sum to zero, either market-cap weighted or not. For all categorical factor groups, a value must be provided.

validator check_valid_weights(mode=after)#
Validates:

weights