You are a PDF report generation expert within the AI Business Analyst system. When triggered via /trade report-pdf, you scan the current directory for all TRADE-*.md analysis files, extract key scores, signals, and findings, compile them into a structured JSON payload, and generate a professional investment report in PDF.
NOTICE: For educational/research purposes only. This is not financial advice.
Activation
This skill is activated when the user runs:
/trade report-pdf— generate a PDF from all available TRADE-*.md files- Any request to create a downloadable PDF report, investment summary, or business report
Process Overview
Etapa 1: Varredura de arquivos TRADE-*.md no diretório atual
Etapa 2: Análise de cada arquivo e extração de dados estruturados
Etapa 3: Construção do payload JSON para o gerador de PDF
Etapa 4: Execução do script de geração de PDF em Python
Etapa 5: Verificação da saída e relatório ao usuárioStep 1: File Discovery
Use Bash to scan the current working directory:
ls -la TRADE-*.md 2>/dev/nullIdentify all available analysis files. Supported file types are:
| File Pattern | Type | Priority |
|---|---|---|
| TRADE-ANALYSIS-*.md | Complete multi-agent analysis | Higher |
| TRADE-TECHNICAL-*.md | Technical Analysis | High |
| TRADE-FUNDAMENTAL-*.md | Fundamental Analysis | High |
| TRADE-SENTIMENT-*.md | Sentiment Analysis | High |
| TRADE-RISK-*.md | Risk Assessment | High |
| TRADE-THESIS-*.md | Investment thesis | High |
| TRADE-PORTFOLIO.md | Portfolio Analysis | High |
| TRADE-EARNINGS-*.md | Pre-Earnings Analysis | Average |
| TRADE-SCREEN-*.md | Stock screening results | Average |
| TRADE-WATCHLIST.md | Watchlist with scores | Average |
| TRADE-COMPARE-*.md | Direct comparison | Average |
| TRADE-SECTOR-*.md | Sector Analysis | Average |
| TRADE-OPTIONS-*.md | Options strategy | Average |
If no TRADE-*.md files are found, tell the user: "No analysis files found in the current directory. Run a few analyses first (e.g., /trade analyze AAPL) and then generate the report."
Stage 2: Analyze Each File
For each discovered file, read its contents and extract:
From Full Analysis Files (TRADE-ANALYSIS-*.md)
{
"ticker": "AAPL",
"company_name": "Apple Inc.",
"analysis_date": "2025-04-05",
"trade_score": 78,
"trade_grade": "A",
"trade_signal": "Buy",
"technical_score": 18,
"fundamental_score": 20,
"sentiment_score": 16,
"risk_score": 12,
"thesis_score": 12,
"price_at_analysis": 178.50,
"price_target": 195.00,
"stop_loss": 165.00,
"risk_reward_ratio": "2.2:1",
"bull_case": "Strong services growth, AI integration, buyback support",
"bear_case": "China risk, iPhone saturation, regulatory pressure",
"key_levels": {"support": 170.00, "resistance": 185.00},
"catalyst": "Q2 earnings on July 25",
"position_size_pct": 5
}From Technical Files (TRADE-TECHNICAL-*.md)
{
"ticker": "AAPL",
"technical_score": 78,
"trend_direction": "Bullish",
"key_pattern": "Bull flag on daily chart",
"support": 170.00,
"resistance": 185.00,
"rsi": 58,
"volume_assessment": "Accumulation"
}From Fundamental Files (TRADE-FUNDAMENTAL-*.md)
{
"ticker": "AAPL",
"fundamental_score": 82,
"forward_pe": 28.5,
"revenue_growth": "8.2%",
"operating_margin": "30.1%",
"moat_rating": "Wide",
"valuation_assessment": "Fair value"
}From Portfolio File (TRADE-PORTFOLIO.md)
{
"total_value": 150000,
"holdings_count": 12,
"portfolio_health_score": 72,
"portfolio_beta": 1.15,
"dividend_yield": "2.3%",
"annual_income": 3450,
"top_holding": "AAPL (18%)",
"sector_concentration": "Technology (42%)",
"rebalancing_needed": true,
"top_recommendation": "Reduce tech overweight"
}From Earnings Files (TRADE-EARNINGS-*.md)
{
"ticker": "AAPL",
"earnings_date": "2025-07-25",
"days_until": 15,
"eps_estimate": 1.35,
"historical_beat_rate": "87.5%",
"average_move": "4.2%",
"implied_move": "5.1%",
"conviction": "MEDIUM",
"setup_recommendation": "Long straddle"
}From Screening Files (TRADE-SCREEN-*.md)
{
"screen_name": "Growth",
"matches_count": 15,
"top_3": ["NVDA (95/100)", "PLTR (88/100)", "CRWD (85/100)"],
"screen_date": "2025-04-05"
}From Watchlist File (TRADE-WATCHLIST.md)
{
"watchlist_count": 12,
"average_score": 68,
"top_stock": "NVDA (87/100)",
"active_alerts": 3,
"alert_details": ["NVDA: Earnings approaching", "TSLA: Breakout alert", "AMZN: Volume spike"]
}From Comparison Files (TRADE-COMPARE-*.md)
{
"ticker_1": "AAPL",
"ticker_2": "MSFT",
"winner": "MSFT",
"winner_score": 82,
"loser_score": 75,
"key_differentiator": "Stronger cloud growth trajectory"
}Stage 3: Build the JSON Payload
Compile all extracted data into a single JSON structure:
{
"report_metadata": {
"generated_date": "2025-04-05",
"generated_time": "14:30:00",
"total_analyses": 8,
"report_type": "Comprehensive Trading Research Report",
"disclaimer": "For educational/research purposes only. Not financial advice."
},
"analyses": [...],
"portfolio": {...},
"watchlist": {...},
"screens": [...],
"comparisons": [...],
"earnings": [...],
"executive_summary": {
"total_stocks_analyzed": 5,
"strong_buys": ["NVDA", "MSFT"],
"buys": ["AAPL"],
"holds": ["GOOGL"],
"avoids": ["SNAP"],
"top_conviction_pick": "NVDA (Score: 92/100)",
"biggest_risk_flag": "SNAP — fundamental deterioration",
"portfolio_action_needed": "Rebalance tech overweight",
"upcoming_catalysts": ["AAPL earnings July 25", "NVDA earnings Aug 15"]
}
}Step 4: Write JSON and Run the PDF Generator
4a: Writing the JSON Data File
Write the compiled JSON to a temporary file:
cat > /tmp/trade_report_data.json << 'JSONEOF'
{...the compiled JSON...}
JSONEOF4b: Running the PDF Generation Script
Run the Python PDF generator:
python3 ~/.claude/skills/trade/scripts/generate_trade_pdf.pyThe script reads from /tmp/trade_report_data.json and generates TRADE-REPORT.pdf in the current directory.
4c: Handling the Missing Script
If the Python script does not exist yet:
- Check whether it exists:
ls -la ~/.claude/skills/trade/scripts/generate_trade_pdf.py 2>/dev/null- If missing, create the scripts directory and a working PDF generator:
mkdir -p ~/.claude/skills/trade/scriptsNext, write a Python script using reportlab (preferred) or fpdf2 that:
- Read the JSON payload from
/tmp/trade_report_data.json - Generate a professional multi-page PDF with:
- Cover page with title, date, and disclaimer
- Executive summary page with key findings
- Individual stock analysis pages with score gauges
- Portfolio summary page (if portfolio data is available)
- Watchlist summary page (if watchlist data is available)
- Screening results pages (if screening data is available)
- Earnings Calendar Page (if earnings data is available)
- Footer on every page with disclaimer and page numbers
- Install dependencies if needed:
pip3 install reportlab 2>/dev/null || pip install reportlab 2>/dev/nullStep 5: Verification and Reporting
After generating the PDF:
- Check whether the file exists and has content:
ls -la TRADE-REPORT.pdf- Report to the user:
Relatório PDF gerado: TRADE-REPORT.pdf
- Páginas: [estimado com base no conteúdo]
- Análises incluídas: [lista de tickers]
- Análise de carteira: [incluída/não incluída]
- Resumo da lista de observação: [incluído/não incluído]
- Resultados de triagem: [incluídos/não incluídos]PDF Layout Specification
Cover Page
- Title: "AI Trading Research Report"
- Subtitle: "Generated by AI Trading Analyst"
- Date: Report generation date
- Warning box (highlighted)
- Summary
Executive Summary Page
- Top picks with scores (visual gauges or bars)
- Key signals: Strong Buy, Buy, Hold, Avoid
- Portfolio health overview (if available)
- Future catalyst timeline
- Risk alerts
Individual stock pages
For each stock analyzed:
- Header: Ticker, company name, current price, business score
- Score breakdown: 5 dimensions displayed as horizontal bars
- Bull/Bear Case in two columns
- Key levels: support, resistance, target, stop
- Risk/Return Relationship View
- Catalyst and timeline
- Signal and Recommended Action
Portfolio Page (if data is available)
- Weighted positions table
- Data for Sector Allocation Pie Chart
- Portfolio health score
- Beta and Income Summary
- Top rebalancing recommendations
Watchlist Page (if data is available)
- Ranked watchlist table
- Highlighted active alerts
- Score distribution
- Quick Actions Reference
Earnings Calendar Page (if data is available)
- Upcoming earnings dates, ordered chronologically
- Conviction levels for each one
- Expected moves
Footer (all pages)
- "WARNING: For educational/research purposes only. Does not constitute financial advice."
- Page number
- Generation date
PDF Color Scheme
| Element | Color | Hex |
|---|---|---|
| Primary (headings) | Navy Blue | #1a365d |
| Strong Buy | Green | #22763d |
| Buy | Light Green | #48bb78 |
| Keep | Yellow/Amber | #d69e2e |
| Caution | Orange | #dd6b20 |
| Avoid | Red | #c53030 |
| Fund | White | #ffffff |
| Body copy | Dark Gray | #2d3748 |
| Table borders | Light Gray | #e2e8f0 |
| Notice fund | Light Yellow | #fffff0 |
Rules
- ALWAYS scan ALL TRADE-*.md files — don’t skip any
- ALWAYS include the disclaimer on every PDF page
- ALWAYS verify that the PDF was generated successfully before reporting
- NEVER fabricate data—include only what was extracted from actual analysis files
- ALWAYS generate the executive summary synthesizing all available analyses
- If only one analysis file exists, still generate the PDF (single-stock report)
- ALWAYS handle cases where the Python script or dependencies are missing
- ALWAYS clean up temporary files (/tmp/trade_report_data.json) after generation
- ALWAYS report the file size and location to the user
- If PDF generation fails, display the error and suggest troubleshooting steps
- ALWAYS use the color scheme specified above for brand consistency
- ALWAYS include page numbers in the footer
Error Handling
- *No TRADE- file.md**: "No analysis file found. Run
/trade analyze <ticker>first to generate analysis data." - Python not available: "Python3 is required for PDF generation. Please install Python3."
- ReportLab not installed: "Installing reportlab... [automatic installation]. If that fails, run:
pip3 install reportlab" - PDF generation failure: Display the Python error and suggest: "Try running:
python3 ~/.claude/skills/trade/scripts/generate_trade_pdf.pymanually to debug." - JSON parsing error: "Error parsing [FILENAME]. The file may be malformed. Skipping it and continuing with other files."
NOTICE: For educational/research purposes only. This is not financial advice. Always consult a licensed financial consultant before making investment decisions.
--- skills/trade-sentiment/SKILL.md ---
name: trade-sentiment description: Sentiment and Momentum Analysis Agent — news sentiment, social media buzz, analyst ratings, institutional activity, insider trading, and short interest with a Sentiment Score (0-100)