FactorToWeightBaseClass#
-
class sigtech.framework.strategies.equity_factor_basket.FactorToWeightBaseClass
Baseclasses:
ABC
Subclasses:
CapWeightedFactorToWeight
Class containing a factor_to_weight method to calculate stock weights from factor exposures.
This allows us to group together this method with the ability to add factors to the FactorExposures object.
-
static combine_factors(factors: DataFrame, factor_weights: Optional[dict] = None, z_score: bool = False, proportion: Optional[float] = None, long_only: bool = False) Series
Sum over the supplied stock-factor loadings to return stock weights.
- Parameters:
factors – Factor indexed
pd.DataFrame
of stock loadings. Stocks as columns.factor_weights – Optional dictionary of factor weights. Keys should match
factors
index.z_score – Boolean of whether to normalise stock-factor loadings before combination. This allows different factors to be put onto the same scale. Default is
False
.proportion – Optional, proportion for long/short allocations.
long_only – If
proportion
is passed withlong_only=True
, only the topproportion
% are returned with positive values and the negative mirror image is removed. Iflong_only=False
both the positive and negative weights are returned. Ifproportion
is not passed this parameter has no effect.
- Returns:
Series of stock weights. Index will be (possibly subset of) columns of
factors
.
-
static summed_weighted_factors(factors: DataFrame, factor_weights: Optional[dict[str, float]] = None, z_score: bool = False) Series
Sum the stock-factor loadings over factors to return stock weightings. If
weights
is passed the factors are appropriately weighted, otherwise they are equally weighted.- Parameters:
factors – Factor indexed
pd.DataFrame
of stock loadings. Stocks as columns.factor_weights – Optional dictionary of factor weights. Keys should match
factors
index.z_score – Boolean of whether to normalise stock-factor loadings before combination. This allows different factors to be put onto the same scale. Default is
False
.
- Returns:
Series of stock weights.