fix: улучшить форматирование Telegram-отчёта
- Добавить плечо и таймфрейм в секцию позиций - Non-breaking spaces для правильных отступов в Telegram - Показывать TF в статистике по каждому активу Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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 <b>RemizovTrader</b>"]
|
||||
lines.append("")
|
||||
S = "\u00a0" # non-breaking space for Telegram
|
||||
lines = ["\U0001f4ca <b>RemizovTrader</b>", ""]
|
||||
|
||||
# --- Portfolio ---
|
||||
lines.append(f"\U0001f4b0 <b>Портфель</b>")
|
||||
lines.append(f" Баланс: <b>${exchange_balance:,.2f}</b> ({total_pct:+.1f}%)")
|
||||
lines.append(f" PnL: ${total_pnl:+,.2f}")
|
||||
lines.append("\U0001f4b0 <b>Портфель</b>")
|
||||
lines.append(f"{S*3}Баланс: <b>${exchange_balance:,.2f}</b> ({total_pct:+.1f}%)")
|
||||
lines.append(f"{S*3}PnL: ${total_pnl:+,.2f}")
|
||||
lines.append("")
|
||||
|
||||
if open_positions:
|
||||
lines.append(f"\U0001f4c8 <b>Позиции</b> ({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}<b>{a['ticker']}</b> {_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 <b>Позиции:</b> нет")
|
||||
lines.append("\U0001f4c8 <b>Позиции:</b> нет")
|
||||
lines.append("")
|
||||
|
||||
# --- Stats per asset ---
|
||||
lines.append(f"\U0001f4ca <b>Статистика</b>")
|
||||
lines.append("\U0001f4ca <b>Статистика</b>")
|
||||
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 <b>Настройки</b>")
|
||||
lines.append("\u2699\ufe0f <b>Настройки</b>")
|
||||
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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user