Utilities#
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) |
|
A class implementing a universe filter timeseries. |
|
Universe generator from |
|
A class implementing a full set of features for single stock filters. |
|
A class generating single stock universes based on customized filters. |
|
A class implementing a single stock filter. |
|
A class implementing a single stock filter (firm level). |
|
SIGMaster using FrameworkObject |
|
Collection of liquidity indicators used to rank and select stocks. |
|
A class representing an equity group. |
|
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. |
|
Collection of covariance estimation methods. |
|
Class designed to filter stocks by fundamentals, e.g. |
|
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. Ifproportion
is passed, the topproportion
% of stocks are given weights of1
and the bottomproportion
% are given weights of-1
. Iflong_only=True
(defaultFalse
) 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 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
.
-
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)