#!/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