Skip to main content

Scrape and analyze stock trades by members of US Congress

Project description

congressional-trades

Scrape and analyze stock trades by members of the US Congress.

PyPI version License: MIT

Features

  • Scrapes directly from official sources (efdsearch.senate.gov)
  • Clean, typed Python API
  • Local caching for fast repeated queries
  • Export to CSV/DataFrame
  • Daily updates via GitHub Actions

Installation

pip install congressional-trades

Quick Start

from congressional_trades import get_trades, get_politicians

# Get all recent trades
trades = get_trades()

# Filter by various criteria
trades = get_trades(
    chamber="senate",
    ticker="NVDA",
    start_date="2024-01-01",
    transaction_type="purchase",
)

# Get as pandas DataFrame
df = get_trades(as_dataframe=True)

# List all politicians
politicians = get_politicians(chamber="senate")

CLI Usage

# List recent trades
congressional-trades list --ticker NVDA --since 2024-01-01

# Export to CSV
congressional-trades export trades.csv

# Force refresh from source
congressional-trades refresh

Data Sources

  • Senate: efdsearch.senate.gov - Electronic Financial Disclosure
  • House: Coming in v2 (PDF parsing required)

Data Model

Each trade includes:

Field Type Description
politician str Full name
chamber str "senate" or "house"
party str "D", "R", or "I"
state str Two-letter state code
ticker str Stock ticker (if resolved)
asset_name str Full asset description
transaction_type str "purchase", "sale", etc.
transaction_date date When trade occurred
disclosure_date date When disclosed
amount_min int Minimum transaction amount
amount_max int Maximum transaction amount

Contributing

Contributions welcome! The biggest need is help with House PDF parsing.

# Development setup
git clone https://github.com/guttu44/congressional-trades
cd congressional-trades
pip install -e ".[dev]"
pytest

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

congressional_trades-0.1.0.tar.gz (19.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

congressional_trades-0.1.0-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

Details for the file congressional_trades-0.1.0.tar.gz.

File metadata

  • Download URL: congressional_trades-0.1.0.tar.gz
  • Upload date:
  • Size: 19.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for congressional_trades-0.1.0.tar.gz
Algorithm Hash digest
SHA256 48d26d5cc5a6c0a4104f843d69d49e4fc15caf3803107cdb9eaabbba41a8c58a
MD5 f7c4b2a88e37ce417a50be4d3bad4507
BLAKE2b-256 3d31eb108732ca838abb7b4c90cf34731f72abec7d3d659e708ef9db783ce95a

See more details on using hashes here.

File details

Details for the file congressional_trades-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for congressional_trades-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4a47407169dbd58afbf635f02c0660f6422966aad1eee5bf401cf8b7c4646c06
MD5 80792e800912565ef6e855c649f8cd67
BLAKE2b-256 6425e66bdca7d3597bc688803a91e8cbe2921e5e6e7a07196d80624d1dd333c3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page