DifferenceMomentumPool

class DifferenceMomentumPool[source]

Bases: MomentumPool

A class for difference-momentum strategies run as TFMM liquidity pools.

This class implements a moving average convergence divergence (MACD) strategy for asset allocation within a TFMM framework. It uses price data to generate MACD signals, which are then translated into weight adjustments.

Parameters:

None

calculate_rule_outputs(params, run_fingerprint, prices, additional_oracle_input)[source]

Calculate the raw weight outputs based on mean-reversion signals.

Parameters:
Return type:

Array

Notes

The class implements a mean-reversion-based strategy for asset allocation within a TFMM framework. It uses price data to generate mean-reversion signals, which are then translated into weight adjustments. The class provides methods to calculate raw weight outputs based on these signals and refine them into final asset weights, taking into account various parameters and constraints defined in the pool setup.

__init__()[source]

Initialize a new AntiMomentumPool instance.

Parameters:

None

calculate_rule_outputs(params, run_fingerprint, prices, additional_oracle_input=None)[source]

Calculate raw weight outputs based on difference between two EWMAs.

Parameters:
  • params (Dict[str, Any]) – Either: - memory_days_1: float (memory period for first EWMA) - memory_days_2: float (memory period for second EWMA) - k: float (scaling factor) Or: - logit_lamb: array (for base lambda calculation) - logit_delta_lamb: array (for delta lambda calculation) - log_k: array (for k calculation)

  • run_fingerprint (Dict[str, Any])

  • prices (Array)

  • additional_oracle_input (Array | None)

Return type:

Array

init_base_parameters(initial_values_dict, run_fingerprint, n_assets, n_parameter_sets=1, noise='gaussian')[source]

Initialize parameters for the momentum pool.

This method sets up the initial parameters for the momentum pool strategy, including weights, memory length (lambda), and the momentum factor (k).

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), and k (momentum factor) 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).