Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
1b5b299
refactor the input dfs into a dynamic input object for greater contai…
bulkcade Mar 3, 2026
5f3d596
Merge remote-tracking branch 'origin/main' into reclamm-phase-1
bulkcade Mar 3, 2026
0dcb04d
add fix for test directory data instead of main data source
bulkcade Mar 4, 2026
ffda35c
import fix
bulkcade Mar 4, 2026
961b796
refactor the dynamic inputs given the runtime errors with lax scan. t…
bulkcade Mar 4, 2026
42d0767
missing file commit
bulkcade Mar 4, 2026
19ee13e
initial implementation
bulkcade Mar 5, 2026
955dca3
add fixes for linear interpolation bug and tests
bulkcade Mar 5, 2026
d9471a4
enable straight through estimation given boolean flag properties of r…
bulkcade Mar 5, 2026
5c0de72
Merge branch 'dev' into reclamm-phase-1
MatthewWilletts Mar 5, 2026
35719bb
fix: replace stale fees_array references with dynamic_inputs check
MatthewWilletts Mar 6, 2026
6c892ae
Merge pull request #74 from QuantAMMProtocol/reclamm-phase-1
MatthewWilletts Mar 6, 2026
b6aab22
remove default get
bulkcade Mar 6, 2026
4e86c4d
noise calibration port from private repo
bulkcade Mar 6, 2026
7e70f33
add new experiments and scripts related to noise modelling and tuning
bulkcade Mar 6, 2026
427044a
add calibration to pyproject
bulkcade Mar 6, 2026
fa39d72
core noise model in base pool updates
bulkcade Mar 6, 2026
fde87af
add noise tests
bulkcade Mar 6, 2026
9812099
port over and combine with dynamic obj noise modelling approach
bulkcade Mar 6, 2026
d39ddcb
add missing imports
bulkcade Mar 7, 2026
9e24857
add reclamm private repo port fixes
bulkcade Mar 7, 2026
6d45c27
ci: install calibration extra and add reclamm branch trigger
MatthewWilletts Mar 9, 2026
8371fc4
fix: use contract's centeredness-preserving formula for price ratio u…
MatthewWilletts Mar 9, 2026
1b9d1eb
fix: add ste_temperature to test fingerprints
MatthewWilletts Mar 9, 2026
54ebe54
Merge pull request #76 from QuantAMMProtocol/price-ratio-change
MatthewWilletts Mar 9, 2026
8bd2c59
fix: replace STE gate on fees check with hard check
MatthewWilletts Mar 9, 2026
75a6540
feat: add volatility calculation, relative arb invariant, and LP supp…
MatthewWilletts Mar 9, 2026
d05fa6b
feat: add noise volume models: tsoukalas_sqrt, tsoukalas_log, loglinear
MatthewWilletts Mar 9, 2026
0245049
feat: add LP supply tracking and noise model dispatch to reCLAMM scan…
MatthewWilletts Mar 9, 2026
f4c4aaf
feat: add noise calibration pipeline
MatthewWilletts Mar 9, 2026
6c48e03
feat: add calibration framework: per-pool fit, joint fit, grid interp…
MatthewWilletts Mar 9, 2026
953144e
feat: add analysis scripts, experiments, and CLI parameter wiring
MatthewWilletts Mar 9, 2026
8c70eb2
fix: drop hardcoded float64 dtype from dynamic_inputs defaults
MatthewWilletts Mar 9, 2026
d05c494
fix: update LP supply tests to use DynamicInputArrays and test data d…
MatthewWilletts Mar 9, 2026
9779dca
fix: update LP supply tests to use DynamicInputArrays and test data d…
MatthewWilletts Mar 9, 2026
2c234e6
Merge pull request #77 from QuantAMMProtocol/noise-modelling
MatthewWilletts Mar 9, 2026
933b653
test: add pinned regression tests for calibration pipeline
MatthewWilletts Mar 10, 2026
32f2e43
feat: fixed-gas calibration mode for loss, per-pool fit, and joint fit
MatthewWilletts Mar 9, 2026
834e547
feat: replace Balancer hourly volatility with Binance minute data
MatthewWilletts Mar 9, 2026
a2ae5a4
fix: grid builder handles stale Binance data and multi-worker dispatch
MatthewWilletts Mar 9, 2026
f6ef0ec
test: comprehensive tests for fixed-gas calibration and Binance volat…
MatthewWilletts Mar 9, 2026
6f98236
test: strengthen calibration tests — fix vacuous assertions and add m…
MatthewWilletts Mar 10, 2026
a42a961
feat: composable CalibrationModel with pluggable Head components
MatthewWilletts Mar 10, 2026
c7ee40d
feat: add MLPHead for nonlinear pool-attribute-to-cadence mapping
MatthewWilletts Mar 10, 2026
ef7d24a
feat: add MLPNoiseHead for nonlinear pool-attribute-to-noise mapping
MatthewWilletts Mar 10, 2026
ccc3c6c
fix: use small random W2 init for MLP heads to avoid degenerate L-BFG…
MatthewWilletts Mar 10, 2026
eb55247
merge: integrate origin/dev into enable-ste-reclamm
MatthewWilletts Mar 10, 2026
43024c3
fix: add missing ste_temperature to test fingerprints after STE merge
MatthewWilletts Mar 10, 2026
03722d9
Merge pull request #75 from QuantAMMProtocol/enable-ste-reclamm
MatthewWilletts Mar 10, 2026
dbd62b2
WIP: MLP calibration with lstsq warm-start and tuned hyperparameters
MatthewWilletts Mar 10, 2026
16f5bf3
merge dev
bulkcade Mar 10, 2026
49671f8
WIP: output clipping on heads, two-stage joint calibration
MatthewWilletts Mar 13, 2026
71f1a3a
feat: add reduced x_obs (k_obs=4) to calibration pipeline
MatthewWilletts Mar 16, 2026
ba30663
feat: parameterize k_obs in noise heads
MatthewWilletts Mar 16, 2026
5a2cbdf
feat: calibrated 8-covariate noise model for reCLAMM simulator
MatthewWilletts Mar 16, 2026
246de0e
feat: configurable n_evaluation_points for Optuna and keep startDateS…
MatthewWilletts Mar 16, 2026
227fe77
feat: add token encoding for token-factored noise model
MatthewWilletts Mar 16, 2026
c7a0c26
feat: add TokenFactoredNoiseHead with additive token decomposition
MatthewWilletts Mar 16, 2026
7edf6ec
feat: integrate token-factored noise into joint calibration pipeline
MatthewWilletts Mar 16, 2026
e8e9031
feat: add reduced x_obs (k_obs=4) pipeline to calibration runner
MatthewWilletts Mar 16, 2026
229e38d
feat: token-factored calibration script with Phase 0 diagnostic and LOO
MatthewWilletts Mar 16, 2026
5db3919
feat: support calibrated noise model in Optuna parameter tuning
MatthewWilletts Mar 16, 2026
5398c3b
feat: add token canonicalization and cross-pool lagged volume features
MatthewWilletts Mar 16, 2026
e99d3e2
feat: report data_loss and reg_loss separately in CalibrationModel.fit
MatthewWilletts Mar 16, 2026
3475198
feat: v2 runner with lambda annealing, cross-pool ablation, and LOO
MatthewWilletts Mar 16, 2026
31f8829
fix: cross-pool x_obs shape mismatch and warm-start k_obs padding
MatthewWilletts Mar 16, 2026
21fb161
feat: cross-pool volume prediction experiments
MatthewWilletts Mar 17, 2026
1056ee0
wip on deepsets
MatthewWilletts Mar 17, 2026
7ab989a
feat: deepsets v2 improvements — relational features, Huber loss, enc…
MatthewWilletts Mar 17, 2026
d6d1e7b
feat: LOO evaluation, warm-start decoder, residual target, minimal en…
MatthewWilletts Mar 17, 2026
5c04a47
feat: learnable cadence via PCHIP, linear market noise model, hybrid …
MatthewWilletts Mar 19, 2026
e661031
feat: per-pool linear noise model, market_linear simulator integratio…
MatthewWilletts Mar 23, 2026
825c8a7
feat: simulator integration for market_linear noise model, TVL standa…
MatthewWilletts Mar 23, 2026
afb8511
feat: causal TVL elasticity analysis — deconfounder + LP event study
MatthewWilletts Mar 26, 2026
82c64c7
feat: TVL counterfactual validation script
MatthewWilletts Mar 26, 2026
75b683f
feat: MLP noise model (Binance-only, no cross-pool DEX dependency) + …
MatthewWilletts Mar 26, 2026
b41d793
merge origin
bulkcade Mar 26, 2026
11b8858
feat: remove panel dependency from simulator arrays, Binance-only pip…
MatthewWilletts Mar 26, 2026
414903d
data: per-pool linear noise model artifact (Binance-only, 22 features…
MatthewWilletts Mar 26, 2026
c936eee
Merge branch 'noise-modelling' of https://github.com/QuantAMMProtocol…
bulkcade Mar 26, 2026
a88fd66
fix: noise volume cadence scaling + price preservation for 2-CLP
MatthewWilletts Mar 27, 2026
5d40a65
compare improvements
bulkcade Mar 27, 2026
5ec81c5
compare improvements
bulkcade Mar 27, 2026
29af7df
data: add sim arrays for 0x9d1fcf346ea1b0
MatthewWilletts Mar 29, 2026
8331b7f
diagnostics
bulkcade Mar 29, 2026
bf033bb
Merge branch 'noise-modelling' of https://github.com/QuantAMMProtocol…
bulkcade Mar 29, 2026
00144e2
perforance improvements
bulkcade Mar 29, 2026
4c9eae7
feat: feature-appropriate scaling, TVL clamp, protocol fee default
MatthewWilletts Mar 31, 2026
b44c228
feat: CMA-ES optimiser + Optuna min_train_returns_over_hodl rejection
MatthewWilletts Mar 31, 2026
b89fa64
feat: Michaelis-Menten noise model + MLP sweep + comparison tooling
MatthewWilletts Mar 31, 2026
1fae546
feat: MM noise model — per-pool K, Optuna sweep, cross-pool TVL analysis
MatthewWilletts Apr 7, 2026
629ff83
feat: observed competitor TVL as K via DeFi Llama network conductance
MatthewWilletts Apr 7, 2026
d3632ec
feat: integrate mm_observed noise model into simulator pipeline
MatthewWilletts Apr 7, 2026
76bcc96
feat: add mm_observed noise model to reClAMM tuning pipeline
MatthewWilletts Apr 7, 2026
b06162f
feat: daily_log_sharpe_excess — Sharpe on excess returns over HODL
MatthewWilletts Apr 10, 2026
29429b1
feat: daily_log_sharpe_excess objective + sweep infrastructure
MatthewWilletts Apr 10, 2026
920eb1f
feat: distributionally robust objective aggregation
MatthewWilletts Apr 10, 2026
3fad415
feat: noise fee fold, in-range gate, blessed-arb experiment
MatthewWilletts Apr 21, 2026
236bce3
fix: declare binance_historical_data and gdown in pyproject.toml
MatthewWilletts Apr 21, 2026
ad05e6d
chore: drop unused gdown dependency
MatthewWilletts Apr 21, 2026
181bd9c
fix: align noise feature standardization with training-time pipeline
MatthewWilletts May 11, 2026
656ecc4
feat: add optional box constraints to CMA-ES
MatthewWilletts May 11, 2026
f5bd5d2
feat: extend reClAMM tune script for CMA-ES bounds and arbitrary pairs
MatthewWilletts May 11, 2026
51a8ab7
feat: report only noise-trader fees as lp_fee_revenue_usd
MatthewWilletts May 11, 2026
f3054b9
feat: plot_reclamm_optuna_result improvements for final-sim panels
MatthewWilletts May 11, 2026
4aa5623
feat: extend period sweep with penalty + long_2021 axes; multi-pool p…
MatthewWilletts May 11, 2026
366999a
feat: end-to-end reClAMM training + evaluation pipeline
MatthewWilletts May 11, 2026
9fdffa8
refactor: ReClammPool uses noise_arrays dict and forwards mm_observed…
MatthewWilletts May 11, 2026
4c92743
fix: subsample lp_supply_array to match arb_frequency
MatthewWilletts May 11, 2026
a242404
fix: subsample all minute-res dynamic arrays by arb_frequency
MatthewWilletts May 11, 2026
7f5ca92
feat: noise model support for Balancer pools
MatthewWilletts May 11, 2026
b8e2225
Merge branch 'noise-modelling' of github.com:QuantAMMProtocol/quantam…
MatthewWilletts May 11, 2026
4b398a2
Merge branch 'noise-modelling' into noise-plus-plus
MatthewWilletts May 11, 2026
b5d8d1b
test: configure mm_observed noise model in lp_fee_revenue tests
MatthewWilletts May 11, 2026
99ea8b3
chore: remove accidental file
MatthewWilletts May 11, 2026
81f0097
Merge pull request #79 from QuantAMMProtocol/noise-plus-plus
MatthewWilletts May 11, 2026
20dd4ef
fix: unify optuna trial schema with cma_es/bfgs and wire cma_es overf…
MatthewWilletts May 15, 2026
856eacb
chore: move noise pipeline scripts to scripts/ and add training guide
MatthewWilletts May 15, 2026
1d7228e
docs: use canonical qsim env name in training guide
MatthewWilletts May 15, 2026
6a857df
docs: cover extending run_full_sweep.sh CONFIGS for a new pair
MatthewWilletts May 15, 2026
6d494d8
docs: add smoke test, objective/penalty definitions, cache and CPU notes
MatthewWilletts May 15, 2026
c71eec0
fixes
bulkcade May 15, 2026
fc3b93c
fixes
bulkcade May 15, 2026
f0b2770
data: add MM artifact, competitor TVL, and 6 winning sweep results
MatthewWilletts May 18, 2026
dd20627
add theming, csv exports and plots md
bulkcade May 19, 2026
40c6bdd
add scripts/run_pr_sweep.py
MatthewWilletts May 19, 2026
65cb66f
fix data download for US users and pandas 3
mendesfabio Jul 8, 2026
8aa118e
Merge pull request #2 from balancer/fix-download-data-geoblock-pandas3
mendesfabio Jul 8, 2026
955208f
fix noise_calibration import on Python 3.9
mendesfabio Jul 8, 2026
0cfe2da
Merge pull request #3 from balancer/fix-py39-pep604-annotations
mendesfabio Jul 8, 2026
0acd60f
update test baselines for protocol_fee_split=0.25 default
mendesfabio Jul 8, 2026
6d2d07b
Merge pull request #4 from balancer/update-baselines-protocol-fee-split
mendesfabio Jul 8, 2026
98ddcce
onboard BTC/ETH and BOLD/USDC pairs; generalize run_final_sims; add o…
mendesfabio Jul 8, 2026
cd1c949
Merge pull request #5 from balancer/btc-eth-pair-onboarding
tiago-hansen Jul 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions .claude/skills/reclamm-pair-onboarding/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
name: reclamm-pair-onboarding
description: Onboard a new token pair for reCLAMM simulations — fetch price data, run the Optuna parameter sweep, and produce final-sim CSVs/plots with candidate pool params. Use when asked to simulate a reCLAMM pool for a pair, gather candidate price_ratio/margin/shift params, or add a pair to run_final_sims.py.
---

# reCLAMM pair onboarding

Pipeline: **price data → Optuna sweep → register pair → `run_final_sims.py`**.
Worked examples on branch `btc-eth-pair-onboarding`: BTC/ETH (Binance data,
real pool coefficients) and BOLD/USDC (CoinGecko data, median-fallback noise).

**Never retrain the noise model.** The checked-in artifacts
(`results/mm_noise/{model.npz,meta.json}`, `results/competitor_tvl/competitor_tvl.npz`)
are fit across 38 pools and reused for every pair; per-pair arrays are built
and cached automatically under `results/mm_noise/_sim_arrays/`.

## Step 1 — price data (`quantammsim/data/<TOKEN>_USD.parquet`)

`BTC_USD.parquet` is required for **every** pair (market features), plus one
parquet per pool token (`TOKEN_MAP` in `quantammsim/calibration/market_features.py`
maps WBTC→BTC, WETH→ETH, USDT→USDC, …).

- **Binance-listed token**: `python scripts/download_data.py <TOKEN>`.
- **Not on Binance**: copy `scripts/prepare_bold_usdc_data.py` (CoinGecko):
daily close+volume → minute grid by forward-fill, daily volume spread /1440
(so the daily resample recovers real volume), stables as flat $1.00 peg.
CoinGecko free tier = **last 365 days only** — this bounds the earliest
simulation start and usually forces a per-pair train window (Step 4).

Check coverage: the parquet must span train start → test end.

## Step 2 — pool id and the noise fallback

Look the pair up in `results/mm_noise/meta.json` (`pool_ids` / `pool_tokens`).

- **Pair present** (e.g. WBTC/WETH → `0xa6f548df93de92`): use that id; the
noise model gets real per-pool coefficients and competitor TVL.
- **Pair absent**: any placeholder id works — the builder falls back to
median coefficients + K=$10M (`noise_model_arrays.py`). Median alpha is
tiny, so organic volume (and fee revenue) will be near zero. If realistic
fees matter, re-anchor: after `build_mm_simulator_arrays`, shift
`noise_base += log(V_max_daily) - mean(noise_base)` and optionally set a
constant competitor K — see `scripts/run_rpl_eth_sweep.py` (~lines 124-134)
for the pattern and the pair's real daily volume for V_max.

## Step 3 — Optuna sweep

Demo scale (~50 trials, minutes; the team's production scale is
`scripts/run_full_sweep.sh`: 300 trials × 4 objectives × 3 penalties per TVL):

```
python scripts/tune_reclamm_calibrated_noise.py \
--noise-model mm_observed --artifact-dir results/mm_noise \
--tokens BTC ETH --pool-id 0xa6f548df93de92 \
--gas-cost 1.0 --fees 0.0025 --initial-pool-value 5000000 \
--objective returns_over_hodl --n-trials 50 --pr-max 5.0 \
--start-date "2025-01-01 00:00:00" --end-date "2025-10-05 00:00:00" \
--output results/full_sweep/returns_over_hodl_<pair>_<tvl>.json
```

- One sweep per (pair, TVL). Search space: price_ratio 1.01–200 (log),
margin 0.01–0.99, shift_exponent 1e-5–125 (log). Cap `--pr-max` sensibly:
~5 for correlated majors, ~1.05 for stable/stable.
- Dates: default train window is 2025-01-01 → 2025-10-05 (pre flash-crash);
keep it unless data starts later. `--end-test-date` sets the OOS span used
for validation metrics.
- Side effect (the part `run_final_sims.py` actually reads): a trajectory
file `results/run_<hash>.json` written by `train_on_historic_data`.

## Step 4 — register the pair and run final sims

Add an entry to `PAIR_CONFIGS` in `scripts/run_final_sims.py` (tokens,
pool_id, gas_cost, fees, the swept TVLs; `--pair` choices follow the dict).
If the pair's data can't cover the default windows, add per-pair overrides:

```python
"train": ("2025-07-15 00:00:00", "2025-10-05 00:00:00"), # optional
"test": ("2025-10-25 00:00:00", "2026-05-01 00:00:00"), # optional
```

The sweep's train window **must match** the pair's train window — trials are
filtered by it (`filter_trials_to_window`).

```
python scripts/run_final_sims.py --pair <name> # or --all
```

Selection: best trial per TVL by OOS `returns_over_hodl` (override with
`--metric`). Outputs in `results/final_sims/`:
`run_{Value,Reserves,TokenValues}_<pair>_<tvl>_{train,test}_<hash>.csv`,
themed plots `<pair>_{train,test}[_weights]_{light,dark}.png`, and
`<pair>_sim_results.pkl`. The printed summary gives train/test RoH and fees.

## Gotchas

- `--method` on `run_final_sims.py` is currently a no-op.
- First run per (pool, window) builds noise arrays (needs network-free local
parquets only); subsequent runs hit the `_sim_arrays` cache.
- Stable pairs: expect PR near the 1.01 floor and near-zero fees under the
median-fallback noise — re-anchor (Step 2) before trusting fee numbers.
- Sweeps and final sims are pure JAX forward passes — a laptop handles demo
scale; production sweeps want the parallel `run_full_sweep.sh` machinery.
4 changes: 1 addition & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
lfs: true

- name: Set up Python 3.9
uses: actions/setup-python@v5
Expand All @@ -25,7 +23,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
pip install -e ".[dev,calibration]"

- name: Run tests with coverage
run: |
Expand Down
143 changes: 143 additions & 0 deletions RECLAMM_PLOTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# Reproducing the AAVE/ETH and COW/ETH plots

This branch (`noise-modelling-fixes-data`) carries the minimum data needed to
produce the final train/test panels and PR-sweep heatmaps for both pairs
without re-running the training sweep.

## What's on the branch

- `results/mm_noise/model.npz` + `meta.json` — the frozen MM noise model.
- `results/competitor_tvl/competitor_tvl.npz` — DeFi Llama competitor TVL.
- `results/full_sweep/<6 files>` — sweep summaries for the 6 winning configs.
- `results/run_<6 hashes>.json` — trial trajectories for the same 6 winners
(read by `scripts/run_final_sims.py`).

What's **not** included and must be pulled locally:

- Binance minute parquets for `BTC`, `ETH`, `AAVE`, `COW`.

## Prerequisites

Conda env per the README:

```
conda activate qsim
```

## 1. Pull Binance price data

```
python scripts/download_data.py BTC ETH AAVE COW
```

Writes `quantammsim/data/<TOKEN>_USD.parquet` per token. `BTC` is required by
the MM noise model's market features; `AAVE`/`COW`/`ETH` are the pair tokens
the simulator reads prices from.

## 2. Final-sims: train/test forward passes and selection

```
python scripts/run_final_sims.py --all
```

Loads the 6 committed `run_<hash>.json` files, picks the single candidate per
`(pair, TVL)` tier, runs train and test forward passes at the picked params,
and writes:

- `results/final_sims/{aave,cow}_{train,test}.png` — share price, fee revenue,
cumulative volume per TVL tier.
- `results/final_sims/{aave,cow}_{train,test}_weights.png` — effective weight
trajectories.
- `results/final_sims/{aave,cow}_sim_results.pkl` — per-tier results cache.

Per-tier picks for this branch's data (printed to stdout as `Params:` lines):

| Tier | PR | margin | shift |
|-----------|---------|--------|--------|
| AAVE 1m | 1.068 | 0.0240 | 0.0225 |
| AAVE 5m | 1.296 | 0.0101 | 0.0675 |
| AAVE 20m | 1.348 | 0.0103 | 0.5411 |
| COW 500k | 99.665 | 0.8235 | 0.1418 |
| COW 2m | 54.549 | 0.8351 | 0.1422 |
| COW 20m | 172.463 | 0.9265 | 0.0521 |

## 3. PR-sweep heatmaps

One `run_pr_sweep.py` invocation per (pair, TVL), with that tier's
`margin`, `shift`, `initial-pool-value`, and the selected PR as a marker.

### AAVE/ETH

Override the pair-specific flags (`run_pr_sweep.py` defaults are COW).

```
mkdir -p results/final_sims/for_fabio/aave/price_ratio_sweep

python scripts/run_pr_sweep.py --tokens AAVE ETH --pool-id 0x9d1fcf346ea1b0 \
--gas-cost 1.0 --fees 0.0025 \
--multi-period --period-months 3 --onchain-pr 2.02 \
--output-dir results/final_sims/for_fabio/aave/price_ratio_sweep \
--prs 1.01 1.1 1.2 1.4 1.6 1.8 2.0 2.5 3.0 4.0 5.0 7.5 10.0 \
--margin 0.0240 --shift 0.0225 --initial-pool-value 1000000 --selected-pr 1.068

python scripts/run_pr_sweep.py --tokens AAVE ETH --pool-id 0x9d1fcf346ea1b0 \
--gas-cost 1.0 --fees 0.0025 \
--multi-period --period-months 3 --onchain-pr 2.02 \
--output-dir results/final_sims/for_fabio/aave/price_ratio_sweep \
--prs 1.01 1.1 1.2 1.4 1.6 1.8 2.0 2.5 3.0 4.0 5.0 7.5 10.0 \
--margin 0.0101 --shift 0.0675 --initial-pool-value 5000000 --selected-pr 1.296

python scripts/run_pr_sweep.py --tokens AAVE ETH --pool-id 0x9d1fcf346ea1b0 \
--gas-cost 1.0 --fees 0.0025 \
--multi-period --period-months 3 --onchain-pr 2.02 \
--output-dir results/final_sims/for_fabio/aave/price_ratio_sweep \
--prs 1.01 1.1 1.2 1.4 1.6 1.8 2.0 2.5 3.0 4.0 5.0 7.5 10.0 \
--margin 0.0103 --shift 0.5411 --initial-pool-value 20000000 --selected-pr 1.348
```

### COW/ETH

The COW selections are at PR ≈ 50–200, so the `--prs` list extends past 10.
The script's defaults already match the COW pair, so the pair-specific flags
can be omitted.

```
mkdir -p results/final_sims/for_fabio/cow/price_ratio_sweep

python scripts/run_pr_sweep.py --multi-period --period-months 3 --onchain-pr 2.02 \
--output-dir results/final_sims/for_fabio/cow/price_ratio_sweep \
--prs 1.01 1.1 1.2 1.4 1.6 1.8 2.0 2.5 3.0 5.0 10.0 30.0 50.0 80.0 100.0 120.0 150.0 200.0 \
--margin 0.8235 --shift 0.1418 --initial-pool-value 500000 --selected-pr 99.665

python scripts/run_pr_sweep.py --multi-period --period-months 3 --onchain-pr 2.02 \
--output-dir results/final_sims/for_fabio/cow/price_ratio_sweep \
--prs 1.01 1.1 1.2 1.4 1.6 1.8 2.0 2.5 3.0 5.0 10.0 30.0 50.0 80.0 100.0 120.0 150.0 200.0 \
--margin 0.8351 --shift 0.1422 --initial-pool-value 2000000 --selected-pr 54.549

python scripts/run_pr_sweep.py --multi-period --period-months 3 --onchain-pr 2.02 \
--output-dir results/final_sims/for_fabio/cow/price_ratio_sweep \
--prs 1.01 1.1 1.2 1.4 1.6 1.8 2.0 2.5 3.0 5.0 10.0 30.0 50.0 80.0 100.0 120.0 150.0 200.0 \
--margin 0.9265 --shift 0.0521 --initial-pool-value 20000000 --selected-pr 172.463
```

### Outputs

Per-period single-config PNGs and one heatmap per invocation, named
`pr_heatmap_<TOKENS>_3mo_m<margin>_s<shift>.png`, under
`results/final_sims/for_fabio/{aave,cow}/price_ratio_sweep/`.

## Gotchas

- **zsh and shell variables**. `python ... $PRS_ARGS` with
`PRS_ARGS="--prs 1.01 1.1 ..."` does not word-split in zsh by default;
argparse receives the whole string as one token and emits
`unrecognized arguments: --prs ...`. Either inline the list (as above)
or use `${=PRS_ARGS}`.
- **COW early-period failures**. The COW pool's data starts around 2024-12.
`run_pr_sweep.py --multi-period` tries each period from `2024-01-01`
onwards; the early periods raise inside `run_single_period`, the script
catches the exception and the final heatmap only contains the surviving
rows. Expected.
- **Re-running with the same `(start, end)` reuses the cached noise array**
in `results/mm_noise/_sim_arrays/<pool_id>_<start>_<end>_mm.npz` —
rebuilding only the first time each period is touched.
Loading
Loading