"""Static column documentation for the most important WRDS table mnemonics.

Maps schema.table -> column_name -> human-readable description.
Used by get_table_schema to enrich raw metadata with meaningful labels.
"""

COLUMN_DOCS: dict[str, dict[str, str]] = {
    "comp.funda": {
        "gvkey": "Global Company Key (Compustat unique identifier)",
        "datadate": "Data Date (fiscal period end date)",
        "fyear": "Fiscal Year",
        "fyr": "Fiscal Year-End Month",
        "tic": "Ticker Symbol",
        "conm": "Company Name",
        "at": "Total Assets",
        "lt": "Total Liabilities",
        "seq": "Stockholders' Equity (Total)",
        "dltt": "Long-Term Debt (Total)",
        "dlc": "Debt in Current Liabilities (Short-Term Debt)",
        "che": "Cash and Short-Term Investments",
        "oibdp": "Operating Income Before Depreciation (EBITDA proxy)",
        "sale": "Net Sales/Revenue",
        "capx": "Capital Expenditures",
        "xint": "Interest Expense (Total)",
        "xrent": "Rental Expense",
        "dp": "Depreciation and Amortization",
        "act": "Current Assets (Total)",
        "lct": "Current Liabilities (Total)",
        "ivst": "Short-Term Investments (Total)",
        "re": "Retained Earnings",
        "ceq": "Common/Ordinary Equity (Total)",
        "csho": "Common Shares Outstanding",
        "prcc_f": "Price Close (Annual, Fiscal Year-End)",
        "ni": "Net Income (Loss)",
        "ib": "Income Before Extraordinary Items",
        "txt": "Income Taxes (Total)",
        "pi": "Pretax Income",
        "ebitda": "Earnings Before Interest, Taxes, Depreciation & Amortization",
        "revt": "Revenue (Total)",
        "cogs": "Cost of Goods Sold",
        "xsga": "Selling, General & Administrative Expense",
        "dv": "Cash Dividends (Common/Ordinary)",
        "wcap": "Working Capital (Balance Sheet)",
        "invt": "Inventories (Total)",
        "rect": "Receivables (Total)",
        "ap": "Accounts Payable",
        "ppent": "Property, Plant & Equipment (Net)",
        "intan": "Intangible Assets (Total)",
        "gdwl": "Goodwill",
    },
    "comp.fundq": {
        "gvkey": "Global Company Key (Compustat unique identifier)",
        "datadate": "Data Date (fiscal quarter end date)",
        "fyearq": "Fiscal Year (Quarterly)",
        "fqtr": "Fiscal Quarter",
        "tic": "Ticker Symbol",
        "conm": "Company Name",
        "atq": "Total Assets (Quarterly)",
        "ltq": "Total Liabilities (Quarterly)",
        "seqq": "Stockholders' Equity (Quarterly)",
        "dlttq": "Long-Term Debt (Quarterly)",
        "dlcq": "Debt in Current Liabilities (Quarterly)",
        "cheq": "Cash and Short-Term Investments (Quarterly)",
        "oibdpq": "Operating Income Before Depreciation (Quarterly)",
        "saleq": "Net Sales/Revenue (Quarterly)",
        "capxy": "Capital Expenditures (Year-to-Date)",
        "xintq": "Interest Expense (Quarterly)",
        "dpq": "Depreciation and Amortization (Quarterly)",
        "actq": "Current Assets (Quarterly)",
        "lctq": "Current Liabilities (Quarterly)",
        "ceqq": "Common Equity (Quarterly)",
        "cshoq": "Common Shares Outstanding (Quarterly)",
        "niq": "Net Income (Quarterly)",
        "ibq": "Income Before Extraordinary Items (Quarterly)",
        "revtq": "Revenue Total (Quarterly)",
        "cogsq": "Cost of Goods Sold (Quarterly)",
        "prccq": "Price Close (Quarterly)",
    },
    "crsp.dsf_v2": {
        "permno": "CRSP Permanent Security Number",
        "permco": "CRSP Permanent Company Number",
        "ticker": "Ticker Symbol",
        "dlycaldt": "Calendar Date (Daily)",
        "dlyprc": "Daily Price (close, negative = bid/ask avg)",
        "dlyret": "Daily Holding Period Return (includes dividends)",
        "dlyvol": "Daily Trading Volume (shares)",
        "dlycap": "Daily Market Capitalization",
        "dlyclose": "Daily Closing Price",
        "dlyhigh": "Daily High Price",
        "dlylow": "Daily Low Price",
        "dlyopen": "Daily Opening Price",
    },
    "crsp.msf_v2": {
        "permno": "CRSP Permanent Security Number",
        "permco": "CRSP Permanent Company Number",
        "ticker": "Ticker Symbol",
        "mthcaldt": "Calendar Date (Monthly, end of month)",
        "mthprc": "Monthly Price (close, negative = bid/ask avg)",
        "mthret": "Monthly Holding Period Return (includes dividends)",
        "mthvol": "Monthly Trading Volume (shares)",
        "mthcap": "Monthly Market Capitalization",
    },
    "wrdsapps_bondret.bondret": {
        "cusip": "Bond CUSIP (9-character identifier)",
        "date": "Observation Date (end of month)",
        "ret_eom": "End-of-Month Bond Return",
        "yield": "Bond Yield (decimal; multiply by 100 for percentage)",
        "price_eom": "End-of-Month Clean Price",
        "duration": "Macaulay Duration",
        "t_spread": "Treasury Spread (decimal; multiply by 10000 for basis points)",
        "t_yld_pt": "Interpolated Treasury Yield at Matching Maturity",
        "amount_outstanding": "Amount Outstanding (face value, millions)",
        "r_sp": "S&P Credit Rating (alphanumeric)",
        "r_mr": "Moody's Credit Rating (alphanumeric)",
        "r_fr": "Fitch Credit Rating (alphanumeric)",
        "rating_cat": "Numeric Rating Category (1=AAA, 21=C/D)",
        "rating_class": "Rating Class (IG=Investment Grade, HY=High Yield)",
        "company_symbol": "Company Ticker Symbol",
    },
    "fisd.fisd_mergedissue": {
        "complete_cusip": "Full 9-Character CUSIP",
        "issuer_id": "FISD Issuer Identifier",
        "issuer_cusip": "6-Character Issuer CUSIP",
        "ticker": "Ticker Symbol (often NULL — use CUSIP linkage instead)",
        "coupon": "Coupon Rate (%)",
        "maturity": "Maturity Date",
        "offering_amt": "Offering Amount (face value, thousands)",
        "security_level": "Security Level (SS=Senior Secured, SU=Senior Unsecured, etc.)",
        "bond_type": "Bond Type (CDEB=Corporate Debenture, CMTN=Medium-Term Note, etc.)",
        "active_issue": "Active Issue Flag (Y/N)",
        "issue_name": "Issue Description/Name",
        "convertible": "Convertible Bond Flag (Y/N)",
        "asset_backed": "Asset-Backed Flag (Y/N)",
        "offering_date": "Original Offering Date",
    },
}
