fix: deduplicate blocked intents in daily Discord report

Show unique (strategy, symbol) combinations with tick-count instead of
listing every blocked intent individually. Submitted and error entries
remain per-item. Eliminates the 96+ duplicate lines in the daily summary.
This commit is contained in:
2026-04-17 21:20:58 +02:00
parent f2caca9175
commit 5962c56949
+36 -11
View File
@@ -52,19 +52,44 @@ def build_daily_summary(
lines.append("")
submitted = [i for i in intents_today if i.get("submitted")]
dry = [i for i in intents_today if not i.get("submitted")]
blocked = [i for i in intents_today if i.get("status") == "blocked"]
errors = [i for i in intents_today if i.get("status") == "error"]
dry = [i for i in intents_today if i.get("status") == "dry_run"]
lines.append(
f"**Today's orders:** {len(submitted)} submitted · {len(dry)} dry/blocked"
f"**Today's activity:** {len(submitted)} submitted · "
f"{len(blocked)} blocked · {len(errors)} errors · {len(dry)} dry-run"
)
for i in intents_today[:20]:
tag = "" if i.get("submitted") else "·"
details = i.get("details_json")
lines.append(
f" {tag} [{i['strategy']}] {i['side']} {i['symbol']} qty={i['qty']} "
f"type={i['order_type']} status={i.get('status')}"
)
if len(intents_today) > 20:
lines.append(f"{len(intents_today)-20} more")
# Submitted orders — show each individually
if submitted:
lines.append(" Submitted:")
for i in submitted[:15]:
lines.append(
f" ✓ [{i['strategy']}] {i['side']} {i['symbol']} "
f"qty={i['qty']} · {i.get('alpaca_order_id', '')[:8]}"
)
if len(submitted) > 15:
lines.append(f"{len(submitted)-15} more")
# Errors — always show (actionable)
if errors:
lines.append(" Errors:")
for i in errors[:10]:
lines.append(f"{i['symbol']} {i['side']} — check logs")
# Blocked — deduplicate by (strategy, symbol), show unique with count
if blocked:
seen: dict[str, int] = {}
for i in blocked:
key = f"{i['strategy']}:{i['symbol']}"
seen[key] = seen.get(key, 0) + 1
lines.append(f" Blocked (unique: {len(seen)}, total ticks: {len(blocked)}):")
for key, count in list(seen.items())[:10]:
strategy, symbol = key.split(":", 1)
lines.append(f" · [{strategy}] {symbol} ×{count}")
if len(seen) > 10:
lines.append(f"{len(seen)-10} more")
return "\n".join(lines)