qis.FactorsData

class qis.FactorsData(factors_prices, factors=None)[source]

Bases: object

tradable factor price levels, optionally validated against a factor-set descriptor.

Passing factors turns the column names into a checked contract: construction fails if an expected factor is missing, which catches a renamed or dropped column at load time rather than in the middle of an estimation. Leaving it None keeps the container generic.

Variables:
  • factors_prices (pandas.DataFrame) – factor price levels, one column per factor, indexed by date

  • factors (Type[enum.Enum] | None) – str-valued Enum whose values are the expected column names. None skips validation

Raises:

ValueError – if factors is given and a factor it names is absent from the columns

Parameters:
__init__(factors_prices, factors=None)
Parameters:
Return type:

None

Methods

__init__(factors_prices[, factors])

from_sql(query[, connection, factors, ...])

Load factor prices from a SQL source.

get_factor_prices(factor[, time_period])

Price series for one factor, by name or enum member.

get_prices([time_period])

Full factor price panel, optionally time-sliced.

load(local_path[, file_name, factors, ...])

Load factor prices from a CSV produced by the production layer.

Attributes

factor_names

Factor column names in panel order.

factors

factors_prices

factors_prices: DataFrame
factors: Type[Enum] | None = None
classmethod load(local_path, file_name='futures_risk_factors', factors=None, time_period=None)[source]

Load factor prices from a CSV produced by the production layer.

Parameters:
Return type:

FactorsData

classmethod from_sql(query, connection=None, factors=None, time_period=None)[source]

Load factor prices from a SQL source.

Forward hook for database-backed instantiation using qis.sql_engine. Wire the project connection here so cohorts can be sourced from the database without changing any consumer. Not yet implemented.

Parameters:
Return type:

FactorsData

property factor_names: List[str]

Factor column names in panel order.

get_factor_prices(factor, time_period=None)[source]

Price series for one factor, by name or enum member.

Parameters:
Return type:

Series

get_prices(time_period=None)[source]

Full factor price panel, optionally time-sliced.

Parameters:

time_period (TimePeriod | None)

Return type:

DataFrame