From ad40fbe3095b2f837b015b3208c0828bd0f47d2b Mon Sep 17 00:00:00 2001 From: Tyler Date: Fri, 3 Apr 2026 19:09:33 -0700 Subject: Make valuation models collapsible --- components/valuation.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'components') diff --git a/components/valuation.py b/components/valuation.py index 031c424..0095f41 100644 --- a/components/valuation.py +++ b/components/valuation.py @@ -1049,26 +1049,28 @@ def _render_models(ticker: str): st.caption(ctx["summary"]) _render_model_availability(ctx) - sections = [] + sections: list[tuple[str, callable]] = [] if ctx["is_financial"] and ctx["pb_available"]: - sections.append(_render_price_to_book_model) + sections.append(("Price / Book", _render_price_to_book_model)) if ctx["dcf_available"]: - sections.append(_render_dcf_model) + sections.append(("Discounted Cash Flow", _render_dcf_model)) if ctx["ev_available"]: - sections.append(_render_ev_ebitda_model) + sections.append(("EV / EBITDA", _render_ev_ebitda_model)) if ctx["ev_revenue_available"] and not ctx["is_financial"]: - sections.append(_render_ev_revenue_model) - if ctx["pb_available"] and _render_price_to_book_model not in sections: - sections.append(_render_price_to_book_model) + sections.append(("EV / Revenue", _render_ev_revenue_model)) + section_renderers = {renderer for _, renderer in sections} + if ctx["pb_available"] and _render_price_to_book_model not in section_renderers: + sections.append(("Price / Book", _render_price_to_book_model)) if not sections: st.info("No valuation model is currently applicable for this company.") st.caption("Use comps, ratios, earnings history, and analyst targets instead.") else: - for i, render_section in enumerate(sections): + for i, (label, render_section) in enumerate(sections): if i > 0: st.divider() - render_section(ctx) + with st.expander(label, expanded=(i == 0)): + render_section(ctx) unavailable = [] if not ctx["dcf_available"]: -- cgit v1.3-2-g0d8e