From 38b02fd05bfee4dc8a2487283d0a147a0050cd56 Mon Sep 17 00:00:00 2001 From: anor Date: Mon, 9 Mar 2026 06:36:44 +1000 Subject: [PATCH] =?UTF-8?q?fix:=20=D1=83=D0=BB=D1=83=D1=87=D1=88=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=82=D0=B8=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20/status=20=D0=B2=20Teleg?= =?UTF-8?q?ram?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Разделение на блоки: Портфель, Позиции, Статистика, Настройки. Co-Authored-By: Claude Opus 4.6 --- src/remizov_trader/notify.py | 75 ++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/src/remizov_trader/notify.py b/src/remizov_trader/notify.py index e8ddaac..028a748 100644 --- a/src/remizov_trader/notify.py +++ b/src/remizov_trader/notify.py @@ -52,50 +52,59 @@ def format_status_report(cfg, conn) -> str: """Format full status report for Telegram.""" from .state import get_all_assets, get_open_position - lines = ["\U0001f4ca RemizovTrader — СТАТУС", ""] - assets = get_all_assets(conn) - total_equity = 0.0 - total_initial = 0.0 - open_positions = [] - - for a in assets: - total_equity += a["equity"] - total_initial += cfg.initial_capital - pos = get_open_position(conn, a["ticker"]) - if pos: - d = "LONG" if pos["direction"] == 1 else "SHORT" - pv = pos["pos_value"] - stop = pos["stop_price"] - open_positions.append(f" {a['ticker']}: {d} @ ${pos['entry_price']:,.2f} " - f"(${pv:,.2f}, stop ${stop:,.2f})") - + total_equity = sum(a["equity"] for a in assets) + total_initial = cfg.initial_capital * len(assets) if assets else cfg.initial_capital total_pnl = total_equity - total_initial total_pct = (total_equity / total_initial - 1) * 100 if total_initial > 0 else 0 - lines.append(f"Капитал: ${total_equity:,.2f} ({total_pct:+.1f}%)") - lines.append(f"PnL: ${total_pnl:+,.2f}") + lines = ["\U0001f4ca RemizovTrader"] lines.append("") + # --- Portfolio --- + lines.append(f"\U0001f4b0 Портфель") + lines.append(f" Капитал: ${total_equity:,.2f} ({total_pct:+.1f}%)") + lines.append(f" PnL: ${total_pnl:+,.2f}") + lines.append("") + + # --- Open positions --- + open_positions = [] + for a in assets: + pos = get_open_position(conn, a["ticker"]) + if pos: + open_positions.append((a, pos)) + if open_positions: - lines.append(f"Открытые позиции ({len(open_positions)}/{cfg.risk.max_open_positions}):") - lines.extend(open_positions) + lines.append(f"\U0001f4c8 Позиции ({len(open_positions)}/{cfg.risk.max_open_positions})") + for a, pos in open_positions: + d = "\U0001f7e2 LONG" if pos["direction"] == 1 else "\U0001f534 SHORT" + entry = pos["entry_price"] + stop = pos["stop_price"] + size = pos["pos_value"] + risk_pct = abs(entry - stop) / entry * 100 + lines.append(f" {a['ticker']}: {d}") + lines.append(f" Вход: ${entry:,.2f} | Стоп: ${stop:,.2f} ({risk_pct:.1f}%)") + lines.append(f" Размер: ${size:,.2f}") else: - lines.append(f"Открытые позиции: 0/{cfg.risk.max_open_positions}") - + lines.append(f"\U0001f4c8 Позиции: нет") lines.append("") - lines.append("Активы:") + + # --- Stats per asset --- + lines.append(f"\U0001f4ca Статистика") for a in assets: - wr = a["wins"] / a["trades_count"] * 100 if a["trades_count"] > 0 else 0 - cb = " [CB]" if a["cb_active"] else "" - lines.append(f" {a['ticker']}: ${a['equity']:,.2f} | " - f"{a['trades_count']} сделок, WR {wr:.0f}%{cb}") - + trades = a["trades_count"] + wr = a["wins"] / trades * 100 if trades > 0 else 0 + cb = " \u26a0\ufe0f CB" if a["cb_active"] else "" + lines.append(f" {a['ticker']}: {trades} сделок, WR {wr:.0f}%{cb}") lines.append("") - lines.append(f"Режим: {cfg.mode} | TF: {cfg.timeframe}") - leverage_str = f" | Плечо: {cfg.risk.leverage}x" if cfg.risk.leverage > 1 else "" - lines.append(f"Риск: {cfg.risk.per_trade*100:.0f}% | " - f"Макс. позиция: {cfg.risk.max_position_pct*100:.0f}%{leverage_str}") + + # --- Settings --- + lines.append(f"\u2699\ufe0f Настройки") + lines.append(f" {cfg.mode} | {cfg.timeframe} | " + f"риск {cfg.risk.per_trade*100:.0f}% | " + f"макс {cfg.risk.max_position_pct*100:.0f}%") + if cfg.risk.leverage > 1: + lines.append(f" Плечо: {cfg.risk.leverage}x") return "\n".join(lines)