diff options
Diffstat (limited to 'components')
| -rw-r--r-- | components/valuation.py | 29 |
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) |
