diff --git a/docs/binance-orderbook-trade-development.md b/docs/binance-orderbook-trade-development.md index 8a2cc57..006ed6b 100644 --- a/docs/binance-orderbook-trade-development.md +++ b/docs/binance-orderbook-trade-development.md @@ -153,7 +153,7 @@ Every Binance UI automation change must report the evidence used: live DOM or st Do not auto-confirm destructive Binance dialogs. The script may open Binance's native cancel confirmation, but final confirmation remains manual. -USDT account rebalancing is a manual action, not an automatic post-close side effect. The inline `再平衡` action becomes available only after the account-order widget has continuously reported zero positions and zero open orders for three seconds, and a fresh all-symbol futures-position response also confirms that every position is flat. Starting any script trade or cancel task invalidates that eligibility immediately. +USDT account rebalancing is a manual action, not an automatic post-close side effect. The inline `账户再平衡` action becomes available only after the account-order widget has continuously reported zero positions and zero open orders for three seconds, and a fresh all-symbol futures-position response also confirms that every position is flat. Starting any script trade or cancel task invalidates that eligibility immediately. The rebalance path is pinned to the current Binance page bundle contract instead of automating the native transfer dialog. It reads Spot and Funding available USDT from `/bapi/asset/v2/private/asset-service/wallet/balance`, reads the U-M Futures transferable amount from `/bapi/futures/v1/private/future/user-data/getMaxWithdrawAmount`, and submits at most two sequential transfers through `/bapi/asset/v1/private/asset-service/wallet/transfer` with `{ asset, amount, kindType }`. Wallet rows are identified by the stable `accountType` values `MAIN`, `CARD`, and `FUTURE`; `walletName` is localized and must not be used as an identifier. The private transfer BAPI uses those same account codes; do not substitute the public SAPI names `FUNDING` or `UMFUTURE`. It does not save an API key and does not fall back to DOM clicking if this private BAPI contract changes. diff --git a/scripts/binance-orderbook-trade.user.js b/scripts/binance-orderbook-trade.user.js index 2ae8670..0f97cc9 100644 --- a/scripts/binance-orderbook-trade.user.js +++ b/scripts/binance-orderbook-trade.user.js @@ -3,7 +3,7 @@ // @namespace binance.orderbook.trade // @icon data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2064%2064%22%3E%3Crect%20width%3D%2264%22%20height%3D%2264%22%20rx%3D%2214%22%20fill%3D%22%23f0b90b%22%2F%3E%3Ctext%20x%3D%2232%22%20y%3D%2249%22%20text-anchor%3D%22middle%22%20font-family%3D%22Arial%2C%20sans-serif%22%20font-size%3D%2242%22%20font-weight%3D%22800%22%20fill%3D%22%23111827%22%3EJ%3C%2Ftext%3E%3C%2Fsvg%3E // @icon64 data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2064%2064%22%3E%3Crect%20width%3D%2264%22%20height%3D%2264%22%20rx%3D%2214%22%20fill%3D%22%23f0b90b%22%2F%3E%3Ctext%20x%3D%2232%22%20y%3D%2249%22%20text-anchor%3D%22middle%22%20font-family%3D%22Arial%2C%20sans-serif%22%20font-size%3D%2242%22%20font-weight%3D%22800%22%20fill%3D%22%23111827%22%3EJ%3C%2Ftext%3E%3C%2Fsvg%3E -// @version 2.7.166 +// @version 2.7.167 // @author jackhai9 // @description 单击订单簿价格,按当前开仓/平仓 tab 自动填数量并执行下单,内置数量倍率面板 // @match https://www.binance.com/*/futures/* @@ -7406,7 +7406,7 @@ async function runUsdtRebalance() { let plan = null; let completed = 0; - setLadderStatus("正在读取再平衡计划"); + setLadderStatus("正在读取账户再平衡计划"); try { await assertUsdtRebalanceTradingState(); const initialBalances = await readCurrentUsdtRebalanceBalances(); @@ -7417,7 +7417,7 @@ return { status: "already_balanced", plan }; } if (!window.confirm(formatUsdtRebalanceConfirmation(plan))) { - setLadderStatus("再平衡已取消"); + setLadderStatus("账户再平衡已取消"); return { status: "cancelled", plan }; } let expectedBalances = initialBalances; @@ -7425,20 +7425,20 @@ await assertUsdtRebalanceTradingState(); const currentBalances = await readCurrentUsdtRebalanceBalances(); if (!areUsdtBalancesEqual(currentBalances, expectedBalances)) { - throw new Error("账户余额已变化,已停止再平衡"); + throw new Error("账户余额已变化,已停止账户再平衡"); } - setLadderStatus(`再平衡中 · ${completed + 1}/${plan.transfers.length} 笔`); + setLadderStatus(`账户再平衡中 · ${completed + 1}/${plan.transfers.length} 笔`); await submitUsdtRebalanceTransfer(transfer); completed += 1; expectedBalances = applyUsdtTransferToBalances(expectedBalances, transfer); await waitForUsdtRebalanceBalances(expectedBalances); } usdtRebalanceEligible = false; - setLadderStatus(`再平衡已完成 · ${completed}/${plan.transfers.length} 笔`); + setLadderStatus(`账户再平衡已完成 · ${completed}/${plan.transfers.length} 笔`); return { status: "completed", plan, completed }; } catch (error) { const message = error?.name === "AbortError" ? "Binance 请求超时" : error?.message || String(error); - const prefix = completed > 0 && plan ? `再平衡部分完成 · ${completed}/${plan.transfers.length} 笔` : "再平衡失败"; + const prefix = completed > 0 && plan ? `账户再平衡部分完成 · ${completed}/${plan.transfers.length} 笔` : "账户再平衡失败"; setLadderStatus(`${prefix} · ${message}`, message); throw error; } @@ -8385,7 +8385,7 @@ "", `
`, `空闲`, - ``, + ``, "
" ].join(""); panelPositionInvalidated = true; diff --git a/src/binance-orderbook-trade/index.user.js b/src/binance-orderbook-trade/index.user.js index 5a2a02e..118a108 100644 --- a/src/binance-orderbook-trade/index.user.js +++ b/src/binance-orderbook-trade/index.user.js @@ -3,7 +3,7 @@ // @namespace binance.orderbook.trade // @icon data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2064%2064%22%3E%3Crect%20width%3D%2264%22%20height%3D%2264%22%20rx%3D%2214%22%20fill%3D%22%23f0b90b%22%2F%3E%3Ctext%20x%3D%2232%22%20y%3D%2249%22%20text-anchor%3D%22middle%22%20font-family%3D%22Arial%2C%20sans-serif%22%20font-size%3D%2242%22%20font-weight%3D%22800%22%20fill%3D%22%23111827%22%3EJ%3C%2Ftext%3E%3C%2Fsvg%3E // @icon64 data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2064%2064%22%3E%3Crect%20width%3D%2264%22%20height%3D%2264%22%20rx%3D%2214%22%20fill%3D%22%23f0b90b%22%2F%3E%3Ctext%20x%3D%2232%22%20y%3D%2249%22%20text-anchor%3D%22middle%22%20font-family%3D%22Arial%2C%20sans-serif%22%20font-size%3D%2242%22%20font-weight%3D%22800%22%20fill%3D%22%23111827%22%3EJ%3C%2Ftext%3E%3C%2Fsvg%3E -// @version 2.7.166 +// @version 2.7.167 // @author jackhai9 // @description 单击订单簿价格,按当前开仓/平仓 tab 自动填数量并执行下单,内置数量倍率面板 // @match https://www.binance.com/*/futures/* @@ -5574,7 +5574,7 @@ import { async function runUsdtRebalance() { let plan = null; let completed = 0; - setLadderStatus('正在读取再平衡计划'); + setLadderStatus('正在读取账户再平衡计划'); try { await assertUsdtRebalanceTradingState(); const initialBalances = await readCurrentUsdtRebalanceBalances(); @@ -5585,7 +5585,7 @@ import { return { status: 'already_balanced', plan }; } if (!window.confirm(formatUsdtRebalanceConfirmation(plan))) { - setLadderStatus('再平衡已取消'); + setLadderStatus('账户再平衡已取消'); return { status: 'cancelled', plan }; } @@ -5594,24 +5594,24 @@ import { await assertUsdtRebalanceTradingState(); const currentBalances = await readCurrentUsdtRebalanceBalances(); if (!areUsdtBalancesEqual(currentBalances, expectedBalances)) { - throw new Error('账户余额已变化,已停止再平衡'); + throw new Error('账户余额已变化,已停止账户再平衡'); } - setLadderStatus(`再平衡中 · ${completed + 1}/${plan.transfers.length} 笔`); + setLadderStatus(`账户再平衡中 · ${completed + 1}/${plan.transfers.length} 笔`); await submitUsdtRebalanceTransfer(transfer); completed += 1; expectedBalances = applyUsdtTransferToBalances(expectedBalances, transfer); await waitForUsdtRebalanceBalances(expectedBalances); } usdtRebalanceEligible = false; - setLadderStatus(`再平衡已完成 · ${completed}/${plan.transfers.length} 笔`); + setLadderStatus(`账户再平衡已完成 · ${completed}/${plan.transfers.length} 笔`); return { status: 'completed', plan, completed }; } catch (error) { const message = error?.name === 'AbortError' ? 'Binance 请求超时' : (error?.message || String(error)); const prefix = completed > 0 && plan - ? `再平衡部分完成 · ${completed}/${plan.transfers.length} 笔` - : '再平衡失败'; + ? `账户再平衡部分完成 · ${completed}/${plan.transfers.length} 笔` + : '账户再平衡失败'; setLadderStatus(`${prefix} · ${message}`, message); throw error; } @@ -6710,7 +6710,7 @@ import { '', `
`, `空闲`, - ``, + ``, '
', ].join(''); panelPositionInvalidated = true;