Utilities

Utilities#

Universe

Defines a timeseries of constituents of a some grouping of instruments (for example constituents of S&P 500, or all stocks in a region, or something else)

UniverseFilterTs

A class implementing a universe filter timeseries.

UniverseGenerator

Universe generator from SIGMaster to define universes over a data range.

StrategySingleStockFilter

A class implementing a full set of features for single stock filters.

StrategySingleStockFilterTs

A class generating single stock universes based on customized filters.

SingleStockFilter

A class implementing a single stock filter.

FirmLevelSingleStockFilter

A class implementing a single stock filter (firm level).

SIGMaster

SIGMaster using FrameworkObject

LiquidityIndicators

Collection of liquidity indicators used to rank and select stocks.

EquityGroup

A class representing an equity group.

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.

CovEstimators

Collection of covariance estimation methods.

EquityUniverseFilter

Class designed to filter stocks by fundamentals, e.g.

EquityInstrument

A class representing an equity instrument.

sigtech.framework.strategies.equity_factor_basket.default_factors_to_weight_function(factors: DataFrame, factor_weights: Optional[dict] = None, z_score: bool = False, proportion: Optional[float] = None, long_only: bool = False, **kwargs) Series

Default factor to weight function - This creates a linear combination of factors.

If proportion is not passed, stock weights are proportional to the sum of the input factor loadings. If proportion is passed, the top proportion % of stocks are given weights of 1 and the bottom proportion % are given weights of -1. If long_only=True (default False) the negative weights are truncated.

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 with long_only=True, only the top proportion % are returned with positive values and the negative mirror image is removed. If long_only=False both the positive and negative weights are returned. If proportion is not passed this parameter has no effect.

Returns:

Series of stock weights. Index will be (possibly subset of) columns of factors.

sigtech.framework.strategies.equity_factor_basket.factor_weighted_factors_to_weight_function(factors: DataFrame, factor_weights: Optional[dict] = None, z_score: bool = False, proportion: Optional[float] = None, long_only: bool = False, **kwargs) Series

Similar to default_factors_to_weight_function but weight the stocks proportionally to their summed factor scores.

sigtech.framework.instruments.equities.get_liquidity_df(liquidity_function, tickers: Union[str, list[str]] = None, exchange_ticker: str = None, dt: date = None, rolling_window: int = 60, min_periods_ratio: float = 0.75, filters: dict = None) DataFrame

Return a DataFrame containing the liquidity values for all the tickers in the given universe of listings. This information can be used to compute the most liquid listing.

Parameters:
  • liquidity_function – The liquidity function to be used.

  • tickers – Tradable ticker used to find all relevant listings or list of tradable tickers. If not provided, exchange_ticker must be provided.

  • exchange_ticker – Exchange ticker used to find all relevant listings. If not provided, tickers must be provided.

  • dt – Date used to compute the liquidity metric among the listings. If not provided, will be equal to the environment date.

  • rolling_window – Rolling window value (default is 60).

  • min_periods_ratio – Minimum number of observations in window required to have a value, as percentage of rolling_window (e.g. 0.75 for 75%). Default is 0.75.

  • filters – Dict of additional SIGMaster filters.

Returns:

pandas DataFrame.

Example:

from sigtech.framework.equities.liquidity_indicators import LiquidityIndicators
from sigtech.framework.instruments.equities import get_liquidity_df

# All listings with exchange ticker 'AAPL' are used as input.
get_liquidity_df(exchange_ticker='AAPL',
                 rolling_window=30,
                 liquidity_function=LiquidityIndicators.rolling_dollar_vol)
sigtech.framework.instruments.equities.get_most_liquid_stock(liquidity_function, tickers: Union[str, list[str]] = None, exchange_ticker: str = None, dt: date = None, rolling_window: int = 60, min_periods_ratio: float = 0.75, filters: dict = None) Optional[str]

Return the most liquid listing given a tradable ticker or exchange ticker.

Parameters:
  • liquidity_function – The liquidity function to be used.

  • tickers – Tradable ticker used to find all relevant listings or list of tradable tickers. If not provided, exchange_ticker must be provided.

  • exchange_ticker – Exchange ticker used to find all relevant listings. If not provided, tickers must be provided.

  • dt – Date used to compute the liquidity metric among the listings. If not provided, will be equal to the environment date.

  • rolling_window – Rolling window value (default is 60).

  • min_periods_ratio – Minimum number of observations in window required to have a value, as percentage of rolling_window (e.g. 0.75 for 75%). Default is 0.75.

  • filters – Dict of additional SIGMaster filters.

Returns:

Ticker of the stock with the highest median of rolling dollar volume for the input date or None if no data is available.

Example:

from sigtech.framework.equities.liquidity_indicators import LiquidityIndicators

# All listings with exchange ticker 'AAPL' are used as input.
sig.get_most_liquid_stock(exchange_ticker='AAPL',
                          rolling_window=30,
                          liquidity_function=LiquidityIndicators.rolling_dollar_vol,
                          filters={'EXCHANGE_COUNTRY_ISO2': ['US']})

# All listings with same exchange ticker as '1000045.SINGLE_STOCK.TRADABLE' are used as input.
sig.get_most_liquid_stock(tickers='1000045.SINGLE_STOCK.TRADABLE',
                          liquidity_function=LiquidityIndicators.rolling_dollar_vol,
                          filters={'EXCHANGE_COUNTRY_ISO2': ['EUROPE']})

# *Only* the listings provided in the list are used as input.
sig.get_most_liquid_stock(tickers=['1000045.SINGLE_STOCK.TRADABLE', '1000046.SINGLE_STOCK.TRADABLE'],
                          liquidity_function=LiquidityIndicators.rolling_dollar_vol)