DEV Community

Mees Wijnants
Mees Wijnants

Posted on

I built a free open source tool to track Nancy Pelosi's official stock trade reports

I wanted a simple way to see every official stock trade report filed by Nancy Pelosi, straight from the source. The data is public, but it is spread over yearly index files and PDFs that are hard to search. So I wrote a small, free and open source Python script that does the searching for you.

Repo: github.com/MeesWijnants/pelosi-trade-finder
Latest filings (auto updated weekly): FILINGS.md

Why this data exists

Under the STOCK Act (2012), members of Congress must report stock trades above $1,000 within 45 days. In the House these reports are called Periodic Transaction Reports (PTRs) and they are published by the House Clerk.

The Clerk offers one ZIP file per year with an XML index of every filing. Each row has the member's name, the filing type, the date and a document ID. PTRs have filing type P.

How the tool works

  1. Download https://disclosures-clerk.house.gov/public_disc/financial-pdfs/{year}FD.zip
  2. Parse the XML and keep rows where FilingType == "P" and the name matches
  3. Build the link to the original PDF: .../ptr-pdfs/{year}/{doc_id}.pdf

No API key, no dependencies, Python 3.8 or newer. Standard library only (urllib, zipfile, xml.etree).

for f in filings:
    if f.get("FilingType") != "P":   # P = Periodic Transaction Report
        continue
    if f.get("Last", "").lower() != last.lower():
        continue
    pdf_url = PTR_PDF_URL.format(year=f["Year"], doc_id=f["DocID"])
Enter fullscreen mode Exit fullscreen mode

Usage

git clone https://github.com/MeesWijnants/pelosi-trade-finder
cd pelosi-trade-finder

# Nancy Pelosi, last 5 years
python pelosi_finder.py

# Any other House member
python pelosi_finder.py --last Crenshaw --first Dan

# Export
python pelosi_finder.py --markdown FILINGS.md --json filings.json
Enter fullscreen mode Exit fullscreen mode

A GitHub Actions workflow runs the script every Monday and commits the fresh FILINGS.md, so the list in the repo stays current without anyone touching it.

What it does not do

  • It does not read the PDFs or extract individual trades. Every result links to the original PDF so you can check it yourself.
  • House only. Senate reports live at efdsearch.senate.gov.
  • It is not investment advice. Filings can be up to 45 days late, so they show what happened, not what will happen.

Why I built it

I'm the founder of Wolf of Washington, an app that tracks the public stock trades of 500+ U.S. politicians and explains them in plain language. The app does the heavy lifting (parsing PDFs, alerts, history). This script is the opposite: the smallest possible tool that shows where the data really comes from. I think that transparency matters more than any feature.

The code is MIT licensed. Issues and pull requests are welcome.


Disclosure: I'm the founder of Wolf of Washington. This post and the tool are for education only and are not investment advice. More about me: wolfofwashington.nl/over-ons

Top comments (0)