
Residual Edge Analyzer
FreeEvaluate strategy performance against baseline returns.
Free · Opens the source repo
What Residual Edge Analyzer does
The Residual Edge Analyzer is a specialized tool designed for quantitative analysts and traders who need to assess the independent performance of their trading strategies. By separating a strategy's returns into declared baseline exposure and residual edge, this skill provides a rigorous statistical framework for understanding whether a strategy's performance is genuinely attributable to skill or merely a reflection of market movements. The tool employs returns-based Ordinary Least Squares (OLS) attribution, which allows users to analyze the robustness of their strategies in various market conditions.
Users begin by preparing a CSV file that includes the strategy returns alongside baseline returns, ensuring that the data is formatted correctly with unique ISO dates and finite numeric values. The analyzer then validates this data against a set of predefined criteria to ensure the integrity of the analysis. Once validated, the user runs the analysis script, which generates both a JSON report and a Markdown summary, detailing the findings in a clear and auditable manner. This report includes crucial metrics such as annualized alpha, residual edge ratio, and rolling stability, which are essential for making informed trading decisions.
The Residual Edge Analyzer is particularly useful in scenarios where traders need to justify their strategies against various baselines, such as market indices or user-defined factors. It is also beneficial for determining whether drawdowns are a result of baseline exposure or strategy-specific behavior. However, it is important to note that this tool is not intended for holdings-based attribution or for analyzing summary metrics without a detailed return series, making it a focused solution for specific analytical needs in trading.
When to use it
Use this tool when you need to evaluate the effectiveness of a trading strategy against established baseline returns, especially after backtesting.
When not to use it
Avoid using this skill for holdings-based analysis or when working with summary metrics that lack a detailed return series.
What you can build with it
Evaluating Strategy Performance
Use the analyzer to determine if your trading strategy's returns are genuinely attributable to skill or simply reflective of market movements.
Post-Backtest Analysis
After backtesting a strategy, apply this tool to ensure that the results are not influenced by baseline exposure, providing a clearer picture of performance.
Understanding Drawdowns
Analyze whether drawdowns in your strategy are due to baseline exposure or specific strategy behaviors, helping to refine your trading approach.
How to install Residual Edge Analyzer
View source1. Install with the skills CLI
npx skills add tradermonty/claude-trading-skills/residual-edge-analyzer --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by tradermontyResidual Edge Analyzer
Overview
Test whether a strategy's apparent performance survives explicit comparison with predeclared baseline return series. Produce an auditable JSON artifact and a concise Markdown report without fetching data or changing trading exposure.
Treat this as a falsification gate after backtest-expert, not as trade authorization.
Prerequisites
- Use Python 3.9+.
- Prepare one CSV containing an ISO date, strategy return, and every baseline return on the same row.
- Prepare a JSON specification following references/input-contract.md.
- Supply actual period returns. Do not substitute CAGR, Sharpe, cumulative P&L, or other summary metrics.
Workflow
1. Define the question before inspecting results
State the claimed independent edge in one sentence. Select a primary baseline that is a plausible simple copy of the strategy, then select at least one alternate baseline model.
Record these declarations in the config:
baseline_selection: predeclaredstrategy_return_basisandbaseline_return_basis: bothgrossor bothnetanalysis_scope:out_of_sample,live, orin_sampleuniverse_data:point_in_time,current_constituents, ornot_applicable
Every declaration is mandatory for a decision-grade verdict. Omitting one is treated as
undeclared, not as benign, and drops the report to REVIEW_REQUIRED. not_applicable
exists so that a baseline with no universe membership can be declared explicitly rather
than left blank.
Do not choose a baseline because it gives the preferred residual result.
2. Validate the return-series contract
Require:
- unique ISO dates;
- finite numeric returns greater than -100%;
- identical frequency and cost basis across strategy and baselines;
- point-in-time membership for same-universe equal-weight or momentum baselines;
- regime labels defined independently of the loss periods being explained.
Stop if the input lacks a dated strategy return series. Report summary-only input as insufficient rather than inventing observations.
3. Run the analyzer
python3 skills/residual-edge-analyzer/scripts/analyze_residual_edge.py \
--input reports/strategy_returns.csv \
--config reports/residual_edge_config.json \
--output-json reports/residual_edge_report.json \
--output-markdown reports/residual_edge_report.md
The script runs the predeclared primary model and all sensitivity models in one execution. It uses an intercept OLS model and HAC/Newey-West standard errors. It reports the residual edge ratio as annualized alpha divided by annualized residual volatility; do not calculate a Sharpe ratio from raw OLS residual mean because an intercept makes that mean zero.
4. Interpret the evidence
Use the four statuses as diagnostic labels:
RESIDUAL_EDGE: alpha, residual edge ratio, and rolling stability clear configured thresholds.BASELINE_EXPLAINED: baseline R-squared is high while residual evidence is weak.RESIDUAL_FRAGILE: results fail one or more robustness gates or change across declared baseline models. Also use this status when rolling analysis is disabled, unavailable, incomplete, or no sensitivity model was supplied.INSUFFICIENT_EVIDENCE: the sample is below the configured minimum.
Read decision_eligibility separately. A statistically interesting result remains
REVIEW_REQUIRED when critical provenance, cost-basis, sample, or multicollinearity
warnings exist, when rolling evidence is unavailable, or when no alternate baseline was
tested.
Inspect:
- primary and sensitivity-model status;
- annualized alpha and HAC t-stat;
- residual edge ratio and residual autocorrelation;
- rolling alpha stability;
- VIF for multi-factor models;
- active-return breakdown across predeclared regimes.
5. Hand off findings
- Send baseline-choice, OOS, and stability findings back to
backtest-expert. - Send recurring residual failure regimes to
signal-postmortem. - Pass only evidence and operating constraints to
trade-performance-coach. - Never change position size, exposure, or orders automatically.
Boundaries
- Do not call this holdings-based contribution analysis. Brinson allocation, selection, and interaction effects require historical holdings, benchmark weights, and constituent returns.
- Do not claim stock-selection alpha from a market-index-only baseline.
- Do not build equal-weight baselines from current constituents and label them point-in-time.
- Do not interpret in-sample residual edge as confirmed alpha.
- Do not mine many regime definitions after seeing losses. Predeclare a small set and confirm findings out of sample.
- Do not assume high R-squared makes a strategy worthless; capacity, tail behavior, costs, and implementation value require separate evidence.
Resources
scripts/analyze_residual_edge.py— deterministic CSV-to-JSON/Markdown analyzer.references/input-contract.md— CSV/config contract and runnable example.references/methodology.md— statistical definitions, interpretation, and limitations.
Frequently asked questions about Residual Edge Analyzer
Similar skills
Power BI Semantic Modeling
Optimize your Power BI data models with best practices.
Data Context Extractor
Tailor data analysis skills to your company's needs.
Power BI Performance Troubleshooting
Systematic guidance for optimizing Power BI performance.
Power BI Model Design Review
Optimize your Power BI data models with expert reviews.
Power BI DAX Formula Optimizer
Optimize your DAX formulas for better performance and clarity.
Fabric Lakehouse
Optimize your data solutions with Lakehouse best practices.
