Core Concepts
AMM Mechanisms
quantammsim implements four main AMM mechanisms:
Balancer Protocol
QuantAMM Protocol
CowAMM Protocol
Gyroscope Protocol
Weight Update Rules
Many pool types have static/preset weights, e.g. Balancer pools and CowAMM pools. For modelling QuantAMM pools, the library supports multiple different strategies (also known as weight update rules):
Momentum
Anti-Momentum
Power Channel
Mean Reversion Channel
Triple Threat Mean Reversion Channel
Difference Momentum (MACD-like)
Min Variance
HODLing Index / Traditional HODLing Index
Understanding Pool Parameters
Memory Days and Lambda
Almost all weight update rules for quantamm pools in quantammsim take as parameters a memory parameter (\(\lambda\)) and a \(k\) parameter. (N.B. some pools include additional parameters.) Given their common use, we will focus on these parameters here. The memory parameter (\(\lambda\)) controls how much historical data influences the pool’s behaviour, as takes a value between 0 and 1:
Short memory (low \(\lambda\)): Responds quickly to data changes
Long memory (high \(\lambda\)): More stable, slower response
The relationship is defined by:
λ = memory_days_to_lamb(memory_days, chunk_period)
While \(\lambda\) is the more fundamental parameter and is closer to how these strategies are mathematically defined, it is often easier to think about the strategy’s memory length. There is a mapping also:
memory_days = lamb_to_memory_days(λ, chunk_period)
Note that the chunk period is the frequency at which the oracle data is observed.
K Parameter
The \(k\) parameter controls the magnitude of weight adjustments:
Higher \(k\): More aggressive rebalancing
Lower \(k\): More conservative approach
In the mathematics of TFMMs, the parameter \(k\) is denoted \(\tilde{k}\).
Example:
run_fingerprint = {
'initial_k_per_day': 20, # Moderate rebalancing
'initial_memory_length': 10.0, # 10-day memory
}
Vector vs Scalar (Universal) Parameters
While the examples above show scalar (universal) parameters, both \(k\) and \(\lambda\) can be specified as vectors to give different values for each asset in the pool:
Scalar (universal) parameters: Same value applies to all assets
Vector parameters: Different values for each asset
For example, in a BTC/ETH/USDC pool:
run_fingerprint = {
'initial_k_per_day': [30, 20, 10], # More aggressive for BTC, less for USDC
'initial_memory_length': [5.0, 7.0, 10.0], # Shorter memory for BTC
}
This allows fine-tuning of how aggressively each asset’s weight responds to market conditions. Common use cases include:
Different rebalancing speeds for volatile vs stable assets
Varying memory lengths based on asset liquidity
Custom parameter sets for different market regimes
Note that when using vector parameters, the length must match the number of assets in the pool. quantammsim natively supports vector parameters.
Training Robustness
Optimising strategy parameters on historical data risks overfitting — the strategy memorises the training period rather than learning generalisable signals. quantammsim provides a multi-level approach to address this:
Walk-forward validation: Train on rolling windows and evaluate on subsequent out-of-sample periods. The Walk-Forward Efficiency (WFE) metric quantifies generalisation quality. See Walk-Forward Analysis.
Ensemble training: Train multiple parameter sets and average their outputs for implicit regularisation. See Ensemble Training.
Hyperparameter tuning: Optimise training hyperparameters (learning rate, regularisation strength, etc.) using OOS metrics as the objective, not in-sample performance. See Hyperparameter Tuning.
Regularisation features: Early stopping, SWA, price noise augmentation, turnover penalty, and weight decay. See Robustness Features.