Rebalancing functions#

sigtech.framework.signal.signal_rebalancing.default_threshold_function(instrument_name, dt, size_date, positions, allocation_ts, strategy) bool

Default threshold function, always returns True.

Parameters
  • instrument_name – Instrument identifier.

  • dt – Reference datetime.

  • size_date – Size date for weight calculation.

  • positions – Strategy positions.

  • allocation_ts – Allocation timeseries.

  • strategy – Strategy object.

Returns

Whether or not to rebalance the instrument given a state. Always True.

sigtech.framework.signal.signal_rebalancing.signal_threshold_check(instrument_name, dt, size_date, positions, allocation_ts, strategy, rebalance_threshold, *args) bool

Signal threshold that returns True only when the difference between the signal weight and the effective weight is greater than a certain amount.

Parameters
  • instrument_name – Instrument identifier.

  • dt – Reference datetime.

  • size_date – Size date for weight calculation.

  • positions – Strategy positions.

  • allocation_ts – Allocation timeseries.

  • strategy – Strategy object.

  • rebalance_threshold – Rebalance threshold.

Returns

Whether or not to rebalance the given instrument.

sigtech.framework.signal.signal_rebalancing.signal_threshold_rebalance_dict(instrument_name, dt, size_date, positions, allocation_ts, strategy, rebalance_dict) float

Signal threshold returning the rebalance size to be applied. The function requires a dictionary containing the allowed rebalance sizes according to the percentage deviation from the target position.

Example:

  • 10% deviated from the target position, rebalance 100%

  • 30% deviated from the target position, rebalance 70%

  • 50% deviated from the target position, rebalance 50%

  • 100% deviated from the target position, do not rebalance.

The above settings can be achieved with rebalance_dict = {.1: 1.0, .3: .7, .5: .5, 1.0: 0.0}.

Parameters
  • instrument_name – Instrument identifier.

  • dt – Reference datetime.

  • size_date – Size date for weight calculation.

  • positions – Strategy positions.

  • allocation_ts – Allocation timeseries.

  • strategy – Strategy object.

  • rebalance_dict – Rebalance thresholds.

Returns

Float representing the rebalance size (zero if no rebalance will be applied).

sigtech.framework.signal.signal_rebalancing.signal_change_threshold_function(instrument_name, dt, size_date, positions, allocation_ts, strategy) bool

Threshold function for signals populated at a higher frequency than they necessarily change. Only triggers a rebalance in the instrument if the signal value has changed compared to the previous value.

Parameters
  • instrument_name – Name of the instrument.

  • dt – Reference datetime.

  • size_date – Size date.

  • positions – Positions.

  • allocation_ts – Timeseries for weight allocation.

  • strategy – Strategy object.

Returns

Whether or not to rebalance the given instrument.

sigtech.framework.signal.signal_rebalancing.signal_change_and_threshold_combined_function(instrument_name, dt, size_date, positions, allocation_ts, strategy, rebalance_threshold) bool

Evaluates both whether the underlying signal has changed and whether the weight is currently deviated away from the target weight more than the given threshold. If either of these two checks return True, the instrument will be rebalanced.

An example of a combined threshold function where two threshold functions are evaluated one after another.

Parameters
  • instrument_name – Instrument identifier.

  • dt – Reference datetime.

  • size_date – Size date for weight calculation.

  • positions – Strategy positions.

  • allocation_ts – Allocation timeseries.

  • strategy – Strategy object.

  • rebalance_threshold – Rebalance threshold.

Returns

Whether or not to rebalance the given instrument.