Brief
C2 · A systematic swing-trading strategy, researched to publication standard#
Objective#
Design, backtest and evaluate one rule-based swing strategy on Indian equities (holding period from two days to about eight weeks) to the standard of M04: a pre-stated hypothesis, codable rules, a survivorship-free universe, realistic costs, walk-forward out-of-sample testing, and inference that accounts for every variant you tried. The deliverable is an honest answer to one question: is there evidence, after selection bias and costs, that this rule has positive expected return, and if so how should it be sized? A well-documented "no" earns full marks; a "yes" that does not survive the checks earns few.
Deliverables#
- Research log (written before and during the work): the hypothesis, its economic rationale (M04 · 4.1–4.3: momentum, reversal, breakout, trend template, VCP, Darvas), and a dated list of every variant tested, including those abandoned. The log is the input to the multiple-testing correction.
- Code: a Python package or notebook that runs end to end from raw data to every table and figure, with fixed random seeds and a single configuration file.
- Report (3,000–6,000 words) following the outline below.
- Trading plan for the strategy in the format of M14 · 14.10.2, with graduation criteria, whether or not the conclusion is positive.
Time budget and minimum viable scope#
The full scope below is a research project: realistically 40–60 hours, most of it in the data pipeline (point-in-time universe, corporate actions) and in the selection-bias work. The full-track plan budgets about 36 hours for a minimum viable version, which must still be honest:
- universe: Nifty 100 constituents, point-in-time from NSE's index change announcements (rather than the Nifty 500);
- one strategy family and at most a handful of logged variants;
- walk-forward with three to five test windows;
- Sharpe standard error, PSR and the deflated Sharpe ratio with the full variant count (items 6–7); PBO may be omitted, with the omission stated;
- a 2,000–3,000-word report, the trading plan and code that reruns end to end.
Everything else in the list below is the extension to the full scope. Acceptance criteria 2 and 5 apply to the full scope; the minimum viable version states how far short of them it falls.
Required analyses#
- Hypothesis and rules (M04 Definitions 4.1–4.2). The signal must be -measurable; position held from the next open. Entry, stop, exit, holding-period cap, position limit and regime filter (M04 Definition 4.8 or your own) written as formulas. State the predicted sign and rough size of the effect before running anything.
- Universe and data hygiene (M04 · 4.4.2–4.4.3; M01 · 1.10). A point-in-time universe (for example Nifty 500 constituents as of each rebalance date) or an explicit statement of how survivorship bias is bounded (Proposition 4.9). Prices adjusted for splits, bonuses and dividends; check at least five corporate actions by hand. A look-ahead catalogue: list each check you performed.
- Costs and slippage (M01 · 1.7; M04 Proposition 4.10; M05 · 5.9). Charges from a dated broker schedule (delivery STT 0.1% each side and the other charges as of your test date), plus a slippage assumption justified from spreads or from M05's square-root law for your trade size. Report gross and net results, turnover and the breakeven cost per side.
- Backtest engine (M04 · 4.4.1, Proposition 4.8). Event-driven or vectorised with a stated equivalence; positions sized by fixed fractional risk (M03 · 3.9) with the stop distance known at entry.
- Walk-forward evaluation (M04 Algorithm 4.2). Rolling or anchored, with training and test lengths fixed before looking at results. Any parameter chosen in-sample is frozen for its test window. Report the stitched out-of-sample equity curve and its statistics separately from in-sample statistics.
- Sharpe ratio inference (M04 · 4.5). Annualised Sharpe with the standard error from Proposition 4.11 (using sample skewness and kurtosis), Lo's autocorrelation adjustment (Proposition 4.12) if daily returns are autocorrelated, the probabilistic Sharpe ratio against zero and the minimum track record length.
- Selection bias (M04 · 4.6). Count the number of variants in your log; compute the expected maximum Sharpe ratio of skill-less trials (Proposition 4.13) using the variance of Sharpe ratios across your trials, and the deflated Sharpe ratio (4.6.3). Compute the probability of backtest overfitting (4.6.6) with combinatorially symmetric cross-validation over at least blocks. Apply Holm or Benjamini–Hochberg (Propositions 4.15–4.16) if you test several distinct hypotheses.
- Robustness. Parameter-neighbourhood plot (performance as a function of each parameter around the chosen value), sub-period results (at least three regimes, including 2008, 2020 and 2026 if your data cover them), and results by market-capitalisation tercile.
- Trade statistics (M03 · 3.1). Expectancy in R, standard deviation of R, win rate, payoff ratio, SQN, and the number of trades needed for with 80% power (M03 · 3.1.1, Corollary 3.1.2, (3.2b)).
- Risk and sizing (M03 · 3.4–3.8; M14 · 14.5, 14.8, 14.13). Maximum drawdown and its duration; the drawdown distribution by bootstrap of trades; fractional-Kelly size under estimation error; portfolio heat limit; ES at 97.5% of daily P&L; a gap-risk scenario (all open positions gap 10% through their stops).
- Live-consistency plan (M14 · 14.10.3). What live results over the first trades would be inconsistent with the backtest?
Data sources#
- Prices: NSE equity bhavcopy archives (daily OHLCV, all listed securities, which avoids survivorship if you keep delisted names) or Yahoo Finance
.NStickers (adjusted closes; survivorship-biased, so document the bias). - Index constituents: NSE index factsheets and historical constituent change announcements (niftyindices.com) for point-in-time membership.
- Corporate actions: NSE corporate-action filings; cross-check against adjusted prices.
- Risk-free rate: RBI 91-day T-bill yields (DBIE) for excess returns.
- Costs: a broker's published charges page, saved with its date.
Acceptance criteria#
- The hypothesis, rules and walk-forward design are dated in the log before the first out-of-sample result.
- The out-of-sample period covers at least five years and at least 200 trades; if the data cannot provide this, say so and widen the universe rather than shorten the test.
- Net-of-cost out-of-sample results are reported with standard errors; no in-sample statistic appears in the conclusion.
- Deflated Sharpe ratio above 0.95 for the selected strategy given the number of variants in the log, or a clear explanation of why it is not and what that implies (the usual correct conclusion: not enough evidence to trade at full size).
- PBO reported; a PBO above 0.5 is treated as evidence that the selection procedure picked noise.
- The breakeven cost per side is at least twice the assumed cost, or the report states that the edge is cost-fragile.
- Results are stable in sign across the parameter neighbourhood and in at least two of three sub-periods; instability is reported, not hidden.
- A third party can rerun the code from raw data and reproduce every number to the reported precision.
Template outline for the write-up#
- Abstract: hypothesis, data, out-of-sample result net of costs, DSR, PBO, conclusion.
- Hypothesis and economic rationale; prior evidence (M04 · 4.3).
- Rules (formal definitions).
- Data, universe and hygiene checks.
- Cost and execution model.
- Methodology: engine, walk-forward design, statistics.
- Results: in-sample (briefly), out-of-sample (in full), trade statistics.
- Inference: Sharpe error bars, PSR, DSR, PBO, multiple testing.
- Robustness: parameters, sub-periods, size terciles.
- Risk and sizing.
- Conclusion and the trading plan (or the decision not to trade).
- Appendix: research log, code description, data checks.
Common failure modes#
- Silent look-ahead: using the close of day to trade at the close of day ; index membership as of today; fundamental data before its publication date.
- Survivorship: testing on today's Nifty 500 back to 2010. Breakout and momentum rules look much better on survivors.
- Undercounted trials: reporting DSR with after trying forty parameter sets. The log exists to prevent this.
- Overlapping returns treated as independent (Proposition 4.4): inflated -statistics for multi-week holding periods.
- Costs as an afterthought: high-turnover rules with 10–20 bps gross edges per trade do not survive Indian delivery STT.
- Optimising the walk-forward: trying several window lengths and reporting the best stitched curve reintroduces selection bias (M04 · 4.4.5).
- Sizing on the backtest's best estimate: full Kelly on an estimated edge is overbetting (M03 · 3.5); use a fraction and the lower confidence bound.