bayesline.api.equity.ContinuousExposureGroupSettings#
- pydantic model bayesline.api.equity.ContinuousExposureGroupSettings#
The settings for a continuous exposure group.
Continuous exposures are exposures that are measured on a continuous scale, e.g. market, size, momentum, etc., and are typically available for most assets.
Show JSON schema
{ "title": "ContinuousExposureGroupSettings", "description": "The settings for a continuous exposure group.\n\nContinuous exposures are exposures that are measured on a continuous scale,\ne.g. market, size, momentum, etc., and are typically available for most assets.", "type": "object", "properties": { "exposure_type": { "const": "continuous", "default": "continuous", "title": "Exposure Type", "type": "string" }, "hierarchy": { "description": "The hierarchy to use for the continuous exposures. This is either aHierarchyLevel or HierarchyGroups object. If a string is passed, the value is converted to a HierarchyLevel of that hierarchy with level=1.", "discriminator": { "mapping": { "groups": "#/$defs/HierarchyGroups", "level": "#/$defs/HierarchyLevel" }, "propertyName": "hierarchy_type" }, "examples": [ "market", { "hierarchy_type": "level", "level": 2, "name": "style" }, { "groupings": { "momentum": [ "mom6" ], "size": [ "size" ] }, "hierarchy_type": "groups", "name": "style" } ], "oneOf": [ { "$ref": "#/$defs/HierarchyLevel" }, { "$ref": "#/$defs/HierarchyGroups" } ], "title": "Hierarchy" }, "factor_group": { "default": "", "description": "By default, the name of the factor group will be the name of the hierarchy. But we can override this by specifying an alias here.", "examples": [ "style", "some_style_group" ], "title": "Factor Group", "type": "string" }, "include": { "anyOf": [ { "const": "All", "type": "string" }, { "items": { "type": "string" }, "type": "array" } ], "default": "All", "description": "Valid industry codes or labels for given hierarchy at any level. If labels are used which may be duplicated, then the code with the highest level is used. If 'All', all codes are included.", "examples": [ [ "momentum" ], "All", [ "Size", "value" ] ], "title": "Include" }, "exclude": { "description": "Valid industry codes or labels for given hierarchy at any level. If labels are used which may be duplicated, then the code with the lowest level is used.", "examples": [ [ "momentum" ], [ "Size", "value" ] ], "items": { "type": "string" }, "title": "Exclude", "type": "array" }, "standardize_method": { "default": "none", "description": "The method to use for standardizing the exposures. If 'none', no standardization is applied. If 'equal_weighted', then the exposures are standardized with the mean and standard deviation of the estimation universe.", "enum": [ "none", "equal_weighted" ], "examples": [ "none", "equal_weighted" ], "title": "Standardize Method", "type": "string" } }, "$defs": { "Hierarchy": { "anyOf": [ { "items": { "type": "string" }, "type": "array" }, { "additionalProperties": { "$ref": "#/$defs/Hierarchy" }, "type": "object" } ] }, "HierarchyGroups": { "additionalProperties": false, "description": "The hierarchy decscription for a custom nested grouping of the hierarchy.\n\nThe top level groupings will turn into factors, whereas any nested\ngroupings will be retained for other uses (e.g. risk decomposition).", "properties": { "hierarchy_type": { "const": "groups", "default": "groups", "title": "Hierarchy Type", "type": "string" }, "name": { "description": "\n The name of the hierarchy to use, e.g. 'trbc' or 'continent'.\n If it is not given then the default hierarchy will be used.\n ", "examples": [ "trbc", "continent" ], "minLength": 1, "title": "Name", "type": "string" }, "groupings": { "additionalProperties": { "$ref": "#/$defs/Hierarchy" }, "description": "\n A nested structure of groupings where the keys are the group names\n and the leaf level is a list of hierarchy codes or labels (at any level)\n to include for this group.\n ", "title": "Groupings", "type": "object" } }, "required": [ "name", "groupings" ], "title": "HierarchyGroups", "type": "object" }, "HierarchyLevel": { "additionalProperties": false, "description": "The hierarchy decscription for a level in the hierarchy.\n\nE.g. for industries specifying level `1` would\ncreate top level sector factors.", "properties": { "hierarchy_type": { "const": "level", "default": "level", "title": "Hierarchy Type", "type": "string" }, "name": { "description": "\n The name of the hierarchy to use, e.g. 'trbc' or 'continent'.\n If it is not given then the default hierarchy will be used.\n ", "examples": [ "trbc", "continent" ], "minLength": 1, "title": "Name", "type": "string" }, "level": { "default": 1, "description": "The level of the hierarchy to use, e.g. 1\n to use all level 1 names (i.e. sectors for industries or\n continents for regions) or 2 to use all level 2\n names (i.e. sub-sectors for industries and\n countries for regions).\n ", "examples": [ 1, 2 ], "minimum": 1, "title": "Level", "type": "integer" } }, "required": [ "name" ], "title": "HierarchyLevel", "type": "object" } }, "additionalProperties": false, "required": [ "hierarchy" ] }
- Config:
frozen: bool = True
extra: str = forbid
- Fields:
exclude (list[str])exposure_type (Literal['continuous'])factor_group (str)hierarchy (bayesline.api._src.equity.exposure_settings.HierarchyLevel | bayesline.api._src.equity.exposure_settings.HierarchyGroups)include (Literal['All'] | list[str])standardize_method (Literal['none', 'equal_weighted'])
- Validators:
check_valid_factor_group»factor_groupset_factor_group»all fieldsvalidate_filters»all fields
- field exposure_type: Literal['continuous'] = 'continuous'#
- Validated by:
set_factor_groupvalidate_filters
- field hierarchy: Annotated[HierarchyType, Field(description='The hierarchy to use for the continuous exposures. This is either aHierarchyLevel or HierarchyGroups object. If a string is passed, the value is converted to a HierarchyLevel of that hierarchy with level=1.', examples=['market', HierarchyLevel(name='style', level=2), HierarchyGroups(name='style', groupings={'momentum': ['mom6'], 'size': ['size']})])] [Required]#
The hierarchy to use for the continuous exposures. This is either aHierarchyLevel or HierarchyGroups object. If a string is passed, the value is converted to a HierarchyLevel of that hierarchy with level=1.
- Constraints:
func = <function _hierarchy_name_to_hierarchy_level at 0x7fe2ecbeb380>
json_schema_input_type = PydanticUndefined
- Validated by:
set_factor_groupvalidate_filters
- field factor_group: str = ''#
By default, the name of the factor group will be the name of the hierarchy. But we can override this by specifying an alias here.
- Validated by:
check_valid_factor_groupset_factor_groupvalidate_filters
- field include: Literal['All'] | list[str] = 'All'#
Valid industry codes or labels for given hierarchy at any level. If labels are used which may be duplicated, then the code with the highest level is used. If ‘All’, all codes are included.
- Validated by:
set_factor_groupvalidate_filters
- field exclude: list[str] [Optional]#
Valid industry codes or labels for given hierarchy at any level. If labels are used which may be duplicated, then the code with the lowest level is used.
- Validated by:
set_factor_groupvalidate_filters
- field standardize_method: Literal['none', 'equal_weighted'] = 'none'#
The method to use for standardizing the exposures. If ‘none’, no standardization is applied. If ‘equal_weighted’, then the exposures are standardized with the mean and standard deviation of the estimation universe.
- Validated by:
set_factor_groupvalidate_filters
- validator validate_filters ContinuousExposureGroupSettings » all fields#
- 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]
The list of hierarchies for the exposure group.
- effective_exposure_group_factors(menu: ExposureSettingsMenu) list[str]#
Get the effective factors.
Effective factors are the factors that are included and not excluded in the exposure group settings.
Parameters#
- menuExposureSettingsMenu
The menu to get the total factors from.
Returns#
- list[str]
The list of effective factors.
- normalize_group_settings(menu: ExposureSettingsMenu, universe_filter_dict: Mapping[str, CategoricalFilterSettings] | None) ContinuousExposureGroupSettings#
Normalize the exposure group settings.
Normalized group settings have all hierarchies replaced by HierarchyGroups with two levels, the factor names and the leaf codes. All includes and excludes are resolved.
This means that if the universe_filter_dict has a filter that trims down to just the North American region, and the ExposureSettings include factors from the same country hierarchy, then the factors will be trimmed down to just include the ones corresponding to the North American region.
Parameters#
- menuExposureSettingsMenu
The menu to get the total factors from.
- universe_filter_dictMapping[str, CategoricalFilterSettings] | None
The universe filter dictionary to potentially further cut the factors down. The keys are the hierarchy names and the values are the filter settings. If None, then no filtering is performed.
Returns#
- ContinuousExposureGroupSettings
The normalized exposure group settings.