fix: add SL sanity check on open_position; add entry_ts display in paper-v53 positions

This commit is contained in:
root 2026-03-04 01:15:09 +00:00
parent 91a8e7a1ea
commit 3352489ce9
2 changed files with 12 additions and 0 deletions

View File

@ -1088,6 +1088,15 @@ def paper_open_trade(
tp1 = price - tp1_multiplier * atr tp1 = price - tp1_multiplier * atr
tp2 = price - tp2_multiplier * atr tp2 = price - tp2_multiplier * atr
# SL 合理性校验:实际距离必须在 risk_distance 的 80%~120% 范围内
actual_sl_dist = abs(sl - price)
if actual_sl_dist < risk_distance * 0.8 or actual_sl_dist > risk_distance * 1.2:
logger.error(
f"[{symbol}] ⚠️ SL校验失败拒绝开仓: direction={direction} price={price:.4f} "
f"sl={sl:.4f} actual_dist={actual_sl_dist:.4f} expected={risk_distance:.4f} atr={atr:.4f}"
)
return
with get_sync_conn() as conn: with get_sync_conn() as conn:
with conn.cursor() as cur: with conn.cursor() as cur:
cur.execute( cur.execute(

View File

@ -207,6 +207,9 @@ function ActivePositions() {
<span className="text-emerald-600">TP2: ${fmtPrice(p.tp2_price)}</span> <span className="text-emerald-600">TP2: ${fmtPrice(p.tp2_price)}</span>
<span className="text-red-500">SL: ${fmtPrice(p.sl_price)}</span> <span className="text-red-500">SL: ${fmtPrice(p.sl_price)}</span>
</div> </div>
<div className="mt-1 text-[9px] text-slate-400">
: {p.entry_ts ? new Date(p.entry_ts).toLocaleString("zh-CN", {hour12:false, month:"2-digit", day:"2-digit", hour:"2-digit", minute:"2-digit", second:"2-digit"} as any) : "-"}
</div>
</div> </div>
); );
})} })}