bayesline.api.equity.FactorModelApi#
- class bayesline.api.equity.FactorModelApi#
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
()r2
()sigma2
()t_stats
()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 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 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 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) Task[DataFrame] #
- abstract 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 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) Task[DataFrame] #
- abstract 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 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) Task[DataFrame] #
- abstract 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 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) Task[DataFrame] #
- abstract 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 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) Task[DataFrame] #
- abstract 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 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) Task[DataFrame] #
- abstract 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 fret_as_task(*, freq: str | None = None, cumulative: bool = False, start: str | date | datetime | None = None, end: str | date | datetime | None = None) Task[DataFrame] #
- abstract t_stats() DataFrame #
- abstract p_values() DataFrame #
- abstract r2() DataFrame #
- abstract sigma2() DataFrame #