bayesline.api.equity.RiskDatasetSettings#

pydantic model bayesline.api.equity.RiskDatasetSettings#

Settings for creating and configuring a risk dataset.

This class defines the configuration for creating a new risk dataset, including reference dataset selection, exposure settings, asset filtering, and date trimming options.

Show JSON schema
{
   "title": "RiskDatasetSettings",
   "description": "Settings for creating and configuring a risk dataset.\n\nThis class defines the configuration for creating a new risk dataset,\nincluding reference dataset selection, exposure settings, asset filtering,\nand date trimming options.",
   "type": "object",
   "properties": {
      "reference_dataset": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "integer"
            }
         ],
         "description": "The dataset (either name or global int identifier) to use as a basis for the new dataset. All data will be sourced from this dataset.",
         "examples": [
            "Bayesline-Global",
            1
         ],
         "title": "Reference Dataset"
      },
      "exposures": {
         "description": "The exposures to use for the new dataset. By default the reference dataset is copied as a basis for the new dataset.",
         "items": {
            "discriminator": {
               "mapping": {
                  "huber_regression": "#/$defs/RiskDatasetHuberRegressionExposureSettings",
                  "referenced": "#/$defs/RiskDatasetReferencedExposureSettings",
                  "unit": "#/$defs/RiskDatasetUnitExposureSettings",
                  "uploaded": "#/$defs/RiskDatasetUploadedExposureSettings"
               },
               "propertyName": "exposure_type"
            },
            "oneOf": [
               {
                  "$ref": "#/$defs/RiskDatasetReferencedExposureSettings"
               },
               {
                  "$ref": "#/$defs/RiskDatasetUploadedExposureSettings"
               },
               {
                  "$ref": "#/$defs/RiskDatasetHuberRegressionExposureSettings"
               },
               {
                  "$ref": "#/$defs/RiskDatasetUnitExposureSettings"
               }
            ]
         },
         "minItems": 1,
         "title": "Exposures",
         "type": "array"
      },
      "exchange_codes": {
         "anyOf": [
            {
               "items": {
                  "type": "string"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "The exchange codes to filter the reference dataset down to.",
         "title": "Exchange Codes"
      },
      "trim_assets": {
         "default": "none",
         "description": "Whether to trim the assets based on the uploaded exposures. If 'none', the assets are not trimmed. If 'asset_union', the assets are trimmed to the union of the asset ids in the uploaded exposures. If 'ccy_union', the assets are trimmed to the union of all currencies in the uploaded exposures.",
         "enum": [
            "none",
            "asset_union",
            "ccy_union"
         ],
         "title": "Trim Assets",
         "type": "string"
      },
      "trim_start_date": {
         "anyOf": [
            {
               "enum": [
                  "none",
                  "earliest_start",
                  "latest_start"
               ],
               "type": "string"
            },
            {
               "format": "date",
               "type": "string"
            }
         ],
         "default": "earliest_start",
         "description": "Whether to trim the start date based on the uploaded exposures. If 'none', the start date is not trimmed. If 'earliest_start', the start date is trimmed to the earliest start date of the uploaded exposures, or the updoaded exposures and the reference dateset when referenced exposures are provided. If 'latest_start', the start date is trimmed to the latest start date the uploaded exposures, or the updoaded exposures and the reference dateset when referenced exposures are provided. If a date is provided, the start date is trimmed to the provided date.",
         "title": "Trim Start Date"
      },
      "trim_end_date": {
         "anyOf": [
            {
               "enum": [
                  "none",
                  "earliest_end",
                  "latest_end"
               ],
               "type": "string"
            },
            {
               "format": "date",
               "type": "string"
            }
         ],
         "default": "latest_end",
         "description": "Whether to trim the end date based on the uploaded exposures. If 'none', the end date is not trimmed. If 'earliest_end', the end date is trimmed to the earliest end date of the uploaded exposures, or the updoaded exposures and the reference dateset when referenced exposures are provided. If 'latest_end', the end date is trimmed to the latest end date of the uploaded exposures, or the updoaded exposures and the reference dateset when referenced exposures are provided. If a date is provided, the end date is trimmed to the provided date.",
         "title": "Trim End Date"
      }
   },
   "$defs": {
      "CalendarSettings": {
         "additionalProperties": false,
         "description": "Define 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"
      },
      "RiskDatasetHuberRegressionExposureSettings": {
         "additionalProperties": false,
         "description": "Settings for Huber regression-based exposure data in a risk dataset.\n\nThis class defines settings for generating exposure data using Huber regression\non time series factors, with options for windowing, regularization, and statistical testing.",
         "properties": {
            "exposure_type": {
               "const": "huber_regression",
               "default": "huber_regression",
               "title": "Exposure Type",
               "type": "string"
            },
            "tsfactors_source": {
               "description": "The source of the timeseries factors.",
               "title": "Tsfactors Source",
               "type": "string"
            },
            "factor_group": {
               "default": "huber_style",
               "description": "The factor group name to use for the regression.",
               "title": "Factor Group",
               "type": "string"
            },
            "include": {
               "anyOf": [
                  {
                     "items": {
                        "type": "string"
                     },
                     "type": "array"
                  },
                  {
                     "const": "All",
                     "type": "string"
                  }
               ],
               "default": "All",
               "description": "The factors to include in the regression.",
               "title": "Include"
            },
            "exclude": {
               "description": "The factors to exclude from the regression.",
               "items": {
                  "type": "string"
               },
               "title": "Exclude",
               "type": "array"
            },
            "fill_miss": {
               "default": true,
               "title": "Fill Miss",
               "type": "boolean"
            },
            "window": {
               "default": 126,
               "description": "The window for the rolling regressions.",
               "title": "Window",
               "type": "integer"
            },
            "epsilon": {
               "default": 1.35,
               "description": "The epsilon for the huber regression.",
               "title": "Epsilon",
               "type": "number"
            },
            "alpha": {
               "default": 0.0001,
               "description": "The alpha for the huber regression.",
               "title": "Alpha",
               "type": "number"
            },
            "alpha_start": {
               "default": 10.0,
               "description": "The alpha when no data is available.",
               "title": "Alpha Start",
               "type": "number"
            },
            "student_t_level": {
               "anyOf": [
                  {
                     "maximum": 1.0,
                     "minimum": 0.0,
                     "type": "number"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The level for the student t-test. If a test for the significance of the factor exposure is not rejected, the factor exposure is set to zero. If None, no test is run and the factor exposure is not set to zero.",
               "title": "Student T Level"
            },
            "clip": {
               "default": [
                  null,
                  null
               ],
               "description": "The clipping lower and upper bounds for the resulting exposures, before potential huberization.",
               "maxItems": 2,
               "minItems": 2,
               "prefixItems": [
                  {
                     "anyOf": [
                        {
                           "type": "number"
                        },
                        {
                           "type": "null"
                        }
                     ]
                  },
                  {
                     "anyOf": [
                        {
                           "type": "number"
                        },
                        {
                           "type": "null"
                        }
                     ]
                  }
               ],
               "title": "Clip",
               "type": "array"
            },
            "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 huberizing the exposures.",
               "title": "Gaussianize Maintain Zeros",
               "type": "boolean"
            },
            "impute": {
               "default": true,
               "description": "Whether to impute missing values for the resulting exposures.",
               "title": "Impute",
               "type": "boolean"
            },
            "currency": {
               "default": "USD",
               "description": "The currency to convert all returns to.",
               "title": "Currency",
               "type": "string"
            },
            "calendar": {
               "$ref": "#/$defs/CalendarSettings",
               "description": "The calendar to use for the rolling regressions."
            }
         },
         "required": [
            "tsfactors_source"
         ],
         "title": "RiskDatasetHuberRegressionExposureSettings",
         "type": "object"
      },
      "RiskDatasetReferencedExposureSettings": {
         "additionalProperties": false,
         "description": "Settings for referenced exposure data in a risk dataset.\n\nThis class defines settings for using exposure data from a reference dataset,\nallowing selective copying of continuous and categorical factor groups.",
         "properties": {
            "exposure_type": {
               "const": "referenced",
               "default": "referenced",
               "title": "Exposure Type",
               "type": "string"
            },
            "continuous_factor_groups": {
               "anyOf": [
                  {
                     "items": {
                        "type": "string"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The continuous factor groups from the reference dataset to carry over. If None (default), all continuous factor groups are carried over.",
               "title": "Continuous Factor Groups"
            },
            "categorical_factor_groups": {
               "anyOf": [
                  {
                     "items": {
                        "type": "string"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The categorical factor groups from the reference dataset to carry over. If None (default), all categorical factor groups are carried over.",
               "title": "Categorical Factor Groups"
            }
         },
         "title": "RiskDatasetReferencedExposureSettings",
         "type": "object"
      },
      "RiskDatasetUnitExposureSettings": {
         "additionalProperties": false,
         "description": "Settings for unit exposure data in a risk dataset.\n\nThis class defines settings for creating unit exposures (exposures of 1.0)\nfor specific factors in a risk dataset.",
         "properties": {
            "exposure_type": {
               "const": "unit",
               "default": "unit",
               "title": "Exposure Type",
               "type": "string"
            },
            "factor_group": {
               "description": "The factor group to use for the unit exposures.",
               "title": "Factor Group",
               "type": "string"
            },
            "factor": {
               "description": "The factor to use for the unit exposures.",
               "title": "Factor",
               "type": "string"
            },
            "factor_type": {
               "default": "continuous",
               "description": "The type of factor to use for the unit exposures.",
               "enum": [
                  "continuous",
                  "categorical"
               ],
               "title": "Factor Type",
               "type": "string"
            }
         },
         "required": [
            "factor_group",
            "factor"
         ],
         "title": "RiskDatasetUnitExposureSettings",
         "type": "object"
      },
      "RiskDatasetUploadedExposureSettings": {
         "additionalProperties": false,
         "description": "Settings for uploaded exposure data in a risk dataset.\n\nThis class defines settings for using exposure data from uploaded sources,\nwith options for gaussianization, missing value filling, and factor group management.",
         "properties": {
            "exposure_type": {
               "const": "uploaded",
               "default": "uploaded",
               "title": "Exposure Type",
               "type": "string"
            },
            "exposure_source": {
               "description": "The uploaded source of the exposures.",
               "title": "Exposure Source",
               "type": "string"
            },
            "continuous_factor_groups": {
               "description": "The continuous factor groups from the uploaded dataset to carry over.",
               "items": {
                  "type": "string"
               },
               "title": "Continuous Factor Groups",
               "type": "array"
            },
            "categorical_factor_groups": {
               "description": "The categorical factor groups from the uploaded dataset to carry over.",
               "items": {
                  "type": "string"
               },
               "title": "Categorical Factor Groups",
               "type": "array"
            },
            "factor_groups_gaussianize": {
               "description": "For which continuous groups to gaussianize the exposures.",
               "items": {
                  "type": "string"
               },
               "title": "Factor Groups Gaussianize",
               "type": "array"
            },
            "factor_groups_gaussianize_maintain_zeros": {
               "description": "For which continuous groups to gaussianize the exposures and maintain zeros.",
               "items": {
                  "type": "string"
               },
               "title": "Factor Groups Gaussianize Maintain Zeros",
               "type": "array"
            },
            "factor_groups_fill_miss": {
               "description": "For which continuous groups to fill missing values.",
               "items": {
                  "type": "string"
               },
               "title": "Factor Groups Fill Miss",
               "type": "array"
            }
         },
         "required": [
            "exposure_source"
         ],
         "title": "RiskDatasetUploadedExposureSettings",
         "type": "object"
      }
   },
   "additionalProperties": false,
   "required": [
      "reference_dataset"
   ]
}

Config:
  • frozen: bool = True

  • extra: str = forbid

Fields:
  • exchange_codes (list[str] | None)

  • exposures (list[bayesline.api._src.equity.riskdataset_settings.RiskDatasetReferencedExposureSettings | bayesline.api._src.equity.riskdataset_settings.RiskDatasetUploadedExposureSettings | bayesline.api._src.equity.riskdataset_settings.RiskDatasetHuberRegressionExposureSettings | bayesline.api._src.equity.riskdataset_settings.RiskDatasetUnitExposureSettings])

  • reference_dataset (str | int)

  • trim_assets (Literal['none', 'asset_union', 'ccy_union'])

  • trim_end_date (Literal['none', 'earliest_end', 'latest_end'] | datetime.date)

  • trim_start_date (Literal['none', 'earliest_start', 'latest_start'] | datetime.date)

field reference_dataset: str | int [Required]#

The dataset (either name or global int identifier) to use as a basis for the new dataset. All data will be sourced from this dataset.

field exposures: list[Annotated[RiskDatasetReferencedExposureSettings | RiskDatasetUploadedExposureSettings | RiskDatasetHuberRegressionExposureSettings | RiskDatasetUnitExposureSettings]] [Optional]#

The exposures to use for the new dataset. By default the reference dataset is copied as a basis for the new dataset.

Constraints:
  • min_length = 1

field exchange_codes: list[str] | None = None#

The exchange codes to filter the reference dataset down to.

field trim_assets: Literal['none', 'asset_union', 'ccy_union'] = 'none'#

Whether to trim the assets based on the uploaded exposures. If ‘none’, the assets are not trimmed. If ‘asset_union’, the assets are trimmed to the union of the asset ids in the uploaded exposures. If ‘ccy_union’, the assets are trimmed to the union of all currencies in the uploaded exposures.

field trim_start_date: Union[Literal['none', 'earliest_start', 'latest_start'], date] = 'earliest_start'#

Whether to trim the start date based on the uploaded exposures. If ‘none’, the start date is not trimmed. If ‘earliest_start’, the start date is trimmed to the earliest start date of the uploaded exposures, or the updoaded exposures and the reference dateset when referenced exposures are provided. If ‘latest_start’, the start date is trimmed to the latest start date the uploaded exposures, or the updoaded exposures and the reference dateset when referenced exposures are provided. If a date is provided, the start date is trimmed to the provided date.

field trim_end_date: Union[Literal['none', 'earliest_end', 'latest_end'], date] = 'latest_end'#

Whether to trim the end date based on the uploaded exposures. If ‘none’, the end date is not trimmed. If ‘earliest_end’, the end date is trimmed to the earliest end date of the uploaded exposures, or the updoaded exposures and the reference dateset when referenced exposures are provided. If ‘latest_end’, the end date is trimmed to the latest end date of the uploaded exposures, or the updoaded exposures and the reference dateset when referenced exposures are provided. If a date is provided, the end date is trimmed to the provided date.

property menu_type: type[RiskDatasetSettingsMenu]#

Get the menu type for this settings object.

Returns#

type[SettingsMenuType]

The menu type for this settings object.

describe(menu: RiskDatasetSettingsMenu) str#

Describe the risk dataset settings.

Parameters#

menuRiskDatasetSettingsMenu

The settings menu to use to describe the settings.

Returns#

str

A description of the risk dataset settings.