Skip to main content
Basket residual on a BTC chart

BTC on 1-hour bars in the 0xArchive Terminal, 2026-10-25.

Open on a chart

Load it on BTC 1h in the terminal, then change its settings or open it in the script editor.
The part of this market’s return that the basket’s shared moves don’t explain, in standard deviations. Near 0, it moved with the basket; far from it, it moved on its own. The chart’s market is always in the basket.

How it works

input.markets holds the basket, editable in the settings, and markets.map((m) => bars({ market: m })) opens a stream per market. On each closed bar ml.pca takes every market’s log return and, over the last Window bars, finds the Components moves they share; the first is usually the whole market rising and falling together. residualZ(0) is what is left of the chart’s own return, over its usual size.
PCA waits until every market in the basket has a full window of bars, so a newly listed market holds the whole basket back until it has the history. Take it out of the basket to start sooner.

The script

basket-residual.ts

Next step

See the next example, Order-flow forecast.
Last modified on October 25, 2026