DefaultUniverses#
-
class sigtech.framework.experimental.default_universes.default_universes.DefaultUniverses
Access the default universes of returns series for quick assessment of signal potential.
Constructor args are passed to the file utilities class used to cache returns series.
Example usage:
from sigtech.framework.experimental.default_universes import DefaultUniverses, AssetType du = DefaultUniverses(force_local=True, local_path='du_store') # Print out a pd.DataFrame of available returns series du.overview() # Fetch (and cache) all predefined PreciousMetals assets du.universe("PreciousMetals")
- Parameters:
force_local – Boolean to override the cache to be set to local rather than use s3 locations.
local_path – Local path to use for the file cache.
-
static overview(return_df: bool = False) Optional[DataFrame]
Return a
pd.DataFrame
of the available default universes. Universes are split by asset type.Example usage:
du = DeafultUniverses() # Print out a pd.DataFrame of available returns series du.overview() # Return the overview dataframe for manual filtering du.overview(return_df=True).loc['Energy']
- Parameters:
return_df – If
True
the overview dataframe is returned from this method for filtering. Otherwise, ifFalse
the dataframe is displayed and nothing is returned.- Returns:
pd.DataFrame if
return_df
elseNone
.
-
universe(universe_name: str, asset_types: Optional[list[sigtech.framework.internal.default_universes.asset_type_mapping.AssetType]] = None, start_date: date = datetime.date(2010, 1, 1), end_date: date = None, eq_freq: str = 'Q', eq_ffields: Optional[list[str]] = None, ccy: bool = 'USD', use_cache: bool = True, tickers: Optional[Union[str, list[str]]] = None, progress: bool = False, raise_exceptions: bool = True) DataFrame
Generate the requested default universe and return a DataFrame of universe returns. Most types of
AssetType
simply use thedefault_strategy_objects
, but typeSingleNameEquity
uses a filter on the Russell 3000 universe for stocks in the requested sector. This filtering can take some time and requires some additional kwargs outlined below.Note
Higher
eq_freq
frequencies will take some time to analyse. Suggestion is'Q'
.Example usage:
from sigtech.framework.experimental.default_universes import DefaultUniverses, AssetType du = DefaultUniverses(force_local=True, local_path='du_store') # Return (and cache) all returns series relating to the U.S. df_usa = du.universe('USA') # Return (and cache) only ETFs and Futures from the "Footfall" category df_footfall = du.universe(universe_name='Footfall', asset_types=[AssetType.ETF, AssetType.Future]) # Return the top 10 stocks (by market cap) in the "Industrials" sector, rebalancing each quarter # In this example we don't use the cache even if available but the new data will be saved into the cache df_industrial_stocks = du.universe( universe_name='Industrials', asset_type=[AssetType.SingleNameEquity], start_date=dtm.date(2020, 1, 1), end_date=None, # Defaults to today, eq_freq='Q', use_cache=False ) # Get reinvestment strategy returns series for specific stock tickers df_stocks = du.universe( 'SpecificStocks', tickers=[ '1000045.SINGLE_STOCK.TRADABLE', '1001962.SINGLE_STOCK.TRADABLE' ] ) # Custom universes can be defined by inheriting from ``Universe``. # The string keys for the assets can be found in the ``loader`` files like: # sigtech/framework/internal/default_universes/loaders/ from sigtech.framework.internal.default_universes.universe import Universe class CustomUniverse(Universe): name = 'MyCustomUniverse' strategy_names = { AssetType.Future: [ "Crude Oil", "Gas Oil" ] } du.universe("MyCustomUniverse")
- Parameters:
asset_types – List of
Types
for which the returns series will be provided.start_date – Starting date for the rates and single name equities filter. No effect on other
AssetTypes
.end_date – End date for the rates and single name equities filter. No effect on other
AssetTypes
.eq_freq – Pandas frequency on which to sample equity single stock universes between
start_date
andend_date
.eq_ffields – List of equity fundamental fields to pass to return single name equity fundamentals.
tickers – List of single name equity tickers to pass to
AssetType.SpecificStocks
(e.g. “1000045.SINGLE_STOCK.TRADABLE”) or list of rates keys (e.g. “USD 2Y”) to pass toAssetType.FairSwapRate
. Ignored for any otherAssetType
.use_cache – Boolean whether to use cache files. NOTE:
use_cache=False
will save new data to the cache even if previous versions exist. The cache will not be cleaned (previous versions removed) until the same query is re-run withuse_cache=True
.progress – If
True
a progress bar is displayed, incrementing each time an asset is loaded.raise_exceptions – If
False
exceptions raised during asset data loading will be captured and logged. Otherwise, ifTrue
(default) exceptions are raised from this method.
- Returns:
DataFrame of universe returns.