All examples

Insider cluster detector

Find tickers where 3+ different insiders bought in the last 30 days. Returns a sorted list, biggest cluster first.

python
import os, requests
from collections import defaultdict

API = "https://sec-stream-io.lovable.app/api/public/v1"
KEY = os.environ["SECSTREAM_KEY"]
H = {"Authorization": f"Bearer {KEY}"}

# /clusters returns Form 4 buys with cluster_count >= min already pre-computed
res = requests.get(f"{API}/clusters", params={"min": 3, "limit": 100}, headers=H).json()

by_ticker = defaultdict(set)
for row in res["data"]:
    if row.get("transaction_code") == "P":  # P = open-market purchase
        by_ticker[row["ticker"]].add(row["insider_name"])

ranked = sorted(by_ticker.items(), key=lambda kv: -len(kv[1]))
for ticker, insiders in ranked[:20]:
    print(f"{ticker:6}  {len(insiders)} insiders: {', '.join(list(insiders)[:3])}…")