QuantsappFaster in the app: live data, alerts, tradingOpen
Log inStart free
Stock F&OPositionalNIFTYhigh complexity

PCA residual stat-arb

This is a statistical arbitrage strategy that looks for stocks moving out of line with the market. It removes the main shared factors, found by principal component analysis, from the daily returns of 20 large caps, and watches what is left over for each stock. When that leftover drifts two standard deviations from its usual level, it buys the laggard's futures or sells the leader's, betting on a return to normal.
Strips the shared market moves out of 20 large-cap stocks' returns, then buys futures of stocks that have lagged their own norm and sells those that have run ahead, expecting them to revert.
Market viewFades moves (mean reversion)
TradesFutures of 20 large-cap stocks, long and short book
RiskOpen-ended (loss not capped by the structure)
CapitalFutures margin
SuitsAdvanced
Trades a month6.7
Typical hold7 days
Profitable months7 of 12
Longest losing run4 trades
Made money inEntry days when NIFTY closed above its openNormal India VIX between 11.5 and 14.5NIFTY rising over 1% while the trade was held
Lost money inEntry days when NIFTY closed below its openFlat opens and calm India VIX below 11.5NIFTY moving less than 1% while held
Default settings
Symbol
Universe
Pca window
N factors
S entry
S exit long
S exit short
Max hold
Max half life
Book rupees
Name cap %
Exec time
Roll time
Backtest this strategy →Change any setting, pick your own period and run it in the Quantsapp web app. Backtesting is part of the Max plan. Pro+ members can use it now as a free trial.
1

How it trades

What it trades
Universe
NIFTY Positional · 1 Oct 25 → 30 Sep 26
Enters
09:16 next session after a stock's residual s-score closes beyond ±2.0
Legs
BUY FUT · Near month, each stock with s-score -2 or lower · Current month · 1 lotSELL FUT · Near month, each stock with s-score +2 or higher · Current month · 1 lot
Exits
signal Long: s-score back to -0.5 or above; short: back to +0.75 or belowtime Held more than 15 sessionsroll Closed 15:15 on monthly expiry, reopened next session at 09:16
Re-entry
Yes - each stock can be re-entered on a new signal once its position is closed
Factors
each session, on the daily close-to-close returns of the UNIVERSE over the last PCA_WINDOW sessions: standardise them, take the N_FACTORS leading eigenvectors of their correlation matrix, and form each factor's return as the eigenvector-weighted sum of the standardised returns (eigen-portfolios).
Score
for each stock, regress its returns on the factor returns over the same window; the cumulated residual X is fitted as an AR(1) / Ornstein-Uhlenbeck process X(t+1) = a + b X(t) + e. s-score = (X now - a/(1-b)) / sqrt(var(e)/(1-b^2)). Stocks whose fit does not mean-revert (b outside 0..1, or reversion slower than MAX_HALF_LIFE sessions) get no score.
Entry
signals from the close of session T are executed at EXEC_TIME of session T+1 on the near-month future: s <= -S_ENTRY -> long; s >= +S_ENTRY -> short. A stock in the F&O ban gets no new position.
Book
one position per stock, all in this backtest's portfolio, tagged long / short residual.
Size
inverse volatility - each new name gets BOOK_RUPEES x (1/vol) / sum(1/vol over the side's signals) x 0.5 of notional, at most NAME_CAP_PCT % of the book, at least 1 lot; longs and shorts each aim at half the book (dollar-neutral up to whole lots).
Exit
long when s >= -S_EXIT_LONG; short when s <= S_EXIT_SHORT; or after MAX_HOLD sessions.
Roll
on a futures expiry day open futures are closed at ROLL_TIME and re-opened in the new near month at the next EXEC_TIME (the holding count carries on).
2

Results

PRE-BUILT · DEFAULTS
NIFTY · 2025-10-01 → 2026-09-30 · 80 trades · before costs
Net P&L+₹53,487
Win rate55%
Max drawdown−₹2,03,095
Avg per trade+₹669
Profit factor1.08
Worst trade−₹79,065
3

Where it made and lost money

Although the book holds longs and shorts, its results followed the NIFTY backdrop. Positions opened on days NIFTY closed above its open made +₹2,17,695 over 44 trades; those opened on days it closed below lost ₹1,30,355 over 35. Trades held while NIFTY rose over 1% earned ₹1,26,148 over 21, while trades held through a flat market (within ±1%) lost ₹60,755 over 30. Normal India VIX between 11.5 and 14.5 made ₹1,19,998 over 42 trades; calm evenings below 11.5 lost ₹57,698 over 22. The longs and shorts are sized per day's signals, so the book is often not balanced and keeps a market tilt; quiet markets also give residuals little room to snap back.

Session direction on the entry day
NIFTY closed above its open+₹2,17,69544 trades59% won
NIFTY closed below its open−₹1,30,35535 trades51% won
How the entry day opened
Gap up of 0.4% or more+₹1,37,78032 trades62% won
Flat open−₹87,58338 trades53% won
Gap down of 0.4% or more+₹37,1429 trades44% won
Market while the trade was held
NIFTY rose over 1% while held+₹1,26,14821 trades67% won
NIFTY within ±1% while held−₹60,75530 trades47% won
NIFTY fell over 1% while held+₹5,56023 trades52% won
India VIX the evening before
VIX below 11.5 (calm)−₹57,69822 trades55% won
VIX 11.5-14.5 (normal)+₹1,19,99842 trades60% won
VIX above 14.5 (nervous)+₹25,04015 trades47% won
Day of the week
Monday+₹18,45512 trades50% won
Tuesday+₹90,62511 trades73% won
Wednesday−₹81,76236 trades50% won
Thursday+₹44,76510 trades60% won
Friday+₹15,25810 trades60% won
Trend going in
Uptrend (NIFTY above its 20-day average)−₹11,95334 trades53% won
Downtrend (NIFTY below its 20-day average)+₹99,29345 trades58% won
Kind of session on the entry day
Quiet session (range under 0.75%)+₹84,47538 trades58% won
Trend day (closed near the high or low)+₹21,65223 trades61% won
Choppy day (wide range, closed mid-range)−₹18,78718 trades44% won
Expiry day (NIFTY weekly)
Expiry day+₹83,03512 trades67% won
Other days+₹4,30567 trades54% won
The same trades, split by the market conditions around each entry, before costs.
4

About this strategy

  1. Each evening, take the last 60 daily returns of the 20 stocks and find the 5 main factors that drive them together (principal components).
  2. Regress each stock on those factors; the running sum of what is left is the stock's residual.
  3. Fit a mean-reverting model to each residual. Stocks whose residual reverts slower than a 30-session half-life get no score; the rest get an s-score, how stretched the residual is.
  4. At 09:16 next session, buy the near-month future of any stock with an s-score of -2 or lower and sell any with +2 or higher. Each stock is its own position.
  5. Size each side's new names by inverse volatility against half of a ₹50 lakh book, capped at 15% of the book per stock, at least 1 lot.
  6. Close a long once its s-score is back to -0.5, a short once back to +0.75, or any position after 15 sessions.
  7. On monthly expiry, positions close at 15:15 and reopen in the next month at 09:16 the following session.

Why traders use it

Large-cap stocks share common drivers such as the market, sectors and interest rates. Removing those leaves the part of each move that is specific to the stock, which often fades when it was caused by short-lived flows rather than news. Running the idea across many stocks at once, with both longs and shorts, spreads the risk of any one call. It is a classic quantitative approach in global markets, adapted here to NSE stock futures.

Works best whenIn this test, positions opened on days NIFTY closed above its open and held while NIFTY rose more than 1% did best. Normal India VIX between 11.5 and 14.5, gap-up openings and NIFTY weekly expiry days were also profitable.
Struggles whenPositions opened on days NIFTY closed below its open, after flat openings, or on calm India VIX evenings below 11.5 lost money in this test, as did trades held through a market that moved less than 1%.

The year in plain words

From 1 Oct 2025 to 30 Sep 2026 on default settings the book closed 80 trades, won 55% and made ₹53,487 before costs (profit factor 1.08). After ₹20 per order and bid-ask slippage only ₹12,472 was left, a profit factor of 1.02. Of the exits, 44 were the s-score coming back, 30 monthly rolls and 4 time stops; the median hold was 7 days. March made ₹82,546 and November ₹69,320, but January lost ₹87,915 and June ₹73,848, and the drawdown reached ₹2,03,095 before costs. Seven of 12 months were positive. Costs took most of a thin edge.

What the settings do

UniverseThe comma-separated list of stocks analysed and traded. More stocks give more signals but require more margin and orders.Pca windowSessions of returns used to find the factors and fit each residual. Shorter windows adapt faster but are noisier.N factorsHow many common factors are removed from each stock's return. More factors leave a purer stock-specific residual but can strip out real signal.S entryHow stretched a residual must be to open a position. Lower values trade more often on smaller deviations.S exit longA long is closed once its s-score rises back to minus this value.S exit shortA short is closed once its s-score falls back to this value.Max holdThe longest a position is held, in sessions, if the s-score has not come back.Max half lifeStocks whose residual takes longer than this many sessions to halve its distance from normal are not traded.Book rupeesThe gross notional the book aims at; each side's new names share half of it, so it sets how many lots each stock gets.Name cap %The most notional any one stock may take, as a percentage of the book, so a single signal cannot dominate.Exec timeThe time next morning at which entries, exits and post-roll re-entries are placed.Roll timeThe time on monthly expiry day at which open futures are closed before reopening in the next month.

Risks

  • There is no price stop; a stock whose residual keeps stretching on real news is held until the 15-session limit, and one trade lost ₹79,065.
  • Longs and shorts are sized from each day's signals, so the book can be mostly long or mostly short and carries market risk.
  • The edge before costs was thin, and ₹20 per order plus slippage removed about three-quarters of it in this test.
  • A ₹50 lakh gross book across many stock futures needs substantial margin, and the drawdown exceeded ₹2 lakh.

Who it suits

Quantitatively minded traders with large margin who want a diversified, rules-based book of stock futures, can handle many orders and monthly rolls, and accept that the result after costs was close to flat in this test.

5

Questions traders ask

Is PCA statistical arbitrage profitable on NSE stock futures?

Only slightly, in this test. From 1 Oct 2025 to 30 Sep 2026 the default book made ₹53,487 before costs and ₹12,472 after ₹20 per order and bid-ask slippage, with a drawdown of ₹2,03,095 before costs. Statutory charges are not included, and they would weigh on it further. Past results do not guarantee future ones.

What is the s-score in stat-arb?

It measures how far a stock's residual, the part of its move not explained by common factors, sits from its estimated long-run level, in units of that residual's typical swing. An s-score of -2 means the stock has lagged unusually; +2 means it has run ahead. It works like a z-score on a mean-reverting model.

Is this a pair trade?

Not exactly. Each stock is its own futures position, long or short. The common factors play the role a partner stock plays in a pair, and longs and shorts are each sized from half the book, but they are not matched one to one, so the book is often unbalanced.

Why are there so many Wednesday trades?

Stock futures expire monthly, so every open position is closed at 15:15 on expiry day and reopened the next session. Each reopening counts as a new trade, and with the monthly expiry on a Tuesday many of them fall on Wednesday. Wednesday entries lost ₹81,762 over 36 trades in this test.

6

Before you rely on it

ADAPTED FOR TODAY'S NSE RULESStock futures in whole lots (lot sizes from the exchange calendar); no overnight cash shorts, so both sides are futures. The universe is a fixed list (see pitfalls).
WATCH OUTThe author's own verdict: futures 2015-2024 with full costs made +10.8 % in total, Sharpe 0.26 (+-0.32) - no statistically supported edge; the edge disappears at 5-8 bps of slippage and the cash-equity version is negative after STT. A fixed list of today's large caps adds survivorship bias.
WHERE THE RULES WERE UNCLEAR · OUR CHOICESThe source's triple-barrier stop and profit widths are not published, so they are left out; the source s-score exits (-0.5 / +0.75) plus the 15-session time stop are used (spec). UNIVERSE defaults to 20 liquid NIFTY F&O stocks rather than the full point-in-time F&O list.
Also known aseigenportfolio stat arbou s-score
Backtests run on historical NSE data with fills at the last traded price. "Before costs" excludes brokerage, taxes and slippage. Quantsapp is not recommending any strategy; it is just a backtesting utility. Past results are not a promise of future returns.

Log in or sign up

Enter your mobile number. New to Quantsapp? The same OTP creates your free account.

+91

By continuing you agree to the Terms of Use and Privacy Policy.