Utilities#

sigtech.framework.strategies.reinvestment_strategy.get_single_stock_strategy(ticker=None, reinvestment_strategy_overrides=None, exchange_ticker=None, mic='XNAS', use_cache=False, most_liquid=False, build=True, tickers=None, exchange_tickers=None, **kwargs)

Method used to generate default reinvestment strategies.

Parameters
  • ticker – Tradable stock id, or list of tradable stock ids.

  • reinvestment_strategy_overrides – Dictionary of overrides for strategy creation.

  • exchange_ticker – Stock identifier, or list of stock identifier.

  • mic – Market identifier code (default is 'XNAS').

  • use_cache – Use the strategy service cache.

  • most_liquid

    If set to True, compute the most liquid listing given the tradable ticker or the exchange ticker (default is False). For more information please check get_most_liquid_stock(). The following keyword arguments are available:

    • liquidity_function: The liquidity function to be used (mandatory).

    • 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.

  • build – If True, build the reinvestment strategy (default True).

  • tickers – List of ticker.

  • exchange_tickers – List of exchange_ticker.

Returns

ReinvestmentStrategy object.

sigtech.framework.strategies.basket_strategies.basket(constituents, ccy, start_date=None, end_date=None, weights=None, total_return=False, t_cost=False, rebalance_frequency='EOM')

Helper function to create a constant weighted basket default.

Parameters
  • constituents – Basket constituents.

  • ccy – Currency identifier.

  • start_date – Start date (optional).

  • end_date – End date (optional).

  • weights – Weights (optional, default is uniform distribution).

  • total_return – Total return version of the strategy (optional, default is False).

  • t_cost – Include trading_costs (optional, default is False).

  • rebalance_frequency – Rebalance frequency, e.g. '1BD', '2BD', '1W', '2W', '1M'.

Returns

BasketStrategy.

sigtech.framework.strategies.basket_strategies.variance_weighted_basket(constituents, target_vol, var_alloc, ccy='USD', start_date=None, end_date=None, total_return=False, t_cost=False, rebalance_frequency='EOM')

Create a constant weighted basket to target a specified vol and incorporating a variance allocation.

Parameters
  • constituents – Basket constituents.

  • target_vol – Target volatility.

  • var_alloc – Volatilities allocation.

  • ccy – Currency identifier (optional).

  • start_date – Start date (optional).

  • end_date – End date (optional).

  • total_return – Total return version of the strategy (optional, default is False).

  • t_cost – Include trading_costs (optional, default is False).

  • rebalance_frequency – Rebalance frequency, e.g. '1BD', '2BD', '1W', '2W', '1M'.

Returns

BasketStrategy.

sigtech.framework.default_strategy_objects.utils.default_strategy_objects_df() pandas.core.frame.DataFrame

Return a DataFrame listing all default strategies available.

sigtech.framework.default_strategy_objects.utils.register_default_strategy(test_on_nightly_only: bool = False) collections.abc.Callable[[...], Any]

Decorator for registering a function to be default_strategy_object function.

Parameters

test_on_nightly_only – The strategy object will not be tested on main CI (default is False).

Returns

Wrapped function without any alteration.

sigtech.framework.default_strategy_objects.utils.search_default_strategies(search_string: Optional[str] = None, regular_expression_string: Optional[str] = None, search_name: Optional[bool] = True, search_path: Optional[bool] = True, search_docs: Optional[bool] = False, call_if_unique: Optional[bool] = False) Sequence[collections.abc.Callable]

Method to search the available default strategy objects. Either a simple string or regular expression can be supplied.

Example use:

from sigtech.framework.default_strategy_objects.utils import search_default_strategies

found_results = search_default_strategies('vg_index')
Parameters
  • search_string – Optional string to search.

  • regular_expression_string – Optional regular expression string to search for matches.

  • search_name – bool flag to set whether names are included in search domain (default is True).

  • search_path – bool flag to set whether paths are included in search domain (default is True).

  • search_docs – bool flag to set whether doc strings are included in search domain (default is False).

  • call_if_unique – bool to call the found method. This is only applied if the result is unique. (default is False).

Returns

List of callable functions that return strategies, If call_if_unique is True a strategy is returned.

sigtech.framework.strategies.constants.var_sizing(instrument_name: str, units: float, dt: datetime.datetime, strategy_name: str, alpha=0.05, horizon=1)

Sizing method based on the historical VaR of the instrument.

Parameters
  • instrument_name – Name of the instrument.

  • units – Target VaR.

  • dt – VaR estimation time.

  • strategy_name – Name of strategy.

  • alpha – The desired VaR quantile (optional, default is 0.05).

  • horizon – The desired time horizon for the returns (optional, default is 1 day).

sigtech.framework.strategies.constants.cvar_sizing(instrument_name: str, units: float, dt: datetime.datetime, strategy_name: str, alpha=0.05, horizon=1)

Sizing method based on the historical CVaR of the instrument.

Parameters
  • instrument_name – Name of the instrument.

  • units – Target CVaR.

  • dt – CVaR estimation time.

  • strategy_name – Name of strategy.

  • alpha – The desired CVaR quantile (optional, default is 0.05).

  • horizon – The desired time horizon for the returns (optional, default is 1 day).

sigtech.framework.strategies.constants.var_portfolio_sizing(instrument_name: str, units: float, dt: datetime.datetime, strategy_name: str, alpha=0.05, horizon=1, var_window: Optional[int] = None)

Sizing method based on the historical portfolio VaR of the strategy.

Parameters
  • instrument_name – Name of the instrument.

  • units – Target VaR.

  • dt – VaR estimation time.

  • strategy_name – Name of strategy.

  • alpha – The desired VaR quantile (optional, default is 0.05).

  • horizon – The desired time horizon for the returns (optional, default is 1 day).

  • var_window – The historical window applied to the VaR period, default is None (i.e. expanding window).

sigtech.framework.strategies.constants.register_sizing_method(name, method)

Allows the user to register a custom sizing method in addition to MODEL, TRADE etc. Example usage:

def percent_sizing(instrument_name, units, dt, strategy_name):
    return units / 100.0

sig.register_sizing_method('PERCENT', percent_sizing)

class MyStrategy(sig.DailyStrategy):

    def strategy_initialization(self, dt):
        # Order 200% of the stock
        self.add_position_target(dtm.date(2021,7,10),
                                 instrument_name='1003331.SINGLE_STOCK.TRADABLE',
                                 units=200.0,
                                 unit_type='PERCENT'
                                 )
sigtech.framework.strategies.analytics.label.country_code_labelling_method(instrument_name)

Default country code labelling method.

sigtech.framework.strategies.analytics.label.country_labelling_method(instrument_name)

Default country labelling method.

sigtech.framework.strategies.analytics.label.continent_labelling_method(instrument_name)

Default continent labelling method.

sigtech.framework.strategies.analytics.label.sig_class_labelling_method(instrument_name)

Default class labelling method.

sigtech.framework.strategies.analytics.label.sig_name_labelling_method(instrument_name)

Default class labelling method.

sigtech.framework.strategies.analytics.label.sig_group_labelling_method(instrument_name)

Default group labelling method.

sigtech.framework.strategies.analytics.label.currency_labelling_method(instrument_name)

Default currency labelling method.

sigtech.framework.strategies.analytics.label.equity_sector_labelling_method(instrument_name, level)

Default equity sector labelling method.

sigtech.framework.strategies.analytics.label.asset_class_labelling_method(instrument_name)

Default equity sector labelling method.

sigtech.framework.strategies.analytics.label.register_labelling_method(label_name: str, method: callable)

Register a custom instrument labelling method. Example usage:

def currency_label_method(instrument_name):
    return sig.obj.get(instrument_name).currency

sig.register_labelling_method('MY_CURRENCY_LABEL', currency_label_method)

print(sig.get_label('MY_CURRENCY_LABEL', 'ESZ20 INDEX'))
sigtech.framework.strategies.analytics.label.get_label(label_name: str, instrument_name: str) str

Obtain a string instrument label from a label and instrument name.

sigtech.framework.strategies.analytics.label.list_labels(label_name=None)

List available labelling methods or enter a labelling method string and get a list of available values.

sigtech.framework.strategies.analytics.label.remove_labelling_method(label_name: str)

Remove a labelling method.