aboutsummaryrefslogtreecommitdiff
path: root/components/valuation.py
diff options
context:
space:
mode:
authorTyler <tyler@tylerhoang.xyz>2026-04-02 18:17:59 -0700
committerTyler <tyler@tylerhoang.xyz>2026-04-02 18:17:59 -0700
commitee9691828bc06334c58a58902615b1c0b654f39a (patch)
tree3e1041c7c21c503b60385aa70081ab3c76c29d87 /components/valuation.py
parent0c146fec412fb99153fbb32fa90f0211aa0c8b32 (diff)
Fix valuation summary formatting
Diffstat (limited to 'components/valuation.py')
-rw-r--r--components/valuation.py29
1 files changed, 21 insertions, 8 deletions
diff --git a/components/valuation.py b/components/valuation.py
index f64b0b4..89e7d49 100644
--- a/components/valuation.py
+++ b/components/valuation.py
@@ -105,6 +105,10 @@ def _coerce_float(value) -> float | None:
return None if pd.isna(out) else out
+def _escape_markdown_currency(value: str) -> str:
+ return value.replace("$", r"\$")
+
+
def render_valuation(ticker: str):
tabs = st.tabs([
"Key Ratios",
@@ -566,9 +570,12 @@ def _render_dcf_model(ctx: dict):
market_message = "above" if valuation_gap > 0 else "below"
if abs(valuation_gap) < 0.005:
market_message = "roughly in line with"
+ implied_value = _escape_markdown_currency(fmt_currency(iv))
+ gap_value = _escape_markdown_currency(fmt_currency(abs(valuation_gap)))
+ current_value = _escape_markdown_currency(fmt_currency(current_price))
st.markdown(
- f"The DCF implies **{fmt_currency(iv)} per share**, which is **{fmt_currency(abs(valuation_gap))} "
- f"{market_message}** the current market price of **{fmt_currency(current_price)}**."
+ f"The DCF implies **{implied_value} per share**, which is **{gap_value} "
+ f"{market_message}** the current market price of **{current_value}**."
)
calc_a, calc_b, calc_c, calc_d = st.columns(4)
@@ -801,10 +808,13 @@ def _render_ev_ebitda_model(ctx: dict):
market_message = "above" if valuation_gap > 0 else "below"
if abs(valuation_gap) < 0.005:
market_message = "roughly in line with"
+ implied_value = _escape_markdown_currency(fmt_currency(imp_price))
+ gap_value = _escape_markdown_currency(fmt_currency(abs(valuation_gap)))
+ current_value = _escape_markdown_currency(fmt_currency(current_price))
st.markdown(
- f"At **{target_multiple:.1f}x EBITDA**, the model implies **{fmt_currency(imp_price)} per share**, "
- f"which is **{fmt_currency(abs(valuation_gap))} {market_message}** the current market price of "
- f"**{fmt_currency(current_price)}**."
+ f"At **{target_multiple:.1f}x EBITDA**, the model implies **{implied_value} per share**, "
+ f"which is **{gap_value} {market_message}** the current market price of "
+ f"**{current_value}**."
)
calc_a, calc_b, calc_c, calc_d = st.columns(4)
@@ -977,10 +987,13 @@ def _render_ev_revenue_model(ctx: dict):
market_message = "above" if valuation_gap > 0 else "below"
if abs(valuation_gap) < 0.005:
market_message = "roughly in line with"
+ implied_value = _escape_markdown_currency(fmt_currency(implied_price))
+ gap_value = _escape_markdown_currency(fmt_currency(abs(valuation_gap)))
+ current_value = _escape_markdown_currency(fmt_currency(current_price))
st.markdown(
- f"At **{target_multiple:.1f}x revenue**, the model implies **{fmt_currency(implied_price)} per share**, "
- f"which is **{fmt_currency(abs(valuation_gap))} {market_message}** the current market price of "
- f"**{fmt_currency(current_price)}**."
+ f"At **{target_multiple:.1f}x revenue**, the model implies **{implied_value} per share**, "
+ f"which is **{gap_value} {market_message}** the current market price of "
+ f"**{current_value}**."
)
calc_a, calc_b, calc_c, calc_d = st.columns(4)