bayesline.api.equity.RiskDatasetSettings#

pydantic model bayesline.api.equity.RiskDatasetSettings#

Show JSON schema
{
   "title": "RiskDatasetSettings",
   "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"
               }
            ]
         },
         "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": "ccy_union",
         "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": "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"
      },
      "RiskDatasetHuberRegressionExposureSettings": {
         "additionalProperties": false,
         "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"
            },
            "huberize": {
               "default": true,
               "description": "Whether to huberize the resulting exposures.",
               "title": "Huberize",
               "type": "boolean"
            },
            "huberize_maintain_zeros": {
               "default": false,
               "description": "Whether to maintain zeros when huberizing the exposures.",
               "title": "Huberize 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,
         "properties": {
            "exposure_type": {
               "const": "referenced",
               "default": "referenced",
               "title": "Exposure Type",
               "type": "string"
            },
            "market_factor_groups": {
               "anyOf": [
                  {
                     "items": {
                        "type": "string"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The factor groups for market cap factors. If None, the market factor from the reference dataset is used.",
               "title": "Market Factor Groups"
            },
            "region_factor_groups": {
               "anyOf": [
                  {
                     "items": {
                        "type": "string"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The factor groups for region factors. If None, the region factor from the reference dataset is used.",
               "title": "Region Factor Groups"
            },
            "industry_factor_groups": {
               "anyOf": [
                  {
                     "items": {
                        "type": "string"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The factor groups for industry factors. If None, the industry factor from the reference dataset is used.",
               "title": "Industry Factor Groups"
            },
            "style_factor_groups": {
               "anyOf": [
                  {
                     "items": {
                        "type": "string"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The factor groups for style factors. If None, the style factor from the reference dataset is used.",
               "title": "Style Factor Groups"
            },
            "other_factor_groups": {
               "anyOf": [
                  {
                     "items": {
                        "type": "string"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The factor groups for other factors. If None, the other factor from the reference dataset is used.",
               "title": "Other Factor Groups"
            }
         },
         "title": "RiskDatasetReferencedExposureSettings",
         "type": "object"
      },
      "RiskDatasetUnitExposureSettings": {
         "additionalProperties": false,
         "properties": {
            "exposure_type": {
               "const": "unit",
               "default": "unit",
               "title": "Exposure Type",
               "type": "string"
            },
            "factor": {
               "description": "The factor to use for the unit exposures.",
               "title": "Factor",
               "type": "string"
            },
            "factor_group": {
               "description": "The factor group to use for the unit exposures.",
               "title": "Factor Group",
               "type": "string"
            },
            "factor_type": {
               "default": "market",
               "description": "The type of factor to use for the unit exposures.",
               "enum": [
                  "market",
                  "region",
                  "industry"
               ],
               "title": "Factor Type",
               "type": "string"
            }
         },
         "required": [
            "factor",
            "factor_group"
         ],
         "title": "RiskDatasetUnitExposureSettings",
         "type": "object"
      },
      "RiskDatasetUploadedExposureSettings": {
         "additionalProperties": false,
         "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"
            },
            "market_factor_group": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The factor group for market cap factors.",
               "title": "Market Factor Group"
            },
            "region_factor_group": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The factor group for region factors.",
               "title": "Region Factor Group"
            },
            "industry_factor_group": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The factor group for industry factors.",
               "title": "Industry Factor Group"
            },
            "style_factor_group": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The factor group for style factors.",
               "title": "Style Factor Group"
            },
            "other_factor_group": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The factor group for other factors.",
               "title": "Other Factor Group"
            },
            "style_factor_fill_miss": {
               "default": true,
               "description": "Whether to fill missing values for the style factors.",
               "title": "Style Factor Fill Miss",
               "type": "boolean"
            },
            "style_factor_huberize": {
               "default": true,
               "description": "Whether to huberize the style factors.",
               "title": "Style Factor Huberize",
               "type": "boolean"
            }
         },
         "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.

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'] = 'ccy_union'#

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.