🤖 AI Hedge Fund API - Agent Skill Guide
[!IMPORTANT]
Continuous Feature Evolution & Live Spec Policy (即時版本同步提醒):
This system undergoes active, continuous evolution. AI Agents, LLMs, and automated clients MUST ALWAYS fetch the latest live version directly from https://hedgeapi.afpicapital.com/skill.md (or https://hedgeapi.afpicapital.com/llms.txt) before executing any analysis, backtest, or debate. Never rely on stale cached schemas or hardcoded analyst rosters.
This document is designed for AI Agents and LLMs to understand and interact with the AI Hedge Fund API.
- Server Base URL:
https://hedgeapi.afpicapital.com
- Latest Live Skill Guide:
https://hedgeapi.afpicapital.com/skill.md
- LLMs Discovery Index:
https://hedgeapi.afpicapital.com/llms.txt
- Full Text Specification:
https://hedgeapi.afpicapital.com/llms-full.txt
- API Documentation:
https://hedgeapi.afpicapital.com/docs
- Health Check:
https://hedgeapi.afpicapital.com/api/health
- Swagger JSON:
https://hedgeapi.afpicapital.com/static/swagger.json
- Supported LLM Engines: Primary Groq (
openai/gpt-oss-20b), TypeSafe SystemOne (clef-flash, clef-flash-q4), Gemini fallback (models/gemini-flash-latest), and OpenAI (gpt-4o). Resilient auto-failover built-in.
📌 Available Endpoints
1. 📊 Run Stock Analysis (POST /api/analysis)
Execute deep investment analysis across selected AI investor personas with optional multi-round round table committee debate.
- Endpoint:
POST /api/analysis
- Headers:
Content-Type: application/json
- Minimal Request Body (JSON):
{
"tickers": "TSLA,NVDA",
"enableRoundTable": true,
"roundTableRounds": 2
}
- Full Request Body Example (JSON):
{
"tickers": "TSLA,NVDA",
"selectedAnalysts": [
"warren_buffett",
"cathie_wood",
"michael_burry",
"wsb",
"technical_analyst"
],
"enableRoundTable": true,
"roundTableRounds": 2,
"initialCash": 100000,
"startDate": "2024-09-01",
"endDate": "2024-12-01"
}
Request Parameters:
| Parameter |
Type |
Required |
Default |
Description |
tickers |
string / array |
✅ |
- |
Tickers or company names across US, HK, TW (e.g. "TSLA,NVDA", "2330", "3293", "700", "9988", "騰訊", "蘋果", "SPCX") |
selectedAnalysts |
array |
❌ |
[] (all 16) |
Analyst registry keys; unknown keys or non-array values return HTTP 400 |
modelName |
string |
❌ |
openai/gpt-oss-20b |
Model identifier: clef-flash, clef-flash-q4, openai/gpt-oss-20b, models/gemini-flash-latest, gpt-4o |
modelProvider |
string |
❌ |
Groq |
Model provider: TypeSafe, Groq, Gemini, OpenAI (clef-flash automatically maps to TypeSafe) |
enableRoundTable |
boolean |
❌ |
false |
Enable multi-round debate committee after analyst signals |
roundTableRounds |
integer |
❌ |
2 |
Number of debate rounds (1 to 3) |
initialCash |
number |
❌ |
100000 |
Optional starting cash (min 100.0, default 100,000.0, supports aliases: initial_cash, initialCapital, capital, cash). Rejects negative, zero, or < 100.0 values with HTTP 400. Directly controls risk manager position limits and recommended shares |
portfolio |
object |
❌ |
— |
Optional dated holdings and cash; its cash takes precedence over initialCash |
pointInTime |
boolean |
❌ |
false |
Enable strict historical cutoff filtering and return source coverage/exclusions |
startDate |
string |
❌ |
3 months ago |
Historical start date (YYYY-MM-DD) |
endDate |
string |
❌ |
Today |
Analysis end date (YYYY-MM-DD) |
portfolio requires as_of (YYYY-MM-DD), non-negative cash, currency (ISO 4217), and positions (array; empty means flat). Each position requires ticker, signed quantity (positive long, negative short), non-negative average_entry_price, and trading currency. A snapshot must not be after endDate or more than 7 calendar days old. Cross-currency positions use a historical Yahoo Finance FX close no later than as_of; the request is rejected when no suitable rate is available. Omit portfolio to preserve legacy initialCash behavior.
Strict point-in-time mode uses verified publication/availability time, not report period or event date. News without a publication timestamp and financial data without filing-level availability metadata are excluded with source-specific reasons. The SEC EDGAR adapter uses filing acceptance time plus a conservative dissemination buffer for eligible US issuers and requires SEC_USER_AGENT; this filing metadata does not make Yahoo financial values point-in-time verified. Current-only security registries are reported as survivorship-biased. Daily price inputs use unadjusted OHLC; future splits are reversed, and dividend cash flows are not modeled in this analysis endpoint.
Resumable backtest grid
POST /api/backtest/grid: accepts runId, tickers, startDate, endDate; optional portfolio, initialCash, cutoffTimeUtc (shared UTC cutoff), selectedAnalysts (array of keys from the analyst registry; unknown keys and non-array values return HTTP 400), dailyRebalancePolicy (daily or none), transactionFeeRate (default 0.001), and slippageRate (default 0.0005).
GET /api/backtest/runs/<run_id>: reads the persisted manifest and result.
- Reusing a
runId resumes the original immutable data snapshots only when the configuration fingerprint matches. SQLite defaults to instance/backtest_runs.sqlite3; Docker Compose mounts ./instance to /app/instance and sets BACKTEST_RUN_DB=/app/instance/backtest_runs.sqlite3 so checkpoints survive container replacement.
- Grid results disclose source coverage, excluded unknown timestamps, benchmark mapping/version, fees, slippage, current-universe survivorship bias, and that dividends are not modeled.
Example: {"runId":"trial-1","tickers":["AAPL","2330.TW"],"startDate":"2026-01-05","endDate":"2026-01-30","cutoffTimeUtc":"23:59:59Z","selectedAnalysts":["technical_analyst"],"initialCash":100000}
Response Format (JSON):
{
"decisions": {
"TSLA": {
"action": "buy | sell | short | hold",
"quantity": 50,
"confidence": 85.0,
"reasoning": "Detailed committee execution rationale..."
}
},
"analyst_signals": {
"warren_buffett_agent": {
"TSLA": {
"signal": "bearish",
"confidence": 90.0,
"reasoning": "DCF valuation indicates -80% margin of safety..."
}
}
},
"round_table": {
"TSLA": {
"signal": "bearish",
"confidence": 65.0,
"discussion_summary": "Warren Buffett and Michael Burry clashed with Cathie Wood on valuation vs innovation...",
"consensus_view": "Valuation and debt risks outweigh short-term growth prospects.",
"dissenting_opinions": "Cathie Wood argued for exponential AI/robotics S-curve adoption.",
"conversation_transcript": "[Warren Buffett]: Intrinsic value doesn't hold up...\n[Cathie Wood]: Look at the innovation engine..."
}
}
}
2. ⚡ Asynchronous Stock Analysis (POST /api/analysis/async) & Task Polling (GET /api/task/<task_id>)
Submit an equity analysis task in the background to avoid HTTP gateway timeouts (recommended for full 16-analyst evaluations or multi-ticker batches).
- Submit Task:
POST /api/analysis/async (Accepts identical payload as /api/analysis)
- Response (HTTP 202 Accepted):
{
"taskId": "c7a840e6-8575-408f-8898-dbe3234d7d0a",
"status": "pending",
"message": "AI 分析任務已在背景建立,請透過 /api/task/<taskId> 查詢進度與結果",
"pollUrl": "/api/task/c7a840e6-8575-408f-8898-dbe3234d7d0a",
"tickers": ["2330.TW"]
}
- Poll Status & Result:
GET /api/task/<task_id> (also /api/analysis/status/<task_id>)
- Status lifecycle:
pending ➔ running ➔ completed (or error).
- Upon
completed, returns the complete analyst_signals, risk_management_agent, and decisions.
3. 🔍 Smart Stock Resolver & Registry (GET /api/stock/resolve)
Resolve company names or regional ticker codes into standardized symbols (Taiwan .TW, Hong Kong .HK, US SPCX, China A-shares) and retrieve official profiles:
- Endpoint:
GET /api/stock/resolve?q=2330 or POST /api/stock/resolve with {"tickers": ["2330", "TSLA", "SPCX", "騰訊"]}
- Global Registry Status:
GET /api/stock/registry/status (32,000+ listings cached with SWR updates)
4. 🏛️ Standalone Round Table Debate (POST /api/round_table)
Run an investment committee debate with pre-computed analyst signals.
- Endpoint:
POST /api/round_table
- Headers:
Content-Type: application/json
- Request Body (JSON):
{
"tickers": "NVDA",
"analystSignals": {
"cathie_wood": {
"NVDA": {"signal": "bullish", "confidence": 90, "reasoning": "Exponential AI infrastructure demand"}
},
"michael_burry": {
"NVDA": {"signal": "bearish", "confidence": 75, "reasoning": "Hyperscaler capex peak and concentration risk"}
}
},
"numRounds": 2
}
Response Format (JSON):
{
"round_table": {
"NVDA": {
"signal": "neutral",
"confidence": 65.0,
"discussion_summary": "Cathie Wood debated Michael Burry on AI capex sustainability...",
"consensus_view": "Strong long-term positioning balanced against near-term concentration risk.",
"dissenting_opinions": "Michael Burry warned of margin compression if hyperscaler spending cools.",
"conversation_transcript": "[Cathie Wood]: AI transformation is just beginning...\n[Michael Burry]: Don't ignore the customer concentration risk..."
}
}
}
5. 💓 Health Check (GET /api/health)
- Endpoint:
GET /api/health
- Response:
{"status": "healthy", "version": "2.0.0", "timestamp": "2026-08-26T07:35:04Z"}
👥 16 Analyst Personas Reference Table
| Analyst Key |
Display Name |
Core Investment Philosophy |
warren_buffett |
Warren Buffett |
Moats, predictable cash flow, ROE > 15%, 30% margin of safety |
charlie_munger |
Charlie Munger |
Inversion mental model, pricing power, management integrity |
ben_graham |
Ben Graham |
Margin of safety, Net-Net (NCAV), conservative P/E & P/B |
cathie_wood |
Cathie Wood |
Disruptive innovation, 5-year S-curves, AI / robotics CAGR > 25% |
bill_ackman |
Bill Ackman |
Activist value investing, high barrier to entry, operational catalysts |
nancy_pelosi |
Nancy Pelosi |
Congressional trading disclosures, legislative and subsidy tailwinds |
michael_burry |
Michael Burry |
Deep value contrarian, FCF yield > 8%, hidden debt & accounting risks |
peter_lynch |
Peter Lynch |
Consumer insight, PEG ratio < 1.0, 10-bagger growth potential |
phil_fisher |
Phil Fisher |
15 qualitative points, R&D productivity, outstanding sales execution |
wsb |
WallStreetBets |
Retail momentum, short squeeze, YOLO options, 2md Reddit hype |
technical_analyst |
Technical Analyst |
Trend following, SMA 20/50/200, RSI, MACD, Bollinger Bands |
fundamentals_analyst |
Fundamentals Analyst |
Financial statements audit, revenue growth, gross & net margins |
sentiment_analyst |
Sentiment Analyst |
2md global news sentiment scoring, SEC Form 4 insider trades |
valuation_analyst |
Valuation Analyst |
Discounted Cash Flow (DCF), EV/EBITDA, relative peer multiples |
stanley_druckenmiller |
Stanley Druckenmiller |
Macro & growth inflections, acceleration rate-of-change, asymmetric risk/reward |
decision_model |
Jev Decision Model |
JEV SystemOne fast structured evaluation, T+1~T+3 directional probability forecasting, PEAD drift |
💡 Agent Usage Tips
- For General Stock Analysis:
- Send
POST /api/analysis with enableRoundTable: true to get both individual analyst metrics and a synthesized committee decision.
- For High-Growth / Tech Stocks:
- Select
["cathie_wood", "michael_burry", "wsb", "valuation_analyst"] to get balanced bull/bear debate on growth vs valuation.
- For Value / Defensive Stocks:
- Select
["warren_buffett", "ben_graham", "charlie_munger", "fundamentals_analyst"].
- For Non-US Stocks (e.g. Taiwan
2330.TW, Hong Kong 0001.HK):
- The system automatically normalizes ticker suffixes and leverages 2md search for global news and sentiment.
- Bilingual Support (English & Traditional Chinese / 雙語輸出):
- All
reasoning, discussion_summary, consensus_view, dissenting_opinions, and conversation_transcript automatically provide comprehensive bilingual explanations in English and Traditional Chinese (【繁體中文解析】).
🔌 Model Context Protocol (MCP) Server Integration
This repository ships with a built-in standard MCP Server (mcp_server.py) compatible with Cursor, Claude Desktop, Windsurf, and Antigravity.
Available MCP Tools:
analyze_stock_with_committee: Run full 16-persona hedge fund analysis and round table debate.
get_stock_quant_audit: Instant quantitative audit returning 95%/99% VaR, CVaR, Realized Volatility Regimes, 5×5 DCF Sensitivity Matrix, Altman Z-Score (bankruptcy risk), Piotroski F-Score (0-9 financial health), Amihud Illiquidity Ratio, and ATR Dynamic Trailing Stops.
Claude Desktop / Cursor Configuration:
{
"mcpServers": {
"ai-hedge-fund": {
"command": "python3",
"args": ["/absolute/path/to/ai-hedge-fund-API/mcp_server.py"],
"env": {
"GROQ_API_KEY": "your_groq_key_here"
}
}
}
}
🛡️ JSON Compliance & Strict Parsing Guarantees (RFC 8259)
- Zero
NaN / Infinity Guarantee: All numerical metrics across all 16 analysts (e.g. momentum_6m, historical_volatility, volatility_z_score, z_score, atr_ratio, dcf_value, etc.) are strictly sanitized to standard JSON floats or null.
- Node.js & TypeScript 100% Safe: Never triggers
SyntaxError: Unexpected token 'N' (NaN is not valid JSON) when executing JSON.parse() in Node.js, Next.js API routes (route.ts), Python, Go, or browser clients.
- Graceful Insufficient Data Handling: When historical price days are shorter than rolling indicator windows (e.g. calculating 6-month momentum on a 3-month timeframe), indicators automatically use
min_periods=1 and fallback to valid numbers or null.
1---2name: ai-hedge-fund3description: AI Hedge Fund Investment Analysis and Multi-Round Committee Debate API. Continuous feature evolution is active—always fetch the latest live spec at https://hedgeapi.afpicapital.com/skill.md before execution. Provides full-stack equity research from 16 legend investor personas and multi-round round table debates with dynamic portfolio allocation.4metadata:5 source: https://skillmd.com/skills/tbdavid2019/ai-hedge-fund6---78# 🤖 AI Hedge Fund API - Agent Skill Guide910> [!IMPORTANT]11> **Continuous Feature Evolution & Live Spec Policy (即時版本同步提醒)**:12> This system undergoes active, continuous evolution. AI Agents, LLMs, and automated clients **MUST ALWAYS fetch the latest live version directly from `https://hedgeapi.afpicapital.com/skill.md` (or `https://hedgeapi.afpicapital.com/llms.txt`) before executing any analysis, backtest, or debate**. Never rely on stale cached schemas or hardcoded analyst rosters.1314This document is designed for AI Agents and LLMs to understand and interact with the **AI Hedge Fund API**.1516- **Server Base URL**: `https://hedgeapi.afpicapital.com`17- **Latest Live Skill Guide**: `https://hedgeapi.afpicapital.com/skill.md`18- **LLMs Discovery Index**: `https://hedgeapi.afpicapital.com/llms.txt`19- **Full Text Specification**: `https://hedgeapi.afpicapital.com/llms-full.txt`20- **API Documentation**: `https://hedgeapi.afpicapital.com/docs`21- **Health Check**: `https://hedgeapi.afpicapital.com/api/health`22- **Swagger JSON**: `https://hedgeapi.afpicapital.com/static/swagger.json`23- **Supported LLM Engines**: Primary Groq (`openai/gpt-oss-20b`), TypeSafe SystemOne (`clef-flash`, `clef-flash-q4`), Gemini fallback (`models/gemini-flash-latest`), and OpenAI (`gpt-4o`). Resilient auto-failover built-in.2425---2627## 📌 Available Endpoints2829### 1. 📊 Run Stock Analysis (`POST /api/analysis`)30Execute deep investment analysis across selected AI investor personas with optional multi-round round table committee debate.3132- **Endpoint**: `POST /api/analysis`33- **Headers**: `Content-Type: application/json`34- **Minimal Request Body (JSON)**:3536```json37{38 "tickers": "TSLA,NVDA",39 "enableRoundTable": true,40 "roundTableRounds": 241}42```4344- **Full Request Body Example (JSON)**:4546```json47{48 "tickers": "TSLA,NVDA",49 "selectedAnalysts": [50 "warren_buffett",51 "cathie_wood",52 "michael_burry",53 "wsb",54 "technical_analyst"55 ],56 "enableRoundTable": true,57 "roundTableRounds": 2,58 "initialCash": 100000,59 "startDate": "2024-09-01",60 "endDate": "2024-12-01"61}62```6364#### Request Parameters:6566| Parameter | Type | Required | Default | Description |67|:---|:---|:---:|:---|:---|68| `tickers` | string / array | ✅ | - | Tickers or company names across US, HK, TW (e.g. `"TSLA,NVDA"`, `"2330"`, `"3293"`, `"700"`, `"9988"`, `"騰訊"`, `"蘋果"`, `"SPCX"`) |69| `selectedAnalysts` | array | ❌ | `[]` (all 16) | Analyst registry keys; unknown keys or non-array values return HTTP 400 |70| `modelName` | string | ❌ | `openai/gpt-oss-20b` | Model identifier: `clef-flash`, `clef-flash-q4`, `openai/gpt-oss-20b`, `models/gemini-flash-latest`, `gpt-4o` |71| `modelProvider` | string | ❌ | `Groq` | Model provider: `TypeSafe`, `Groq`, `Gemini`, `OpenAI` (`clef-flash` automatically maps to `TypeSafe`) |72| `enableRoundTable` | boolean | ❌ | `false` | Enable multi-round debate committee after analyst signals |73| `roundTableRounds` | integer | ❌ | `2` | Number of debate rounds (1 to 3) |74| `initialCash` | number | ❌ | `100000` | Optional starting cash (min 100.0, default 100,000.0, supports aliases: `initial_cash`, `initialCapital`, `capital`, `cash`). Rejects negative, zero, or < 100.0 values with HTTP 400. Directly controls risk manager position limits and recommended shares |75| `portfolio` | object | ❌ | — | Optional dated holdings and cash; its `cash` takes precedence over `initialCash` |76| `pointInTime` | boolean | ❌ | `false` | Enable strict historical cutoff filtering and return source coverage/exclusions |77| `startDate` | string | ❌ | 3 months ago | Historical start date (`YYYY-MM-DD`) |78| `endDate` | string | ❌ | Today | Analysis end date (`YYYY-MM-DD`) |7980`portfolio` requires `as_of` (`YYYY-MM-DD`), non-negative `cash`, `currency` (ISO 4217), and `positions` (array; empty means flat). Each position requires `ticker`, signed `quantity` (positive long, negative short), non-negative `average_entry_price`, and trading `currency`. A snapshot must not be after `endDate` or more than 7 calendar days old. Cross-currency positions use a historical Yahoo Finance FX close no later than `as_of`; the request is rejected when no suitable rate is available. Omit `portfolio` to preserve legacy `initialCash` behavior.8182Strict point-in-time mode uses verified publication/availability time, not report period or event date. News without a publication timestamp and financial data without filing-level availability metadata are excluded with source-specific reasons. The SEC EDGAR adapter uses filing acceptance time plus a conservative dissemination buffer for eligible US issuers and requires `SEC_USER_AGENT`; this filing metadata does not make Yahoo financial values point-in-time verified. Current-only security registries are reported as survivorship-biased. Daily price inputs use unadjusted OHLC; future splits are reversed, and dividend cash flows are not modeled in this analysis endpoint.8384#### Resumable backtest grid8586- `POST /api/backtest/grid`: accepts `runId`, `tickers`, `startDate`, `endDate`; optional `portfolio`, `initialCash`, `cutoffTimeUtc` (shared UTC cutoff), `selectedAnalysts` (array of keys from the analyst registry; unknown keys and non-array values return HTTP 400), `dailyRebalancePolicy` (`daily` or `none`), `transactionFeeRate` (default `0.001`), and `slippageRate` (default `0.0005`).87- `GET /api/backtest/runs/<run_id>`: reads the persisted manifest and result.88- Reusing a `runId` resumes the original immutable data snapshots only when the configuration fingerprint matches. SQLite defaults to `instance/backtest_runs.sqlite3`; Docker Compose mounts `./instance` to `/app/instance` and sets `BACKTEST_RUN_DB=/app/instance/backtest_runs.sqlite3` so checkpoints survive container replacement.89- Grid results disclose source coverage, excluded unknown timestamps, benchmark mapping/version, fees, slippage, current-universe survivorship bias, and that dividends are not modeled.9091Example: `{"runId":"trial-1","tickers":["AAPL","2330.TW"],"startDate":"2026-01-05","endDate":"2026-01-30","cutoffTimeUtc":"23:59:59Z","selectedAnalysts":["technical_analyst"],"initialCash":100000}`9293#### Response Format (JSON):94```json95{96 "decisions": {97 "TSLA": {98 "action": "buy | sell | short | hold",99 "quantity": 50,100 "confidence": 85.0,101 "reasoning": "Detailed committee execution rationale..."102 }103 },104 "analyst_signals": {105 "warren_buffett_agent": {106 "TSLA": {107 "signal": "bearish",108 "confidence": 90.0,109 "reasoning": "DCF valuation indicates -80% margin of safety..."110 }111 }112 },113 "round_table": {114 "TSLA": {115 "signal": "bearish",116 "confidence": 65.0,117 "discussion_summary": "Warren Buffett and Michael Burry clashed with Cathie Wood on valuation vs innovation...",118 "consensus_view": "Valuation and debt risks outweigh short-term growth prospects.",119 "dissenting_opinions": "Cathie Wood argued for exponential AI/robotics S-curve adoption.",120 "conversation_transcript": "[Warren Buffett]: Intrinsic value doesn't hold up...\n[Cathie Wood]: Look at the innovation engine..."121 }122 }123}124```125126---127128### 2. ⚡ Asynchronous Stock Analysis (`POST /api/analysis/async`) & Task Polling (`GET /api/task/<task_id>`)129Submit an equity analysis task in the background to avoid HTTP gateway timeouts (recommended for full 16-analyst evaluations or multi-ticker batches).130131- **Submit Task**: `POST /api/analysis/async` (Accepts identical payload as `/api/analysis`)132- **Response (HTTP 202 Accepted)**:133```json134{135 "taskId": "c7a840e6-8575-408f-8898-dbe3234d7d0a",136 "status": "pending",137 "message": "AI 分析任務已在背景建立,請透過 /api/task/<taskId> 查詢進度與結果",138 "pollUrl": "/api/task/c7a840e6-8575-408f-8898-dbe3234d7d0a",139 "tickers": ["2330.TW"]140}141```142- **Poll Status & Result**: `GET /api/task/<task_id>` (also `/api/analysis/status/<task_id>`)143 - Status lifecycle: `pending` ➔ `running` ➔ `completed` (or `error`).144 - Upon `completed`, returns the complete `analyst_signals`, `risk_management_agent`, and `decisions`.145146---147148### 3. 🔍 Smart Stock Resolver & Registry (`GET /api/stock/resolve`)149Resolve company names or regional ticker codes into standardized symbols (Taiwan `.TW`, Hong Kong `.HK`, US SPCX, China A-shares) and retrieve official profiles:150- **Endpoint**: `GET /api/stock/resolve?q=2330` or `POST /api/stock/resolve` with `{"tickers": ["2330", "TSLA", "SPCX", "騰訊"]}`151- **Global Registry Status**: `GET /api/stock/registry/status` (32,000+ listings cached with SWR updates)152153---154155### 4. 🏛️ Standalone Round Table Debate (`POST /api/round_table`)156Run an investment committee debate with pre-computed analyst signals.157158- **Endpoint**: `POST /api/round_table`159- **Headers**: `Content-Type: application/json`160- **Request Body (JSON)**:161162```json163{164 "tickers": "NVDA",165 "analystSignals": {166 "cathie_wood": {167 "NVDA": {"signal": "bullish", "confidence": 90, "reasoning": "Exponential AI infrastructure demand"}168 },169 "michael_burry": {170 "NVDA": {"signal": "bearish", "confidence": 75, "reasoning": "Hyperscaler capex peak and concentration risk"}171 }172 },173 "numRounds": 2174}175```176177#### Response Format (JSON):178```json179{180 "round_table": {181 "NVDA": {182 "signal": "neutral",183 "confidence": 65.0,184 "discussion_summary": "Cathie Wood debated Michael Burry on AI capex sustainability...",185 "consensus_view": "Strong long-term positioning balanced against near-term concentration risk.",186 "dissenting_opinions": "Michael Burry warned of margin compression if hyperscaler spending cools.",187 "conversation_transcript": "[Cathie Wood]: AI transformation is just beginning...\n[Michael Burry]: Don't ignore the customer concentration risk..."188 }189 }190}191```192193---194195### 5. 💓 Health Check (`GET /api/health`)196- **Endpoint**: `GET /api/health`197- **Response**: `{"status": "healthy", "version": "2.0.0", "timestamp": "2026-08-26T07:35:04Z"}`198199---200201## 👥 16 Analyst Personas Reference Table202203| Analyst Key | Display Name | Core Investment Philosophy |204|:---|:---|:---|205| `warren_buffett` | **Warren Buffett** | Moats, predictable cash flow, ROE > 15%, 30% margin of safety |206| `charlie_munger` | **Charlie Munger** | Inversion mental model, pricing power, management integrity |207| `ben_graham` | **Ben Graham** | Margin of safety, Net-Net (NCAV), conservative P/E & P/B |208| `cathie_wood` | **Cathie Wood** | Disruptive innovation, 5-year S-curves, AI / robotics CAGR > 25% |209| `bill_ackman` | **Bill Ackman** | Activist value investing, high barrier to entry, operational catalysts |210| `nancy_pelosi` | **Nancy Pelosi** | Congressional trading disclosures, legislative and subsidy tailwinds |211| `michael_burry` | **Michael Burry** | Deep value contrarian, FCF yield > 8%, hidden debt & accounting risks |212| `peter_lynch` | **Peter Lynch** | Consumer insight, PEG ratio < 1.0, 10-bagger growth potential |213| `phil_fisher` | **Phil Fisher** | 15 qualitative points, R&D productivity, outstanding sales execution |214| `wsb` | **WallStreetBets** | Retail momentum, short squeeze, YOLO options, 2md Reddit hype |215| `technical_analyst` | **Technical Analyst** | Trend following, SMA 20/50/200, RSI, MACD, Bollinger Bands |216| `fundamentals_analyst` | **Fundamentals Analyst** | Financial statements audit, revenue growth, gross & net margins |217| `sentiment_analyst` | **Sentiment Analyst** | 2md global news sentiment scoring, SEC Form 4 insider trades |218| `valuation_analyst` | **Valuation Analyst** | Discounted Cash Flow (DCF), EV/EBITDA, relative peer multiples |219| `stanley_druckenmiller` | **Stanley Druckenmiller** | Macro & growth inflections, acceleration rate-of-change, asymmetric risk/reward |220| `decision_model` | **Jev Decision Model** | JEV SystemOne fast structured evaluation, T+1~T+3 directional probability forecasting, PEAD drift |221222---223224## 💡 Agent Usage Tips2252261. **For General Stock Analysis**:227 - Send `POST /api/analysis` with `enableRoundTable: true` to get both individual analyst metrics and a synthesized committee decision.2282. **For High-Growth / Tech Stocks**:229 - Select `["cathie_wood", "michael_burry", "wsb", "valuation_analyst"]` to get balanced bull/bear debate on growth vs valuation.2303. **For Value / Defensive Stocks**:231 - Select `["warren_buffett", "ben_graham", "charlie_munger", "fundamentals_analyst"]`.2324. **For Non-US Stocks** (e.g. Taiwan `2330.TW`, Hong Kong `0001.HK`):233 - The system automatically normalizes ticker suffixes and leverages 2md search for global news and sentiment.2345. **Bilingual Support (English & Traditional Chinese / 雙語輸出)**:235 - All `reasoning`, `discussion_summary`, `consensus_view`, `dissenting_opinions`, and `conversation_transcript` automatically provide comprehensive bilingual explanations in English and Traditional Chinese (【繁體中文解析】).236237---238239## 🔌 Model Context Protocol (MCP) Server Integration240241This repository ships with a built-in standard **MCP Server** ([`mcp_server.py`](file:///Users/david/git/tbdavid2019/ai-hedge-fund-API/mcp_server.py)) compatible with **Cursor**, **Claude Desktop**, **Windsurf**, and **Antigravity**.242243### Available MCP Tools:2441. `analyze_stock_with_committee`: Run full 16-persona hedge fund analysis and round table debate.2452. `get_stock_quant_audit`: Instant quantitative audit returning 95%/99% VaR, CVaR, Realized Volatility Regimes, 5×5 DCF Sensitivity Matrix, Altman Z-Score (bankruptcy risk), Piotroski F-Score (0-9 financial health), Amihud Illiquidity Ratio, and ATR Dynamic Trailing Stops.246247### Claude Desktop / Cursor Configuration:248```json249{250 "mcpServers": {251 "ai-hedge-fund": {252 "command": "python3",253 "args": ["/absolute/path/to/ai-hedge-fund-API/mcp_server.py"],254 "env": {255 "GROQ_API_KEY": "your_groq_key_here"256 }257 }258 }259}260```261262---263264## 🛡️ JSON Compliance & Strict Parsing Guarantees (RFC 8259)265266- **Zero `NaN` / `Infinity` Guarantee**: All numerical metrics across all 16 analysts (e.g. `momentum_6m`, `historical_volatility`, `volatility_z_score`, `z_score`, `atr_ratio`, `dcf_value`, etc.) are strictly sanitized to standard JSON floats or `null`.267- **Node.js & TypeScript 100% Safe**: Never triggers `SyntaxError: Unexpected token 'N' (NaN is not valid JSON)` when executing `JSON.parse()` in Node.js, Next.js API routes (`route.ts`), Python, Go, or browser clients.268- **Graceful Insufficient Data Handling**: When historical price days are shorter than rolling indicator windows (e.g. calculating 6-month momentum on a 3-month timeframe), indicators automatically use `min_periods=1` and fallback to valid numbers or `null`.