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
24 changes: 21 additions & 3 deletions docs/binance-orderbook-trade-ui-automation.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,24 @@ The assembler rejects unknown bundle fields and refuses to overwrite its input f
or an existing capture. This command is the standard boundary between CDP collection
and capture summary; do not replace it with an ad hoc Node snippet.

The current checked-in L4 reference is the isolated zero-order HYPEUSDT run. The
older captures remain immutable evidence; the active baseline comes from the latest
page-owned completion sample:
The checked-in L4 references cover the isolated zero-order path and the one-order
native cancel-dialog paths. Older captures remain immutable evidence; active
baselines come from the latest page-owned completion samples:

- `e2e/binance-orderbook/live-baselines/no-orders-2026-08-27-page-ready.capture.json`
- `e2e/binance-orderbook/live-baselines/no-orders.baseline.json`
- `e2e/binance-orderbook/live-baselines/dialog-smoke-2026-08-27.capture.json`
- `e2e/binance-orderbook/live-baselines/dialog-smoke.baseline.json`

The dialog reference used HYPEUSDT userscript `2.7.126` with one far-from-market,
Post Only test order per confirm sample. It contains three isolated cancel samples
and three isolated confirm samples. Every sample restored the page state, recorded
zero fills, left zero test-owned residual orders, and observed zero uncaught errors.
The reference medians are 66.3 ms from action click to native dialog for cancel,
85.0 ms for confirm, 43.6 ms from cancel decision to final readiness, and 1285.7 ms
from confirm decision to final readiness. These values describe one captured Chrome
and Binance environment; comparison policy, rather than a copied timing constant,
defines the regression threshold.

Each scenario kind owns one exact wall-clock segment contract. A scenario cannot add,
omit, or reorder segments independently of its kind and must contain at least three
Expand All @@ -320,6 +332,12 @@ live capacity evidence. Capacity shortfalls must skip or abort the scale explici
they must never silently relabel a smaller run as medium or large. Current leverage is
read-only evidence for this calculation and the live runner must not change it.

Capacity evidence persists `testBudget`, not the exact account balance. The caller
allocates a positive test budget no greater than the verified live balance, and the
capacity helper proves the requested order count against that budget. This preserves
the capacity contract without publishing account financial data in repository
artifacts.

`testOrderLedger` is the evidence behind the fill and cleanup claims. Its `created`,
`fills`, and `residual` collections use the same exact order identity: symbol, side,
position side, price, quantity, and creation timestamp. A fill or residual record that
Expand Down
17 changes: 11 additions & 6 deletions e2e/binance-orderbook/helpers/live-order-scale-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const PROFILE_FIELDS = [
'scaleRatios',
];
const LIVE_CONTEXT_FIELDS = [
'availableBalance',
'testBudget',
'currentLeverage',
'perOrderPrice',
'perOrderQuantity',
Expand Down Expand Up @@ -65,16 +65,16 @@ function multiplyDecimalStrings(left, right, path) {
}

function floorAffordableOrders({
availableBalance,
testBudget,
currentLeverage,
safetyFactor,
perOrderNotional,
}) {
const balance = parsePositiveDecimal(availableBalance, 'liveContext.availableBalance');
const budget = parsePositiveDecimal(testBudget, 'liveContext.testBudget');
const safety = parsePositiveDecimal(safetyFactor, 'liveContext.safetyFactor');
const notional = parsePositiveDecimal(perOrderNotional, 'capacity.perOrderNotional');
const numerator = balance.numerator * BigInt(currentLeverage) * safety.numerator * notional.scale;
const denominator = balance.scale * safety.scale * notional.numerator;
const numerator = budget.numerator * BigInt(currentLeverage) * safety.numerator * notional.scale;
const denominator = budget.scale * safety.scale * notional.numerator;
return Number(numerator / denominator);
}

Expand Down Expand Up @@ -105,7 +105,7 @@ export function validateLiveOrderScaleProfile(profile) {
function validateLiveContext(context) {
assertRecord(context, 'liveContext');
assertExactKeys(context, LIVE_CONTEXT_FIELDS, 'liveContext');
for (const field of ['availableBalance', 'perOrderPrice', 'perOrderQuantity', 'safetyFactor']) {
for (const field of ['testBudget', 'perOrderPrice', 'perOrderQuantity', 'safetyFactor']) {
parsePositiveDecimal(context[field], `liveContext.${field}`);
}
const safety = parsePositiveDecimal(context.safetyFactor, 'liveContext.safetyFactor');
Expand Down Expand Up @@ -133,6 +133,11 @@ function deriveScaleCount(capacity, ratio, minimum) {
return Math.max(minimum, Math.round(capacity * ratio));
}

/**
* Builds serializable capacity evidence from a caller-allocated test budget.
* The caller must keep the budget within the verified live balance so persisted
* evidence proves capacity without disclosing the account's exact balance.
*/
export function createLiveOrderCapacityEvidence(liveContext) {
validateLiveContext(liveContext);
const perOrderNotional = multiplyDecimalStrings(
Expand Down
11 changes: 9 additions & 2 deletions e2e/binance-orderbook/helpers/live-performance-probe.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,13 @@ export function installBinanceLivePerformanceProbe(options = {}) {
.reduce((innermost, dialog) => (
innermost?.contains(dialog) ? dialog : (innermost || dialog)
), null);
const readDialogContaining = (button) => Array.from(document.querySelectorAll(dialogSelector))
.filter(isVisible)
.filter((dialog) => dialog.contains(button))
.filter((dialog) => matchesDialogText(normalizeText(dialog.textContent)))
.reduce((innermost, dialog) => (
innermost?.contains(dialog) ? dialog : (innermost || dialog)
), null);
const readSemanticState = () => {
const panel = readPanel();
const cancelButton = readCancelButton(panel);
Expand Down Expand Up @@ -447,8 +454,8 @@ export function installBinanceLivePerformanceProbe(options = {}) {
return;
}
if (run.startedAtMonotonicMs === null) return;
const dialog = button.closest(dialogSelector);
if (isVisible(dialog) && matchesDialogText(normalizeText(dialog.textContent))) {
const dialog = readDialogContaining(button);
if (dialog) {
appendEvent('dialog-action', {
text: normalizeText(button.textContent),
primary: button.matches('button.bn-button.bn-button__primary'),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,282 @@
{
"schemaVersion": 1,
"capturedAt": "2026-08-27T00:15:44.472Z",
"environment": {
"browser": "Chrome 151.0.7922.174",
"os": "macOS (MacIntel)",
"route": "https://www.binance.com/zh-CN/futures/HYPEUSDT",
"symbol": "HYPEUSDT",
"userscriptSha256": "f4bb60af07044e21f684d1978535795363ade1c240dde0de6b904767cfa87a18",
"userscriptVersion": "2.7.126"
},
"scenarios": [
{
"name": "cancel-dialog-cancel",
"parameters": {
"kind": "dialog-cancel",
"testOrderCount": 1
},
"applicableSegments": [
"clickToFirstFeedback",
"clickToDialog",
"decisionToFinalReady"
],
"samples": [
{
"capacityEvidence": {
"currentLeverage": 2,
"perOrderPrice": "94",
"perOrderQuantity": "0.06",
"safetyFactor": "0.8",
"liveMaxNumOrdersLimit": 200,
"existingCurrentSymbolOpenOrders": 0,
"outstandingTestOwnedOrders": 0,
"perOrderNotional": "5.64",
"maxNewOrdersBySlots": 199,
"maxNewOrdersByMargin": 1,
"testBudget": "5.64"
},
"segmentsMs": {
"clickToFirstFeedback": 24.800000190734863,
"clickToDialog": 81.40000009536743,
"decisionToFinalReady": 55.59999990463257
},
"testOrderLedger": {
"created": [
{
"symbol": "HYPEUSDT",
"side": "SELL",
"positionSide": "SHORT",
"price": "94",
"quantity": "0.06",
"createdAt": "2026-08-26T23:53:32.871Z"
}
],
"fills": [],
"residual": []
},
"stateRestored": true,
"noFills": true,
"residualTestOrders": 0,
"uncaughtErrors": 0,
"maxLongTaskMs": 0,
"maxLongAnimationFrameMs": 220.79999995231628
},
{
"capacityEvidence": {
"currentLeverage": 2,
"perOrderPrice": "94",
"perOrderQuantity": "0.06",
"safetyFactor": "0.8",
"liveMaxNumOrdersLimit": 200,
"existingCurrentSymbolOpenOrders": 0,
"outstandingTestOwnedOrders": 0,
"perOrderNotional": "5.64",
"maxNewOrdersBySlots": 199,
"maxNewOrdersByMargin": 1,
"testBudget": "5.64"
},
"segmentsMs": {
"clickToFirstFeedback": 19.200000047683716,
"clickToDialog": 66.29999995231628,
"decisionToFinalReady": 43.60000014305115
},
"testOrderLedger": {
"created": [
{
"symbol": "HYPEUSDT",
"side": "SELL",
"positionSide": "SHORT",
"price": "94",
"quantity": "0.06",
"createdAt": "2026-08-26T23:53:32.871Z"
}
],
"fills": [],
"residual": []
},
"stateRestored": true,
"noFills": true,
"residualTestOrders": 0,
"uncaughtErrors": 0,
"maxLongTaskMs": 0,
"maxLongAnimationFrameMs": 0
},
{
"capacityEvidence": {
"currentLeverage": 2,
"perOrderPrice": "94",
"perOrderQuantity": "0.06",
"safetyFactor": "0.8",
"liveMaxNumOrdersLimit": 200,
"existingCurrentSymbolOpenOrders": 0,
"outstandingTestOwnedOrders": 0,
"perOrderNotional": "5.64",
"maxNewOrdersBySlots": 199,
"maxNewOrdersByMargin": 1,
"testBudget": "5.64"
},
"segmentsMs": {
"clickToFirstFeedback": 15.399999856948853,
"clickToDialog": 44.29999995231629,
"decisionToFinalReady": 39.5
},
"testOrderLedger": {
"created": [
{
"symbol": "HYPEUSDT",
"side": "SELL",
"positionSide": "SHORT",
"price": "94",
"quantity": "0.06",
"createdAt": "2026-08-26T23:53:32.871Z"
}
],
"fills": [],
"residual": []
},
"stateRestored": true,
"noFills": true,
"residualTestOrders": 0,
"uncaughtErrors": 0,
"maxLongTaskMs": 0,
"maxLongAnimationFrameMs": 0
}
]
},
{
"name": "cancel-dialog-confirm",
"parameters": {
"kind": "dialog-confirm",
"testOrderCount": 1
},
"applicableSegments": [
"clickToFirstFeedback",
"clickToDialog",
"decisionToFinalReady"
],
"samples": [
{
"capacityEvidence": {
"currentLeverage": 2,
"perOrderPrice": "94",
"perOrderQuantity": "0.06",
"safetyFactor": "0.8",
"liveMaxNumOrdersLimit": 200,
"existingCurrentSymbolOpenOrders": 0,
"outstandingTestOwnedOrders": 0,
"perOrderNotional": "5.64",
"maxNewOrdersBySlots": 199,
"maxNewOrdersByMargin": 1,
"testBudget": "5.64"
},
"segmentsMs": {
"clickToFirstFeedback": 19.399999856948853,
"clickToDialog": 85,
"decisionToFinalReady": 1285.7000000476837
},
"testOrderLedger": {
"created": [
{
"symbol": "HYPEUSDT",
"side": "SELL",
"positionSide": "SHORT",
"price": "94",
"quantity": "0.06",
"createdAt": "2026-08-26T23:53:32.871Z"
}
],
"fills": [],
"residual": []
},
"stateRestored": true,
"noFills": true,
"residualTestOrders": 0,
"uncaughtErrors": 0,
"maxLongTaskMs": 59,
"maxLongAnimationFrameMs": 94
},
{
"capacityEvidence": {
"currentLeverage": 2,
"perOrderPrice": "94",
"perOrderQuantity": "0.06",
"safetyFactor": "0.8",
"liveMaxNumOrdersLimit": 200,
"existingCurrentSymbolOpenOrders": 0,
"outstandingTestOwnedOrders": 0,
"perOrderNotional": "5.64",
"maxNewOrdersBySlots": 199,
"maxNewOrdersByMargin": 1,
"testBudget": "5.64"
},
"segmentsMs": {
"clickToFirstFeedback": 22.40000009536743,
"clickToDialog": 75.40000009536743,
"decisionToFinalReady": 1265.5000000000002
},
"testOrderLedger": {
"created": [
{
"symbol": "HYPEUSDT",
"side": "SELL",
"positionSide": "SHORT",
"price": "94",
"quantity": "0.06",
"createdAt": "2026-08-27T00:22:11.178Z"
}
],
"fills": [],
"residual": []
},
"stateRestored": true,
"noFills": true,
"residualTestOrders": 0,
"uncaughtErrors": 0,
"maxLongTaskMs": 173,
"maxLongAnimationFrameMs": 229.1999998092651
},
{
"capacityEvidence": {
"currentLeverage": 2,
"perOrderPrice": "94",
"perOrderQuantity": "0.06",
"safetyFactor": "0.8",
"liveMaxNumOrdersLimit": 200,
"existingCurrentSymbolOpenOrders": 0,
"outstandingTestOwnedOrders": 0,
"perOrderNotional": "5.64",
"maxNewOrdersBySlots": 199,
"maxNewOrdersByMargin": 1,
"testBudget": "5.64"
},
"segmentsMs": {
"clickToFirstFeedback": 19.700000047683716,
"clickToDialog": 290.7000000476837,
"decisionToFinalReady": 1368.5999999046326
},
"testOrderLedger": {
"created": [
{
"symbol": "HYPEUSDT",
"side": "SELL",
"positionSide": "SHORT",
"price": "94",
"quantity": "0.06",
"createdAt": "2026-08-27T00:24:39.256Z"
}
],
"fills": [],
"residual": []
},
"stateRestored": true,
"noFills": true,
"residualTestOrders": 0,
"uncaughtErrors": 0,
"maxLongTaskMs": 201,
"maxLongAnimationFrameMs": 270.89999985694885
}
]
}
]
}
Loading
Loading