bayesline.api.equity.ModelConstructionSettings#

pydantic model bayesline.api.equity.ModelConstructionSettings#

Defines settings to build a factor risk model.

Show JSON schema
{
   "title": "ModelConstructionSettings",
   "description": "Defines settings to build a factor risk model.",
   "type": "object",
   "properties": {
      "currency": {
         "default": "USD",
         "description": "The currency of the factor risk model.",
         "examples": [
            "USD",
            "EUR"
         ],
         "title": "Currency",
         "type": "string"
      },
      "weights": {
         "default": "SqrtCap",
         "description": "The regression weights used for the factor risk model.",
         "enum": [
            "SqrtCap",
            "InvIdioVar"
         ],
         "examples": [
            "SqrtCap",
            "InvIdioVar"
         ],
         "title": "Weights",
         "type": "string"
      },
      "return_clip_bounds": {
         "default": [
            -0.1,
            0.1
         ],
         "description": "The bounds for the return clipping.",
         "examples": [
            [
               -0.1,
               0.1
            ],
            [
               null,
               null
            ]
         ],
         "maxItems": 2,
         "minItems": 2,
         "prefixItems": [
            {
               "anyOf": [
                  {
                     "maximum": 0,
                     "type": "number"
                  },
                  {
                     "type": "null"
                  }
               ]
            },
            {
               "anyOf": [
                  {
                     "minimum": 0,
                     "type": "number"
                  },
                  {
                     "type": "null"
                  }
               ]
            }
         ],
         "title": "Return Clip Bounds",
         "type": "array"
      },
      "thin_category_shrinkage": {
         "additionalProperties": {
            "minimum": 0,
            "type": "number"
         },
         "description": "The ridge-shrinkage penalty for categorical factors with the than 10 assets with strictly positive exposure. Interpolation is used to scale the shrinkage strength (for zero assets) to 0.0 (for 10 assets). The keys are the (categorical) factor groups and the values are the shrinkage penalty.",
         "title": "Thin Category Shrinkage",
         "type": "object"
      },
      "thin_category_shrinkage_overrides": {
         "additionalProperties": {
            "minimum": 0,
            "type": "number"
         },
         "description": "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.",
         "title": "Thin Category Shrinkage Overrides",
         "type": "object"
      },
      "zero_sum_constraints": {
         "additionalProperties": {
            "enum": [
               "none",
               "equal_weights",
               "mcap_weighted"
            ],
            "type": "string"
         },
         "description": "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.",
         "examples": [
            {
               "industry": [
                  "none"
               ]
            },
            {
               "country": [
                  "mcap_weighted"
               ],
               "industry": [
                  "equal_weights"
               ]
            }
         ],
         "title": "Zero Sum Constraints",
         "type": "object"
      },
      "known_factor_map": {
         "additionalProperties": {
            "type": "string"
         },
         "description": "A mapping from tuple of factor groups and factor names (labels) to known series. These factors will have fixed returns derived from the series.",
         "title": "Known Factor Map",
         "type": "object"
      },
      "fx_convert_returns": {
         "default": true,
         "description": "Whether to convert the asset returns to the currency of the factor model.",
         "title": "Fx Convert Returns",
         "type": "boolean"
      }
   },
   "additionalProperties": false
}

Config:
  • frozen: bool = True

  • extra: str = forbid

Fields:
  • currency (str)

  • fx_convert_returns (bool)

  • known_factor_map (Mapping[tuple[str, str], str])

  • return_clip_bounds (tuple[float | None, float | None])

  • thin_category_shrinkage (Mapping[str, float])

  • thin_category_shrinkage_overrides (Mapping[tuple[str, str], float])

  • weights (Literal['SqrtCap', 'InvIdioVar'])

  • zero_sum_constraints (Mapping[str, Literal['none', 'equal_weights', 'mcap_weighted']])

Validators:
  • check_valid_weights » weights

field currency: str = 'USD'#

The currency of the factor risk model.

field weights: Literal['SqrtCap', 'InvIdioVar'] = 'SqrtCap'#

The regression weights used for the factor risk model.

Validated by:
  • check_valid_weights

field return_clip_bounds: tuple[Optional[Annotated[float]], Optional[Annotated[float]]] = (-0.1, 0.1)#

The bounds for the return clipping.

field thin_category_shrinkage: Mapping[str, Annotated[float]] [Optional]#

The ridge-shrinkage penalty for categorical factors with the than 10 assets with strictly positive exposure. Interpolation is used to scale the shrinkage strength (for zero assets) to 0.0 (for 10 assets). The keys are the (categorical) factor groups and the values are the shrinkage penalty.

field thin_category_shrinkage_overrides: Mapping[tuple[str, str], Annotated[float]] [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 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.

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 fx_convert_returns: bool = True#

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

property menu_type: type[ModelConstructionSettingsMenu]#

Get the menu type for this settings object.

Returns#

type[SettingsMenuType]

The menu type for this settings object.

validator check_valid_weights Literal['SqrtCap', 'InvIdioVar']  »  weights#
describe(menu: ModelConstructionSettingsMenu) str#

Describe the available settings.

Parameters#

menuModelConstructionSettingsMenu

The menu to get context information from.

Returns#

str

The description of the model construction settings.