Tearsheet Generator Skill
About
This skill generates custom tearsheets using the QuantStats library - a Python library for portfolio analytics.
Key Features:
- Custom SVG visualizations (returns, drawdowns, monthly heatmaps)
- Professional HTML tearsheets
- MAE (Maximum Adverse Excursion) analysis
- Leverage recommendations based on risk metrics
- Copyable strategy configurations
Generate comprehensive trading strategy tearsheets with:
- IBM Plex Mono font styling (QuantStats format)
- MAE (Max Adverse Excursion) percentile analysis (p90-p99)
- Optimal leverage recommendations with stop-loss levels
- Fixed Position (Static) vs Full Position (Dynamic) analysis
- 10%, 20%, 30% liquidation buffer calculations
- Full trade list with entry/exit details and MAE stats
- Copyable strategy config text boxes
- Multiple leverage scenario comparisons (1x, 10x, 15x, 20x)
Quick Start
# Generate tearsheet from trades CSV
/generate-tearsheet SOL_MTF_EMA_001 --trades ./trades.csv --capital 10000
# Verify backtest with Nautilus Trader
/verify-backtest SOL_MTF_EMA_001 --trades ./trades.csv
# Test optimal leverage configuration
/verify-mae-lev SOL_MTF_EMA_001 --leverage p95
Commands
/generate-tearsheet
Generate a complete tearsheet with all analysis sections.
/verify-backtest
Verify tearsheet results against Nautilus Trader for accuracy validation.
/verify-mae-lev
Run backtest with optimal leverage config derived from MAE analysis.
Output Files
Each tearsheet generation produces:
{strategy}_comparison.html - Full HTML tearsheet
{strategy}_comparison_metrics.json - JSON metrics for programmatic access
Key Sections
1. Key Performance Metrics
- B&H, Fix1x, Dyn1x, Fix10x, Dyn10x columns
- Cumulative Return, CAGR, Sharpe, Sortino, Max DD, Calmar
- Intratrade risk metrics with liquidation distance
2. MAE Analysis & Optimal Leverage
- MAE distribution table (min, mean, p50, p75, p90-p99, max)
- Safe leverage recommendations per percentile
- Stop loss table with % PRICE movement (not position cost)
3. Fixed Position (Static) Analysis
- Leverage table: 5x, 10x, 15x, 20x, 25x, 30x
- Columns: Liq @ %Price, Rec. SL, Max Loss, +10% Buffer, +20% Buffer, Risk Level
4. Full Position (Dynamic) Analysis
- Warning about compounding risk
- Leverage table: 1x, 2x, 3x, 5x, 10x
- Recommendation per leverage level
5. Buffer Analysis Summary
- +10%, +20%, +30% buffers above worst MAE
- Safety check for 10x, 15x, 20x leverage
6. Full Trade List
- All trades with entry/exit times, prices, side, PnL, MAE, MFE, duration
- Scrollable table with sticky headers
- Summary row with averages
7. Strategy Configuration
- Original config text box (copyable JSON)
- MAE-optimized config text box (copyable JSON)
- Backtest methodology description
Dependencies
- Python 3.10+
- pandas, numpy, matplotlib
- StrategyComparisonTearsheet from backtesting.tearsheets
Installation
The skill uses the tearsheet generator at:
/Users/DanBot/Desktop/dev/Backtests/backtesting/tearsheets/strategy_comparison_tearsheet.py
Ensure this path is accessible or update the script paths accordingly.
1---2name: tearsheet-generator3description: Generate professional tearsheets with custom SVG visualizations using the QuantStats library. Creates performance reports with MAE analysis, leverage recommendations, and trade lists. Use when analyzing strategy performance or generating visual reports.4---5
6# Tearsheet Generator Skill
7
8## About
9
10This skill generates custom tearsheets using the [QuantStats library](https://github.com/ranaroussi/quantstats) - a Python library for portfolio analytics.
11
12**Key Features:**
13- Custom SVG visualizations (returns, drawdowns, monthly heatmaps)
14- Professional HTML tearsheets
15- MAE (Maximum Adverse Excursion) analysis
16- Leverage recommendations based on risk metrics
17- Copyable strategy configurations
18
19Generate comprehensive trading strategy tearsheets with:
20- IBM Plex Mono font styling (QuantStats format)
21- MAE (Max Adverse Excursion) percentile analysis (p90-p99)
22- Optimal leverage recommendations with stop-loss levels
23- Fixed Position (Static) vs Full Position (Dynamic) analysis
24- 10%, 20%, 30% liquidation buffer calculations
25- Full trade list with entry/exit details and MAE stats
26- Copyable strategy config text boxes
27- Multiple leverage scenario comparisons (1x, 10x, 15x, 20x)
28
29## Quick Start
30
31```bash
32# Generate tearsheet from trades CSV
33/generate-tearsheet SOL_MTF_EMA_001 --trades ./trades.csv --capital 10000
34
35# Verify backtest with Nautilus Trader
36/verify-backtest SOL_MTF_EMA_001 --trades ./trades.csv
37
38# Test optimal leverage configuration
39/verify-mae-lev SOL_MTF_EMA_001 --leverage p95
40```
41
42## Commands
43
44### /generate-tearsheet
45Generate a complete tearsheet with all analysis sections.
46
47### /verify-backtest
48Verify tearsheet results against Nautilus Trader for accuracy validation.
49
50### /verify-mae-lev
51Run backtest with optimal leverage config derived from MAE analysis.
52
53## Output Files
54
55Each tearsheet generation produces:
56- `{strategy}_comparison.html` - Full HTML tearsheet
57- `{strategy}_comparison_metrics.json` - JSON metrics for programmatic access
58
59## Key Sections
60
61### 1. Key Performance Metrics
62- B&H, Fix1x, Dyn1x, Fix10x, Dyn10x columns
63- Cumulative Return, CAGR, Sharpe, Sortino, Max DD, Calmar
64- Intratrade risk metrics with liquidation distance
65
66### 2. MAE Analysis & Optimal Leverage
67- MAE distribution table (min, mean, p50, p75, p90-p99, max)
68- Safe leverage recommendations per percentile
69- Stop loss table with % PRICE movement (not position cost)
70
71### 3. Fixed Position (Static) Analysis
72- Leverage table: 5x, 10x, 15x, 20x, 25x, 30x
73- Columns: Liq @ %Price, Rec. SL, Max Loss, +10% Buffer, +20% Buffer, Risk Level
74
75### 4. Full Position (Dynamic) Analysis
76- Warning about compounding risk
77- Leverage table: 1x, 2x, 3x, 5x, 10x
78- Recommendation per leverage level
79
80### 5. Buffer Analysis Summary
81- +10%, +20%, +30% buffers above worst MAE
82- Safety check for 10x, 15x, 20x leverage
83
84### 6. Full Trade List
85- All trades with entry/exit times, prices, side, PnL, MAE, MFE, duration
86- Scrollable table with sticky headers
87- Summary row with averages
88
89### 7. Strategy Configuration
90- Original config text box (copyable JSON)
91- MAE-optimized config text box (copyable JSON)
92- Backtest methodology description
93
94## Dependencies
95
96- Python 3.10+
97- pandas, numpy, matplotlib
98- StrategyComparisonTearsheet from backtesting.tearsheets
99
100## Installation
101
102The skill uses the tearsheet generator at:
103`/Users/DanBot/Desktop/dev/Backtests/backtesting/tearsheets/strategy_comparison_tearsheet.py`
104
105Ensure this path is accessible or update the script paths accordingly.