test-driven-development
OBobra/superpowers298k2,631 new stars in the last 7 days
Expert guidance for systematic backtesting of trading strategies. Use when developing, testing, stress-testing, or validating quantitative trading strategies. Covers "beating ideas to death" methodology, parameter robustness testing, slippage modeling, bias prevention, and interpreting backtest results. Applicable when user asks about backtesting, strategy validation, robustness testing, avoiding overfitting, or systematic trading development.
Systematic approach to backtesting trading strategies based on professional methodology that prioritizes robustness over optimistic results.
Goal: Find strategies that "break the least", not strategies that "profit the most" on paper.
Principle: Add friction, stress test assumptions, and see what survives. If a strategy holds up under pessimistic conditions, it's more likely to work in live trading.
Use this skill when:
Define the edge in one sentence.
Example: "Stocks that gap up >3% on earnings and pull back to previous day's close within first hour provide mean-reversion opportunity."
If you can't articulate the edge clearly, don't proceed to testing.
Define with complete specificity:
Critical: No subjective judgment allowed. Every decision must be rule-based and unambiguous.
Test over:
Examine initial results for basic viability. If fundamentally broken, iterate on hypothesis.
This is where 80% of testing time should be spent.
Parameter sensitivity:
Execution friction:
Time robustness:
Sample size:
Walk-forward analysis:
Warning signs:
Questions to answer:
Decision criteria:
Use the evaluation script for a structured, quantitative assessment:
python3 skills/backtest-expert/scripts/evaluate_backtest.py \
--total-trades 150 \
--win-rate 62 \
--avg-win-pct 1.8 \
--avg-loss-pct 1.2 \
--max-drawdown-pct 15 \
--years-tested 8 \
--num-parameters 3 \
--slippage-tested \
--output-dir reports/
The script scores across 5 dimensions (Sample Size, Expectancy, Risk Management, Robustness, Execution Realism). Treat the machine-readable decision and blocking_reasons as authoritative. The 0–100 quality_score is diagnostic: even a high score cannot override non-positive expectancy (except that fewer than 30 trades yields NOT_EVALUABLE first), a 50% or greater drawdown, a stricter user-supplied drawdown limit, insufficient trades, missing slippage/friction validation, a test period shorter than five years, or results that look too good (win rate above 90% with max drawdown below 5%, reason too_good, which needs a look-ahead and data audit before adoption). verdict remains a conservative Deploy/Refine/Abandon compatibility field that is never better than the score-based verdict. Use --max-acceptable-drawdown-pct to set a personal limit below the hard 50% ceiling; equality with the personal limit is allowed. Invalid inputs exit with status 1 and no report.
Add friction everywhere:
Rationale: Strategies that survive pessimistic assumptions often outperform in live trading.
Look for parameter ranges where performance is stable, not optimal values that create performance spikes.
Good: Strategy profitable with stop loss anywhere from 1.5% to 3.0% Bad: Strategy only works with stop loss at exactly 2.13%
Stable performance indicates genuine edge; narrow optima suggest curve-fitting.
Wrong approach: Study hand-picked "market leaders" that worked Right approach: Test every stock that met criteria, including those that failed
Selective examples create survivorship bias and overestimate strategy quality.
Intuition: Useful for generating hypotheses Validation: Must be purely data-driven
Never let attachment to an idea influence interpretation of test results.
Recognize these patterns early to save time:
See references/failed_tests.md for detailed examples and diagnostic framework.
reports/backtest_eval_<timestamp>.json — structured evaluation with per-dimension scores, red flags, decision, blocking_reasons, and verdictreports/backtest_eval_<timestamp>.md — human-readable report with dimension table, key metrics, and red flag detailsKey JSON fields:
decision: authoritative result, one of DEPLOY, REFINE, ABANDON, REJECT, RISK_LIMIT_EXCEEDED, VALIDATION_REQUIRED, NOT_EVALUABLE. Gate precedence: NOT_EVALUABLE (fewer than 30 trades or profit-factor overflow), then REJECT, then RISK_LIMIT_EXCEEDED, then VALIDATION_REQUIRED (no slippage test, under 5 years, or too_good). Only when no gate blocks does the score yield DEPLOY/REFINE/ABANDON.blocking_reasons: IDs of every gate that fired (profit_factor_overflow, small_sample, negative_expectancy, zero_expectancy, excessive_drawdown, risk_limit_exceeded, no_slippage_test, short_test_period, too_good); all are preserved even when a higher-precedence gate sets the decision.profit_factor: may be null. profit_factor_status explains why: FINITE (numeric value), NO_LOSSES (positive gross profit, no gross loss), UNDEFINED_ZERO_GROSS (no gross profit and no gross loss), or OVERFLOW (ratio overflow despite nonzero losses).File: references/methodology.md
When to read: For detailed guidance on specific testing techniques.
Contents:
File: references/failed_tests.md
When to read: When strategy fails tests, or learning from past mistakes.
Contents:
Time allocation: Spend 20% generating ideas, 80% trying to break them.
Context-free requirement: If strategy requires "perfect context" to work, it's not robust enough for systematic trading.
Red flag: If backtest results look too good (>90% win rate, minimal drawdowns, perfect timing), audit carefully for look-ahead bias or data issues.
Tool limitations: Understand your backtesting platform's quirks (interpolation methods, handling of low liquidity, data alignment issues).
Statistical significance: Small edges require large sample sizes to prove. 5% edge per trade needs 100+ trades to distinguish from luck.
This skill focuses on systematic/quantitative backtesting where:
Discretionary traders study differently—this skill may not apply to setups requiring subjective judgment.
OBobra/superpowers298k2,631 new stars in the last 7 days
MAmattpocock/skills288k10,178 new stars in the last 7 days
AFaffaan-m/ECC278k4,046 new stars in the last 7 days
Audit accessibility on Web, iOS, and Android to meet WCAG 2.2, with keyboard navigation and screen-reader support.
AFaffaan-m/ECC278k4,046 new stars in the last 7 days
AFaffaan-m/ECC278k4,046 new stars in the last 7 days
FIfirecrawl/firecrawl191k2,010 new stars in the last 7 days