Skip to main content
ℹ️ Informational only. This series shows how to automate SEC EDGAR data retrieval. Nothing here is investment or legal advice. Always consult a qualified professional before making investment decisions.
👁️ PART 2 OF 5

Insider Trading Monitor — Track Every Form 4 on Your Watchlist

Insider Activity Monitoring · Cluster Buying Detection

What is a Form 4?

Insiders (officers, directors, 10%+ shareholders) must file Form 4 within 2 business days of any transaction. Includes:

  • Transaction type: purchase (P), sale (S), gift (G), option exercise (M)
  • Share count and price
  • Post-transaction ownership
  • Relationship to company: CEO, director, 10% owner, etc.

Why It Matters

Insiders can sell for many reasons: diversification, taxes, mortgages, life events. But insiders only buy for one reason — they think the stock is going up. Cluster buying (multiple insiders buying in the same 1–2 week window) is one of the highest-signal events in public markets.

Architecture

The Form 4 monitor fetches the EDGAR feed every 2 hours, filters filings by your watchlist, classifies transaction types, checks for cluster signals, and notifies you:

EDGAR Form 4 feed → OpenClaw HEARTBEAT (every 2 hours) → filter by watchlist → classify transaction → check for cluster signal → notify if threshold met

HEARTBEAT Configuration

name: form4_monitor
schedule: "0 */2 * * *"
steps:
  - fetch:
      url: "https://www.sec.gov/cgi-bin/browse-edgar?action=getcurrent&type=4&dateb=&owner=include&count=40&output=atom"
      headers:
        User-Agent: "YourName your@email.com"
  - filter:
      field: cik
      values: "{{ watchlist_ciks }}"
  - classify:
      field: transaction_type
      map:
        P: "Open market purchase 🟢"
        S: "Open market sale 🔴"
        M: "Option exercise"
        G: "Gift"
  - cluster_check:
      window_days: 14
      min_insiders: 2
      alert_on_match: true
  - notify:
      channel: email
      subject: "👁️ Insider Activity: {{ ticker }} — {{ insider_name }} {{ transaction_type }}"

Cluster Signal Detection

Python function to detect cluster buying — multiple insiders purchasing within a 14-day window:

from collections import defaultdict
from datetime import datetime, timedelta

def detect_cluster_buying(transactions: list, window_days: int = 14) -> bool:
    cutoff = datetime.now() - timedelta(days=window_days)
    buyers = set()
    for t in transactions:
        if t["type"] == "P" and datetime.fromisoformat(t["date"]) > cutoff:
            buyers.add(t["insider_name"])
    return len(buyers) >= 2  # Two or more distinct insiders buying = cluster

Signal Quality by Role

Signal Strength Notes
CEO open market purchase ⭐⭐⭐⭐⭐ Highest conviction — CEO has full visibility
Multiple directors buying same week ⭐⭐⭐⭐⭐ Cluster signal — board sees opportunity
CFO purchase ⭐⭐⭐⭐ Strong — CFO knows the numbers intimately
Director purchase ⭐⭐⭐ Good signal — but less insider info than C-suite
Any insider sale Low signal — many reasons to sell (taxes, diversification)
Option exercise + immediate sale Typically compensation — not conviction

FAQ

Q: Are Form 4s always filed within 2 days?

A: Required within 2 business days. Late filers are flagged in EDGAR — itself a signal worth tracking. Delays can indicate disorganization or intentional concealment.

Q: What's the difference between a 10% owner and a director?

A: 10% owners file based on economic ownership percentage; directors and officers file based on their role regardless of ownership percentage. A director who owns 0.1% still files.

Q: Should I alert on sales?

A: Sales are low signal. But track them for context — if the CEO is selling, you should know. Focus automation on purchases and cluster detection.