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.0.tar.gz (7.0 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.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for politician_trade_score-2025.1.0.tar.gz
Algorithm Hash digest
SHA256 1ba001a9a3659d97030f5b9af90a106bc915078264923d5f4a27f612a7296952
MD5 2d8347447e0be495fbc2a55c314998ca
BLAKE2b-256 193fb78d7ffbcb907368f2323c002afe7dad7ec340bf6bd3775b228c5b76c36d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for politician_trade_score-2025.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 14772d57ca0b55e1371481523b3a36d7b4bbcfeef8c2561083a3b8a25420455b
MD5 dc326c9466890ceec5ad9ab779cb54bc
BLAKE2b-256 5904b97a1e732871b55cb536b7b4444ef576669d339d266446fd1289da4ca4aa

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