SignalStrategy
building block is a user-friendly class that easily converts a DataFrame of signals to a strategy, while providing generalised strategy options. SignalStrategy
is a generic class that converts any signal object to a trading strategy. There are a number of generic inputs that can be used to adjust the strategy behaviour. In most instances, the SignalStrategy
class is used to quickly and easily create a robust strategy.rebalance_frequency
: 'EOD'
= end of month, 'SOM'
= start of month, '1W-FRI'
= rebalance weekly every Friday, and'YEARLY'
= start of each year.allocation_function
: allocation functions can be passed in to the strategy as an extra layer of manipulation to the signal weights as needed. A full list of available, pre-built functions are listed below.threshold_function
: this is another final step that determines whether a rebalance should go ahead. It is typically used to avoid unnecessary trades when the current position and the desired position are very close. instrument_mapping
: this dictionary provides a mapping from the column name of the signal DataFrame to the name of the instrument we want to trade. allocation_function
argument that will further manipulate the signal weights as defined by the function. Some pre-built allocation functions are available for easy and quick use, and can be accessed within sig.signal_library.allocation
.universe
consisting of RollingFutureStrategy
objects. A simple momentum signal is formed from their rolling three month returns. The long_short_dollar_neutral
allocation function is used to transform the input signals into strategy positions. Further elaboration on Allocation Functions:instrument_mapping
argument can be provided to the SignalStrategy
to indicate which instruments should be traded by the strategy. 'ES'
is the name of the column in the signal_df
representing the signal for the corresponding rolling futures strategy: USD ES INDEX LONG FRONT RF STRATEGY
. instrument_mapping['ES']
will yield the string 'USD ES INDEX LONG FRONT RF STRATEGY'.
SignalStrategy
, along with an allocation function, the signal's name, and other required arguments:proportion
, and so the strategy will be long the top 25% of signal values, and short the bottom 25%. That is to say, long 2 strategies and short 2 strategies from this universe of 8 strategies on any given date. allocation_function
argument that will further transform the signal value inputs before converting to portfolio weights. A range of pre-built allocation functions are available for quick and easy use on the platform. These can be accessed from sig.SignalStrategy.AVAILABLE_ALLOCATION_FUNCTIONS
. identity
allocation function simply returns the unchanged allocations as given by the signal strategy output. This method is chosen by default if no allocation function is passed to the object. equal_signal_driven
allocation function weights a list of instruments with the same weights. This function takes a list of instruments and returns a DataFrame, with each instrument signal multiplied by an equal factor.normalize_weights
allocation function normalises all weights to have 100% gross notional exposure. The total sum of all weights after normalisation is equal to 100% of the gross notional exposure of the strategy.equally_weighted
allocation function divides the allocations by the number of instruments. All instrument signals are equal to each other. This is slightly different from the equal_signal_driven
allocation function where the weighting is multiplied by the original signal value. static_weighted
allocation function takes a set of weights in dictionary format and supplies this to the signal time-series. Each weight within the dictionary is multiplied by the signal value.time_varying_weighted
allocation function takes a set of time-series weights in dictionary format and supplies this to the signal time-series. Each weight within the dictionary is multiplied by the signal value. This is different to the static_weighted
allocation function where only static weights are supplied.long_short
allocation function takes two arguments, a long_instrument_name
as well as a short_instrument_name
. The purpose of this allocation function is to trade a series signal long on one instrument and short on another.long_short_dollar_neutral
allocation function takes a proportion
argument (value between 0-1) whereby the strategy will take long and short positions over the top and bottom proportion of signal values, asserting 100% gross exposure.factor_optimised_allocations
function runs a factor optimisation task for each signal entry. The allocation function takes a number of arguments:factor_exposure_object
: uses the FactorExposures
class which implements estimation methods for exposures i.e. performing a series of multivariate time-series regressions based on a configuration.optimization_problem
: uses the FactorOptimizationProblem
class which stores a portfolio optimisation problem configuration. The problem is composed of two parts: objectives and constraints. These can be added to the instance through set_optimizer_objective
andset_optimizer_bounds
.optimizer (Optional)
: uses the FactorOptimizer
class which stores a portfolio optimisation problem configuration. To run an optimisation problem, a FactorOptimizationProblem
object needs to be provided together with the FactorExposure
object that contains the data.periods (Optional)
: chosen time window.base (Optional)
: optimiser base.instrument_mapping
: mapping in dictionary format from the column name of the signal to the instrument to trade.SignalStrategy
building block rebalances its weights periodically, as defined by the user-supplied rebalance_frequency
parameter. threshold_function
within the SignalStrategy
object that will dictate whether rebalancing takes place. sparse_threshold_function
found under sig.signal_library.threshold_fns
. sig.SignalStrategy.AVAILABLE_THRESHOLD_FUNCTIONS
. sparse_threshold_function
will not trigger rebalancing to a zero weight unless there is a current position. So the signal can be primarily composed of zeros which will only be used for closing positions. weights_df
, can be used to determine the position weighting of the strategy the signal is mapped to. In this instance, we can define our own threshold function that looks like the following:threshold_kwargs
. You can implement this through the SignalStrategy
building block:SignalStrategy
objectsSignalStrategy
building block.sigtech.framework.default_strategy_objects.rolling_futures
.sig.signal_library.core.from_ts
. Like all instruments and strategies, this signal object and its history can be retrieved with its unique name using obj.get("...").history()
..history()
runs the backtest and provides a pandas series of the performance of the strategy:IntradaySignalStrategy
building block clones the functionality of the existing SignalStrategy
class but sets the defaults of certain parameters to intraday-focused values. This offers a more efficient way of creating intraday strategies.use_signal_for_rebalance_dates=True
, t0_execution=True
, execution_delay='5 minutes'
.