bayesline.api.equity.DerivedRiskDatasetSettings#

pydantic model bayesline.api.equity.DerivedRiskDatasetSettings#

Settings for creating a derived risk dataset built on top of a parent.

A derived dataset is configured by selecting a reference dataset, optionally overriding exposures, filtering assets/exchanges, and trimming dates. All underlying market data is sourced from the reference dataset.

For datasets assembled directly from upload sources (no parent), see RootRiskDatasetSettings. The discriminated union of both variants is exposed as AnyRiskDatasetSettings.

Show JSON schema
{
   "title": "DerivedRiskDatasetSettings",
   "description": "Settings for creating a *derived* risk dataset built on top of a parent.\n\nA derived dataset is configured by selecting a reference dataset, optionally\noverriding exposures, filtering assets/exchanges, and trimming dates. All\nunderlying market data is sourced from the reference dataset.\n\nFor datasets assembled directly from upload sources (no parent), see\n``RootRiskDatasetSettings``. The discriminated union of both variants is\nexposed as ``AnyRiskDatasetSettings``.",
   "type": "object",
   "properties": {
      "kind": {
         "const": "derived",
         "default": "derived",
         "description": "Discriminator field for the risk dataset settings union (derived vs root). Use ``derived`` for datasets built on top of a parent reference dataset; use ``root`` (on RootRiskDatasetSettings) for datasets built directly from upload sources.",
         "title": "Kind",
         "type": "string"
      },
      "is_system_wide": {
         "default": false,
         "description": "Whether the risk dataset is system wide and provided by Bayesline.",
         "title": "Is System Wide",
         "type": "boolean"
      },
      "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_assets_sources": {
         "anyOf": [
            {
               "items": {
                  "type": "string"
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "Restrict the asset/ccy union used by ``trim_assets`` to these upload sources. ``None`` (default) preserves the prior behaviour: the union is taken across every uploaded-exposure source in ``exposures``. Each entry must be the ``exposure_source`` of an ``uploaded``-type entry in ``exposures``. Only meaningful when ``trim_assets`` is ``'asset_union'`` or ``'ccy_union'``.",
         "title": "Trim Assets Sources"
      },
      "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 uploaded exposures and the reference dataset when referenced exposures are provided. If 'latest_start', the start date is trimmed to the latest start date the uploaded exposures, or the uploaded exposures and the reference dataset 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 uploaded exposures and the reference dataset when referenced exposures are provided. If 'latest_end', the end date is trimmed to the latest end date of the uploaded exposures, or the uploaded exposures and the reference dataset 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": "Calendar settings carrying exchange filters to construct calendars from.",
         "properties": {
            "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_forward_fill": {
               "description": "For which factor groups to forward-fill exposures along time, gated by the priced-day mask (no fill on days the asset is not in the modeling universe). Applied before gaussianizing and fill_miss. Supports both continuous (dense) and categorical (sparse) groups; for categorical groups the fill preserves one-hot semantics within each (asset, group) when the upload itself is one-hot. Each entry must also appear in ``continuous_factor_groups`` or ``categorical_factor_groups``.",
               "items": {
                  "type": "string"
               },
               "title": "Factor Groups Forward Fill",
               "type": "array"
            },
            "factor_groups_gaussianize": {
               "description": "For which continuous groups to gaussianize the exposures. Each entry must also appear in ``continuous_factor_groups``.",
               "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. ``maintain_zeros`` only takes effect during gaussianization, so each entry must also appear in ``factor_groups_gaussianize`` (and therefore in ``continuous_factor_groups``).",
               "items": {
                  "type": "string"
               },
               "title": "Factor Groups Gaussianize Maintain Zeros",
               "type": "array"
            },
            "factor_groups_fill_miss": {
               "description": "For which continuous groups to fill missing values. Each entry must also appear in ``continuous_factor_groups``.",
               "items": {
                  "type": "string"
               },
               "title": "Factor Groups Fill Miss",
               "type": "array"
            },
            "hierarchy_sources": {
               "additionalProperties": {
                  "type": "string"
               },
               "description": "Mapping from factor group name to uploaded hierarchy dataset name. Factor groups not in this mapping use a flat hierarchy from factor names.",
               "title": "Hierarchy Sources",
               "type": "object"
            }
         },
         "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])

  • is_system_wide (bool)

  • kind (Literal['derived'])

  • reference_dataset (str | int)

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

  • trim_assets_sources (list[str] | None)

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

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

Validators:
  • _validate_trim_assets_sources » all fields

  • validate_reference_dataset » reference_dataset

field kind: Literal['derived'] = 'derived'#

Discriminator field for the risk dataset settings union (derived vs root). Use derived for datasets built on top of a parent reference dataset; use root (on RootRiskDatasetSettings) for datasets built directly from upload sources.

Validated by:
  • _strip_unknown_on_load

  • _validate_trim_assets_sources

field is_system_wide: bool = False#

Whether the risk dataset is system wide and provided by Bayesline.

Validated by:
  • _strip_unknown_on_load

  • _validate_trim_assets_sources

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.

Validated by:
  • _strip_unknown_on_load

  • _validate_trim_assets_sources

  • validate_reference_dataset

validator validate_reference_dataset str | int  »  reference_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

Validated by:
  • _strip_unknown_on_load

  • _validate_trim_assets_sources

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

The exchange codes to filter the reference dataset down to.

Validated by:
  • _strip_unknown_on_load

  • _validate_trim_assets_sources

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.

Validated by:
  • _strip_unknown_on_load

  • _validate_trim_assets_sources

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

Restrict the asset/ccy union used by trim_assets to these upload sources. None (default) preserves the prior behaviour: the union is taken across every uploaded-exposure source in exposures. Each entry must be the exposure_source of an uploaded-type entry in exposures. Only meaningful when trim_assets is 'asset_union' or 'ccy_union'.

Validated by:
  • _strip_unknown_on_load

  • _validate_trim_assets_sources

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 uploaded exposures and the reference dataset when referenced exposures are provided. If ‘latest_start’, the start date is trimmed to the latest start date the uploaded exposures, or the uploaded exposures and the reference dataset when referenced exposures are provided. If a date is provided, the start date is trimmed to the provided date.

Validated by:
  • _strip_unknown_on_load

  • _validate_trim_assets_sources

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 uploaded exposures and the reference dataset when referenced exposures are provided. If ‘latest_end’, the end date is trimmed to the latest end date of the uploaded exposures, or the uploaded exposures and the reference dataset when referenced exposures are provided. If a date is provided, the end date is trimmed to the provided date.

Validated by:
  • _strip_unknown_on_load

  • _validate_trim_assets_sources

get_references() Sequence[str | int]#

Get references for this settings object.

Returns#

Sequence[str | int]

A sequence of references (strings or integers) 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.