Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions docs/binance-orderbook-trade-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,20 @@ and the evidence report contract are owned by

Do not auto-confirm destructive Binance dialogs. The script may open Binance's native cancel confirmation, but final confirmation remains manual.

USDT account rebalancing has separate automatic excess withdrawal and manual full-allocation paths. The inline `账户再平衡` action becomes available only after the account-order widget has continuously reported zero positions and zero open orders for two 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. When a cancellation or continuous-close task ends, readable zero account counters restart the same guarded eligibility window even if the counts did not change during the task or the earlier check was blocked by the running task. A continuous session restarts this window only after the whole session ends, not between rounds. Hidden pages defer qualification until the existing visibility lifecycle observes the account again. The action opens a script-owned native `<dialog>` styled with Binance color variables; it shows current and target balances plus the exact transfer plan, focuses Cancel by default, and proceeds only after an explicit confirmation. Escape and Cancel close it without transferring funds.

Automatic withdrawal runs once per verified globally flat episode after the same
two-second zero-counter window. Its target keeps 10% of total available USDT in
Futures, sends only Futures excess toward Funding's 50% target, and sends the
remainder to Spot. It never debits Funding or Spot, and never refills Futures.
Targets display the balances actually reachable by these outward-only transfers.
The manual action keeps its explicit confirmation and full 5:4:1 allocation.
USDT account rebalancing has automatic and manually confirmed paths that share the same full-allocation planner. The inline `账户再平衡` action becomes available only after the account-order widget has continuously reported zero positions and zero open orders for two 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. When a cancellation or continuous-close task ends, readable zero account counters restart the same guarded eligibility window even if the counts did not change during the task or the earlier check was blocked by the running task. A continuous session restarts this window only after the whole session ends, not between rounds. Hidden pages defer qualification until the existing visibility lifecycle observes the account again. The action opens a script-owned native `<dialog>` styled with Binance color variables; it shows current and target balances plus the exact transfer plan, focuses Cancel by default, and proceeds only after an explicit confirmation. Escape and Cancel close it without transferring funds.

Automatic rebalancing runs once per verified globally flat episode after the same
two-second zero-counter window. Both paths allocate total available USDT to
Funding 50%, Spot 40%, and Futures 10% through `buildUsdtRebalancePlan`.
Funding and Spot targets are floored to eight decimals; Futures receives the
remainder so the complete balance is conserved. Any of the three accounts may
donate to an underallocated account, including refilling Futures after a loss
once the account has no positions or open orders. Funding and Spot are adjusted
even when Futures already holds its target. At most two sequential transfers
complete the allocation, and unchanged final balances produce an empty plan for
either entrypoint. An empty automatic plan reports that no transfer is needed;
it does not record an automatic transfer completion. The manual action retains
its explicit confirmation.
Automatic qualification, waiting, progress, completion, and failure messages use
the separate `jh-binance-auto-rebalance-status` row. It starts hidden, uses safe
text/title updates, and retains paired Chinese/English status and progress across
Expand Down Expand Up @@ -383,6 +389,12 @@ without claiming automatic success. New authoritative activity removes the
completion marker together with the old episode; the marker never grants
transfer eligibility.

Upgrading the allocation policy preserves existing episode records. A consumed
episode, including an older completed outward-only plan, is not rerun because
its balances miss the new targets. New authoritative account activity is still
required before another automatic episode; an explicit manual rebalance can
adjust the current balances in the meantime.

Every automatic attempt and every transfer step verifies all-symbol positions,
POST `/bapi/futures/v1/private/future/order/open-orders` with `{}`, and POST
`/bapi/futures/v1/private/future/order/open-algo-order` with
Expand All @@ -400,7 +412,7 @@ The rebalance path is pinned to the current Binance page bundle contract instead

For manual full rebalancing, the user must approve one native confirmation that shows the current balances, 5:4:1 targets, and exact transfer list. After confirmation, the script rechecks all positions, all open orders, and the exact three-account balance snapshot before every transfer. Each successful response must then be reflected by a fresh balance read before the next transfer starts. An intervening position, order, or balance change stops the task; a partial completion is reported explicitly and is never retried or rolled back automatically.

Automatic withdrawal requires visibility again before each transfer. Hiding the tab after the user confirms a manual rebalance does not cancel its remaining transfers. The initial eligibility and preview still require a visible trading page; each confirmed transfer continues to require the same fresh account checks, matching balances, and current trading route while hidden.
Automatic rebalancing requires visibility again before each transfer. Hiding the tab after the user confirms a manual rebalance does not cancel its remaining transfers. The initial eligibility and preview still require a visible trading page; each confirmed transfer continues to require the same fresh account checks, matching balances, and current trading route while hidden.

Ladder replacement must stay scoped and direction-aware. Automatic replacement may cancel only visible basic open-order rows for the current symbol and the same plan direction (`开多`, `开空`, `平多`, or `平空`). It must not use current-symbol cancel-all for ladder replacement, must not touch conditional/protection orders, and must retry the ladder plan only after the replacement path is validated by current DOM rows.

Expand Down
4 changes: 2 additions & 2 deletions docs/binance-strategy27-events-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ V10 live projection. The VPS remains the only market-data and event-analysis
authority. The userscript opens no Binance market-data WebSocket, uses no
Binance API key, and does not recalculate the four force groups.

Version 0.6.10 retains this installation's private gateway configuration and
Version 0.6.11 retains this installation's private gateway configuration and
provides a shared read-only transport. Strategy29 owns its own summary panel,
lifecycle and panel position. The existing `strategy27GatewayOrigin` and
`strategy27GatewayAuthSecret` storage keys remain the single credential source;
Expand Down Expand Up @@ -183,7 +183,7 @@ ADR 032 in CorsairQuant owns the server-side rule and transport contract. The
browser does not reconstruct candidates from ordinary events or recalculate
market evidence. The client, lifecycle, panel, SVG chart layer and optional-job
controller are wired into the entrypoint and tested together. The source and
generated install artifact are version 0.6.10 with identical metadata headers.
generated install artifact are version 0.6.11 with identical metadata headers.
The generated artifact passes syntax, release-contract and isolated execution
checks, including candidate delivery, paired SVG markers, clear and context stop.
Binance operator-page validation remains outstanding. Server/gateway rollout
Expand Down
2 changes: 1 addition & 1 deletion docs/binance-strategy29-bollinger-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ already-loaded native chart candles. The summary reads the authenticated
unified loopback gateway; it does not call Binance market-data or account APIs,
submit orders, rotate hidden charts, or add remote events as chart drawings.

Install Strategy29 0.5.10 with orderbook 2.7.199 or later, or use it alone.
Install Strategy29 0.5.11 with orderbook 2.7.199 or later, or use it alone.
Install CorsairQuant signal client 0.6.7 for the remote summary.
Do not combine it with the embedded observer in orderbook 2.7.198.
After updating/disabling the old script, reload the page. An embedded observer
Expand Down
2 changes: 1 addition & 1 deletion docs/binance-strategy31-volume-reversal-development.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Strategy31 volume reversal signals

Source: `src/binance-strategy31-volume-reversal/`. Installer:
`scripts/binance-strategy31-volume-reversal.user.js` (0.1.4).
`scripts/binance-strategy31-volume-reversal.user.js` (0.1.5).
Install alongside CorsairQuant signal client 0.6.7, which owns private gateway
authentication. The shared bridge explicitly advertises the `strategy31` capability.

Expand Down
2 changes: 1 addition & 1 deletion e2e/binance-orderbook/helpers/account-lifecycle-host.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export async function openAccountLifecycleHost(page, {
orders = ORDER_SETS.current,
apiPositions = [],
leverage = 2,
balances = { FUNDING: '100', MAIN: '0', UMFUTURE: '0' },
balances = { FUNDING: '50', MAIN: '40', UMFUTURE: '10' },
} = {}) {
await installScenarioClock(page);
const loaded = await openUserscriptScenario(page, createCancelScenario({
Expand Down
8 changes: 4 additions & 4 deletions e2e/binance-orderbook/specs/account-lifecycle-behavior.pw.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,18 +362,18 @@ for (const [name, response] of [
}

test('user previews balances published during qualification instead of an earlier account snapshot', async ({ page }) => {
// Given the account begins its flat window with one hundred USDT in Funding.
// Given already balanced accounts begin their flat qualification window.
const host = await openSettledAccount(page);
await host.setNativeOrders([]);
await page.clock.runFor(1000);

// When a native wallet update moves twenty USDT to Spot before qualification completes.
host.api.setBalances({ FUNDING: '80', MAIN: '20', UMFUTURE: '0' });
// When a native wallet update doubles each balance before qualification completes.
host.api.setBalances({ FUNDING: '100', MAIN: '80', UMFUTURE: '20' });
await page.clock.runFor(1000);
await host.waitForPositionResponses(3);
await expectEligible(page);

// Then automatic qualification reads current wallets without transferring a futures deficit.
// Then automatic qualification reads the still-balanced wallets without a transfer.
const automaticWalletReads = host.api.snapshot().requests.filter(request => request.pathname === ACCOUNT_PATHS.wallets).length;
expect(automaticWalletReads).toBe(1);
await host.expectNoTradingActions();
Expand Down
8 changes: 8 additions & 0 deletions e2e/binance-orderbook/specs/account-rebalance-behavior.pw.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,18 @@ async function openRebalance(page, balances, options) {
const response = api.handle({ pathname, method: request.method(), body });
await route.fulfill({ status: response.status, contentType: 'application/json', body: JSON.stringify(response.body) });
});
// Manual scenarios start after this empty episode has already been consumed.
await page.evaluate(async () => {
const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode('fixture-account'));
const accountKey = 'userscripts:automatic-usdt-rebalance:v1:'
+ Array.from(new Uint8Array(digest), byte => byte.toString(16).padStart(2, '0')).join('');
localStorage.setItem(accountKey, JSON.stringify({ version: 1, status: 'consumed' }));
});
await page.clock.runFor(2000);
const action = page.locator('[data-usdt-rebalance]');
await expect(action).toBeVisible();
await expect(action).toBeEnabled();
await expect(page.locator('#jh-binance-auto-rebalance-status')).toHaveText('本轮不再自动执行账户再平衡');
return { api, errors, action, status: page.locator('#jh-binance-ladder-status') };
}

Expand Down
Loading
Loading