a
This commit is contained in:
parent
6e922d7921
commit
17e3d10d89
|
|
@ -269,7 +269,14 @@ async def ensure_all_positions_sltp(limit: int = Query(50, ge=1, le=200, descrip
|
|||
for sym in symbols:
|
||||
try:
|
||||
res = await _ensure_exchange_sltp_for_symbol(sym)
|
||||
results.append({"symbol": sym, "ok": True, "orders": res.get("orders")})
|
||||
results.append(
|
||||
{
|
||||
"symbol": sym,
|
||||
"ok": True,
|
||||
"orders": res.get("orders"),
|
||||
"open_protection_orders": res.get("open_protection_orders"),
|
||||
}
|
||||
)
|
||||
except Exception as e:
|
||||
errors.append({"symbol": sym, "ok": False, "error": str(e)})
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ const StatsDashboard = () => {
|
|||
const [closingSymbol, setClosingSymbol] = useState(null)
|
||||
const [sltpSymbol, setSltpSymbol] = useState(null)
|
||||
const [sltpAllBusy, setSltpAllBusy] = useState(false)
|
||||
const [sltpDebugText, setSltpDebugText] = useState('')
|
||||
const [message, setMessage] = useState('')
|
||||
const [tradingConfig, setTradingConfig] = useState(null)
|
||||
|
||||
|
|
@ -113,12 +114,14 @@ const StatsDashboard = () => {
|
|||
}
|
||||
setSltpSymbol(symbol)
|
||||
setMessage('')
|
||||
setSltpDebugText('')
|
||||
try {
|
||||
const res = await api.ensurePositionSLTP(symbol)
|
||||
const slId = res?.orders?.stop_market?.orderId
|
||||
const tpId = res?.orders?.take_profit_market?.orderId
|
||||
const cnt = Array.isArray(res?.open_protection_orders) ? res.open_protection_orders.length : 0
|
||||
setMessage(`${symbol} 已补挂保护单:SL=${slId || '-'} / TP=${tpId || '-'}(币安条件单可见,当前检测到保护单 ${cnt} 条)`)
|
||||
setMessage(`${symbol} 已尝试补挂:SL=${slId || '-'} / TP=${tpId || '-'}(当前检测到保护单 ${cnt} 条)`)
|
||||
setSltpDebugText(JSON.stringify(res || {}, null, 2))
|
||||
await loadDashboard()
|
||||
} catch (error) {
|
||||
setMessage(`补挂失败 ${symbol}: ${error.message || '未知错误'}`)
|
||||
|
|
@ -134,11 +137,20 @@ const StatsDashboard = () => {
|
|||
}
|
||||
setSltpAllBusy(true)
|
||||
setMessage('')
|
||||
setSltpDebugText('')
|
||||
try {
|
||||
const res = await api.ensureAllPositionsSLTP(50)
|
||||
const ok = res?.ok ?? 0
|
||||
const failed = res?.failed ?? 0
|
||||
setMessage(`一键补挂完成:成功 ${ok} / 失败 ${failed}(请在币安【条件单/止盈止损】里查看)`)
|
||||
let openCnt = 0
|
||||
try {
|
||||
const arr = Array.isArray(res?.results) ? res.results : []
|
||||
openCnt = arr.reduce((acc, it) => acc + (Array.isArray(it?.open_protection_orders) ? it.open_protection_orders.length : 0), 0)
|
||||
} catch (e) {
|
||||
openCnt = 0
|
||||
}
|
||||
setMessage(`一键补挂完成:成功 ${ok} / 失败 ${failed}(检测到保护单 ${openCnt} 条)`)
|
||||
setSltpDebugText(JSON.stringify(res || {}, null, 2))
|
||||
await loadDashboard()
|
||||
} catch (error) {
|
||||
setMessage(`一键补挂失败: ${error.message || '未知错误'}`)
|
||||
|
|
@ -227,6 +239,14 @@ const StatsDashboard = () => {
|
|||
{message && (
|
||||
<div className={`message ${message.includes('失败') || message.includes('错误') ? 'error' : 'success'}`}>
|
||||
{message}
|
||||
{sltpDebugText ? (
|
||||
<details style={{ marginTop: '8px' }}>
|
||||
<summary style={{ cursor: 'pointer' }}>查看补挂返回详情(用于排查)</summary>
|
||||
<pre style={{ marginTop: '8px', whiteSpace: 'pre-wrap', wordBreak: 'break-word', fontSize: '12px' }}>
|
||||
{sltpDebugText}
|
||||
</pre>
|
||||
</details>
|
||||
) : null}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user