SignalStrategybuilding block is a user-friendly class that easily converts a DataFrame of signals to a strategy, while providing generalised strategy options.
SignalStrategyis 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
SignalStrategyclass is used to quickly and easily create a robust strategy.
'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_functionargument 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
RollingFutureStrategyobjects. A simple momentum signal is formed from their rolling three month returns. The
long_short_dollar_neutralallocation function is used to transform the input signals into strategy positions. Further elaboration on Allocation Functions:
instrument_mappingargument can be provided to the
SignalStrategyto indicate which instruments should be traded by the 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_functionargument 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
identityallocation 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_drivenallocation 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_weightsallocation 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_weightedallocation 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_drivenallocation function where the weighting is multiplied by the original signal value.
static_weightedallocation 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_weightedallocation 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_weightedallocation function where only static weights are supplied.
long_shortallocation function takes two arguments, a
long_instrument_nameas 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_neutralallocation function takes a
proportionargument (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_allocationsfunction runs a factor optimisation task for each signal entry. The allocation function takes a number of arguments:
factor_exposure_object: uses the
FactorExposuresclass which implements estimation methods for exposures i.e. performing a series of multivariate time-series regressions based on a configuration.
optimization_problem: uses the
FactorOptimizationProblemclass 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
optimizer (Optional): uses the
FactorOptimizerclass which stores a portfolio optimisation problem configuration. To run an optimisation problem, a
FactorOptimizationProblemobject needs to be provided together with the
FactorExposureobject 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.
SignalStrategybuilding block rebalances its weights periodically, as defined by the user-supplied
SignalStrategyobject that will dictate whether rebalancing takes place.
sparse_threshold_functionwill 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
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
.history()runs the backtest and provides a pandas series of the performance of the strategy:
IntradaySignalStrategybuilding block clones the functionality of the existing
SignalStrategyclass but sets the defaults of certain parameters to intraday-focused values. This offers a more efficient way of creating intraday strategies.