This commit is contained in:
薇薇安 2026-01-19 22:31:27 +08:00
parent 17e3d10d89
commit 899171d434

View File

@ -232,8 +232,9 @@ async def ensure_position_sltp(symbol: str):
except HTTPException:
raise
except Exception as e:
logger.error(f"{symbol} 补挂止盈止损失败: {e}", exc_info=True)
raise HTTPException(status_code=500, detail=f"补挂止盈止损失败: {str(e)}")
msg = str(e) or repr(e) or "unknown error"
logger.error(f"{symbol} 补挂止盈止损失败: {msg}", exc_info=True)
raise HTTPException(status_code=500, detail=f"补挂止盈止损失败: {msg}")
@router.post("/positions/sltp/ensure-all")
@ -277,8 +278,18 @@ async def ensure_all_positions_sltp(limit: int = Query(50, ge=1, le=200, descrip
"open_protection_orders": res.get("open_protection_orders"),
}
)
except HTTPException as he:
errors.append(
{
"symbol": sym,
"ok": False,
"status_code": getattr(he, "status_code", None),
"detail": getattr(he, "detail", None),
}
)
except Exception as e:
errors.append({"symbol": sym, "ok": False, "error": str(e)})
msg = str(e) or repr(e) or "unknown error"
errors.append({"symbol": sym, "ok": False, "error": msg})
return {
"total": len(symbols),