bayesline.api.equity.AsyncFactorModelEngineApi#

class bayesline.api.equity.AsyncFactorModelEngineApi#

Provide access to factor risk model engine operations.

A factor model engine is responsible for building and managing factor risk models based on provided settings.

__init__()#

Methods

__init__()

get_model([mode])

Get a built factor model instance for the given settings.

get_model_as_task([mode])

Get a built factor model instance as a task.

Attributes

settings

Get the settings used to create this risk model.

abstract property settings: FactorRiskModelSettings#

Get the settings used to create this risk model.

Returns#

FactorRiskModelSettings

The settings used to create this risk model.

abstract async get_model(mode: Literal['compute', 'compute-and-persist', 'get-or-compute', 'get-or-compute-and-persist', 'get-or-fail'] = 'get-or-compute-and-persist') AsyncFactorModelApi#

Get a built factor model instance for the given settings.

Parameters#

modeGetModelMode, default=”get-or-compute-and-persist”

The mode to use to get the model. If compute, will compute the model from scratch and return it, without persisting it. If get-or-compute-and-persist, will check if the model is already persisted (and up to date) and return it if so, or else compute it from scratch and persist it. If get-or-compute, will check if the model is already persisted and return it if so, or else compute it from scratch and return it without persisting it. If compute-and-persist, will compute the model from scratch and persist it. If get-or-fail, will return the model if it is already persisted, or else raise an error if the model is not persisted.

Returns#

AsyncFactorModelApi

A built factor model instance for the given settings.

abstract async get_model_as_task(mode: Literal['compute', 'compute-and-persist', 'get-or-compute', 'get-or-compute-and-persist', 'get-or-fail'] = 'get-or-compute-and-persist') AsyncTask[AsyncFactorModelApi]#

Get a built factor model instance as a task.

Parameters#

modeGetModelMode, default=”get-or-compute-and-persist”

The mode to use to get the model. If compute, will compute the model from scratch and return it, without persisting it. If get-or-compute-and-persist, will check if the model is already persisted (and up to date) and return it if so, or else compute it from scratch and persist it. If get-or-compute, will check if the model is already persisted and return it if so, or else compute it from scratch and return it without persisting it. If compute-and-persist, will compute the model from scratch and persist it. If get-or-fail, will return the model if it is already persisted, or else raise an error if the model is not persisted.

Returns#

AsyncTask[FactorModelApi]

A task that will return a built factor model instance for the given settings.