# Insider-buying clusters

**What you build:** a script that scans every open-market insider purchase in a date window, finds the company with the most purchases, and opens one buyer's Form 4.

**The result:** the company with the most purchases in the window was Larimar Therapeutics. Its insiders bought shares on November 11 and 12, 2026, among them the President and CEO, Carole Ben-Maimon, who paid $2.7675 a share on November 11.

## The script

The company with the most purchases feeds step 2, and one of its purchases feeds step 3.

```python
import os
import requests
from collections import Counter

API = "https://api.secblast.com"
KEY = os.environ["SECBLAST_API_KEY"]

def get(path, **params):
    r = requests.get(API + path, params=params, headers={"Authorization": f"Bearer {KEY}"}, timeout=30)
    r.raise_for_status()
    return r

# 1. Scan the window: every open-market purchase (code P) in Table I, page by page.
rows, cursor = [], None
while True:
    page = get("/v3/ownership/insiders/transactions", code="P", table="non_derivative",
               filed_from="2026-11-02", filed_to="2026-11-13", limit=500, cursor=cursor).json()
    rows += page["data"]
    cursor = page["next_cursor"]
    if not page["has_more"]:
        break

# The company with the most purchases.
issuer_cik, buys = Counter(r["issuer"]["cik"] for r in rows).most_common(1)[0]
print(issuer_cik, buys)

# 2. Narrow to that company: its three newest purchases.
issuer_rows = get("/v3/ownership/insiders/transactions", code="P", issuer_cik=issuer_cik,
                  filed_from="2026-11-02", filed_to="2026-11-13", limit=3).json()["data"]

# 3. Open one buyer's Form 4: here, Carole Ben-Maimon's.
buyer = next(r for r in issuer_rows if r["owners"][0]["name"].startswith("BEN-MAIMON"))
form4 = get(f"/v3/filings/{buyer['accession']}/ownership").json()
print(form4["owners"][0]["name"], form4["tables"]["non_derivative_transactions"])

```

## What each step returns

**1. Scan the window.** `code=P` keeps only open-market purchases, and `table=non_derivative` keeps Table I, the common-stock rows. The script pages through the window and counts the rows by `issuer.cik`.

```json
{
  "data": [
    {
      "issuer": {"cik":"0001374690","name":"Larimar Therapeutics, Inc."},
      "owners": [{"name":"Hamilton Thomas Edward"}],
      "shares": "70000",
      "price": "2.6726",
      "transaction_date": "2026-11-12",
      "accession": "0001193125-26-459008"
    },
    {
      "issuer": {"cik":"0001374690","name":"Larimar Therapeutics, Inc."},
      "owners": [{"name":"BEN-MAIMON CAROLE"}],
      "shares": "18050",
      "price": "2.7675",
      "transaction_date": "2026-11-11",
      "accession": "0001193125-26-458853"
    },
    {
      "issuer": {"cik":"0001374690","name":"Larimar Therapeutics, Inc."},
      "owners": [{"name":"Celano Michael"}],
      "shares": "18460",
      "price": "2.7081",
      "transaction_date": "2026-11-11",
      "accession": "0001193125-26-458834"
    }
  ],
  "has_more": true,
  "next_cursor": "…"
}
```

**2. Narrow to the company.** The same query with `issuer_cik` returns only that company's purchases. `limit=3` keeps the three newest.

```json
{
  "data": [
    {
      "owners": [{"name":"Hamilton Thomas Edward"}],
      "shares": "70000",
      "price": "2.6726",
      "transaction_date": "2026-11-12",
      "accession": "0001193125-26-459008"
    },
    {
      "owners": [{"name":"BEN-MAIMON CAROLE"}],
      "shares": "18050",
      "price": "2.7675",
      "transaction_date": "2026-11-11",
      "accession": "0001193125-26-458853"
    },
    {
      "owners": [{"name":"THOMAS FRANK E"}],
      "shares": "8000",
      "price": "2.725",
      "transaction_date": "2026-11-11",
      "accession": "0001193125-26-458848"
    }
  ],
  "has_more": true,
  "next_cursor": "eyJhIjoiMDAwMTE5MzEy…"
}
```

**3. Open a Form 4.** The ownership record names the owner and their role, every transaction, and the footnotes. The script opens Carole Ben-Maimon's, the second row of step 2.

```json
{
  "accession": "0001193125-26-458853",
  "issuer": {"cik":"0001374690","name":"Larimar Therapeutics, Inc.","trading_symbol_raw":"LRMR"},
  "filing": {"form_type":"4","filing_date":"2026-11-12","status":"final"},
  "owners": [
    {
      "name": "BEN-MAIMON CAROLE",
      "cik": "0001529611",
      "relationship": {
        "is_director": true,
        "is_officer": true,
        "is_ten_percent_owner": false,
        "officer_title": "President and CEO"
      }
    }
  ],
  "tables": {
    "non_derivative_transactions": [
      {
        "transaction_code": "P",
        "transaction_date": "2026-11-11",
        "security_title": "Common Stock",
        "shares": "18050",
        "price": "2.7675",
        "acquired_disposed": "A",
        "shares_after": "386326",
        "ownership_form": "D"
      }
    ]
  },
  "footnotes": [
    {
      "id": "F2",
      "text": "The price reported in Column 4 is a weighted average price. These shares were purchased in multiple transactions at prices ranging from $2.765 to $2.77, inclusive. …"
    }
  ]
}
```
