
BTC on 1-day bars in the 0xArchive Terminal, 2026-10-28.
Open on a chart
Load it on BTC 1d in the terminal, then change its settings or open it in the script editor.
How it works
universe.topN(25) picks the 25 perps with the most dollar volume over the last 30 days, among those with 60 days of prices, again every 30 days. The pick reads only days before it, from every perp that traded then, delisted ones included, so the run never holds a coin for what it later became.
On each Sunday’s close, pool.resid(market, 'BTC', 15, 60) and pool.volatility(market, 30) give each member’s score, and portfolio.longShort(scores, { quantile: 0.2, sides: 'long' }) turns the top fifth into equal weights that add up to the account. strategy.targets() sets the whole book: a coin that leaves the top fifth is sold at the next open. Set Sides to long the top and short the bottom instead.
The Strategy report’s Markets tab shows what each coin made after fees, slippage and funding, and Book each rebalance’s weights beside the universe’s picks. A portfolio pays a flat 2 bps of slippage a fill: the archive’s order book readings start on 6 Sep 2026.
The script
residual-momentum.ts