Skip to main content

Score stocks based on US politician trade disclosures (Capitol Trades).

Project description

politician-trade-score

Install (editable)

pip install -e .

On Windows PowerShell

If PowerShell blocks virtual-environment activation, use this one-time PATH update to point pip and poltrade to your venv:

# from your project root
py -3.13 -m venv .venv
$env:Path = "$PWD\.venv\Scripts;$env:Path"
where python
where pip

pip install -e .

#Then run the CLI
## CLI usage

Fetch recent trades and score tickers:

```bash
poltrade --tickers AAPL TSLA --pages 50 --hold-length 180 --buy-weight 0.8 --details
  • --tickers One or more tickers.
  • --pages Number of pages to fetch from Capitol Trades (default 303 in the original).
  • --hold-length Lookback window in days for the date filter (default 180 in the original).
  • --buy-weight Weight on buy-ratio in final score. Recency weight is 1 - buy-weight.
  • --details Print the intermediate details shown by the original script.

You can also pass explicit start and end dates (YYYY-MM-DD) instead of --hold-length:

poltrade --tickers NVDA --start-date 2025-06-01 --end-date 2025-09-01

Library usage

from poltrade.data import gather_data
from poltrade.score import PoliticianTradeScorer

data = gather_data()
scorer = PoliticianTradeScorer(buy_ratio_weight=0.8, recency_weight=0.2)
score = scorer.final_score(data, "AAPL", details=True, tutorial=True)

Notes

  • The gather_data function relies on pandas.read_html to scrape capitoltrades.com pages.

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

politician_trade_score-2025.1.2.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

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

politician_trade_score-2025.1.2-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file politician_trade_score-2025.1.2.tar.gz.

File metadata

File hashes

Hashes for politician_trade_score-2025.1.2.tar.gz
Algorithm Hash digest
SHA256 fe8a95daac9735e2633c444f8e621ecb4510d72178a7cecb3d64dd5cf328e644
MD5 087e9e999275cbaab53c923710d7464f
BLAKE2b-256 aa00b0da3baf6f13a2a072e5f814d210352f5ce57edd9dd3c9d8242bb1290e59

See more details on using hashes here.

File details

Details for the file politician_trade_score-2025.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for politician_trade_score-2025.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5ae7cebab440f1a12377d8f8c5e44396f201dfd50ab78cd727a33a9565b91215
MD5 1946a38113c668b41c87e60e61b76e29
BLAKE2b-256 b6ce00df601ebd74e481393d0c01e4b472d68eea6ff9e077cc4b70a95c34cd55

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