/india-trading-skills:backtest-labfrom india-trading-skills
Backtests rule-based swing strategies on NSE/BSE daily bars with Indian market frictions (STT, stamp duty, GST, DP, slippage, gap-through stops, circuit limits). Includes six built-in strategies, parameter sweeps, walk-forward, and Monte Carlo simulation. Uses stdlib only, offline.
Ships in india-trading-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
A backtest cannot prove an idea works. It can show quickly that an idea does not. Judge a rule set by how little it degrades when Indian charges, overnight gaps, unseen years and bad luck are piled on, and treat a spectacular first run as a reason for suspicion.
python3 scripts/backtest.py strategies # rules and defaults
python3 scripts/backtest.py run --csv tcs.csv --strategy sma-cross --params fast=20 slow=50
python3 scripts/backtest.py run --symbol POLYCAB --strategy 52w-high --risk-pct 1 --tax --trades-csv t.csv
python3 scripts/backtest.py run --csv hdfcbank.csv --strategy donchian-breakout --regime-csv nifty.csv
python3 scripts/backtest.py run --csv nifty.csv --strategy sma-cross --segment futures --lot-size 65 \
--allow-short --leverage 3 --size-pct 300
python3 scripts/backtest.py sweep --csv tcs.csv --strategy sma-cross --grid fast=10,20,30 slow=50,100,200
python3 scripts/backtest.py walkforward --csv tcs.csv --strategy donchian-breakout \
--grid entry_n=20,40,55 exit_n=10,20 --is-bars 756 --oos-bars 252
python3 scripts/backtest.py montecarlo --csv tcs.csv --strategy ema-pullback --sims 2000 --seed 7
python3 scripts/backtest.py montecarlo --from-trades t.csv --ruin-dd 25
Inputs follow technical-analysis: --csv, --candles (broker-MCP JSON, null candles skipped) or
--symbol (yfinance, --period 10y). --start sets the first trading day while earlier bars still
warm up the indicators. --grid also takes ranges (fast=10:50:10). Every command takes --json.
Bad input exits 2 with one error: line.
--strategy, override with --params key=value)| Name | Rule (long side; shorts mirror it) | Defaults |
|---|---|---|
| sma-cross | fast SMA crosses above slow; out when back below | fast 20, slow 50, stop 3×ATR |
| ema-pullback | close above a rising trend EMA, low tags the EMA, close back above it | ema 20, trend 100, 2×ATR, target 2R, 20 bars |
| rsi-reversion | RSI(period) below buy_below while above the trend SMA; out above sell_above | 2, 10, 70, trend 200, 10 bars |
| donchian-breakout | close above the prior entry_n high; out below the prior exit_n low | 20 / 10, 2×ATR |
| bollinger-reversion | close below the lower band; out at the middle band | 20, k 2, trend 0 (off), 20 bars |
| 52w-high | close above the prior lookback-bar high; out below the exit SMA | 252, exit_ma 50, 2.5×ATR |
Every strategy also takes stop_atr (k × ATR14 from the fill), stop_pct (overrides it),
target_r and max_hold (bars), where 0 turns each one off. There is no custom-code hook: new
rules are added to the script as reviewed code.
--slippage-bps (default 5) on every fill. Use 15–30 for small caps.trading-costs (charges.py) for each round trip, by --segment delivery|intraday|futures and --broker. A delivery buy sold the same day is charged as intraday.--size-pct (default 100% of equity), --risk-pct (risk to the initial stop, the
position-sizing method) or --fixed-inr. The size is set on the signal close, capped by the cash
available at the fill, and rounded down to whole shares or whole --lot-size lots (futures, SME).--segment futures --allow-short. An Indian cash-market short has to be bought
back the same session (SLB aside), so a multi-day short only exists as futures. Futures notional ≤
equity × --leverage. Rollover, basis and margin calls are not modelled.--circuit-band 2|5|10|20, an open at the band limit gets no fill. The entry is
skipped; an exit or stop waits for the next unlocked open. Each case is listed under order events.--regime-csv nifty.csv (or --regime-symbol NIFTY) allows longs only while the
benchmark closes above its --regime-ma (200) SMA on the signal day, and shorts only below it.--rf (default 6.5% a year, about a liquid
fund or T-bill; change it).--tax applies indian-tax-for-traders rates for a rough post-tax view: STCG 20% (held ≤12
months), LTCG 12.5% above ₹1.25 lakh per FY, intraday and futures at --slab-pct, plus 4% cess.
It is approximate: losses are not carried forward and STT is treated as deductible, which it is not.--regime-csv,
and include a bad phase (2008, 2015–16, 2018 small caps, March 2020, late 2024–early 2025).--circuit-band, higher slippage). Stop
orders are DAY-only on exchanges, so a real system needs GTTs (see breakout-planner).market-regime (../market-regime/scripts/regime.py): test whether a NIFTY trend filter
(--regime-csv) cuts drawdown more than it cuts return before using it live.run → sweep → walkforward → montecarlo, and stop at the first red flag.position-sizing (../position-sizing/scripts/risk.py): choose a --risk-pct that keeps the Monte
Carlo 95th-percentile drawdown survivable.trading-discipline: --trades-csv writes journal columns, so
python3 ../trading-discipline/scripts/discipline.py review t.csv breaks the backtest down by
weekday and setup. Compare it with your live journal later; a large gap is a warning.breakout-planner: 52w-high and donchian-breakout are rough stand-ins for its Stage-2 entries.
They tell you whether breakout buying pays on a stock at all, not whether a given VCP will work.Limits: one symbol and one position at a time (no portfolio rotation), daily or weekly bars, no options, no tick rounding.
NAME: strategy (params) | segment on NSE via broker | capital | sizing | slippage
start → end | bars (years) | signal on close, fill next open | charges as of <date>
Strategy vs Buy & hold: total return, CAGR, max DD, volatility, Sharpe (rf), Sortino, Calmar
Trades N: W / L / BE | win rate | avg win / loss | PF | expectancy ₹ (R) | payoff | losing streak
Exposure | avg hold | max DD dates | longest underwater | charges (% of gross profit) | slippage
Year table | last trades | order events | red flags | data notes
Educational analysis, not investment advice. A backtest describes the past, not your next trade.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
backtesting, swing-trading, indian-stock-market, nse, bse, parameter-optimization
npx claudepluginhub xdhruv/claude-trading-skills-india-mv --plugin india-trading-skills36 skills in this plugin
/breakout-plannerStage-2 breakout setups on NSE/BSE stocks: a trend-template check (rising 200 DMA, 50>150>200
stack, distance from 52-week high/low, relative strength vs NIFTY), base detection (volatility
contraction with successively tighter pullbacks, or a flat base) with pivot, depth, duration,
volume dry-up and a grade, then an order-ready plan: trigger, chase limit, capped stop, size,
Indian charges, R targets, GTT/SL templates, circuit-band and NSE tick-size checks. breakout.py
scans a folder of CSVs or yfinance symbols and ranks them, offline-capable.
Use when the user asks: "is X in a Stage 2 uptrend", "find VCP setups", "where is the pivot on X",
"plan a breakout trade in X", "breakout buy point and stop", "scan these stocks for breakouts",
"Minervini trend template for NSE stocks", "how do I place a GTT for a breakout", or any question
about buying stocks as they clear a base.
/broker-integrationConnect Claude to Indian brokers and use them safely: official MCP servers for Groww, Zerodha
Kite, Dhan, Upstox, Fyers and Kotak Neo (endpoints, auth, read vs order capabilities as of Oct 2026),
tool discovery and capability mapping, saving candles for the analysis scripts, a mandatory
order-confirmation protocol, SEBI retail-algo/static-IP rules, and data fallbacks (yfinance, CSV).
Use when the user asks to connect or set up Groww/Zerodha/Kite/Dhan/Upstox/Fyers/Angel One, "fetch my
holdings/positions", "get live price", "place/modify/cancel an order", "set a GTT", "why was my order
rejected", or when another skill needs live data.
2 plugins ship this exact skill · first indexed Nov 4, 2026
Other plugins' skills for the same job