DEV Community

Cover image for We Spent Months Cleaning SEC EDGAR 13F Data So You Don't Have To
James Hsiao
James Hsiao

Posted on • Originally published at alphasmo.com

We Spent Months Cleaning SEC EDGAR 13F Data So You Don't Have To

The data isn't the hard part. Cleaning it is.

SEC EDGAR is public, free, and a mess. Every quarter, 13,000+ institutional investment managers file Form 13F, disclosing their U.S. equity holdings. In theory that's a beautiful dataset — every hedge fund, every pension fund, every bank, all in one place. In practice, the raw filings actively fight you:

  • The same institution files under different names, sometimes even in the same quarter. In our own database right now: BlackRock, Inc. and BlackRock Inc. are two distinct CIK registrations for what most people would call "one" institution. Multiply that across 13,000+ filers and you get a long tail of near-duplicate names that break any naive GROUP BY institution_name.
  • CUSIPs don't map cleanly to tickers. Foreign issuers frequently use CUSIP prefixes that don't resolve through the usual reference data — we ended up building a fallback resolution path (Yahoo Finance lookups plus manual validation rules) just to keep ticker coverage from silently degrading over time.
  • Quarters arrive gradually, not all at once. The SEC gives managers up to 45 days after quarter-end to file. If you naively take "the latest quarter with any data" as your reporting period, you'll rank a barely-started quarter — where only a handful of small filers have reported so far — ahead of the real, complete prior quarter. We learned this the hard way: an unclamped "most recent quarter" query once let 115 newly-onboarded institutions' entire existing portfolios get counted as "new inflow" with nothing to offset them, because a first-time filer has no prior-quarter row to diff against. That's the kind of bug that doesn't throw an error — it just quietly produces a chart that looks plausible and is wrong.
  • Amendments (13F-A) revise, replace, or partially restate earlier filings, and the XML schema itself has shifted over the years, so parsing "just the latest 13F" isn't a fixed target.

None of this is exotic — it's the normal cost of working with real-world government filing data. But it's exactly the kind of unglamorous plumbing that eats a weekend project before you get to the interesting part: actually asking questions like "what is smart money buying right now?"

So we built the CLI so you don't have to

AlphaSMO is a free public API + CLI + MCP server sitting on top of all that cleaned-up 13F and Form 4 insider-trading data. No signup required to try it:

npx alphasmo stocks flows --limit 8
Enter fullscreen mode Exit fullscreen mode

That returns stocks ranked by net institutional buy/sell flow for the quarter — piped or scripted, it comes back as JSON automatically:

[
  {
    "ticker": "BRK-A",
    "issuer_name": "BERKSHIRE HATHAWAY INC-CL A",
    "net_value_change_usd": 255068024828,
    "avg_weight_pct": 1.42,
    "institution_count": 1418
  }
]
Enter fullscreen mode Exit fullscreen mode

The flagship signal is smart money convergence — tickers where 13F institutions and company insiders (Form 4 filers) are both buying at the same time:

npx alphasmo convergence --limit 5 --format table
Enter fullscreen mode Exit fullscreen mode
┌────────┬─────────────────────┬────────────┬───────────────┬───────────────┬────────────┐
│ ticker │ issuer              │ confidence │ unique buyers │ cluster alert │ last buy   │
├────────┼─────────────────────┼────────────┼───────────────┼───────────────┼────────────┤
│ KKR    │ KKR & CO INC        │ 80.48      │ 5             │ yes           │ 2026-03-04 │
├────────┼─────────────────────┼────────────┼───────────────┼───────────────┼────────────┤
│ ELV    │ ELEVANCE HEALTH INC │ 70         │ 2             │ no            │ 2026-07-17 │
├────────┼─────────────────────┼────────────┼───────────────┼───────────────┼────────────┤
│ IP     │ INTERNATIONAL PAPER │ 62.59      │ 3             │ yes           │ 2026-03-12 │
└────────┴─────────────────────┴────────────┴───────────────┴───────────────┴────────────┘
Enter fullscreen mode Exit fullscreen mode

Output format auto-detects context — a real table in your terminal, JSON when piped or spawned by a script or an AI agent. --csv gets you a spreadsheet-ready export directly:

alphasmo insider trades AAPL --csv | column -s, -t
Enter fullscreen mode Exit fullscreen mode

Built for AI agents too

The same data ships as an MCP server, so Claude, ChatGPT, Cursor, or any MCP-compatible client can pull live 13F and insider data mid-conversation, without you writing a single integration line:

claude mcp add alphasmo -- npx -y alphasmo@latest mcp
Enter fullscreen mode Exit fullscreen mode

Tools exposed: search_institutions, get_institution_profile, get_institution_holdings, get_stock_overview, get_stock_flows, get_insider_activity, get_smart_money_convergence.

Try it

npm install -g alphasmo
alphasmo --help
Enter fullscreen mode Exit fullscreen mode

Anonymous requests work out of the box at a lower rate limit; a free API key (alphasmo.com/developer) raises it. Full REST reference (curl-friendly, no CLI required) is at alphasmo.com/developer/docs, and the same underlying data — institution profiles, holdings, quarter-over-quarter changes — is browsable directly at alphasmo.com/13f.

The raw data is public. We just did the annoying part first.

Top comments (0)