Stage 07.4.3.8 — Telegram execution alerts
This commit is contained in:
@@ -52,6 +52,34 @@ def format_usd_amount(value: float) -> str:
|
||||
return f"{value:,.2f}".replace(",", " ")
|
||||
|
||||
|
||||
def format_usd_price(value: float | int | str | None) -> str:
|
||||
if value is None:
|
||||
return "—"
|
||||
|
||||
try:
|
||||
return f"{float(value):,.2f}".replace(",", " ")
|
||||
except (TypeError, ValueError):
|
||||
return "—"
|
||||
|
||||
|
||||
def format_usd_pnl(value: float | int | str | None) -> str:
|
||||
if value is None:
|
||||
return "—"
|
||||
|
||||
try:
|
||||
pnl = float(value)
|
||||
except (TypeError, ValueError):
|
||||
return "—"
|
||||
|
||||
if pnl > 0:
|
||||
return f"🟢 +{format_usd_price(pnl)} USD"
|
||||
|
||||
if pnl < 0:
|
||||
return f"🔴 -{format_usd_price(abs(pnl))} USD"
|
||||
|
||||
return f"⚪ {format_usd_price(0)} USD"
|
||||
|
||||
|
||||
def render_currency_line(
|
||||
*,
|
||||
currency: str,
|
||||
|
||||
Reference in New Issue
Block a user