bayesline.api.equity.RootRiskDatasetSettings#
- pydantic model bayesline.api.equity.RootRiskDatasetSettings#
Settings for creating a root risk dataset directly from uploads.
A root dataset has no reference dataset. It is assembled by reading from seven upload sources (market_cap, price, exposures, exchange_dates, exchange_rates, series, idmap) and producing a
ConsolidatedDataParamsthat can subsequently be referenced by the standardDerivedRiskDatasetSettingsflow.All upload rows are expected to be in master-id space (
asset_id_typecolumn equal tomaster_id_type). Foreign-id rows in the same uploads are tolerated but ignored during root-dataset construction.Shares the joint
RiskDatasetSettingsMenuwithDerivedRiskDatasetSettings; the validator populates theavailable_*_sourcesfields relevant to this variant. Thekinddiscriminator routes Pydantic-union dispatch.Show JSON schema
{ "title": "RootRiskDatasetSettings", "description": "Settings for creating a *root* risk dataset directly from uploads.\n\nA root dataset has no reference dataset. It is assembled by reading from\nseven upload sources (market_cap, price, exposures, exchange_dates,\nexchange_rates, series, idmap) and producing a ``ConsolidatedDataParams``\nthat can subsequently be referenced by the standard ``DerivedRiskDatasetSettings``\nflow.\n\nAll upload rows are expected to be in master-id space (``asset_id_type``\ncolumn equal to ``master_id_type``). Foreign-id rows in the same uploads\nare tolerated but ignored during root-dataset construction.\n\nShares the joint ``RiskDatasetSettingsMenu`` with ``DerivedRiskDatasetSettings``;\nthe validator populates the ``available_*_sources`` fields relevant to this\nvariant. The ``kind`` discriminator routes Pydantic-union dispatch.", "type": "object", "properties": { "kind": { "const": "root", "default": "root", "description": "Discriminator field for the risk dataset settings union. ``root`` selects this variant for datasets built directly from upload sources (no reference dataset).", "title": "Kind", "type": "string" }, "market_cap_source": { "description": "Upload source name providing per-asset-day market-cap data: (date, asset_id, asset_id_type, ccy, market_cap, volume, idio_vol).", "title": "Market Cap Source", "type": "string" }, "price_source": { "description": "Upload source name providing prices: (date, asset_id, asset_id_type, ccy, close, return, delisted).", "title": "Price Source", "type": "string" }, "exposures_source": { "description": "Upload source name providing factor exposures: (date, asset_id, asset_id_type, factor_group, factor, exposure).", "title": "Exposures Source", "type": "string" }, "exchange_dates_source": { "description": "Upload source name providing trading-day membership per exchange: (date, exchange).", "title": "Exchange Dates Source", "type": "string" }, "exchange_rates_source": { "description": "Upload source name providing single-base USD FX rates: (date, ccy, fx_rate).", "title": "Exchange Rates Source", "type": "string" }, "series_source": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "description": "Upload source name providing time series in long format: (date, series, value). Optional.", "title": "Series Source" }, "idmap_source": { "description": "Upload source name providing the id-map table: (start_date, end_date, from_id_type, from_id, to_id_type, to_id). The (master_id_type -> master_id_core_type) projection is extracted during dataset construction.", "title": "Idmap Source", "type": "string" }, "dense_factor_groups": { "additionalProperties": { "anyOf": [ { "type": "string" }, { "type": "null" } ] }, "description": "Mapping of dense factor-group name to hierarchy upload source. Use ``None`` as the value to use a default flat hierarchy.", "title": "Dense Factor Groups", "type": "object" }, "sparse_factor_groups": { "additionalProperties": { "anyOf": [ { "type": "string" }, { "type": "null" } ] }, "description": "Mapping of sparse factor-group name to hierarchy upload source. Use ``None`` as the value to use a default flat hierarchy.", "title": "Sparse Factor Groups", "type": "object" }, "master_id_type": { "default": "bayesid", "description": "The canonical asset-id type. Upload rows whose ``asset_id_type`` does not equal this value are ignored.", "title": "Master Id Type", "type": "string" }, "master_id_core_type": { "default": "bayesid_core", "description": "The canonical core-asset-id type. Used to extract the asset-to-core mapping from the idmap upload.", "title": "Master Id Core Type", "type": "string" }, "as_of_date": { "anyOf": [ { "type": "string" }, { "format": "date", "type": "string" }, { "format": "date-time", "type": "string" } ], "description": "Snapshot date for the IdMapper. Only id-mapping rows whose ``start_date <= as_of_date`` are retained when constructing the dataset's ``IdMapper``. Pick the date as of which the uploaded idmap should be considered authoritative \u2014 typically the most recent date for which the upload contains complete mappings. Accepts a ``date``, ``datetime``, or ISO-format string; the consumer normalizes via ``to_date(...)``.", "title": "As Of Date" } }, "additionalProperties": false, "required": [ "market_cap_source", "price_source", "exposures_source", "exchange_dates_source", "exchange_rates_source", "idmap_source", "as_of_date" ] }
- Config:
frozen: bool = True
extra: str = forbid
- Fields:
as_of_date (str | datetime.date | datetime.datetime)dense_factor_groups (dict[str, str | None])exchange_dates_source (str)exchange_rates_source (str)exposures_source (str)idmap_source (str)kind (Literal['root'])market_cap_source (str)master_id_core_type (str)master_id_type (str)price_source (str)series_source (str | None)sparse_factor_groups (dict[str, str | None])
- Validators:
_validate_hierarchy_sources»dense_factor_groups_validate_hierarchy_sources»sparse_factor_groups_validate_required_source»exchange_dates_source_validate_required_source»exchange_rates_source_validate_required_source»exposures_source_validate_required_source»idmap_source_validate_required_source»market_cap_source_validate_required_source»price_source_validate_series_source»series_source
-
field kind:
Literal['root'] = 'root'# Discriminator field for the risk dataset settings union.
rootselects this variant for datasets built directly from upload sources (no reference dataset).- Validated by:
_strip_unknown_on_load
-
field market_cap_source:
str[Required]# Upload source name providing per-asset-day market-cap data: (date, asset_id, asset_id_type, ccy, market_cap, volume, idio_vol).
- Validated by:
_strip_unknown_on_load_validate_required_source
-
field price_source:
str[Required]# Upload source name providing prices: (date, asset_id, asset_id_type, ccy, close, return, delisted).
- Validated by:
_strip_unknown_on_load_validate_required_source
-
field exposures_source:
str[Required]# Upload source name providing factor exposures: (date, asset_id, asset_id_type, factor_group, factor, exposure).
- Validated by:
_strip_unknown_on_load_validate_required_source
-
field exchange_dates_source:
str[Required]# Upload source name providing trading-day membership per exchange: (date, exchange).
- Validated by:
_strip_unknown_on_load_validate_required_source
-
field exchange_rates_source:
str[Required]# Upload source name providing single-base USD FX rates: (date, ccy, fx_rate).
- Validated by:
_strip_unknown_on_load_validate_required_source
-
field series_source:
str|None= None# Upload source name providing time series in long format: (date, series, value). Optional.
- Validated by:
_strip_unknown_on_load_validate_series_source
-
field idmap_source:
str[Required]# Upload source name providing the id-map table: (start_date, end_date, from_id_type, from_id, to_id_type, to_id). The (master_id_type -> master_id_core_type) projection is extracted during dataset construction.
- Validated by:
_strip_unknown_on_load_validate_required_source
-
field dense_factor_groups:
dict[str,str|None] [Optional]# Mapping of dense factor-group name to hierarchy upload source. Use
Noneas the value to use a default flat hierarchy.- Validated by:
_strip_unknown_on_load_validate_hierarchy_sources
-
field sparse_factor_groups:
dict[str,str|None] [Optional]# Mapping of sparse factor-group name to hierarchy upload source. Use
Noneas the value to use a default flat hierarchy.- Validated by:
_strip_unknown_on_load_validate_hierarchy_sources
-
field master_id_type:
str= 'bayesid'# The canonical asset-id type. Upload rows whose
asset_id_typedoes not equal this value are ignored.- Validated by:
_strip_unknown_on_load
-
field master_id_core_type:
str= 'bayesid_core'# The canonical core-asset-id type. Used to extract the asset-to-core mapping from the idmap upload.
- Validated by:
_strip_unknown_on_load
-
field as_of_date:
str|date|datetime[Required]# Snapshot date for the IdMapper. Only id-mapping rows whose
start_date <= as_of_dateare retained when constructing the dataset’sIdMapper. Pick the date as of which the uploaded idmap should be considered authoritative — typically the most recent date for which the upload contains complete mappings. Accepts adate,datetime, or ISO-format string; the consumer normalizes viato_date(...).- Validated by:
_strip_unknown_on_load
- get_references() Sequence[str | int]#
Get references for this settings object.
Returns#
- Sequence[str | int]
A sequence of upload-source references for this settings object.
- map_references(fn: Callable[[str | int], str | int]) Self#
Return a copy with every reference rewritten by
fn.The structural dual of
get_references(): it appliesfnto each reference this settings object holds — recursing into nested settings — and returns a rewritten copy, leaving all non-reference fields untouched. The base implementation has no references and returnsselfunchanged, mirroringget_references()(whose default is[]); a subclass that overrides one must override the other in lockstep so the two stay consistent (a parity test enforces this).fnis applied purely structurally — this object knows where its references live, not what a rewrite means. Any resolution context (e.g. a current user or a user directory) must be captured by the caller in thefnclosure; the settings layer never learns of it.Parameters#
- fnCallable[[str | int], str | int]
Applied to each reference leaf. Must preserve a reference’s kind (a name stays a name, an id stays an id).
Returns#
- Self
A copy with references rewritten.
- describe(menu: RiskDatasetSettingsMenu) str#
Describe the root risk dataset settings.
Parameters#
- menuRiskDatasetSettingsMenu
The settings menu to use to describe the settings.
Returns#
- str
A description of the root risk dataset settings.