"""DB stats and sample data""" import sqlite3 conn = sqlite3.connect("data/edf.db") print("=== DB Stats ===") for t in ["companies", "market_data", "financial_data", "volatility", "merton_results"]: c = conn.execute(f"SELECT COUNT(*) FROM {t}").fetchone()[0] print(f" {t}: {c:,}") print("\n=== Volatility sample ===") rows = conn.execute("SELECT ticker, sigma_E FROM volatility ORDER BY ticker LIMIT 5").fetchall() for r in rows: print(f" {r[0]}: sigma_E={r[1]:.4f}") print("\n=== Financial sample ===") rows = conn.execute(""" SELECT ticker, total_assets, default_point, leverage_ratio FROM financial_data WHERE total_assets IS NOT NULL ORDER BY total_assets DESC LIMIT 5 """).fetchall() for r in rows: dp = f"{r[2]:,.0f}" if r[2] else "N/A" lev = f"{r[3]:.3f}" if r[3] else "N/A" print(f" {r[0]}: TA={r[1]:,.0f} DP={dp} LEV={lev}") # Overlap: tickers with BOTH volatility AND financial_data both = conn.execute(""" SELECT COUNT(DISTINCT v.ticker) FROM volatility v JOIN financial_data f ON v.ticker = f.ticker """).fetchone()[0] print(f"\n=== Merton 산출 가능 종목 (KRX+DART 모두 있는 종목): {both} ===") conn.close()