bayesline.api.equity.TSBetaExposureGroupSettings#

pydantic model bayesline.api.equity.TSBetaExposureGroupSettings#

Exposure group settings for time-series beta exposures from uploaded time-series.

Computes rolling betas between asset returns and uploaded factor time-series at report time, without requiring a risk dataset rebuild.

Show JSON schema
{
   "title": "TSBetaExposureGroupSettings",
   "description": "Exposure group settings for time-series beta exposures from uploaded time-series.\n\nComputes rolling betas between asset returns and uploaded factor\ntime-series at report time, without requiring a risk dataset rebuild.",
   "type": "object",
   "properties": {
      "exposure_type": {
         "const": "tsbeta",
         "default": "tsbeta",
         "title": "Exposure Type",
         "type": "string"
      },
      "tsfactors_source": {
         "description": "The name of the uploaded time-series factors dataset.",
         "title": "Tsfactors Source",
         "type": "string"
      },
      "factor_group": {
         "description": "The output factor group name for these exposures.",
         "title": "Factor Group",
         "type": "string"
      },
      "include": {
         "anyOf": [
            {
               "const": "All",
               "type": "string"
            },
            {
               "items": {
                  "type": "string"
               },
               "type": "array"
            }
         ],
         "default": "All",
         "description": "Factor names to include from the uploaded dataset. 'All' includes all.",
         "title": "Include"
      },
      "exclude": {
         "description": "Factor names to exclude from the uploaded dataset.",
         "items": {
            "type": "string"
         },
         "title": "Exclude",
         "type": "array"
      },
      "currency": {
         "default": "USD",
         "description": "Currency for computing asset returns.",
         "title": "Currency",
         "type": "string"
      },
      "window": {
         "default": 252,
         "description": "Rolling window size for time-series beta computation.",
         "minimum": 2,
         "title": "Window",
         "type": "integer"
      },
      "return_clip_bounds": {
         "default": [
            null,
            null
         ],
         "description": "Clip asset returns to (lower, upper) before regression. None means no clip.",
         "maxItems": 2,
         "minItems": 2,
         "prefixItems": [
            {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "null"
                  }
               ]
            },
            {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "null"
                  }
               ]
            }
         ],
         "title": "Return Clip Bounds",
         "type": "array"
      },
      "rolling_regression": {
         "description": "Rolling regression method for beta computation.",
         "discriminator": {
            "mapping": {
               "huber": "#/$defs/RollingHuberBetaSettings",
               "ols": "#/$defs/RollingBetaSettings"
            },
            "propertyName": "method"
         },
         "oneOf": [
            {
               "$ref": "#/$defs/RollingBetaSettings"
            },
            {
               "$ref": "#/$defs/RollingHuberBetaSettings"
            }
         ],
         "title": "Rolling Regression"
      },
      "gaussianize": {
         "default": true,
         "description": "Whether to gaussianize the resulting exposures.",
         "title": "Gaussianize",
         "type": "boolean"
      },
      "gaussianize_maintain_zeros": {
         "default": false,
         "description": "Whether to maintain zeros when gaussianizing the exposures.",
         "title": "Gaussianize Maintain Zeros",
         "type": "boolean"
      }
   },
   "$defs": {
      "RollingBetaSettings": {
         "description": "OLS rolling beta (univariate per factor).",
         "properties": {
            "method": {
               "const": "ols",
               "default": "ols",
               "title": "Method",
               "type": "string"
            },
            "overlap": {
               "default": 5,
               "description": "Overlap (convolution) window for overlapped returns before beta computation.",
               "minimum": 1,
               "title": "Overlap",
               "type": "integer"
            }
         },
         "title": "RollingBetaSettings",
         "type": "object"
      },
      "RollingHuberBetaSettings": {
         "description": "Robust Huber rolling beta (univariate per factor, with intercept).",
         "properties": {
            "method": {
               "const": "huber",
               "default": "huber",
               "title": "Method",
               "type": "string"
            },
            "max_iter": {
               "default": 10,
               "minimum": 1,
               "title": "Max Iter",
               "type": "integer"
            },
            "level": {
               "anyOf": [
                  {
                     "type": "number"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "Student t-test level for shrinking insignificant betas to zero.",
               "title": "Level"
            },
            "epsilon": {
               "default": 1.35,
               "exclusiveMinimum": 0,
               "title": "Epsilon",
               "type": "number"
            },
            "alpha": {
               "default": 0.0001,
               "minimum": 0,
               "title": "Alpha",
               "type": "number"
            }
         },
         "title": "RollingHuberBetaSettings",
         "type": "object"
      }
   },
   "additionalProperties": false,
   "required": [
      "tsfactors_source",
      "factor_group"
   ]
}

Config:
  • frozen: bool = True

  • extra: str = forbid

Fields:
  • currency (str)

  • exclude (list[str])

  • exposure_type (Literal['tsbeta'])

  • factor_group (str)

  • gaussianize (bool)

  • gaussianize_maintain_zeros (bool)

  • include (Literal['All'] | list[str])

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

  • rolling_regression (bayesline.api._src.equity.exposure_settings.RollingBetaSettings | bayesline.api._src.equity.exposure_settings.RollingHuberBetaSettings)

  • tsfactors_source (str)

  • window (int)

Validators:
  • _validate_clip_bounds » return_clip_bounds

field exposure_type: Literal['tsbeta'] = 'tsbeta'#
field tsfactors_source: str [Required]#

The name of the uploaded time-series factors dataset.

field factor_group: str [Required]#

The output factor group name for these exposures.

field include: Literal['All'] | list[str] = 'All'#

Factor names to include from the uploaded dataset. ‘All’ includes all.

field exclude: list[str] [Optional]#

Factor names to exclude from the uploaded dataset.

field currency: str = 'USD'#

Currency for computing asset returns.

field window: int = 252#

Rolling window size for time-series beta computation.

Constraints:
  • ge = 2

field return_clip_bounds: tuple[float | None, float | None] = (None, None)#

Clip asset returns to (lower, upper) before regression. None means no clip.

Validated by:
  • _validate_clip_bounds

field rolling_regression: RollingRegressionSettings [Optional]#

Rolling regression method for beta computation.

field gaussianize: bool = True#

Whether to gaussianize the resulting exposures.

field gaussianize_maintain_zeros: bool = False#

Whether to maintain zeros when gaussianizing the exposures.

property hierarchies: list[Annotated[HierarchyLevel | HierarchyGroups, FieldInfo(annotation=NoneType, required=True, discriminator='hierarchy_type'), BeforeValidator(func=_hierarchy_name_to_hierarchy_level, json_schema_input_type=PydanticUndefined)]]#

The list of hierarchies for the exposure group.

Returns#

list[HierarchyType]

Empty list; tsbeta exposures have no hierarchies.

effective_exposure_group_factors(menu: ExposureSettingsMenu) list[str]#

Get the effective factors.

Parameters#

menuExposureSettingsMenu

The menu to get the total factors from (unused).

Returns#

list[str]

Empty list; factors are resolved at report time from uploaded data.

normalize_group_settings(menu: ExposureSettingsMenu, universe_filter_dict: Mapping[str, CategoricalFilterSettings] | None) TSBetaExposureGroupSettings#

Normalize the exposure group settings.

Parameters#

menuExposureSettingsMenu

The menu to get the total factors from (unused).

universe_filter_dictMapping[str, CategoricalFilterSettings] | None

The universe filter dictionary (unused).

Returns#

TSBetaExposureGroupSettings

Self, unchanged; tsbeta groups do not need normalization.