u
This commit is contained in:
parent
ae9f4cf87c
commit
c0fac4b870
@ -151,14 +151,32 @@ def check_abnormal_orders():
|
||||
# 6. 最近的活动日志
|
||||
print("【6】最近10条订单变更记录(按时间倒序):")
|
||||
print("-" * 80)
|
||||
recent_orders = db.query(PaperOrder).order_by(
|
||||
PaperOrder.updated_at.desc()
|
||||
).limit(10).all()
|
||||
# 使用 COALESCE 来优先显示 closed_at,其次 opened_at,最后 created_at
|
||||
recent_orders = db.execute(text("""
|
||||
SELECT
|
||||
COALESCE(closed_at, opened_at, created_at) as last_time,
|
||||
symbol,
|
||||
side,
|
||||
status,
|
||||
entry_price,
|
||||
filled_price
|
||||
FROM paper_orders
|
||||
ORDER BY last_time DESC
|
||||
LIMIT 10
|
||||
""")).fetchall()
|
||||
|
||||
for order in recent_orders:
|
||||
print(f" {order.updated_at.strftime('%H:%M:%S')} | {order.symbol} | "
|
||||
f"{order.side.value:4s} | {order.status.value:15s} | "
|
||||
f"入场:{order.entry_price} 成交:{order.filled_price}")
|
||||
last_time = order[0]
|
||||
symbol = order[1]
|
||||
side = order[2]
|
||||
status = order[3]
|
||||
entry_price = order[4]
|
||||
filled_price = order[5]
|
||||
|
||||
time_str = last_time.strftime('%H:%M:%S') if last_time else 'N/A'
|
||||
filled_str = f"{filled_price:.2f}" if filled_price else "NULL"
|
||||
print(f" {time_str} | {symbol} | {side:4s} | {status:15s} | "
|
||||
f"入场:{entry_price:.2f} 成交:{filled_str}")
|
||||
print()
|
||||
|
||||
print("=" * 80)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user