bayesline.api.equity.FactorRiskModelSettings#

pydantic model bayesline.api.equity.FactorRiskModelSettings#

Defines all settings needed to build a factor risk model.

Show JSON schema
{
   "title": "FactorRiskModelSettings",
   "description": "Defines all settings needed to build a factor risk model.",
   "type": "object",
   "properties": {
      "universe": {
         "description": "The universe to build the factor risk model on.",
         "items": {
            "anyOf": [
               {
                  "type": "string"
               },
               {
                  "type": "integer"
               },
               {
                  "$ref": "#/$defs/UniverseSettings"
               }
            ]
         },
         "maxItems": 1,
         "minItems": 1,
         "title": "Universe",
         "type": "array"
      },
      "exposures": {
         "description": "The exposures to build the factor risk model on.",
         "items": {
            "anyOf": [
               {
                  "type": "string"
               },
               {
                  "type": "integer"
               },
               {
                  "$ref": "#/$defs/ExposureSettings"
               }
            ]
         },
         "minItems": 1,
         "title": "Exposures",
         "type": "array"
      },
      "modelconstruction": {
         "description": "The model construction settings to use for the factor risk model.",
         "items": {
            "anyOf": [
               {
                  "type": "string"
               },
               {
                  "type": "integer"
               },
               {
                  "$ref": "#/$defs/ModelConstructionSettings"
               }
            ]
         },
         "minItems": 1,
         "title": "Modelconstruction",
         "type": "array"
      }
   },
   "$defs": {
      "CalendarSettings": {
         "additionalProperties": false,
         "description": "Defines the settings for the calendar.",
         "properties": {
            "dataset": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The name of the underlying dataset to use. If none is given then the configured default dataset is used.",
               "examples": [
                  "Bayesline-US"
               ],
               "title": "Dataset"
            },
            "filters": {
               "default": [
                  [
                     "XNYS"
                  ]
               ],
               "description": "The filters to apply. Each filter is a list of exchange MIC codes. The outer list will be treated as an OR conditions, while the inner lists will be treated as an AND conditions. For example, `[['A', 'B'], ['C']]` means that the holidays are the days where either A and B are both holidays, or C is a holiday.",
               "examples": [
                  [
                     [
                        "XNYS"
                     ]
                  ],
                  [
                     [
                        "XNYS",
                        "XNAS"
                     ]
                  ],
                  [
                     [
                        "XNYS"
                     ],
                     [
                        "XNAS"
                     ]
                  ]
               ],
               "items": {
                  "items": {
                     "type": "string"
                  },
                  "type": "array"
               },
               "minItems": 1,
               "title": "Filters",
               "type": "array"
            }
         },
         "title": "CalendarSettings",
         "type": "object"
      },
      "ExposureSettings": {
         "additionalProperties": false,
         "description": "Defines exposures as hierarchy of selected styles and substyles.",
         "properties": {
            "market": {
               "default": true,
               "description": "\n        Whether to include the market factor in the model.\n        ",
               "title": "Market",
               "type": "boolean"
            },
            "styles": {
               "anyOf": [
                  {
                     "additionalProperties": {
                        "items": {
                           "type": "string"
                        },
                        "type": "array"
                     },
                     "type": "object"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "\n        A mapping where the keys are style codes or labels and the values are\n        lists of included sub-style names or labels.\n        By default (None) the entire available style/substyle hierarchy will be used.\n        Passing an empty dict will exclude all styles.\n        ",
               "title": "Styles"
            },
            "standardize_styles": {
               "default": true,
               "description": "Whether to standardize the style exposures.",
               "title": "Standardize Styles",
               "type": "boolean"
            },
            "industries": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/HierarchyLevel"
                  },
                  {
                     "$ref": "#/$defs/HierarchyGroups"
                  },
                  {
                     "type": "null"
                  }
               ],
               "description": "\n        The definition of how industry factors are being constructed.\n        The default is to use the same hiearchy as was used to define the universe\n        at level 1 (i.e. coarse grouping).\n        None indicates that no industry factors should be included.\n        ",
               "title": "Industries"
            },
            "regions": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/HierarchyLevel"
                  },
                  {
                     "$ref": "#/$defs/HierarchyGroups"
                  },
                  {
                     "type": "null"
                  }
               ],
               "description": "\n        The definition of how region factors are being constructed.\n        The default is to use the same hiearchy as was used to define the universe\n        at level 2 (i.e. granular grouping).\n        None indicates that no region factors should be included.\n        ",
               "title": "Regions"
            },
            "other": {
               "additionalProperties": {
                  "type": "string"
               },
               "description": "\n        A mapping of other factors to include in the model, to the exposure names or\n        labels. For example, to include the risk free rate as an exposure, the mapping\n        could be `{\"Risk Free Rate\": \"us_rate_3m\"}`, or \n        `{\"Risk-Free-Rate\": \"3 Month US TBill Rate\"}`, the key being the exposure name \n        in the output.\n        ",
               "title": "Other",
               "type": "object"
            }
         },
         "title": "ExposureSettings",
         "type": "object"
      },
      "Hierarchy": {
         "anyOf": [
            {
               "items": {
                  "type": "string"
               },
               "type": "array"
            },
            {
               "additionalProperties": {
                  "$ref": "#/$defs/Hierarchy"
               },
               "type": "object"
            }
         ]
      },
      "HierarchyGroups": {
         "description": "The hierarchy group description allows for a nested definition\nof groupings.\nThe top level groupings will turn into factors, whereas any nested\ngroupings will be retained for other uses (e.g. risk decomposition).",
         "properties": {
            "hierarchy": {
               "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": "Hierarchy",
               "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": [
            "hierarchy",
            "groupings"
         ],
         "title": "HierarchyGroups",
         "type": "object"
      },
      "HierarchyLevel": {
         "description": "The hierarchy level description turns every name at\nthe configured level into a separate factor.\n\nE.g. for industries specifying level `1` would\ncreate top level sector factors.",
         "properties": {
            "hierarchy": {
               "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": "Hierarchy",
               "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": [
            "hierarchy"
         ],
         "title": "HierarchyLevel",
         "type": "object"
      },
      "IndustrySettings": {
         "additionalProperties": false,
         "description": "Specifies include and exclude filters for industries.\n\nAssets are includes if they are part of at least one include\nand not part of any exclude.\n\nBy default all industries for the given hierarchy are included.",
         "properties": {
            "hierarchy": {
               "default": "trbc",
               "description": "The industry hierarchy to use.",
               "examples": [
                  "trbc"
               ],
               "minLength": 1,
               "title": "Hierarchy",
               "type": "string"
            },
            "include": {
               "anyOf": [
                  {
                     "items": {
                        "type": "string"
                     },
                     "type": "array"
                  },
                  {
                     "const": "All",
                     "type": "string"
                  }
               ],
               "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.",
               "examples": [
                  [
                     "3571"
                  ],
                  "All",
                  [
                     "Materials",
                     "1010"
                  ]
               ],
               "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": [
                  [
                     "3571"
                  ],
                  [
                     "Materials",
                     "1010"
                  ]
               ],
               "items": {
                  "type": "string"
               },
               "title": "Exclude",
               "type": "array"
            }
         },
         "title": "IndustrySettings",
         "type": "object"
      },
      "MCapSettings": {
         "additionalProperties": false,
         "description": "Specifies the lower and upper bound for the market cap filter.\n\nBy default the bounds are infinite.",
         "properties": {
            "lower": {
               "default": 0.0,
               "description": "Lower bound of the cap filter in USD.",
               "examples": [
                  10000000000.0
               ],
               "minimum": 0.0,
               "title": "Lower",
               "type": "number"
            },
            "upper": {
               "default": 1e+20,
               "description": "Upper bound of the cap filter in USD.",
               "examples": [
                  1000000000000.0
               ],
               "exclusiveMinimum": 0.0,
               "title": "Upper",
               "type": "number"
            },
            "gdp_deflator_asof": {
               "anyOf": [
                  {
                     "format": "date",
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "\n        The as of date to adjust the market cap bounds for GDP through time.\n        If no date is specified then the market cap bounds are static through time.\n        ",
               "title": "Gdp Deflator Asof"
            }
         },
         "title": "MCapSettings",
         "type": "object"
      },
      "ModelConstructionSettings": {
         "additionalProperties": false,
         "description": "Defines settings to build a factor risk model.",
         "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"
            },
            "alpha": {
               "default": 0.0,
               "description": "The ridge-shrinkage factor for the factor risk model.",
               "minimum": 0,
               "title": "Alpha",
               "type": "number"
            },
            "alpha_overrides": {
               "additionalProperties": {
                  "minimum": 0,
                  "type": "number"
               },
               "description": "The alpha override for the factor risk model. The keys are the factor names and the values are the alpha overrides.",
               "title": "Alpha Overrides",
               "type": "object"
            },
            "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": [
                        {
                           "type": "number"
                        },
                        {
                           "type": "null"
                        }
                     ]
                  },
                  {
                     "anyOf": [
                        {
                           "type": "number"
                        },
                        {
                           "type": "null"
                        }
                     ]
                  }
               ],
               "title": "Return Clip Bounds",
               "type": "array"
            },
            "known_factors": {
               "additionalProperties": {
                  "type": "string"
               },
               "description": "The known factor returns to use for the factor risk model which are added as independent factors with known (constrained) values. The keys are the names that should be used in the factor model and the values are the underlying known factors that should be used. ",
               "examples": [
                  {},
                  {
                     "Risk Free Rate": "us_rate_3m"
                  }
               ],
               "title": "Known Factors",
               "type": "object"
            }
         },
         "title": "ModelConstructionSettings",
         "type": "object"
      },
      "RegionSettings": {
         "additionalProperties": false,
         "description": "Specifies include and exclude filters for countries and regions.\n\nAssets are includes if they are part of at least one include\nand not part of any exclude.\n\nBy default all countries for the given hierarchy are included.",
         "properties": {
            "hierarchy": {
               "default": "continent",
               "description": "The region hierarchy to use.",
               "examples": [
                  "continent"
               ],
               "minLength": 1,
               "title": "Hierarchy",
               "type": "string"
            },
            "include": {
               "anyOf": [
                  {
                     "items": {
                        "type": "string"
                     },
                     "type": "array"
                  },
                  {
                     "const": "All",
                     "type": "string"
                  }
               ],
               "default": "All",
               "description": "Valid country/region codes or labels at any level. If labels are used which may be duplicated, then the code with the highest level is used.",
               "examples": [
                  [
                     "Europe",
                     "CAN"
                  ],
                  "All"
               ],
               "title": "Include"
            },
            "exclude": {
               "description": "Valid country/region codes or labels at any level. If labels are used which may be duplicated, then the code with the lowest level is used.",
               "examples": [
                  [
                     "DEU"
                  ]
               ],
               "items": {
                  "type": "string"
               },
               "title": "Exclude",
               "type": "array"
            }
         },
         "title": "RegionSettings",
         "type": "object"
      },
      "UniverseSettings": {
         "additionalProperties": false,
         "description": "Defines an asset universe as a set of regional, industry and market cap filters.",
         "properties": {
            "dataset": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The name of the underlying dataset to use. If none is given then the configured default dataset is used.",
               "examples": [
                  "Bayesline-US"
               ],
               "title": "Dataset"
            },
            "id_type": {
               "default": "bayesid",
               "description": "The default id type to use for the universe.",
               "enum": [
                  "bayesid",
                  "ticker",
                  "composite_figi",
                  "cik",
                  "cusip8",
                  "cusip9",
                  "isin",
                  "sedol6",
                  "sedol7",
                  "proxy",
                  "name"
               ],
               "examples": [
                  "cusip9",
                  "bayesid"
               ],
               "title": "Id Type",
               "type": "string"
            },
            "calendar": {
               "$ref": "#/$defs/CalendarSettings",
               "description": "The calendar settings to use for the universe."
            },
            "industry": {
               "$ref": "#/$defs/IndustrySettings",
               "description": "\n        Filters that determine which industries to include and exclude in the universe.\n        "
            },
            "region": {
               "$ref": "#/$defs/RegionSettings",
               "description": "\n        Filters that determine which countries/continents to include and exclude in the\n        universe.\n        "
            },
            "mcap": {
               "$ref": "#/$defs/MCapSettings",
               "description": "\n        Filters that determine which market caps to include and exclude in the universe.\n        "
            }
         },
         "title": "UniverseSettings",
         "type": "object"
      }
   },
   "additionalProperties": false
}

Config:
  • frozen: bool = True

  • extra: str = forbid

Fields:
  • exposures (list[str | int | bayesline.api._src.equity.exposure_settings.ExposureSettings])

  • modelconstruction (list[str | int | bayesline.api._src.equity.modelconstruction_settings.ModelConstructionSettings])

  • universe (list[str | int | bayesline.api._src.equity.universe_settings.UniverseSettings])

classmethod default(*, dataset: str | None = None) FactorRiskModelSettings#
field universe: Annotated[list[str | int | UniverseSettings]] [Optional]#

The universe to build the factor risk model on.

Constraints:
  • func = <function ensure_list at 0x7ff512eaafc0>

  • json_schema_input_type = PydanticUndefined

  • min_length = 1

  • max_length = 1

  • references = <class ‘bayesline.api._src.equity.universe_settings.UniverseSettings’>

  • extractor = <function FactorRiskModelSettings.<lambda> at 0x7ff512eab2e0>

field exposures: Annotated[list[str | int | ExposureSettings]] [Optional]#

The exposures to build the factor risk model on.

Constraints:
  • func = <function ensure_list at 0x7ff512eaafc0>

  • json_schema_input_type = PydanticUndefined

  • min_length = 1

  • references = <class ‘bayesline.api._src.equity.exposure_settings.ExposureSettings’>

  • extractor = <function FactorRiskModelSettings.<lambda> at 0x7ff512eab420>

field modelconstruction: Annotated[list[str | int | ModelConstructionSettings]] [Optional]#

The model construction settings to use for the factor risk model.

Constraints:
  • func = <function ensure_list at 0x7ff512eaafc0>

  • json_schema_input_type = PydanticUndefined

  • min_length = 1

  • references = <class ‘bayesline.api._src.equity.modelconstruction_settings.ModelConstructionSettings’>

  • extractor = <function FactorRiskModelSettings.<lambda> at 0x7ff512eab560>