How to download SEC Form 4 insider trading data in Python

Data Sources
Tutorial
Python
I show how to download U.S. Securities and Exchange Commission insider trading data for free in Python and convert it into a readable DataFrame with ticker, trade date, reporting owners, price, and filing date.
Published

November 22, 2026

Updated

November 26, 2026

downloading SEC insider trading data in Python

The U.S. Securities and Exchange Commission (SEC) publishes free data from Forms 3, 4 and 5 filed since January 2006. People who file these forms include directors, certain officers, and investors who own more than 10% of a class of a company’s registered shares; Form 4 reports most of their trades in that company’s securities. I show how to download this data into Python. First, I download one quarter, then build a panel of its purchases and sales by trade date. I also show how to choose a ticker when looking up a stock’s closing price with insider trades.

Downloading a quarter

To get the URL needed for the download, I copy the ZIP link for 2026 Q3 on the SEC’s Insider Transactions Data Sets page, which lists one ZIP file per quarter. For another quarter, copy its ZIP link from the same page, because the folder in the URL differs between quarters. To get several quarters, you can rewrite the code as a loop over their ZIP links and join the panels with pd.concat.

The SEC allows at most 10 requests per second and asks for a name and contact email in each request (SEC rules for automated access). You can save your name and email on your Windows machine instead of in the notebook, which would otherwise expose them if you accidentally shared your notebook with someone else. On Windows, run setx SEC_USER_AGENT "Your Name your@email.com" once in PowerShell. Then close Jupyter and the program you started it from, reopen them, and run the notebook from the first cell.

NoteCode: downloading one quarter
import io
import os
import zipfile

import pandas as pd
import requests

URL = ("https://www.sec.gov/files/datastandardsinnovation/data/insider-transactions-data-sets/"
       "2026q3_form345.zip")
HEADERS = {"User-Agent": os.environ["SEC_USER_AGENT"]}

response = requests.get(URL, headers=HEADERS, timeout=120)
response.raise_for_status()
archive = zipfile.ZipFile(io.BytesIO(response.content))
print("\n".join(archive.namelist()))

submissions = pd.read_csv(archive.open("SUBMISSION.tsv"), sep="\t", dtype=str,
                          keep_default_na=False, na_values=[""])
owners = pd.read_csv(archive.open("REPORTINGOWNER.tsv"), sep="\t", dtype=str)
trades = pd.read_csv(archive.open("NONDERIV_TRANS.tsv"), sep="\t", dtype=str)
print(len(submissions), "filings,", len(owners), "owner rows,", len(trades), "transaction rows")
DERIV_HOLDING.tsv
DERIV_TRANS.tsv
FOOTNOTES.tsv
NONDERIV_HOLDING.tsv
NONDERIV_TRANS.tsv
OWNER_SIGNATURE.tsv
REPORTINGOWNER.tsv
SUBMISSION.tsv
FORM_345_metadata.json
FORM_345_readme.htm
38152 filings, 41346 owner rows, 59885 transaction rows

The code reads three of the eight tables. SUBMISSION gives the form type and the company’s name and ticker, REPORTINGOWNER the reporting owners, and NONDERIV_TRANS the transactions in common stock, notes and other securities that are not derivatives. The filing number, ACCESSION_NUMBER, links the three tables. Since pandas reads NA as missing by default and NA is also the ticker of Nano Labs, I tell pandas to treat only empty fields in SUBMISSION as missing.

Keeping purchases and sales

I keep the purchases (P) and sales (S) in NONDERIV_TRANS from original Forms 4, on the open market or in private transactions, and add the filing date, the company’s name, the ticker and the company’s Central Index Key (CIK) from SUBMISSION.

columns = ["ACCESSION_NUMBER", "FILING_DATE", "ISSUERCIK", "ISSUERNAME", "ISSUERTRADINGSYMBOL"]
form4 = submissions.loc[submissions["DOCUMENT_TYPE"] == "4", columns]
deals = trades[trades["TRANS_CODE"].isin(["P", "S"])].merge(form4, on="ACCESSION_NUMBER")
print(len(deals), "rows coded P or S")
print(deals["TRANS_CODE"].value_counts())
30091 rows coded P or S
TRANS_CODE
S    25053
P     5038
Name: count, dtype: int64

Of the 30,091 rows kept from the 2026 Q3 file, 25,053 are coded S and 5,038 are coded P. Some of these trades took place before July, because the quarter refers to the filing date.

Adding the reporting owners

Some filings name several reporting owners, such as a fund and the firm that manages it, so I combine the names on each filing first. Joining every owner would give 41,042 rows instead of 30,091. And you should check for repeats when you add up trades, because separate filings can report the same trade.

print(len(deals.merge(owners, on="ACCESSION_NUMBER")), "rows after joining every owner")

names = owners.groupby("ACCESSION_NUMBER")["RPTOWNERNAME"].agg("; ".join).rename("OWNERS")
deals = deals.merge(names, on="ACCESSION_NUMBER")
print(len(deals), "rows after combining the owners on each filing")
41042 rows after joining every owner
30091 rows after combining the owners on each filing

Building a panel of trades

Each row of the panel is one reported transaction, indexed by trade date, with the reporting owners and the filing date of its Form 4. A Form 4 is generally due by the end of the second business day after the trade. The table below shows the seven reported sales of Apple shares in the 2026 Q3 file.

labels = {"TRANS_DATE": "date", "ISSUERTRADINGSYMBOL": "ticker", "ISSUERNAME": "company",
          "OWNERS": "owners", "SECURITY_TITLE": "security", "TRANS_CODE": "code",
          "TRANS_SHARES": "shares", "TRANS_PRICEPERSHARE": "price", "FILING_DATE": "filed",
          "ISSUERCIK": "cik"}
panel = deals.rename(columns=labels)[list(labels.values())]
panel["date"] = pd.to_datetime(panel["date"], format="%d-%b-%Y")
panel["filed"] = pd.to_datetime(panel["filed"], format="%d-%b-%Y")
panel[["shares", "price"]] = panel[["shares", "price"]].astype(float)
panel = panel.set_index("date").sort_index(kind="stable")
print(panel[panel["ticker"] == "AAPL"].to_string())
           ticker     company             owners      security code  shares   price      filed         cik
date                                                                                                      
2026-08-11   AAPL  Apple Inc.  Newstead Jennifer  Common Stock    S  1439.0  307.75 2026-08-13  0000320193
2026-08-18   AAPL  Apple Inc.  Newstead Jennifer  Common Stock    S  1439.0  307.49 2026-08-20  0000320193
2026-08-25   AAPL  Apple Inc.  Newstead Jennifer  Common Stock    S  1439.0  310.95 2026-08-27  0000320193
2026-09-01   AAPL  Apple Inc.  Newstead Jennifer  Common Stock    S  1439.0  317.01 2026-09-03  0000320193
2026-09-08   AAPL  Apple Inc.  Newstead Jennifer  Common Stock    S  1438.0  317.23 2026-09-10  0000320193
2026-09-15   AAPL  Apple Inc.  Newstead Jennifer  Common Stock    S  1438.0  330.19 2026-09-17  0000320193
2026-09-22   AAPL  Apple Inc.  Newstead Jennifer  Common Stock    S  2399.0  340.06 2026-09-24  0000320193

All seven are sales by Jennifer Newstead, one a week from 11 August to 22 September 2026, and each was filed two days after the trade.

Linking the trades to stock prices

To link a trade to stock prices, you need its date and the ticker of the security that traded. So for the Apple sale on 22 September 2026, you need AAPL’s closing price that day, without adjustments for later stock splits or dividends.

The ticker is text that the filer enters, so it can hold several symbols or a placeholder such as NONE, and cik finds the same company across filings and years.

For example, both of Lennar’s rows dated 29 September 2026 show LEN, the ticker of its Class A shares, although one of them is a purchase of 100 Class B shares, which trade as LEN.B.

columns = ["ticker", "company", "security", "code", "shares", "price"]
lennar = panel[panel["cik"] == "0000920760"]
print(lennar["ticker"].value_counts())
print(lennar.loc["2026-09-29", columns].to_string())
ticker
LEN, LEN.B    16
LEN           14
Name: count, dtype: int64
           ticker            company              security code   shares  price
date                                                                           
2026-09-29    LEN  LENNAR CORP /NEW/  Class B Common Stock    P    100.0  80.00
2026-09-29    LEN  LENNAR CORP /NEW/  Class A Common Stock    P  12289.0  81.95

So if you filter for the exact text LEN, you miss the 16 Lennar rows marked “LEN, LEN.B”. Check security and use your price source’s ticker for the share class that traded.

There are also rows for securities other than shares, such as notes.

print(panel.loc[panel["ticker"] == "FINS", columns].to_string())
           ticker                                           company                                                 security code      shares        price
date                                                                                                                                                      
2026-07-08   FINS  Angel Oak Financial Strategies Income Term Trust  5.364% Series C Senior Unsecured Notes due July 8, 2030    P  40000000.0  40000000.00
2026-09-14   FINS  Angel Oak Financial Strategies Income Term Trust                                             Common Stock    P      1000.0        12.53
2026-09-25   FINS  Angel Oak Financial Strategies Income Term Trust                                             Common Stock    P      1000.0        11.90

On one FINS row, both shares and price show 40,000,000. The price footnote in FOOTNOTES.tsv says that $40,000,000 was the total face value of the notes bought, so multiplying shares by price gives a wrong purchase value.

Conclusion

The SEC’s insider trading data is a free database of insider trades with one ZIP file per quarter since 2006. You start with one quarter, combine the owner names on each filing, and build a panel by trade date. Also, always keep the filing date, and check which security traded and which ticker it had before you link a trade to stock prices.

References

U.S. Securities and Exchange Commission. (n.d.). Insider transactions data sets [Documentation]. Retrieved November 22, 2026, from https://www.sec.gov/files/insider_transactions_readme.pdf

U.S. Securities and Exchange Commission. (2026). Insider transactions data sets [Data set]. Retrieved November 22, 2026, from https://www.sec.gov/data-research/sec-markets-data/insider-transactions-data-sets