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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for politician_trade_score-2025.1.1.tar.gz
Algorithm Hash digest
SHA256 10edefce520692838e5f90d52c32f27193464a7dd7129c7067605491b65b9293
MD5 a78a802eeae66a1dc5cf9a2ae905e003
BLAKE2b-256 6e9b0807e56f02fe11d1b3430592a925af94843e15092569fe636c0a4e8aba89

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for politician_trade_score-2025.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a92689647015fd46962a7f1253eace2c6873ac4e43f25480f754a8c6932f089d
MD5 ce79e56363fdb98473ed2d43da36fd30
BLAKE2b-256 06e38f046421cac881ff9ff1b0a2183d3c2c7e0e4a65ef4fa8a7dcf67b9e3d0b

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