How to download SEC Schedule 13D data in Python

The U.S. Securities and Exchange Commission (SEC) publishes Schedule 13D filings on EDGAR, its filing system. An investor who acquires more than 5% of a company’s voting shares and may try to influence control of the company must file a Schedule 13D within five business days. Each filing includes holdings, the purpose, and the trades of the previous 60 days. In this post, I show how to download this data into Python.
Downloading the list of filings
SEC’s EDGAR is a database for collecting and storing data that we will use to retrieve Schedule 13D filings for July to September 2026. For another quarter from 2025 onward, when every filing is an XML file, change the year and quarter in the URL of the master index. To get several quarters, you can rewrite the code as a loop over their URLs and join the panels with pd.concat.
Each request requires disclosing your name and contact email (SEC rules for automated access), and the maximum is 10 requests per second. One possibility, which I do, is to save my name and email in PowerShell so that if I share my notebook (which I do here), there is no need to show them; although they are not that confidential, it is good practice. To do so 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 both, and run the notebook from the start.
import io
import os
import re
import time
from xml.etree import ElementTree
import pandas as pd
import requests
from requests.adapters import HTTPAdapter
from urllib3.util import Retry
URL = "https://www.sec.gov/Archives/edgar/full-index/2026/QTR3/master.idx"
HEADERS = {"User-Agent": os.environ["SEC_USER_AGENT"]}
response = requests.get(URL, headers=HEADERS, timeout=300)
response.raise_for_status()
columns = ["cik", "company", "form", "filed", "file"]
index = pd.read_csv(io.BytesIO(response.content), encoding="latin-1", sep="|", skiprows=11,
names=columns, dtype=str)
filings = index[index["form"] == "SCHEDULE 13D"].copy()
filings["accession"] = filings["file"].str.split("/").str[-1].str.removesuffix(".txt")
filings["folder"] = ("https://www.sec.gov/Archives/"
+ filings["file"].str.removesuffix(".txt").str.replace("-", "") + "/")
filings = filings.drop_duplicates("accession")
print(len(index), "rows in the index,", len(filings), "initial Schedule 13D filings")302560 rows in the index, 270 initial Schedule 13D filings
Building a panel
Since 18 December 2024, every initial Schedule 13D comes as an XML file, primary_doc.xml. The code retries the request up to five times if the SEC’s server does not respond within 60 seconds or returns error 429, 500, 502, 503, or 504.
NS = {"s": "http://www.sec.gov/edgar/schedule13D"}
retry = Retry(total=5, backoff_factor=1, status_forcelist=[429, 500, 502, 503, 504])
session = requests.Session()
session.mount("https://", HTTPAdapter(max_retries=retry))
rows = []
for accession, folder in zip(filings["accession"], filings["folder"]):
response = session.get(folder + "primary_doc.xml", headers=HEADERS, timeout=60)
response.raise_for_status()
root = ElementTree.fromstring(response.content)
persons = pd.read_xml(io.BytesIO(response.content), xpath="//s:reportingPersonInfo",
namespaces=NS)
shares = pd.to_numeric(persons["aggregateAmountOwned"], errors="coerce")
percent = pd.to_numeric(persons["percentOfClass"], errors="coerce")
rows.append({"accession": accession,
"event_date": root.findtext(".//s:dateOfEvent", namespaces=NS),
"filer": persons["reportingPersonName"].iloc[0],
"issuer": root.findtext(".//s:issuerInfo/s:issuerName", namespaces=NS),
"shares_m": shares.iloc[0] / 1e6, "percent": percent.iloc[0]})
time.sleep(0.2)
panel = pd.DataFrame(rows).merge(filings[["accession", "filed", "folder"]], on="accession")
panel["event_date"] = pd.to_datetime(panel["event_date"], format="%m/%d/%Y", errors="coerce")
panel["filed"] = pd.to_datetime(panel["filed"], format="%Y-%m-%d")
print(len(panel), "filings")
columns = ["filed", "event_date", "filer", "issuer", "shares_m", "percent"]
print(panel.loc[panel["filed"] == "2026-09-16", columns].round(2).to_string(index=False))270 filings
filed event_date filer issuer shares_m percent
2026-09-16 2026-09-11 Oasis Management Co Ltd. VAIL RESORTS INC 2.20 6.20
2026-09-16 2026-09-15 PICTET ASSET MANAGEMENT SA Dynatrace, Inc. 14.56 5.00
2026-09-16 2026-09-09 Shaun Anthony Quin Stewards, Inc. 20.21 9.60
2026-09-16 2026-09-09 Vincent C Napolitano Stewards, Inc. 40.58 19.20
2026-09-16 2026-09-09 Glen Anthony Whitefoord Steward Stewards, Inc. 106.00 35.90
2026-09-16 2026-09-09 Charles Robert Abele Stewards, Inc. 36.34 17.20
2026-09-16 2026-09-10 MIG REF II INFR, LLC Vulcan Infrastructure and Power Inc. 2.92 8.23
| Column | Meaning |
|---|---|
| filed | Day the investor filed the Schedule 13D |
| event_date | Date of the event that requires the filing, such as the day the investor passed 5% |
| filer, issuer | The first investor named on the cover page, and the company |
| shares_m, percent | That investor’s shares in millions, and their percent of the class |
This panel has 270 initial filings. For example, on 16 September 2026, Oasis Management reported 2.2 million shares of Vail Resorts.
Reading the trades
Here I show a snapshot of Oasis’s trades in the first table of Exhibit Schedule B.
folder = panel.loc[panel["accession"] == "0000902664-26-003832", "folder"].item()
response = session.get(folder + "0000902664-26-003832-index.htm", headers=HEADERS, timeout=60)
response.raise_for_status()
documents = pd.read_html(io.StringIO(response.text))[0]
accepted = re.search(r'Accepted</div>\s*<div class="info">([^<]+)', response.text).group(1)
exhibit = documents.loc[documents["Description"] == "SCHEDULE B", "Document"].item()
response = session.get(folder + exhibit, headers=HEADERS, timeout=60)
response.raise_for_status()
table = pd.read_html(io.StringIO(response.text), header=0)[0]
labels = {"Trade Date": "date", "Shares Purchased (Sold)": "shares", "Price Per Share ($)": "price"}
trades = table.rename(columns=labels)[list(labels.values())]
trades["date"] = pd.to_datetime(trades["date"], format="%m/%d/%Y")
trades["shares"] = pd.to_numeric(trades["shares"].astype(str)
.str.replace(r"[,)]", "", regex=True).str.replace("(", "-"))
print("Accepted:", accepted)
print(trades.to_string(index=False))Accepted: 2026-09-16 08:56:40
date shares price
2026-07-16 -100000 149.99
2026-07-17 -1732 149.26
2026-07-20 -100113 146.17
2026-07-21 -100630 146.90
2026-07-22 -70916 145.82
2026-07-24 -200000 147.38
2026-09-04 -23374 135.08
2026-09-11 466763 139.34
Six sales from 16 to 24 July lowered Oasis’s stake below 5%. On 11 September, the date of the event, Oasis bought 466,763 shares at a weighted average price of $139.34 and crossed back above 5%. EDGAR accepted the filing on 16 September at 08:56 Eastern Time, before the market opened.
Conclusion
This post shows how to download Schedule 13D filings in Python and convert them into a panel. The data is useful for studying how large shareholders trade and when their trades become public.
References
Oasis Management Co Ltd. (2026, September 16). Schedule 13D [Vail Resorts, Inc.]. U.S. Securities and Exchange Commission. https://www.sec.gov/Archives/edgar/data/812011/000090266426003832/0000902664-26-003832-index.htm
U.S. Securities and Exchange Commission. (2023). Modernization of beneficial ownership reporting (Release No. 33-11253). Federal Register, 88, 76896. https://www.federalregister.gov/documents/2023/11/07/2023-22678/modernization-of-beneficial-ownership-reporting