From 63cf6a29da4436be3a6ce2eaf5e281f0230edb54 Mon Sep 17 00:00:00 2001 From: anor Date: Tue, 10 Mar 2026 00:10:41 +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=20Telegram-=D0=BE=D1=82?= =?UTF-8?q?=D1=87=D1=91=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Добавить плечо и таймфрейм в секцию позиций - Non-breaking spaces для правильных отступов в Telegram - Показывать TF в статистике по каждому активу Co-Authored-By: Claude Opus 4.6 --- src/remizov_trader/notify.py | 57 ++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/src/remizov_trader/notify.py b/src/remizov_trader/notify.py index ab930d8..546439c 100644 --- a/src/remizov_trader/notify.py +++ b/src/remizov_trader/notify.py @@ -117,71 +117,66 @@ def format_status_report(cfg, conn) -> str: cur_price = _get_current_price(cfg, a["ticker"]) open_positions.append((a, pos, cur_price)) - lines = ["\U0001f4ca RemizovTrader"] - lines.append("") + S = "\u00a0" # non-breaking space for Telegram + lines = ["\U0001f4ca RemizovTrader", ""] # --- Portfolio --- - lines.append(f"\U0001f4b0 Портфель") - lines.append(f" Баланс: ${exchange_balance:,.2f} ({total_pct:+.1f}%)") - lines.append(f" PnL: ${total_pnl:+,.2f}") + lines.append("\U0001f4b0 Портфель") + lines.append(f"{S*3}Баланс: ${exchange_balance:,.2f} ({total_pct:+.1f}%)") + lines.append(f"{S*3}PnL: ${total_pnl:+,.2f}") lines.append("") if open_positions: lines.append(f"\U0001f4c8 Позиции ({len(open_positions)}/{cfg.risk.max_open_positions})") for a, pos, cur_price in open_positions: d = "\U0001f7e2 LONG" if pos["direction"] == 1 else "\U0001f534 SHORT" - # Find per-asset timeframe - _tf = cfg.timeframe - for ac in cfg.assets: - if ac.ticker == a["ticker"]: - _tf = ac.timeframe or cfg.timeframe - break + ac = next((x for x in cfg.assets if x.ticker == a["ticker"]), None) + _tf = (ac.timeframe if ac and ac.timeframe else cfg.timeframe) + lev = cfg.leverage_for(ac) if ac else cfg.risk.leverage entry = pos["entry_price"] stop = pos["stop_price"] size = pos["pos_value"] pos_size = pos["pos_size"] risk_pct = abs(entry - stop) / entry * 100 + pnl_str = "" if cur_price: upnl = pos_size * (cur_price - entry) * pos["direction"] upnl_pct = (cur_price / entry - 1) * 100 * pos["direction"] pnl_icon = "\U0001f7e2" if upnl >= 0 else "\U0001f534" - pnl_str = f"\n {pnl_icon} PnL: ${upnl:+,.2f} ({upnl_pct:+.1f}%) @ ${cur_price:,.2f}" - else: - pnl_str = "" + pnl_str = f"\n{S*6}{pnl_icon} PnL: ${upnl:+,.2f} ({upnl_pct:+.1f}%) @ ${cur_price:,.2f}" - lines.append(f" {a['ticker']} ({_tf}): {d}") - lines.append(f" Вход: ${entry:,.2f} | Стоп: ${stop:,.2f} ({risk_pct:.1f}%)") - lines.append(f" Размер: ${size:,.2f}{pnl_str}") + lines.append("") + lines.append(f"{S*3}{a['ticker']} {_tf} {lev}x") + lines.append(f"{S*6}{d} @ ${entry:,.2f}") + lines.append(f"{S*6}Стоп: ${stop:,.2f} ({risk_pct:.1f}%) | ${size:,.2f}{pnl_str}") else: - lines.append(f"\U0001f4c8 Позиции: нет") + lines.append("\U0001f4c8 Позиции: нет") lines.append("") # --- Stats per asset --- - lines.append(f"\U0001f4ca Статистика") + lines.append("\U0001f4ca Статистика") for a in assets: trades = a["trades_count"] wr = a["wins"] / trades * 100 if trades > 0 else 0 cb = " \u26a0\ufe0f CB" if a["cb_active"] else "" - # Show per-asset weight/ws if configured ac = next((x for x in cfg.assets if x.ticker == a["ticker"]), None) - extra = "" - if ac and ac.weight > 0: + if ac: + _tf = ac.timeframe or cfg.timeframe lev = cfg.leverage_for(ac) ws = ac.window_size or cfg.model.window_size - extra = f" | ws={ws} {lev}x {ac.weight*100:.0f}%" - lines.append(f" {a['ticker']}: {trades} сделок, WR {wr:.0f}%{extra}{cb}") + w_pct = f"{ac.weight*100:.0f}%" if ac.weight > 0 else "" + extra = f" | {_tf} ws={ws} {lev}x {w_pct}" + else: + extra = "" + lines.append(f"{S*3}{a['ticker']}: {trades} сд. WR {wr:.0f}%{extra}{cb}") lines.append("") # --- Settings --- - lines.append(f"\u2699\ufe0f Настройки") + lines.append("\u2699\ufe0f Настройки") tfs = sorted(set(a.timeframe or cfg.timeframe for a in cfg.assets)) - tf_str = "/".join(tfs) - lines.append(f" {cfg.mode} | TF: {tf_str} | " - 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") + lines.append(f"{S*3}{cfg.mode} | TF: {'/'.join(tfs)} | " + f"риск {cfg.risk.per_trade*100:.0f}%") return "\n".join(lines)