Skip to main content
sandbox · synthetic pricesdaily bars · long/shortpoint-in-time mechanicsturnover-aware costs

Cross-sectional momentum, point-in-time.

The shape of a cross-sectional backtest, on24 synthetic tickersover 750 bars — prices are generated in the browser with a slow per-ticker drift, so momentum should work by construction. Useful for seeing the mechanics: form a momentum score on a closed60-bar window ending yesterday, long the top quantile and short the bottom, hold for 10 bars, eat 4 bps per rebalance turnover. Sharpe isagainst an equal-weighted long-only benchmark. To run the same loop against real predictions from a trained model, see/backtest; for this strategy's catalog entry — provenance, cited notes, leaderboard entries — see/strategies/xs_momentum_demo.

sharpe
ann. return
ann. vol
max drawdown
avg turnover
rebalances
equity · strategy vs equal-weighted benchmark
base = 1.0. Strategy is long top quantile, short bottom, rebalanced every 10 bars.
strategy benchmark (eq-weight long)
mean · stdev · hit-rate
run_id
code_sha
params_hash
strategy xs_momentum
universe
window
cost_bps
sharpe
max_dd
timestamp
how this is wired

runBacktest() insrc/lib/backtest.ts is a single ~200-line deterministic module — synthetic prices, signal, weights, pnl, equity. No I/O, no async. This is a teaching sandbox, not a backtest you can trust. The price generator adds a slow per-ticker sine-wave drift on top of a shared market factor, so cross-sectional momentum picks up signal the data was designed to expose. The point is to make the mechanics of ranking, holding, turnover and cost legible — not to evaluate a strategy. For that, see /backtest, which runs on the alphakernel engine with real predictions from a trained model.

Signal is formed on a closed window ending att-1: log-return over the lookback. Long the top quantile, short the bottom, equal-weighted within each leg. Rebalances are spaced holding bars apart; between rebalances the weights drift but aren't re-sorted. The very first rebalance can only fire after the lookback window has closed — which is why strategy pnl is exactly zero for the warm-up period (the property the test suite pins down).

Transaction costs are applied per rebalance, multiplied by gross weight turnover∑|w_new − w_old|. Increasing the cost monotonically reduces realised return — easy to verify, hard to get wrong without breaking another invariant.

The benchmark is equal-weighted, long-only, on the same synthetic universe — the alpha to clear is what the long/short adds on top of "just hold everything." Sharpe is annualised with√252, drawdown is peak-to-trough on equity, turnover is the per-rebalance mean.

deskgdfindgfstrategiesgsfeaturesgepromotionsgpapigabotgbwritinggw

Shortcuts are no-ops while typing in an input or textarea.