MinVariancePool

class MinVariancePool[source]

Bases: TFMMBasePool

A class for min variance strategies run as TFMM (Temporal Function Market Making) liquidity pools, extending the TFMMBasePool class.

This class implements a min variance strategy for asset allocation within a TFMM framework. It uses price data to generate min variance weights.

Parameters:

None

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

Calculate the raw weight outputs based on min variance calculations.

Parameters:
Return type:

Array

calculate_fine_weights(rule_output, initial_weights, run_fingerprint, params)[source]

Refine the raw weight outputs to produce final weights.

Parameters:
Return type:

Array

calculate_weights(params, run_fingerprint, prices, additional_oracle_input)

Orchestrate the weight calculation process.

Notes

The class provides methods to calculate raw weight outputs based on min variance 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 MinVariancePool instance.

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

Calculate the raw weight outputs based on minimum variance optimization.

This method computes target weights that minimize portfolio variance. It processes the input prices to calculate return variances, which are then used to determine inverse-variance weighted allocations.

Parameters:
  • params (Dict[str, Any]) – A dictionary of strategy parameters including lambda values.

  • run_fingerprint (Dict[str, Any]) – A dictionary containing run-specific settings including chunk_period and max_memory_days.

  • prices (jnp.ndarray) – An array of asset prices over time.

  • additional_oracle_input (Optional[jnp.ndarray], optional) – Additional input data, if any. Not used in this implementation.

Returns:

Raw weight outputs representing the target minimum variance weights.

Return type:

jnp.ndarray

Notes

The method performs the following steps: 1. Extracts chunkwise price values from the input prices. 2. Calculates return variances using an EWMA estimator. 3. Computes inverse-variance weights via the min variance formula.

Unlike momentum-based rules, these outputs represent target weights directly, not weight changes to be applied incrementally.

calculate_fine_weights(rule_output, initial_weights, run_fingerprint, params)[source]

Refine raw weight outputs to produce final weights for the momentum pool.

This method takes the raw weight outputs calculated from momentum signals and refines them into final asset weights. It applies various constraints and adjustments defined in the pool parameters and run fingerprint.

Parameters:
  • rule_output (jnp.ndarray) – Raw weight changes or outputs from momentum calculations.

  • initial_weights (jnp.ndarray) – Initial weights of assets in the pool.

  • run_fingerprint (Dict[str, Any]) – Dictionary containing run-specific parameters and settings.

  • params (Dict[str, Any]) – Pool parameters.

Returns:

Refined weights for each asset in the pool over the specified time period.

Return type:

jnp.ndarray

Notes

Uses the calc_fine_weight_output_from_weights function to perform the actual refinement. The implementation of this function should handle details such as weight interpolation, maximum change limits, and ensuring weights sum to 1.

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).

classmethod process_parameters(update_rule_parameters, run_fingerprint)[source]

Process Min Variance pool parameters from web interface input.