TripleThreatMeanReversionChannelPool
- class TripleThreatMeanReversionChannelPool[source]
Bases:
MomentumPoolQuantAMM pool combining mean-reversion channel and trend-following rules.
The “triple threat” refers to three interacting signal components:
Channel-based mean reversion – A Gaussian envelope modulates a cubic function of the normalised price gradient, producing a signal that reverts positions when price is within the channel width.
Trend component – Outside the channel, a power-law scaling of the price gradient drives trend-following behaviour.
Interaction – The
pre_exp_scalingparameter controls the relative contribution of trend vs. channel; the Gaussian envelope naturally cross-fades between the two regimes.
Each of the three signal components uses its own EWMA timescale (controlled by separate
logit_lambentries), allowing the channel, trend, and envelope to operate on different look-back horizons.Inherits from
MomentumPooland overridescalculate_rule_outputsto apply the triple-threat update rule instead of a pure momentum rule.See also
MeanReversionChannelPoolChannel-only (no trend) variant.
MomentumPoolPure trend-following base class.
- calculate_rule_outputs(params, run_fingerprint, prices, additional_oracle_input=None)[source]
Calculate the raw weight outputs based on mean reversion channel signals.
This method computes the raw weight adjustments for the mean reversion channel strategy. It processes the input prices to calculate gradients, which are then used to determine weight updates.
- Parameters:
- Returns:
Raw weight outputs representing the suggested weight adjustments.
- Return type:
jnp.ndarray
Notes
The method performs the following steps: 1. Calculates the memory days based on the lambda parameter. 2. Computes the ‘k’ factor which scales the weight updates. 3. Extracts chunkwise price values from the input prices. 4. Calculates price gradients using the calc_gradients function. 5. Applies the mean reversion channel weight update formula to get raw weight outputs.
The raw weight outputs are not the final weights, but rather the changes to be applied to the previous weights. These will be refined in subsequent steps.
- init_base_parameters(initial_values_dict, run_fingerprint, n_assets, n_parameter_sets=1, noise='gaussian')[source]
Initialize parameters for a power channel pool.
This method sets up the initial parameters for the power channel pool strategy, including weights, memory length (lambda), the update agressiveness (k) and the exponents.
- Parameters:
initial_values_dict (Dict[str, Any]) – Dictionary containing initial values for various parameters.
run_fingerprint (Dict[str, Any]) – Dictionary containing run-specific settings and parameters.
n_assets (int) – The number of assets in the pool.
n_parameter_sets (int, optional) – The number of parameter sets to initialize, by default 1.
noise (str, optional) – The type of noise to apply during initialization, by default “gaussian”.
- Returns:
Dictionary containing the initialized parameters for the momentum pool.
- Return type:
Dict[str, jnp.array]
- Raises:
ValueError – If required initial values are missing or in an incorrect format.
Notes
This method handles the initialization of parameters for initial weights, lambda (memory length parameter), the update agressiveness (k), the exponents and the width for each asset and parameter set. It processes the initial values to ensure they are in the correct format and applies any necessary transformations (e.g., logit transformations for lambda).