Skip to main content

custom_index.py / fo_effect.py — Custom Indices (Leverage Study, F&O Effect)

Research question (2026-09-27): can leverage generate extra alpha?

backend/nseeod/custom_index.py builds an index of all NSE F&O stocks:

  • equal-weighted;
  • held through their near-month futures;
  • rolled at every monthly expiry;
  • base 1000, from the first stock-futures expiry (Nov 2001).

It is built at 1x, 2x and 3x (configurable). Results live in their own tables (ci_master, ci_level, ci_holding), never in scr_master, scr_nseeq_eod or the NSE-index idx_* tables. They are shown on the Leverage Study page.

Method​

At each monthly expiry R(k) (the expiry-day close):

StepRule
UniverseStocks whose future expiring R(k+1) trades on R(k): the F&O list as it was then, so survivorship-free. Stocks added to F&O join from the next cycle; stocks removed leave at expiry, as NSE runs its contracts.
Positionq_i = (L · NAV / N) / F_i(R(k)), so the notional is L × NAV, split equally
Daily NAVNAV(t) = NAV(t−1) + Σ q_i·(F_i(t) − F_i(t−1)) + NAV(t−1)·r·days/365
RollClose at the expiring contract's close on R(k+1), open the next contract at its close; leverage resets to L
Costscost_bps (default 5) per side on every notional traded
RuinNAV ≤ 0 stops the series

Rebalance dates are the actual monthly expiries, taken from the stock futures' own last trading days (rebalance_dates(), 299 so far; see Validation): holiday-shifted, and on Tuesday from Sep 2025.

Collateral rate r (decided 2026-09-27: implied): each expiry, r = (F_NIFTY / S_NIFTY − 1) · 365 / days + NIFTY dividend yield.

  • F is the NIFTY future expiring R(k+1) and S is the NIFTY spot close.
  • The future's premium is funding cost minus dividends, so the dividend yield (scr_indexpepb, from 2012) is added back. Before 2012 the 2012–26 average of 1.3% is used.
  • The rate is clipped to 0–20%.
  • It is noisy, and below true money-market rates in some years (≈1.4% in 2005–06, 2.4% in 2020), because NIFTY futures traded near or below spot. It is still the market's own price of funding.
  • The rate applied each day is stored in ci_level.cash_rate. --cash-rate 6.5 gives a fixed rate instead.

Splits / bonuses inside a cycle: NSE adjusts running futures (price down, quantity up; RELIANCE's Sep-2017 future went 1,646.95 → 821.25 on the 1:1 bonus). Each contract's earlier prices are scaled by the stock's scr_corp_action factor, only when the contract's own jump confirms it: within ±18% in log terms, or, for a big split (factor and jump both below 0.8), within ±50%, since a split can land on a crash day. Ordinary dividends need nothing, since futures already price them.

Positions are fractional (it's an index). A lot-rounded variant (lotsize) is possible later.

Measuring "extra alpha"​

  • CAGR, volatility, Sharpe, max drawdown, Calmar, worst month, longest drawdown per series.
  • CAGR − L × 1x CAGR: the volatility drag, i.e. what leverage lost to compounding and costs.
  • Growth-optimal (Kelly) leverage of the 1x series, (mean excess return) / variance: the leverage that would have maximised compound growth.
  • Not the answer: regression "alpha vs 1x". With futures leverage it is mechanical, about −(L−1) × r: every series earns interest on the same collateral. It's stored but not interpreted.

Results (local, 2026-09-27): Nov 2001 → Sep 2026, base 1000​

SeriesFinal NAVCAGRVolatilitySharpeMax drawdownWorst monthCAGR − L × 1x
1x16,25911.9%24.7%0.37−71.9%−31.1%—
2x7,0748.2%53.8%0.33−97.1%−73.2%−15.6 pts
3x0: wiped out 2008-10-23 (it had reached 35,611 by end-2007)———−100%——

Growth-optimal (Kelly) leverage of the 1x series: 1.50x.

Answer to the research question, for this universe and period: leverage did not add alpha.

  • Return per unit of risk falls slightly with leverage (Sharpe 0.37 → 0.33).
  • Compounding punishes it: 2x ended at less than half of 1x's value after a −97% drawdown in 2008.
  • 3x was wiped out in the 2008 crash.
  • The best constant leverage in hindsight is only ~1.5x, and that assumes the 1x volatility and drawdowns are bearable.
  • The one exception is a strong trending stretch: 2001–2007, when 2x and 3x did far better than 1x before giving it all back.

Universe size per cycle: 31 stocks (Nov 2001) → 200+ (2007 onward, 133–228 by cycle).

Validation (engine checks)​

Full range, Nov 2001 → Sep 2026:

CheckResult
Leverage identity, first day of each cycleexact (0 error) on all 298 cycles (2x) and all 83 cycles 3x lived
1x futures + collateral vs an equal-weight spot total-return series (same members and expiries)daily correlation 0.995. The futures route trailed spot TR by 1.7% a year: ~1.2% roll costs (5 bps × 2 sides × 12), the rest the stock-futures premium over the NIFTY-implied rate
Splits / bonuses inside a cycle284 scaled, 0 left unconfirmed. JINDALSTEL's 1:5 split on the 2008-01-21 crash day (future 0.14× vs factor 0.2) counts as confirmed under the "big split" rule
Two contracts in one seriesSome stocks have two contracts of the same series on the same day (the Sep-2025 Thursday→Tuesday switch; relabelled masters). The contract that traded on the rebalance day is used, a sibling only on days it has no price. Before this rule (fixed 2026-09-28) the choice depended on database row order: 12 holdings in 5 cycles differed between PC and VPS, and the 1x NAV by 0.3%
Expiries299 series, one per month; holiday shifts (e.g. 2008-12-25 → 24) and the relabelled June-2023 series handled

Expiry dates come from the stock futures themselves: a date on which at least 10 stock-futures contracts last traded, with holiday-shifted last days. Series less than 3 days apart are merged (June 2023: "29-Jun" until 06-27, "28-Jun" on expiry day). Taking the dates from index-future names was wrong: that also matched NIFTYNXT50 and sector futures, and the stray duplicate-expiry masters.

Earlier engine checks (2010–2013 test window)​

CheckResult
Leverage identity on the first day of each cycle: ret_L = L·ret_1 − (L−1)·r·days/365exact (error 0 on 47 cycles). Later in a cycle the effective leverage drifts until the next reset, by design
1x futures vs an equal-weight spot total-return series with the same members and expiries (built for the check only)daily correlation 0.996. 1x futures + collateral trailed spot TR by ~3.0% a year: ~1.2% roll costs, the rest the stock-futures premium over the NIFTY-implied rate
Split / bonus inside a cycle53 scaled, 1 not confirmed by the future (left unscaled)

F&O effect study (fo_effect.py)​

Question (2026-09-27, from the user's observation): does a stock lose momentum once it enters F&O?

backend/nseeod/fo_effect.py builds equal-weight cash indices, total return, base 1000, rebalanced at every monthly expiry (the same calendar as the leverage study). Members are taken as they were at each expiry.

CodeMembers at each expiry
FO-EW-EQStocks with a stock future in the next series (the leverage study's list)
NONFO-N500-EWNIFTY 500 members (idx_members_on) minus F&O stocks, from 2003 (tracker within ±15 from then)
NONFO-T750-EWOwn top 750 mainboard stocks by 6-month median traded value (≥ 120 of 126 days traded; ETFs excluded) minus F&O, from Nov 2001
FO-NEW12-EWF&O stocks whose futures started within the last 12 expiries
SPREAD-FO-N500 / SPREAD-FO-T750Daily long FO-EW-EQ, short the non-F&O index

Why no official "NIFTY 500 + Smallcap 250 = 750": Smallcap 250 is part of NIFTY 500 (ranks 251–500), so the union is ~500 stocks. The official 750-stock index is NIFTY Total Market (NIFTY 500 + Microcap 250), which the constituent tracker does not have. T750 stands in for it.

Method:

  • Buy-and-hold inside a cycle (weights drift), back to equal weight at the next expiry.
  • A stock with no row on a day returns 0; delisted stocks keep their last close until the next rebalance.
  • Prices come from eq_store.get_returns_panel(adjust='total') (splits, bonuses, dividends; renames joined).
  • Two kinds of days are skipped (return 0):
    • 1,304 stock-days with an unresolved REVIEW corporate action: mostly splits and bonuses before 2006 that NSE's records lack (ITC 2005-09-21 showed −93%), and demergers without a factor.
    • Returns across a gap of more than 31 days: e.g. GECALSTHOM's last row in 2002 joined to AREVA T&D in 2008 gave +4,956%.

Event study (ci_event):

  • Events: every entry into the F&O list after the Nov 2001 launch batch (576), and every exit (399). A gap of up to 2 expiries out of the list is not counted as an exit.
  • Event date: the first (last) day any of the stock's futures traded. Cycle 0 is the expiry cycle containing that date.
  • Abnormal return (AR): per cycle from −24 to +24, the stock's total return minus the same-cycle return of NONFO-T750-EW (or of NONFO-N500-EW).
  • Reported: the average AR summed over windows (CAR) with t-stats, overall and per era.

Results (local, 2026-09-27)​

SeriesFromFinal NAVCAGRVolSharpeMax DD
F&O stocks FO-EW-EQNov 200134,46015.3%23.7%0.50−71.8%
Non-F&O NIFTY 500Jan 200372,19819.8%20.0%0.75−69.7%
Non-F&O top 750Nov 200190,04019.9%23.0%0.68−77.1%
F&O new entrants (≤ 12 expiries)Feb 200314,60512.0%28.3%0.48−77.2%
Spread F&O − non-F&O NIFTY 500Jan 2003482−3.0%10.9%—−59.0%
Spread F&O − non-F&O top 750Nov 2001337−4.3%11.7%—−70.8%

Entries (576), abnormal return vs non-F&O top 750:

Window (expiry cycles)−24..−1−12..−10+1..+12+13..+24
Mean CAR+41.1% (t 13.7)+17.5% (t 8.5)−0.4%−3.8% (t −2.4)+0.9% (t 0.6)

The pattern holds against the NIFTY 500 benchmark (+46.7% before, −3.5% in +1..+12) and in every era. The post-entry lag was largest in 2014–19 (−12.5% vs top 750 in +1..+12).

Exits (399): −19.9% in the 24 cycles before (t −6.6), and a further −5.8% in +1..+12 (t −2.4). Stocks removed from F&O keep lagging.

Reading:

  • The momentum happens before entry, not after. NSE admits stocks on market cap and turnover, so they join after a large run-up (+41% over the benchmark in 2 years).
  • After entry the excess return stops, and turns slightly negative in the first year (−3.8%, significant). This is consistent with the observation, but it is "momentum ends" more than "momentum reverses".
  • As a group, the F&O stocks trailed the non-F&O stocks by ~4.5 points a year over 25 years, at similar volatility. This is partly a size effect: non-F&O stocks are smaller.
  • Limits:
    • equal weight;
    • no costs;
    • delisted stocks keep their last price;
    • the unreviewed pre-2006 corporate actions are skipped, not applied;
    • the NIFTY 500 tracker is approximate (±15 members) before 2020.
python -m nseeod.fo_effect build [--apply] [--cost-bps 0]
python -m nseeod.fo_effect events [--type entry|exit]

Usage​

Run from backend/:

python -m nseeod.custom_index build [--leverage 1,2,3] [--cash-rate implied|6.5] [--cost-bps 5] [--from --to] [--apply]
python -m nseeod.custom_index stats

build fully recomputes the ci_* rows for those series (derived data). The Bhav Downloader recomputes them after each run, once the tables exist (BhavProcessor._update_custom_index).

TableContent
ci_masterSeries code (FO-EW-FUT-1X …), parameters (params JSON), stats JSON (metrics + calendar years)
ci_levelDaily nav, daily_ret, n_members, gross_exposure, cash_rate
ci_holdingPer expiry and series: stock, contract, entry price, quantity, weight (cash series: stock and weight only)
ci_eventF&O entry / exit events: per event and cycle −24..+24, stock return and both benchmarks' returns

API (app/api/custom_index.py): GET /api/custom-index/series?study=leverage|fo_effect, /levels?codes=, /holdings?code=&date=, /events?type=entry|exit&bench=a|b, /events/list.