Most retail backtesting tools run a strategy on one instrument at a time. Real quant research involves applying a strategy across a universe of instruments simultaneously, managing position limits, sector diversification, and portfolio-level risk. alphabench's basket backtest tool does exactly this.
This guide walks through the end-to-end workflow: fundamental screening, universe construction, basket backtest, and portfolio-level analysis.
1. Define your investment universe
Start by describing the kind of stocks you want in your universe:
"Find NSE large-cap stocks with ROE > 18%, ROCE > 15%, revenue growth > 12% over the last year, and debt-to-equity below 0.5. Exclude banks and NBFCs."
The Researcher agent calls find_instruments with these filters against the full NSE
universe (60,000+ instruments). It returns a ranked list of matches with:
- Instrument name, sector, market cap
- The key fundamental metrics (ROE, ROCE, revenue growth, margins, P/E, P/B)
- A quality score based on the combination of filters
A well-constructed screen typically returns 15-40 instruments, enough for a meaningful basket backtest.
2. Build the basket
Once you have the screened universe, ask the Quant agent to run a basket backtest:
"Run an EMA crossover strategy (20/50) on all 28 stocks from the screen. Limit to 5 positions at a time, equally weighted. If more than 5 signals fire on the same day, rank by momentum and take the top 5. Test the last 3 years."
The Quant agent calls backtest_basket with:
- The instrument list from the screen
- Your position limit (max simultaneous positions)
- Entry/exit signal rules (same as any single-instrument strategy)
- Position sizing (equal weight, risk-parity, or momentum-ranked)
- Ranking rule when more signals fire than positions are available
3. What the basket backtest returns
Results have two layers: portfolio level and per-instrument level.
Portfolio-level results:
- Equity curve for the full portfolio across the test period
- Sharpe, CAGR, max drawdown, win rate (on a per-trade basis)
- Average number of positions held at any time
- Signal frequency per month (to judge if the strategy is active enough)
- Turnover rate (positions opened/closed per month)
Per-instrument breakdown:
- Each stock's contribution to the portfolio P&L
- Individual win rate and average hold time
- Whether the stock was consistently in the portfolio or rarely selected by the ranking
This breakdown lets you identify free-riders (stocks that almost never signal and drag overall quality) vs consistent performers.
4. Adding sector constraints
A basket backtest without sector constraints can end up concentrated in one sector that happened to trend during the test period, which is a form of accidental sector bet.
"Same basket backtest, but cap exposure to any single sector at 30% of the portfolio."
The Quant agent enforces sector limits at the position-opening stage: if adding a new position would breach the sector cap, the next-ranked stock outside that sector is used instead.
5. Comparing screened vs unscreened
A useful experiment is comparing the basket backtest on your screened universe vs the full Nifty 50 INDICES:NIFTY 50 or Nifty 100:
"Run the same EMA crossover strategy on all Nifty 100 stocks (no fundamental filter) and compare the result to the screened portfolio from before."
This tells you whether the fundamental screen actually added value or whether the signal would have worked equally well on a random large-cap basket.
6. Universe refreshing
Fundamental screens are based on quarterly data. In a realistic portfolio, you'd re-screen every quarter and adjust holdings. The rolling backtest tool supports this:
"Run the same strategy but re-screen the universe every quarter using the fundamentals available at that point. Rebalance the basket on each re-screen date."
The Quant agent calls backtest_rolling_strategy with the quarterly rebalance dates,
ensuring the historical screen uses only data available at the time (no look-ahead).
7. Interpreting portfolio-level metrics
Basket backtests produce different metrics than single-instrument backtests:
| Metric | What to look for |
|---|---|
| Portfolio Sharpe | Should be higher than median single-instrument Sharpe (diversification benefit) |
| Max drawdown | Should be lower than the worst individual stock's drawdown |
| Win rate | Less meaningful for baskets. Focus on profit factor instead. |
| Turnover | High turnover erodes returns through transaction costs |
| Capacity | How much capital can this strategy absorb without market impact |
If the portfolio Sharpe is lower than the median single-instrument Sharpe, the stocks in the basket are correlated in a bad way and not diversifying. Consider adding sector constraints or narrowing the screen criteria.
8. From basket backtest to paper trading
When a basket backtest looks promising, paper trading it is simple:
"Deploy the top 5 momentum-ranked stocks from the screened basket to paper trading. Start monitoring today."
The platform creates a paper deployment that applies the EMA crossover signal to the screened universe daily, ranks signals by momentum, opens up to 5 positions, and tracks P&L against live tick data.
See Paper Trading for the monitoring workflow.