# Research Subagents

> Before the Build agent writes a strategy, dedicated subagents fetch historical data, classify the market regime, and pull news. Outputs land as structured files in the algo workspace.

Source: https://finnyai.tech/docs/research

## Why subagents

The Build agent designs strategies; it shouldn't also be scraping headlines and fitting parquet files. Each research task runs as a focused subagent with its own context window and a hard tool-call budget. The Build agent waits for results before it generates anything (see **single-round dispatch** below).

## Data extractor

Dispatched via `finny_extract_data`. Fetches OHLCV for a symbol and date range, then writes it as parquet into the algo's `data/stock/` or `data/crypto/` directory. Tries multiple sources (Binance for crypto, yfinance for stocks/ETFs) and picks the one with best coverage.

### What comes back

- **Price stats**: high, low, median, p5, p95
- **Performance**: total return %, annualized vol %, max drawdown %
- **Data quality**: coverage %, gaps, OHLC violations, outlier bars
- **Regime classification**: trending-up / trending-down / range-bound / high-vol-chop, with confidence

### Regime taxonomy

| Regime | Trigger |
|--------|---------|
| `trending-up` | >5% return with moderate drawdown |
| `trending-down` | <-5% return |
| `range-bound` | small return, narrow price range |
| `high-vol-chop` | >40% annualized vol with <5–10% net return |

### Parameter suggestions

The extractor turns the regime + volatility profile into a starting-point parameter set, strategy family (e.g. mean-reversion for range-bound, momentum-pullback for trending-up), Bollinger width, lookback bars, stop loss %, take profit %, and max hold bars. Everything is written as a `data_brief.md` into the workspace so the Build agent can read it.

## News researcher

Dispatched via `finny_research_dispatch`. The researcher runs autonomously with a budget of ~30 tool calls split across:

- Discord channels (2–4 calls)
- Web search (3–4 queries)
- Web fetch for full articles (3–5 URLs)

### Headlines file

One markdown table per day at `data/news/headlines/YYYY-MM-DD.md`:

```markdown
# Headlines, 2025-05-20
| Time (UTC) | Headline | Source | Slug |
|------------|----------|--------|------|
| 14:30 | Trump announces China tariff reduction | Reuters | trump-china-tariff |
```

### Body articles

Full write-ups live at `data/news/body/<slug>.md` with summary, key facts, market impact, and citations. The Build agent reads headlines first and only opens bodies it needs, keeps context proportional to the work.

## Discord news integration

Six curated channels are exposed via `finny_discord_read`:

- **trump**: Trump-related political news
- **options-flow**: Unusual options activity
- **dark-pool**: Dark pool prints
- **china-us-news**: US–China trade / relations
- **market-news**: Broad market headlines
- **congressional-trades**: Congressional stock trades

Each call returns 1–20 recent posts with id, timestamp, title, excerpt, and URL. The tool handles both embed-style messages and MonitoRSS Components-V2 format.

## Single-round dispatch

When the user specifies a date range, data extraction and news research are **mandatory**. The Build agent's turn ends after dispatch and only resumes once subagents return, preventing the old race where the builder generated a strategy before the research data was on disk.

> **Regime-aware briefs**: The data brief written by the extractor feeds directly into the Build agent's next turn. Whether the market is bull, bear, or chopping shapes which strategy family the builder reaches for and what starting parameters it picks.
