FactorExposures#

class sigtech.framework.analytics.optimization.factor_exposure.FactorExposures

A class implementing estimation methods for exposures to factors for a selection of instruments, i.e. performing a series of multivariate time-series regressions based on a configuration.

The configuration is created by adding steps to the object.

  • A fit() method executes the steps on the data provided, calculating the factor loadings across the instruments.

  • A report() method is available to generate a report summarizing the results.

Here is an example of configuring an object to perform a multivariate regression across a dataframe of factors, followed by a single regression of a factor series against the remaining residual.

factor_exposure = sig.FactorExposures()
factor_exposure.add_regression_factors(FACTOR_DATAFRAME)
factor_exposure.add_regression_factors(FACTOR_SERIES)

factor_exposure.fit(RETURNS_DATA_DICTIONARY)

factor_exposure.report()
DEFAULT_FACTOR_TS_METHODS = {}
AVAILABLE_COV_ESTIMATORS

alias of sigtech.framework.analytics.optimization.factor_exposure.CovEstimators

add_step(factor_names, params_dict=None)

Add a regression step to the fitting process.

Parameters
  • factor_names – List of timeseries factors to include in the regression step.

  • params_dict – Dictionary of parameters for the regression.

clear_steps()

Clear the configuration of regressions to perform.

store_prior_fit()

Store a backup of prior fit to recover later.

recover_prior_fit()

Recover the stored fit data.

add_regression_factors(ts, names=None, include_in_fit=True, fit_params=None)

Add timeseries factors to the calculation.

Parameters
  • ts – DataFrame or Series of factor values.

  • names – List of names given to the factors.

  • include_in_fit – Boolean flag to determine if a regression step is added (default is True).

  • fit_params – Parameters for the regression step.

add_factor_exposures(set_exposures)

Set the factor exposure overrides.

Parameters

set_exposures – Dictionary of factor-keyed dictionaries giving exposures on each instrument.

add_factor_exposure_method(name, method, method_kwargs=None)

Add a factor exposure method.

Parameters
  • name – Name to use for the factor.

  • method – Method mapping (instrument name, instrument timeseries) to factor exposure.

  • method_kwargs – kwargs for method.

add_cross_score(name, old_name)

Add a factor which uses the percentile of another base factor.

Parameters
  • name – Factor name

  • old_name – Base factor name.

Returns

add_raw_factor_labels(label_identifiers, factor_name=None)

Add a raw factor flag to identify instruments with a specified label.

Parameters
  • label_identifiers – list of label names and required result tuples.

  • factor_name – name of factor.

Returns

name of factor (string)

add_raw_factor_timeseries(name, method=None, history_field=None, fundamental_field=None, sector_ids=None, zscore_period=None, fundamental_freq=None, method_kwargs=None)

Add a data timeseries to use for a factor. This can be generated via a method, from a stock history, fundamental data or using a sector. If a period is supplied a z-score mapping is also applied.

Parameters
  • name – Factor name

  • method – Optional method use to generate timeseries from instrument.

  • history_field – Optional history field.

  • fundamental_field – Optional fundamental field.

  • zscore_period – Optional z-score period length.

  • fundamental_freq – Optional frequency for fundamental data.

  • method_kwargs – Optional kwargs for a supplied method.

Returns

fit(instrument_data, dt=None)

Run the regression steps to evaluate the loadings and residuals against a series of inputs.

Parameters

instrument_data – Series, DataFrame or dictionary of instruments and their return series.

Returns

DataFrame of exposure, DataFrame of residuals.

construct_replicating_basket_strategy(rep_ts, currency='USD', name=None, start_date=None, freq='1BD')

Construct a basket strategy that replicates the series returns using factors.

Parameters
  • rep_ts – Input timeseries.

  • currency – Currency identifier.

  • name – Basket strategy name (optional).

  • start_date – Basket strategy start date (optional).

  • freq – (optional, default is '1BD').

Returns

BasketStrategy object.

report(portfolio_weights=None)

Generate a report for the exposures of a portfolio using the fitted factor loadings.

Parameters

portfolio_weights – Dictionary or Series of allocation in portfolio (optional).

rolling_exposures(portfolio_df, instrument_df=None, window=None)

Evaluate historical exposures by providing a DataFrame of historical allocations.

If no instrument data is provided, then the previously fit exposures are used historically. If a window is provided, then a rolling fit is performed to calculate the exposures.

Parameters
  • portfolio_df – DataFrame or allocations.

  • instrument_df – DataFrame of instrument data (optional).

  • window – Rolling window length (optional).

Returns

DataFrame of exposures.

covariance_estimator(df, missing=None)

Covariance estimator used in the report. It defaults to the classical maximum likelihood estimator.

Parameters
  • df – Input DataFrame.

  • missing – Identifier for missing data behaviour: 'drop', 'fill' or 'fill_scaled' (optional).

Returns

Covariance data.

factor_covariance(start=None, end=None)

Covariance estimate for timeseries factors.

Parameters
  • start – Period start date (optional).

  • end – Period end date (optional).

Returns

Covariance data.

residual_covariance()

Covariance estimate for residuals.