bayesline.api.equity.AsyncFactorModelApi#

class bayesline.api.equity.AsyncFactorModelApi#

Bases: ABC

Methods

__init__()

dates()

Returns All dates covered by this risk model.

estimation_universe(*[, start, end, ...])

Obtains the risk model estimation universe for this risk model.

estimation_universe_as_task(*[, start, end, ...])

exposures(*[, start, end, id_type, stage])

Obtains the risk model exposures for this risk model.

exposures_as_task(*[, start, end, id_type, ...])

factors(*which)

Parameters which: FactorType The factor types to return, e.g. Market, Style, Industry, Region. By default returns all factors.

fret(*[, freq, cumulative, start, end])

Parameters freq: str, optional The frequency of the return aggregation, e.g. D for daily. Defaults to daily (i.e. unaggregated) cumulative: bool, optional If True, returns the cumulative returns. :8: (WARNING/2) Definition list ends without a blank line; unexpected unindent. start: DateLike, optional end: DateLike, optional

fret_as_task(*[, freq, cumulative, start, end])

future_asset_returns(*[, start, end, id_type])

Obtains the asset returns for this risk model on the next day.

future_asset_returns_as_task(*[, start, ...])

market_caps(*[, start, end, id_type])

Obtains the exposure-weighted market caps for this risk model.

market_caps_as_task(*[, start, end, id_type])

p_values()

p_values_as_task()

r2()

r2_as_task()

sigma2()

sigma2_as_task()

t_stats()

t_stats_as_task()

universe(*[, start, end, id_type, stage])

Obtains the risk model universe for this risk model.

universe_as_task(*[, start, end, id_type, stage])

weights(*[, start, end, id_type])

Obtains the idiosynchratic volatility weights for this risk model.

weights_as_task(*[, start, end, id_type])

abstract async dates() list[date]#

Returns#

All dates covered by this risk model.

abstract async factors(*which: Literal['Market', 'Style', 'Industry', 'Region', 'Other']) list[str]#

Parameters#

which: FactorType

The factor types to return, e.g. Market, Style, Industry, Region. By default returns all factors.

Returns#

list of all factors for the given factor types.

abstract async exposures(*, start: str | date | datetime | None = None, end: str | date | datetime | None = None, id_type: Literal['bayesid', 'ticker', 'composite_figi', 'cik', 'cusip8', 'cusip9', 'isin', 'sedol6', 'sedol7', 'proxy', 'name'] | None = None, stage: int = 1) DataFrame#

Obtains the risk model exposures for this risk model.

Parameters#

start: DateLike, optional

The start date of the data to return, inclusive.

end: DateLike, optional

The end date of the data to return, inclusive.

id_type: IdType, optional

The id type to return asset ids in, e.g. ticker. The given id type must be supported by the linked universe.

stage: int, default=1,

The stage of the factor model to return exposures for, of the potentially multi-stage regression. Default to 1 (the first stage).

Raises#

ValueError

If the given id type is not supported or date range is invalid.

Returns#

pl.DataFrame

The data for the given date range with the first two column as the date and asset id. The remaining columns are the individual styles.

abstract async exposures_as_task(*, start: str | date | datetime | None = None, end: str | date | datetime | None = None, id_type: Literal['bayesid', 'ticker', 'composite_figi', 'cik', 'cusip8', 'cusip9', 'isin', 'sedol6', 'sedol7', 'proxy', 'name'] | None = None, stage: int = 1) AsyncTask[DataFrame]#
abstract async universe(*, start: str | date | datetime | None = None, end: str | date | datetime | None = None, id_type: Literal['bayesid', 'ticker', 'composite_figi', 'cik', 'cusip8', 'cusip9', 'isin', 'sedol6', 'sedol7', 'proxy', 'name'] | None = None, stage: int = 1) DataFrame#

Obtains the risk model universe for this risk model.

Parameters#

start: DateLike, optional

The start date of the data to return, inclusive.

end: DateLike, optional

The end date of the data to return, inclusive.

id_type: IdType, optional

The id type to return asset ids in, e.g. ticker. The given id type must be supported by the linked universe.

stage: int, default=1,

The stage of the factor model to return universe for, of the potentially multi-stage regression. Default to 1 (the first stage).

Raises#

ValueError

If the given id type is not supported or date range is invalid.

Returns#

pl.DataFrame

The data for the given date range where the first column is the date and the remaining columns are the asset ids. The values are the universe inclusion.

abstract async universe_as_task(*, start: str | date | datetime | None = None, end: str | date | datetime | None = None, id_type: Literal['bayesid', 'ticker', 'composite_figi', 'cik', 'cusip8', 'cusip9', 'isin', 'sedol6', 'sedol7', 'proxy', 'name'] | None = None, stage: int = 1) AsyncTask[DataFrame]#
abstract async estimation_universe(*, start: str | date | datetime | None = None, end: str | date | datetime | None = None, id_type: Literal['bayesid', 'ticker', 'composite_figi', 'cik', 'cusip8', 'cusip9', 'isin', 'sedol6', 'sedol7', 'proxy', 'name'] | None = None, stage: int = 1) DataFrame#

Obtains the risk model estimation universe for this risk model.

Parameters#

start: DateLike, optional

The start date of the data to return, inclusive.

end: DateLike, optional

The end date of the data to return, inclusive.

id_type: IdType, optional

The id type to return asset ids in, e.g. ticker. The given id type must be supported by the linked universe.

stage: int, default=1,

The stage of the factor model to return universe for, of the potentially multi-stage regression. Default to 1 (the first stage).

Raises#

ValueError

If the given id type is not supported or date range is invalid.

Returns#

pl.DataFrame

The data for the given date range where the first column is the date and the remaining columns are the asset ids. The values are the estimation universe inclusion.

abstract async estimation_universe_as_task(*, start: str | date | datetime | None = None, end: str | date | datetime | None = None, id_type: Literal['bayesid', 'ticker', 'composite_figi', 'cik', 'cusip8', 'cusip9', 'isin', 'sedol6', 'sedol7', 'proxy', 'name'] | None = None, stage: int = 1) AsyncTask[DataFrame]#
abstract async market_caps(*, start: str | date | datetime | None = None, end: str | date | datetime | None = None, id_type: Literal['bayesid', 'ticker', 'composite_figi', 'cik', 'cusip8', 'cusip9', 'isin', 'sedol6', 'sedol7', 'proxy', 'name'] | None = None) DataFrame#

Obtains the exposure-weighted market caps for this risk model.

Parameters#

start: DateLike, optional

The start date of the data to return, inclusive.

end: DateLike, optional

The end date of the data to return, inclusive.

id_type: IdType, optional

The id type to return asset ids in, e.g. ticker. The given id type must be supported by the linked universe.

Raises#

ValueError

If the given id type is not supported or date range is invalid.

Returns#

pl.DataFrame

The data for the given date range where the rows are the total market cap for each date, weighted by the exposure of each asset. For industry factors, this specifically means that the value is the sum of all assets in the estimation universe in that industry.

abstract async market_caps_as_task(*, start: str | date | datetime | None = None, end: str | date | datetime | None = None, id_type: Literal['bayesid', 'ticker', 'composite_figi', 'cik', 'cusip8', 'cusip9', 'isin', 'sedol6', 'sedol7', 'proxy', 'name'] | None = None) AsyncTask[DataFrame]#
abstract async weights(*, start: str | date | datetime | None = None, end: str | date | datetime | None = None, id_type: Literal['bayesid', 'ticker', 'composite_figi', 'cik', 'cusip8', 'cusip9', 'isin', 'sedol6', 'sedol7', 'proxy', 'name'] | None = None) DataFrame#

Obtains the idiosynchratic volatility weights for this risk model.

Parameters#

start: DateLike, optional

The start date of the data to return, inclusive.

end: DateLike, optional

The end date of the data to return, inclusive.

id_type: IdType, optional

The id type to return asset ids in, e.g. ticker. The given id type must be supported by the linked universe.

Raises#

ValueError

If the given id type is not supported or date range is invalid.

Returns#

pl.DataFrame

The data for the given date range where the rows are the idiosyncratic volatility for each date.

abstract async weights_as_task(*, start: str | date | datetime | None = None, end: str | date | datetime | None = None, id_type: Literal['bayesid', 'ticker', 'composite_figi', 'cik', 'cusip8', 'cusip9', 'isin', 'sedol6', 'sedol7', 'proxy', 'name'] | None = None) AsyncTask[DataFrame]#
abstract async future_asset_returns(*, start: str | date | datetime | None = None, end: str | date | datetime | None = None, id_type: Literal['bayesid', 'ticker', 'composite_figi', 'cik', 'cusip8', 'cusip9', 'isin', 'sedol6', 'sedol7', 'proxy', 'name'] | None = None) DataFrame#

Obtains the asset returns for this risk model on the next day.

Parameters#

start: DateLike, optional

The start date of the data to return, inclusive.

end: DateLike, optional

The end date of the data to return, inclusive.

id_type: IdType, optional

The id type to return asset ids in, e.g. ticker. The given id type must be supported by the linked universe.

Raises#

ValueError

If the given id type is not supported or date range is invalid.

Returns#

pl.DataFrame

The data for the given date range where the index is the date and the columns are the asset id. The values are the asset returns.

abstract async future_asset_returns_as_task(*, start: str | date | datetime | None = None, end: str | date | datetime | None = None, id_type: Literal['bayesid', 'ticker', 'composite_figi', 'cik', 'cusip8', 'cusip9', 'isin', 'sedol6', 'sedol7', 'proxy', 'name'] | None = None) AsyncTask[DataFrame]#
abstract async fret(*, freq: str | None = None, cumulative: bool = False, start: str | date | datetime | None = None, end: str | date | datetime | None = None) DataFrame#

Parameters#

freq: str, optional

The frequency of the return aggregation, e.g. D for daily. Defaults to daily (i.e. unaggregated)

cumulative: bool, optional

If True, returns the cumulative returns.

start: DateLike, optional end: DateLike, optional

Returns#

pl.DataFrame

The factor returns for the given date range.

abstract async fret_as_task(*, freq: str | None = None, cumulative: bool = False, start: str | date | datetime | None = None, end: str | date | datetime | None = None) AsyncTask[DataFrame]#
abstract async t_stats() DataFrame#
abstract async t_stats_as_task() AsyncTask[DataFrame]#
abstract async p_values() DataFrame#
abstract async p_values_as_task() AsyncTask[DataFrame]#
abstract async r2() DataFrame#
abstract async r2_as_task() AsyncTask[DataFrame]#
abstract async sigma2() DataFrame#
abstract async sigma2_as_task() AsyncTask[DataFrame]#