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.3.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.3-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for politician_trade_score-2025.1.3.tar.gz
Algorithm Hash digest
SHA256 74172cac1533c043d5395bacbb1e826ba40e9693f8bbabd996552929ac1f9795
MD5 33852417be2c4f763e9dfae6706b4fe5
BLAKE2b-256 8ab99e50d6c7aedce4544c78f491bc10f7077dcf6f4c2eedd31371a26bf3a4e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for politician_trade_score-2025.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7cc6c19f56f1f0e8c75e79db97d044e7a269146be8b00a23ff53b82b2d07fb7f
MD5 db7da6e69438486f26301f1e981d0051
BLAKE2b-256 9963675217e31d676c30c829d08af04c00d22d7efcf3b924ba18d349e2f1b038

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