Add watchlist system and pre-market trading reports
New Features: - Watchlist system for tracking specific Congress members - Trading report generation with multiple formats - Pre-market-close automated updates (3 PM) New Scripts: - scripts/fetch_congress_members.py: Manage watchlist * 29 known active traders (curated list) * Optional ProPublica API integration (all 535 members) * Create/view/manage watchlist - scripts/generate_trading_report.py: Generate trading reports * Filter by watchlist or show all * Multiple formats: text, HTML, JSON * Summary statistics (buys/sells, top tickers) * Color-coded output (🟢 BUY, 🔴 SELL) - scripts/pre_market_close_update.sh: 3 PM automation * Quick fetch of latest trades * Enrichment of new securities * Generate and display report * Saves to reports/ directory Documentation: - WATCHLIST_GUIDE.md: Complete guide * List of 29 known active traders * How to create/customize watchlist * Schedule options (pre-market, post-market) * Email setup (optional) * FAQ and examples Known Active Traders Include: Senate: Tuberville, Rand Paul, Mark Warner, Rick Scott House: Pelosi, Crenshaw, MTG, Gottheimer, Brian Higgins Use Cases: ✅ Daily reports at 3 PM (1 hour before close) ✅ See what Congress bought/sold recently ✅ Track specific members you care about ✅ Export to HTML/JSON for further analysis
This commit is contained in:
Executable
+85
@@ -0,0 +1,85 @@
|
||||
#!/bin/bash
|
||||
# Pre-Market-Close POTE Update
|
||||
# Run at 3 PM ET (1 hour before market close)
|
||||
# Fetches latest disclosures and generates actionable report
|
||||
|
||||
set -e
|
||||
|
||||
# --- Configuration ---
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
LOG_DIR="${PROJECT_DIR}/logs"
|
||||
REPORT_DIR="${PROJECT_DIR}/reports"
|
||||
LOG_FILE="${LOG_DIR}/pre_market_$(date +%Y%m%d).log"
|
||||
REPORT_FILE="${REPORT_DIR}/trading_report_$(date +%Y%m%d).txt"
|
||||
|
||||
# Ensure directories exist
|
||||
mkdir -p "$LOG_DIR" "$REPORT_DIR"
|
||||
|
||||
# Redirect output to log
|
||||
exec > >(tee -a "$LOG_FILE") 2>&1
|
||||
|
||||
echo "=========================================="
|
||||
echo " POTE Pre-Market-Close Update"
|
||||
echo " $(date)"
|
||||
echo " Running 1 hour before market close"
|
||||
echo "=========================================="
|
||||
|
||||
# Activate virtual environment
|
||||
cd "$PROJECT_DIR"
|
||||
source venv/bin/activate
|
||||
|
||||
# --- Step 1: Quick Fetch of New Trades ---
|
||||
echo ""
|
||||
echo "--- Fetching Latest Congressional Trades ---"
|
||||
python scripts/fetch_congressional_trades.py --days 3
|
||||
FETCH_EXIT=$?
|
||||
|
||||
if [ $FETCH_EXIT -ne 0 ]; then
|
||||
echo "⚠️ WARNING: Failed to fetch trades (API may be down)"
|
||||
echo " Generating report from existing data..."
|
||||
fi
|
||||
|
||||
# --- Step 2: Quick Security Enrichment ---
|
||||
echo ""
|
||||
echo "--- Enriching New Securities ---"
|
||||
python scripts/enrich_securities.py --limit 10
|
||||
ENRICH_EXIT=$?
|
||||
|
||||
# --- Step 3: Generate Trading Report ---
|
||||
echo ""
|
||||
echo "--- Generating Trading Report ---"
|
||||
python scripts/generate_trading_report.py \
|
||||
--days 7 \
|
||||
--watchlist-only \
|
||||
--format text \
|
||||
--output "$REPORT_FILE"
|
||||
|
||||
REPORT_EXIT=$?
|
||||
|
||||
if [ $REPORT_EXIT -eq 0 ]; then
|
||||
echo "✅ Report saved to: $REPORT_FILE"
|
||||
echo ""
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "📊 REPORT PREVIEW"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
cat "$REPORT_FILE"
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
else
|
||||
echo "❌ Failed to generate report"
|
||||
fi
|
||||
|
||||
# --- Step 4: Optional Price Update (Quick) ---
|
||||
# Uncomment if you want prices updated before market close
|
||||
# echo ""
|
||||
# echo "--- Quick Price Update ---"
|
||||
# python scripts/fetch_sample_prices.py --days 5
|
||||
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo " Update Complete - $(date)"
|
||||
echo "=========================================="
|
||||
|
||||
# Exit successfully even if some steps warned
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user