COMPLETE: Cross-official pattern detection and ranking system
New Module:
- src/pote/monitoring/pattern_detector.py: Pattern analysis engine
* rank_officials_by_timing(): Rank all officials by suspicion
* identify_repeat_offenders(): Find systematic offenders
* analyze_ticker_patterns(): Per-stock suspicious patterns
* get_sector_timing_analysis(): Sector-level analysis
* get_party_comparison(): Democrat vs Republican comparison
* generate_pattern_report(): Comprehensive report
Analysis Features:
- Official Rankings:
* By average timing score
* Suspicious trade percentage
* Alert rates
* Pattern classification
- Repeat Offender Detection:
* Identifies officials with 50%+ suspicious trades
* Historical pattern tracking
* Systematic timing advantage detection
- Comparative Analysis:
* Cross-party comparison
* Sector analysis
* Ticker-specific patterns
* Statistical aggregations
New Script:
- scripts/generate_pattern_report.py: Comprehensive reports
* Top 10 most suspicious officials
* Repeat offenders list
* Most suspiciously traded stocks
* Sector breakdowns
* Party comparison stats
* Text/JSON formats
New Tests (11 total, all passing):
- test_rank_officials_by_timing
- test_identify_repeat_offenders
- test_analyze_ticker_patterns
- test_get_sector_timing_analysis
- test_get_party_comparison
- test_generate_pattern_report
- test_rank_officials_min_trades_filter
- test_empty_data_handling
- test_ranking_score_accuracy
- test_sector_stats_accuracy
- test_party_stats_completeness
Usage:
python scripts/generate_pattern_report.py --days 365
Report Includes:
- Top suspicious officials ranked
- Repeat offenders (50%+ suspicious rate)
- Most suspiciously traded tickers
- Sector analysis
- Party comparison
- Interpretation guide
Total Test Suite: 93 tests passing ✅
ALL 3 PHASES COMPLETE!
POTE – Public Officials Trading Explorer
Research-only tool for tracking and analyzing public stock trades by government officials.
⚠️ Important: This project is for personal research and transparency analysis only. It is NOT for investment advice or live trading.
What is this?
POTE tracks stock trading activity of government officials (starting with U.S. Congress) using lawfully available public data sources. It computes research metrics, descriptive signals, and risk/ethics flags to help understand trading patterns.
Key constraints
- Public data only: House Stock Watcher (free!), yfinance (free!), QuiverQuant/FMP (optional)
- Research framing: All outputs are descriptive analytics, not trading recommendations
- No inside information claims: We use public disclosures that may be delayed or incomplete
Current Status
✅ PR1 Complete: Project scaffold, DB models, price loader
✅ PR2 Complete: Congressional trade ingestion (House Stock Watcher)
✅ PR3 Complete: Security enrichment + deployment infrastructure
✅ PR4 Complete: Phase 2 analytics - returns, benchmarks, performance metrics
45+ passing tests, 88%+ coverage
Quick start
🚀 Already deployed? See QUICKSTART.md for full usage guide!
📦 Deploying? See PROXMOX_QUICKSTART.md for Proxmox LXC deployment (recommended).
Local Development
# Install
git clone <your-repo>
cd pote
make install
source venv/bin/activate
# Run migrations
make migrate
# Ingest sample data (offline, for testing)
python scripts/ingest_from_fixtures.py
# Enrich securities with company info
python scripts/enrich_securities.py
# With internet:
python scripts/fetch_congressional_trades.py
python scripts/fetch_sample_prices.py
# Run tests
make test
# Lint & format
make lint format
Production Deployment
# Proxmox LXC (Recommended - 5 minutes)
bash scripts/proxmox_setup.sh
# Docker
docker-compose up -d
Tech stack
- Language: Python 3.10+
- Database: PostgreSQL or SQLite (dev)
- Data: House Stock Watcher (free!), yfinance (free!), QuiverQuant/FMP (optional)
- Libraries: SQLAlchemy, Alembic, pandas, numpy, httpx, yfinance, scikit-learn
- Testing: pytest (28 tests, 87%+ coverage)
Documentation
Getting Started:
README.md– This fileQUICKSTART.md– ⭐ How to use your deployed POTE instanceSTATUS.md– Current project statusFREE_TESTING_QUICKSTART.md– Test for $0OFFLINE_DEMO.md– Works without internet!
Deployment:
PROXMOX_QUICKSTART.md– ⭐ Proxmox quick deployment (5 min)docs/07_deployment.md– Full deployment guide (all platforms)docs/08_proxmox_deployment.md– Proxmox detailed guideDockerfile+docker-compose.yml– Docker setup
Technical:
docs/00_mvp.md– MVP roadmapdocs/01_architecture.md– Architecturedocs/02_data_model.md– Database schemadocs/03_data_sources.md– Data sourcesdocs/04_safety_ethics.md– Research-only guardrailsdocs/05_dev_setup.md– Dev conventionsdocs/06_free_testing_data.md– Testing strategies
PR Summaries:
docs/PR1_SUMMARY.md– Scaffold + price loaderdocs/PR2_SUMMARY.md– Congressional tradesdocs/PR3_SUMMARY.md– Enrichment + deploymentdocs/PR4_SUMMARY.md– ⭐ Analytics foundation (returns, benchmarks, metrics)
What's Working Now
- ✅ SQLAlchemy models for officials, securities, trades, prices
- ✅ Alembic migrations
- ✅ Price loader with yfinance (idempotent, upsert)
- ✅ Congressional trade ingestion from House Stock Watcher (FREE!)
- ✅ Security enrichment (company names, sectors, industries)
- ✅ ETL to populate officials & trades tables
- ✅ Docker + deployment infrastructure
- ✅ 37 passing tests with 87%+ coverage
- ✅ Linting (ruff + mypy) all green
- ✅ Works 100% offline with fixtures
What You Can Do Now
Analyze Performance
# Analyze specific official
python scripts/analyze_official.py "Nancy Pelosi" --window 90
# System-wide analysis
python scripts/calculate_all_returns.py
Add More Data
# Manual entry
python scripts/add_custom_trades.py
# CSV import
python scripts/scrape_alternative_sources.py import trades.csv
Next Steps (Phase 3)
- Signals: "follow_research", "avoid_risk", "watch" with confidence scores
- Clustering: group officials by trading behavior patterns
- API: FastAPI backend for queries
- Dashboard: React/Streamlit visualization
See docs/00_mvp.md for the full roadmap.
License: MIT (for research/educational use only)
Disclaimer: Not investment advice. Use public data only. No claims about inside information.