Source code · Python

report_data.py

51 lines · Part of UnitedHealth estimates report · All code · Read only; the files run as published

"""Build the data behind the UnitedHealth estimates report (app/lib/unhReport.json). The report carries no rating, price target or forecast of our own. It bringstogether, each with its source and date: reported figures (SEC XBRL indata/facts.json, the 10-K and 10-Q segment and membership tables), what thecompany projects (dated guidance and call commentary), and Wall Streetconsensus from Koyfin (6 Nov 2026) and S&P Capital IQ (27 Oct to 5 Nov 2026).The reported tables are the ones assembled in model.py; its valuation model isno longer published. Usage: python report_data.py <out.json>""" import jsonimport osimport sys HERE = os.path.dirname(os.path.abspath(__file__))sys.path.insert(0, HERE)import model as m  # noqa: E402  (reported tables, guidance history, peers) KOY = json.load(open(os.path.join(HERE, "data", "koyfin_2026_11_06.json")))  def main(out_path):    price = KOY["price"]["close_2026_11_05"]    shares = m.SHARES_OUT    mcap = price * shares    years = [str(y) for y in range(2015, 2026)]    hist = {y: {k: m.hist[y][k] for k in ("revenue", "operating_income", "net_income", "eps", "cfo", "capex", "dividends", "buybacks", "premiums", "medical_costs")}            for y in years}    a = KOY["annual"]    comps = [{k: c[k] for k in ("ticker", "price", "fwd_pe", "ttm_pe")} for c in m.comps()]    result = {        "meta": {"report_date": "6 November 2026", "price": price, "price_date": "5 Nov 2026", "prior_close": m.PRICE,                 "shares_out": shares, "mcap": mcap, "latest_quarter": "Q3 2026 (10-Q filed 3 Nov 2026)",                 "week52": {"high": m.CIQ["dated_close"]["week52_high_close"], "low": m.CIQ["dated_close"]["week52_low_close"]}},        "history": hist, "segments": m.SEGMENTS, "members": m.MEMBERS, "risk_members": m.risk_members,        "guidance": m.GUIDANCE, "nine": m.NINE, "nine_2025": m.NINE_2025, "bs_q3": m.BS_Q3,        "koyfin": KOY, "ciq": {"consensus": m.CIQ["consensus"], "call": m.CIQ["q3_2026_call_qa"]},        "comps": comps, "valuation": {"pe": {y: price / e for y, e in zip(a["years"], a["eps"])}},    }    with open(out_path, "w") as f:        json.dump(result, f, indent=1, default=float)    print("mcap", round(mcap), "pe", {k: round(v, 1) for k, v in result["valuation"]["pe"].items()})    print("revenue", {y: round(hist[y]["revenue"]) for y in years})    print("dividends", {y: round(hist[y]["dividends"] or 0) for y in years})  if __name__ == "__main__":    main(sys.argv[1])