处理问题

This commit is contained in:
zlt 2026-08-03 10:49:15 +08:00
parent 2f1dcf3373
commit 32f18a5461
1 changed files with 25 additions and 4 deletions

View File

@ -148,28 +148,49 @@ def account():
def instructions():
"""今日一栏必须写成「投/余/废」三个数, 不能只印一个剩余量。
2026-08-03 实机教训: 当日配额已出完这一句, 在两种完全相反的情形下长得一模一样
(a) 该投的都投出去了单子正挂着 (正常) (b) 分片到期作废一股没成却把额度吃光了
(bug)用户盯着同一句话反复调试, 而真正的区别在**投出去的那些现在是什么下场**
三个数一摆就分得开: 作废那栏不是 0, 就说明有额度被白占过
"""
from app.repo import pms_repo
from app.services import executor
rows = pms_repo.list_instructions(statuses=list(LIVE_INS), limit=50)
_sec(f"在途指令 {len(rows)}")
if not rows:
print(" (无) —— 方案还没转指令就跑 make t-mat; 一条方案都没有就先下命令")
return
from datetime import datetime
ymd = int(datetime.now().strftime("%Y%m%d"))
print(" " + _pad("代码", 11) + _pad("方向", 5) + _pad("总量", 8)
+ _pad("已成", 7) + _pad("状态", 11) + _pad("配额", 7) + "最近裁决")
+ _pad("已成", 7) + _pad("状态", 11) + _pad("今日 投/余/废", 15) + "最近裁决")
for r in rows:
d = (r.get("progress") or {}).get("last_decision") or {}
prog = r.get("progress") or {}
d = prog.get("last_decision") or {}
act = d.get("action") or ""
mark = {"FIRE": "", "WAIT": "·", "STOP": "", "SKIP": ""}.get(act, " ")
why = _short(d.get("reason") or "(本轮还没轮到它)", 26)
why = _short(d.get("reason") or "(本轮还没轮到它)", 24)
at = d.get("at") or ""
kids = [c for c in (prog.get("children") or []) if int(c.get("ymd") or 0) == ymd]
try:
used = executor._consumed_today(kids, ymd)
except Exception:
used = sum(int(c.get("qty") or 0) for c in kids)
void = sum(int(c.get("qty") or 0) for c in kids) - used
left = d.get("qty_hint")
left = "" if left is None else str(left)
q = f"{used}/{left}/{void}"
print(" " + _pad(r["ts_code"], 11)
+ _pad("" if r["side"] == "buy" else "", 5)
+ _pad(str(r["qty"]), 8)
+ _pad(str(r.get("exec_qty") or 0), 7)
+ _pad(r["status"], 11)
+ _pad(str(d.get("qty_hint") or ""), 7)
+ _pad(q, 15)
+ f"{mark} {at} {act} {why}")
print(" 裁决: ▶出手 ·等条件(待会儿再看) ■本日停手(如不追高) ○当日跳过(停牌/一字板)")
print(" 今日 投/余/废 = 今天已投放(仍在途或已成)/本日剩余额度/到期作废已退回额度的量")
def outbound():