What a ranking backtest tests
A rotation strategy is a rule: at each rebalance, score every candidate, hold the top few, repeat.
The tool stk_rank_backtest runs that rule on Indian stocks or sector indices with daily history from 2004 and reports the result against NIFTY 50. You set four things: the universe, how to score, how often to rebalance, and how to hold. The general idea of sector rotation is covered in sector rotation in India; this is how to test it.

Universes without survivorship bias
| Universe | Meaning |
|---|---|
| sectors | 17 NSE sector and size indices, for sector rotation. |
| liquid100 / 250 / 500 / 1000 | The N most-traded stocks as of each rebalance date. |
The liquid universes are rebuilt at every rebalance from trailing turnover. A company that was liquid in 2012 and delisted in 2016 is in the 2012 universe and absent from the 2016 one, as it was in reality. Signals are computed on the decision day's close and filled at the next session's open, so the backtest never trades a close it could not have traded.
Scoring and holding settings
| Setting | Choices |
|---|---|
| Factors | 1-, 3-, 6- and 12-month price change; relative strength vs NIFTY 50; low volatility; risk-adjusted momentum; nearness to the 52-week high; distance above the 200-day average. Weighted as you like — each is ranked within the universe, so weights need not sum to 1. |
| Presets | classic momentum, long momentum, relative strength, risk-adjusted, quality trend, balanced. |
| Rebalance | Weekly, monthly (default) or quarterly. |
| Hold | Top N, 1–50 (default 3). |
| Weighting | Equal (default), by score, or inverse volatility. |
| Regime filter | On by default: sit in cash at a rebalance when market breadth is risk-off. |
| Require uptrend | Only buy names above their 200-DMA. |
| Cost | Per side, in basis points; default 20 (0.20%). |
Reading the result
The answer is insight, not a price dump: CAGR against NIFTY 50, maximum drawdown, Sharpe, the share of years it beat the index, how much cost consumed each year, the names it held most, and an ablation — the same strategy with the regime filter off, which shows whether the filter earned its place.
stk_compare_backtests runs 2 to 4 variants over the same window, for questions like "monthly or quarterly?" or "top 3 or top 10?". stk_stock_profile describes one stock over N years — CAGR vs the index, volatility, worst drawdown, distance from highs, 200-DMA position and per-year returns.
A worked example
You ask: "Hold the top 15 of the 500 most liquid stocks by 6-month momentum, quarterly, only above the 200-DMA." The assistant runs liquid500, a single 6-month-change factor, top 15, quarterly, require uptrend on.
Cost arithmetic to check its numbers against, with hypothetical turnover: if each quarter replaces 6 of 15 names, 40% of the portfolio is sold and 40% bought. At 20 bps a side that is 0.40 × 0.20% × 2 = 0.16% a quarter, about 0.64% a year. Switch to weekly and the same churn per rebalance costs thirteen times as much.

What it does not model
- Taxes on gains are not modelled and would reduce net returns.
- Market impact beyond the cost you set is not modelled, which matters most in liquid1000.
- A stock that stops trading is carried at its last price until the next rebalance sells it.
- The first ~400 sessions of the data are used to warm up indicators, so very early start dates begin later.
Where to find it
- Connect your assistant (see connecting your AI).
- Ask it to list the universes and factors, then describe the rule.
- Ask for a comparison to settle one choice at a time. The Stocks Scanner shows today's members of a screen.
Common questions
Is the stock backtest free of survivorship bias?
Yes. The liquid universes are rebuilt at every rebalance from that date's turnover, so delisted companies are included while they traded.
Does it trade at the close it ranks on?
No. Signals use the decision day's close and fills happen at the next session's open.
What does the regime filter do?
When market breadth is risk-off at a rebalance, the portfolio moves to cash. Every run also reports the result with the filter off.
Can I compare monthly and quarterly rebalancing directly?
Yes. Ask for a comparison: it runs 2 to 4 variants over the same window and returns CAGR, excess return, drawdown and Sharpe for each, with a verdict.
Can I get the full price series from the AI?
No. The tools return results and insights, not OHLC data. Use the chart in the Stocks Scanner to see bars.
More on Ask AI & AI backtesting
More in Ask AI & AI backtesting · App: AI backtesting · Definitions: glossary · All: every article