dexbot 1.6.12 → 1.6.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +65 -1
- package/README.md +2 -2
- package/analysis/README.md +9 -11
- package/analysis/ama_fitting/README.md +5 -3
- package/claw/README.md +1 -0
- package/claw/docs/AI_BOT_LIBRARY_API.md +3 -1
- package/claw/docs/DEXBOT2_TUNING_CHEAT_SHEET.md +4 -4
- package/claw/modules/claw_bridge.ts +0 -3
- package/claw/modules/claw_catalog.ts +8 -4
- package/claw/modules/claw_skill_md.ts +1 -0
- package/claw/modules/dexbot_profiles.ts +59 -15
- package/claw/modules/types.ts +2 -1
- package/claw/package.json +3 -3
- package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
- package/claw/runtimes/openclaw-plugin/package.json +1 -1
- package/claw/skills/margin-trading/SKILL.md +1 -1
- package/claw/skills/margin-trading/references/position-management.md +1 -1
- package/claw/tsconfig.json +2 -2
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +1 -14
- package/dist/analysis/ama_fitting/fetch_lp_candles.js +51 -41
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts +1 -24
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js +36 -18
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js +18 -66
- package/dist/analysis/analyze_args.d.ts +12 -0
- package/dist/analysis/analyze_args.js +20 -0
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts +1 -16
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js +20 -101
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js +26 -92
- package/dist/analysis/bot_fitting/backtest_lookback_drawdown.js +19 -34
- package/dist/analysis/bot_fitting/shared_utils.d.ts +71 -3
- package/dist/analysis/bot_fitting/shared_utils.js +124 -8
- package/dist/analysis/chart_ui.d.ts +30 -1
- package/dist/analysis/chart_ui.js +37 -1
- package/dist/analysis/fills_cache.d.ts +3 -23
- package/dist/analysis/fills_cache.js +3 -84
- package/dist/analysis/fills_source.d.ts +31 -1
- package/dist/analysis/fills_source.js +69 -1
- package/dist/analysis/grid_correction_check.d.ts +1 -23
- package/dist/analysis/grid_correction_check.js +15 -58
- package/dist/analysis/math_utils.d.ts +85 -1
- package/dist/analysis/math_utils.js +116 -1
- package/dist/analysis/price_sources.d.ts +22 -1
- package/dist/analysis/price_sources.js +23 -0
- package/dist/analysis/resolve_source.js +31 -10
- package/dist/analysis/trade_profitability.d.ts +6 -0
- package/dist/analysis/trade_profitability.js +23 -97
- package/dist/analysis/tradingview/analyze_tradingview.d.ts +1 -17
- package/dist/analysis/tradingview/analyze_tradingview.js +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +27 -40
- package/dist/analysis/trend_detection/backtest_ama_slope_huber.d.ts +1 -101
- package/dist/analysis/trend_detection/backtest_ama_slope_huber.js +22 -80
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +11 -37
- package/dist/analysis/trend_detection/volatility_chart_generator.js +9 -10
- package/dist/analysis/worker_pool.d.ts +38 -0
- package/dist/analysis/worker_pool.js +67 -0
- package/dist/dexbot.js +67 -48
- package/dist/market_adapter/ama_signal_runner.js +21 -54
- package/dist/market_adapter/candle_utils.d.ts +7 -1
- package/dist/market_adapter/candle_utils.js +11 -1
- package/dist/market_adapter/cli_args.d.ts +22 -0
- package/dist/market_adapter/cli_args.js +30 -0
- package/dist/market_adapter/core/config_normalizers.js +11 -6
- package/dist/market_adapter/core/kibana_candles.d.ts +3 -1
- package/dist/market_adapter/core/kibana_candles.js +3 -2
- package/dist/market_adapter/core/market_adapter_service.d.ts +85 -85
- package/dist/market_adapter/core/market_adapter_service.js +93 -158
- package/dist/market_adapter/core/signals/hurst_analyzer.d.ts +1 -6
- package/dist/market_adapter/core/signals/hurst_analyzer.js +1 -1
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts +1 -11
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js +1 -1
- package/dist/market_adapter/inputs/fetch_book_data.js +0 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +63 -107
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +8 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js +25 -7
- package/dist/market_adapter/inputs/kibana_feed_source.js +4 -26
- package/dist/market_adapter/inputs/window_cache.d.ts +4 -72
- package/dist/market_adapter/inputs/window_cache.js +52 -177
- package/dist/market_adapter/interval_utils.d.ts +11 -1
- package/dist/market_adapter/interval_utils.js +16 -1
- package/dist/market_adapter/lp_chart_runner.d.ts +3 -0
- package/dist/market_adapter/lp_chart_runner.js +37 -19
- package/dist/market_adapter/market_adapter.js +27 -72
- package/dist/market_adapter/utils/data_discovery.d.ts +45 -1
- package/dist/market_adapter/utils/data_discovery.js +220 -27
- package/dist/market_adapter/utils/month_shards.d.ts +84 -0
- package/dist/market_adapter/utils/month_shards.js +237 -0
- package/dist/modules/account_bots.d.ts +8 -6
- package/dist/modules/account_bots.js +112 -131
- package/dist/modules/account_orders.d.ts +49 -4
- package/dist/modules/account_orders.js +114 -49
- package/dist/modules/bitshares-native/chain_client.d.ts +1 -1
- package/dist/modules/bitshares-native/chain_client.js +14 -13
- package/dist/modules/bitshares-native/crypto/ecc_core.d.ts +1 -2
- package/dist/modules/bitshares-native/crypto/ecc_core.js +1 -1
- package/dist/modules/bitshares-native/resolvers.js +22 -25
- package/dist/modules/bitshares-native/serial/chain_constants.d.ts +1 -2
- package/dist/modules/bitshares-native/serial/chain_constants.js +1 -2
- package/dist/modules/bitshares-native/serial/types.js +22 -50
- package/dist/modules/bitshares-native/signing_client.d.ts +1 -1
- package/dist/modules/bot_defaults.d.ts +18 -3
- package/dist/modules/bot_defaults.js +34 -8
- package/dist/modules/bot_settings.d.ts +5 -1
- package/dist/modules/bot_settings.js +55 -21
- package/dist/modules/broadcast_failure.d.ts +2 -1
- package/dist/modules/chain_orders.d.ts +1 -1
- package/dist/modules/chain_orders.js +51 -96
- package/dist/modules/cli_start_onboarding.d.ts +2 -1
- package/dist/modules/config.js +6 -1
- package/dist/modules/constants.d.ts +14 -6
- package/dist/modules/constants.js +32 -6
- package/dist/modules/cr_planner.d.ts +1 -1
- package/dist/modules/cr_planner.js +1 -5
- package/dist/modules/credit_pricing.d.ts +2 -1
- package/dist/modules/credit_pricing.js +36 -40
- package/dist/modules/credit_runtime.d.ts +7 -0
- package/dist/modules/credit_runtime.js +45 -73
- package/dist/modules/daemon_node_health.d.ts +4 -3
- package/dist/modules/dexbot_class.d.ts +33 -17
- package/dist/modules/dexbot_class.js +113 -61
- package/dist/modules/dexbot_cow_runtime.d.ts +62 -181
- package/dist/modules/dexbot_cow_runtime.js +380 -69
- package/dist/modules/dexbot_credential_client.d.ts +1 -23
- package/dist/modules/dexbot_credential_client.js +2 -3
- package/dist/modules/dexbot_fill_runtime.d.ts +2 -3
- package/dist/modules/dexbot_fill_runtime.js +17 -7
- package/dist/modules/dexbot_maintenance_runtime.d.ts +36 -81
- package/dist/modules/dexbot_maintenance_runtime.js +137 -133
- package/dist/modules/dexbot_startup_runtime.d.ts +0 -1
- package/dist/modules/dexbot_startup_runtime.js +25 -14
- package/dist/modules/dexbot_state_recovery.js +16 -0
- package/dist/modules/general_settings.d.ts +1 -1
- package/dist/modules/graceful_shutdown.js +17 -11
- package/dist/modules/key_store.d.ts +0 -5
- package/dist/modules/key_store.js +1 -2
- package/dist/modules/lazy_shim.d.ts +11 -0
- package/dist/modules/lazy_shim.js +16 -0
- package/dist/modules/node_connect_policy.d.ts +3 -2
- package/dist/modules/node_failure_ledger.d.ts +6 -5
- package/dist/modules/order/accounting.js +11 -11
- package/dist/modules/order/export.js +2 -2
- package/dist/modules/order/format.d.ts +26 -3
- package/dist/modules/order/format.js +33 -3
- package/dist/modules/order/genesis_policy.d.ts +4 -4
- package/dist/modules/order/genesis_policy.js +6 -3
- package/dist/modules/order/grid.d.ts +26 -12
- package/dist/modules/order/grid.js +468 -80
- package/dist/modules/order/grid_reconcile.d.ts +1 -1
- package/dist/modules/order/grid_reconcile.js +5 -5
- package/dist/modules/order/grid_reconcile_internal.js +48 -40
- package/dist/modules/order/index.d.ts +35 -8
- package/dist/modules/order/logger.d.ts +1 -8
- package/dist/modules/order/logger.js +2 -11
- package/dist/modules/order/manager.d.ts +18 -15
- package/dist/modules/order/manager.js +91 -74
- package/dist/modules/order/strategy.d.ts +2 -2
- package/dist/modules/order/strategy.js +51 -21
- package/dist/modules/order/sync_engine.js +4 -0
- package/dist/modules/order/utils/math.d.ts +3 -3
- package/dist/modules/order/utils/math.js +38 -27
- package/dist/modules/order/utils/order.d.ts +58 -58
- package/dist/modules/order/utils/order.js +158 -137
- package/dist/modules/order/utils/system.d.ts +202 -35
- package/dist/modules/order/utils/system.js +409 -31
- package/dist/modules/order/utils/validate.js +28 -6
- package/dist/modules/order/utils/withPoolRef.d.ts +2 -1
- package/dist/modules/paths.js +32 -34
- package/dist/modules/runtime_settings.d.ts +3 -5
- package/dist/modules/runtime_settings.js +3 -3
- package/dist/modules/settings_merge.d.ts +2 -2
- package/dist/modules/socket_json_client.d.ts +2 -1
- package/dist/modules/types.d.ts +89 -30
- package/dist/modules/utils/errors.js +1 -3
- package/dist/modules/version_notice.d.ts +11 -10
- package/dist/pm2.d.ts +0 -1
- package/dist/pm2.js +56 -35
- package/dist/scripts/analyze-git.js +2 -15
- package/dist/scripts/analyze-orders.d.ts +1 -1
- package/dist/scripts/analyze-orders.js +4 -4
- package/dist/scripts/chart_command.js +2 -2
- package/dist/scripts/check_any.d.ts +4 -0
- package/dist/scripts/check_any.js +53 -21
- package/dist/scripts/diagnose-pool-history.js +1 -6
- package/dist/scripts/divergence-calc.js +6 -6
- package/dist/scripts/run-tests.js +0 -1
- package/dist/scripts/sync-version.js +0 -10
- package/dist/scripts/validate_bots.d.ts +1 -1
- package/dist/scripts/validate_bots.js +3 -3
- package/dist/unlock.js +7 -2
- package/docs/BITSHARES_ONBOARDING.md +8 -12
- package/docs/COPY_ON_WRITE_MASTER_PLAN.md +2 -3
- package/docs/COW_INVARIANTS.md +6 -6
- package/docs/DEXBOT_COMPARISON.md +7 -7
- package/docs/EVOLUTION.md +10 -8
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +8 -6
- package/docs/GRID_PRICE_INVARIANT.md +3 -3
- package/docs/GRID_RECALCULATION.md +4 -1
- package/docs/GRID_RECONCILE.md +4 -4
- package/docs/LIFECYCLE.md +11 -11
- package/docs/LOGGING.md +14 -0
- package/docs/MPA_CREDIT_USAGE.md +1 -1
- package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +12 -4
- package/docs/README.md +3 -3
- package/docs/WORKFLOW.md +1 -0
- package/docs/architecture.md +25 -16
- package/docs/developer_guide.md +7 -2
- package/market_adapter/README.md +6 -4
- package/package.json +6 -9
- package/scripts/README.md +43 -38
- package/tests/README.md +26 -11
- package/dist/scripts/diagnose-kibana-candles.d.ts +0 -3
- package/dist/scripts/diagnose-kibana-candles.js +0 -82
- package/scripts/git-viewer.sh +0 -489
- package/scripts/postinstall.js +0 -16
|
@@ -70,7 +70,7 @@ export declare function decideStartupGridAction({ persistedGrid, chainOpenOrders
|
|
|
70
70
|
* - Then create missing orders if chain has fewer than target.
|
|
71
71
|
* - Then cancel excess orders if chain has more than target.
|
|
72
72
|
*
|
|
73
|
-
* Targets are derived from config.
|
|
73
|
+
* Targets are derived from config.coreOrders.{buy,sell} and chain counts are computed
|
|
74
74
|
* from current on-chain open orders.
|
|
75
75
|
* @param {Object} params - Destructured parameters
|
|
76
76
|
* @param {Object} params.manager - OrderManager instance
|
|
@@ -4,7 +4,7 @@ import { _countActiveOnGrid, _cancelChainOrder, _recoverStartupSyncFailure, _ref
|
|
|
4
4
|
import { ORDER_TYPES, ORDER_STATES, TIMING } from '../constants.js';
|
|
5
5
|
import { readOpenOrdersGuarded } from '../chain_orders.js';
|
|
6
6
|
import { getAssetFeesSafe, priceSlotEqual } from './utils/math.js';
|
|
7
|
-
import { isOrderPlaced, parseChainOrder, isOrderOnChain, findLiveOrderOwnerByChainId, chainOrderMatchesSlotWithTolerance, duplicateOrphanLogInfo,
|
|
7
|
+
import { isOrderPlaced, parseChainOrder, isOrderOnChain, findLiveOrderOwnerByChainId, chainOrderMatchesSlotWithTolerance, duplicateOrphanLogInfo, resolveEdgeCount, } from './utils/order.js';
|
|
8
8
|
import * as Format from './format.js';
|
|
9
9
|
import { getErrorMessage } from '../utils/errors.js';
|
|
10
10
|
function _startupChainSnapshotSignature(orders, manager) {
|
|
@@ -142,7 +142,7 @@ export async function decideStartupGridAction({ persistedGrid, chainOpenOrders,
|
|
|
142
142
|
* - Then create missing orders if chain has fewer than target.
|
|
143
143
|
* - Then cancel excess orders if chain has more than target.
|
|
144
144
|
*
|
|
145
|
-
* Targets are derived from config.
|
|
145
|
+
* Targets are derived from config.coreOrders.{buy,sell} and chain counts are computed
|
|
146
146
|
* from current on-chain open orders.
|
|
147
147
|
* @param {Object} params - Destructured parameters
|
|
148
148
|
* @param {Object} params.manager - OrderManager instance
|
|
@@ -180,11 +180,11 @@ export async function reconcileGridOrders({ manager, config, account, privateKey
|
|
|
180
180
|
const parsedChain = (chainOpenOrders || [])
|
|
181
181
|
.map((co) => ({ chain: co, parsed: parseChainOrder(co, manager.assets) }))
|
|
182
182
|
.filter((x) => x.parsed !== null);
|
|
183
|
-
const activeCfg = (config && config.
|
|
183
|
+
const activeCfg = (config && config.coreOrders) ? config.coreOrders : {};
|
|
184
184
|
let targetBuy = Math.max(0, Number.isFinite(Number(activeCfg.buy)) ? Number(activeCfg.buy) : 1)
|
|
185
|
-
+
|
|
185
|
+
+ resolveEdgeCount(config, 'buy');
|
|
186
186
|
let targetSell = Math.max(0, Number.isFinite(Number(activeCfg.sell)) ? Number(activeCfg.sell) : 1)
|
|
187
|
-
+
|
|
187
|
+
+ resolveEdgeCount(config, 'sell');
|
|
188
188
|
const chainBuys = parsedChain.filter((x) => x.parsed.type === ORDER_TYPES.BUY).map((x) => x.chain);
|
|
189
189
|
const chainSells = parsedChain.filter((x) => x.parsed.type === ORDER_TYPES.SELL).map((x) => x.chain);
|
|
190
190
|
// PHASE 1: In-memory reconciliation under lock — pure planning, no blockchain I/O.
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { ORDER_TYPES, ORDER_STATES, TIMING, BTS_PRECISION } from '../constants.js';
|
|
8
8
|
import { readOpenOrdersGuarded } from '../chain_orders.js';
|
|
9
9
|
import { getMinOrderSize, getAssetFees, getAssetFeesSafe, blockchainToFloat, findCrossedOrder, resolveGapBand, isSlotInRail, priceSlotEqual } from './utils/math.js';
|
|
10
|
-
import { isOrderPlaced, parseChainOrder, buildCreateOrderArgs, buildOutsideInPairGroups, extractBatchOperationResults, chainOrderMatchesSlotWithTolerance, buildCrossingCheckCandidates, isCrossingCheckCandidate, getSideBudget, calculateBudgetedSizes,
|
|
10
|
+
import { isOrderPlaced, parseChainOrder, buildCreateOrderArgs, buildOutsideInPairGroups, extractBatchOperationResults, chainOrderMatchesSlotWithTolerance, buildCrossingCheckCandidates, isCrossingCheckCandidate, getSideBudget, calculateBudgetedSizes, getCoreOrdersTotal, convertToSpreadPlaceholder, isOrderGoneErrorMessage, clearDuplicateOrphanDetection, resolveEdgeCount, resolveLiveEdgeAnchorPrice, edgeOrderIdSet, compareEdge, parseSlotIndex, reportGridPriceInvariant, liveWindowIdSet } from './utils/order.js';
|
|
11
11
|
import { resolveAccountRef } from './utils/system.js';
|
|
12
12
|
import * as Format from './format.js';
|
|
13
13
|
import { getErrorMessage, getErrorCode, getErrorName } from '../utils/errors.js';
|
|
@@ -58,7 +58,7 @@ function computePlacementCrossing(manager, gridOrder, excludeChainOrderId = null
|
|
|
58
58
|
*/
|
|
59
59
|
function _countActiveOnGrid(manager, type) {
|
|
60
60
|
// Slot-N gated: fork-kept shelf/manual orders (non-slot-N ids, e.g.
|
|
61
|
-
// deep-*) sit outside window accounting — same gate as
|
|
61
|
+
// deep-*) sit outside window accounting — same gate as edge
|
|
62
62
|
// classification and matched-excess candidates (issue #27 follow-up).
|
|
63
63
|
// Without this, a live shelf inflates matchedOnGrid, suppresses
|
|
64
64
|
// neededSlots/creates, and its chain-count surplus cancels real window
|
|
@@ -107,7 +107,7 @@ function _deriveBudgetedSideSizes(manager, type) {
|
|
|
107
107
|
if (!funds)
|
|
108
108
|
return derived;
|
|
109
109
|
const side = type === ORDER_TYPES.BUY ? 'buy' : 'sell';
|
|
110
|
-
const totalTarget =
|
|
110
|
+
const totalTarget = getCoreOrdersTotal(manager.config);
|
|
111
111
|
const budget = getSideBudget(side, funds, manager.config, totalTarget);
|
|
112
112
|
if (!(budget > 0))
|
|
113
113
|
return derived;
|
|
@@ -182,7 +182,7 @@ function _pickVirtualSlotsToActivate(manager, type, count) {
|
|
|
182
182
|
.filter(typeFilter)
|
|
183
183
|
.filter(inRail)
|
|
184
184
|
// Slot-N gated: fork-kept shelf/manual slots (non-slot-N ids, e.g.
|
|
185
|
-
// deep-*) must never activate as window orders — same gate as
|
|
185
|
+
// deep-*) must never activate as window orders — same gate as edge
|
|
186
186
|
// classification and startup cancel candidates (issue #27 follow-up).
|
|
187
187
|
// A VIRTUAL shelf passes the type + fail-open geometry filters above;
|
|
188
188
|
// without this it would consume window activation budget at an
|
|
@@ -235,10 +235,10 @@ function _pickVirtualSlotsToActivate(manager, type, count) {
|
|
|
235
235
|
return valid;
|
|
236
236
|
}
|
|
237
237
|
/**
|
|
238
|
-
* Pick edge-pinned
|
|
238
|
+
* Pick edge-pinned edge slots (floor for BUY, ceiling for SELL).
|
|
239
239
|
* Same rail membership gate as _pickVirtualSlotsToActivate, opposite end:
|
|
240
|
-
* the
|
|
241
|
-
* Size gate is STRICTER than that picker's —
|
|
240
|
+
* the edge ladder rests at the grid edge instead of the market window.
|
|
241
|
+
* Size gate is STRICTER than that picker's — edge orders activate only with
|
|
242
242
|
* their own stored size (>= min order size), never a locally derived one,
|
|
243
243
|
* so an unsized edge slot waits for the target-grid sizing pipeline.
|
|
244
244
|
* @param {Object} manager - OrderManager instance.
|
|
@@ -248,7 +248,7 @@ function _pickVirtualSlotsToActivate(manager, type, count) {
|
|
|
248
248
|
* @returns {Array<Object>} Array of picked edge slots (edge first).
|
|
249
249
|
* @private
|
|
250
250
|
*/
|
|
251
|
-
function
|
|
251
|
+
function _pickEdgeSlots(manager, orderType, count, excludeIds = null) {
|
|
252
252
|
if (count <= 0)
|
|
253
253
|
return [];
|
|
254
254
|
const type = orderType;
|
|
@@ -259,20 +259,20 @@ function _pickEdgeReserveSlots(manager, orderType, count, excludeIds = null) {
|
|
|
259
259
|
const typeFilter = boundaryKnown
|
|
260
260
|
? (slot) => slot && (slot.type === type || slot.type === ORDER_TYPES.SPREAD)
|
|
261
261
|
: (slot) => slot && slot.type === type;
|
|
262
|
-
//
|
|
262
|
+
// Edge classification (edgeOrderIdSet / countLiveEdgeOrders) is
|
|
263
263
|
// slot-N gated; keep placement in agreement so a kept virtual non-grid
|
|
264
|
-
// shelf is never activated as
|
|
264
|
+
// shelf is never activated as an edge order it would then never be counted
|
|
265
265
|
// as (issue #27 follow-up). No-op upstream (grids only mint slot-N).
|
|
266
266
|
const gridSlot = (slot) => parseSlotIndex(slot?.id) !== null;
|
|
267
267
|
// Both edges anchor at the live grid's own edge (ladder/rail extreme):
|
|
268
268
|
// floor — nearest at/above the live floor first; ceiling — nearest
|
|
269
269
|
// at/below the live ceiling first. Stale out-of-grid slots sort last.
|
|
270
|
-
const edgeAnchor =
|
|
270
|
+
const edgeAnchor = resolveLiveEdgeAnchorPrice(manager, edgeDesc ? 'sell' : 'buy');
|
|
271
271
|
const edgeFirst = Array.from(manager.orders.values())
|
|
272
272
|
.filter(typeFilter)
|
|
273
273
|
.filter(gridSlot)
|
|
274
274
|
.filter(inRail)
|
|
275
|
-
.sort((a, b) =>
|
|
275
|
+
.sort((a, b) => compareEdge(a, b, edgeDesc ? 'ceiling' : 'floor', edgeAnchor));
|
|
276
276
|
let effectiveMin = 0;
|
|
277
277
|
try {
|
|
278
278
|
effectiveMin = getMinOrderSize(type, manager.assets);
|
|
@@ -287,10 +287,10 @@ function _pickEdgeReserveSlots(manager, orderType, count, excludeIds = null) {
|
|
|
287
287
|
if (excludeIds && excludeIds.has(slot.id))
|
|
288
288
|
continue;
|
|
289
289
|
if (!slot.orderId && slot.state === ORDER_STATES.VIRTUAL) {
|
|
290
|
-
// Exact sizes only:
|
|
290
|
+
// Exact sizes only: an edge order is activated solely with the size the
|
|
291
291
|
// grid already carries (written by the target-grid sizing pipeline
|
|
292
292
|
// and persisted with the slot). No local re-derivation — a second
|
|
293
|
-
// sizing rule here could place the
|
|
293
|
+
// sizing rule here could place the edge with a size the target
|
|
294
294
|
// grid then has to correct on the next cycle. An unsized slot
|
|
295
295
|
// simply waits for the sizing pipeline instead of being guessed.
|
|
296
296
|
const storedSize = Number(slot.size) || 0;
|
|
@@ -1401,32 +1401,32 @@ async function _reconcileStartupSide({ orderType, targetCount, chainSideOrders,
|
|
|
1401
1401
|
const matchedOnGrid = _countActiveOnGrid(manager, orderType);
|
|
1402
1402
|
const neededSlots = Math.max(0, targetCount - matchedOnGrid);
|
|
1403
1403
|
let desiredSlots = _pickVirtualSlotsToActivate(manager, orderType, neededSlots);
|
|
1404
|
-
//
|
|
1404
|
+
// Edge ladder: the closest-first picker above backfills the middle. Swap
|
|
1405
1405
|
// its farthest tail for edge-pinned slots (floor for BUY, ceiling for SELL)
|
|
1406
1406
|
// so startup converges to window + edge instead of one contiguous block.
|
|
1407
|
-
let
|
|
1408
|
-
const
|
|
1409
|
-
const
|
|
1410
|
-
if (
|
|
1407
|
+
let edgeOrderIds = null;
|
|
1408
|
+
const edgeSide = orderType === ORDER_TYPES.SELL ? 'sell' : 'buy';
|
|
1409
|
+
const edgeCount = resolveEdgeCount(manager.config, edgeSide);
|
|
1410
|
+
if (edgeCount > 0) {
|
|
1411
1411
|
const pickedIds = new Set(desiredSlots.map((s) => s?.id).filter(Boolean));
|
|
1412
|
-
const freshEdge =
|
|
1413
|
-
const
|
|
1414
|
-
|
|
1415
|
-
// Window first, then the ready edge
|
|
1416
|
-
// still MISSING on-chain is held back for the edge (a live
|
|
1412
|
+
const freshEdge = _pickEdgeSlots(manager, orderType, edgeCount, pickedIds);
|
|
1413
|
+
const edgeAnchor = resolveLiveEdgeAnchorPrice(manager, edgeSide);
|
|
1414
|
+
edgeOrderIds = edgeOrderIdSet(Array.from(manager.orders.values()), manager.config, orderType, edgeAnchor, liveWindowIdSet(manager, orderType));
|
|
1415
|
+
// Window first, then the ready edge orders. Only the edge share
|
|
1416
|
+
// still MISSING on-chain is held back for the edge (a live edge order is
|
|
1417
1417
|
// already part of matchedOnGrid and must not shrink the window plan), so
|
|
1418
1418
|
// an edge pick that is not activatable yet (exact-size rule) leaves its
|
|
1419
1419
|
// slot unplanned: the target-grid pipeline then creates it at the edge
|
|
1420
1420
|
// with its own sizes, instead of the plan filling it with a middle
|
|
1421
1421
|
// window slot that the next cycle would have to rotate out.
|
|
1422
|
-
// Note: if the window picker itself took an edge/
|
|
1422
|
+
// Note: if the window picker itself took an edge/edge slot (only
|
|
1423
1423
|
// when the rail is too short to fill the window closer to market),
|
|
1424
|
-
// that slot is not a placed
|
|
1424
|
+
// that slot is not a placed edge order, so the plan comes out one short
|
|
1425
1425
|
// here and the target grid settles it on the next cycle.
|
|
1426
|
-
const
|
|
1427
|
-
? [...
|
|
1426
|
+
const liveEdges = edgeOrderIds
|
|
1427
|
+
? [...edgeOrderIds].filter((id) => isOrderPlaced(manager.orders.get(id))).length
|
|
1428
1428
|
: 0;
|
|
1429
|
-
const missingReserves = Math.max(0,
|
|
1429
|
+
const missingReserves = Math.max(0, edgeCount - liveEdges);
|
|
1430
1430
|
const keepCount = Math.max(0, neededSlots - missingReserves);
|
|
1431
1431
|
desiredSlots = [...desiredSlots.slice(0, keepCount), ...freshEdge];
|
|
1432
1432
|
}
|
|
@@ -1449,6 +1449,14 @@ async function _reconcileStartupSide({ orderType, targetCount, chainSideOrders,
|
|
|
1449
1449
|
const planVacatedRailRefill = (chainOrder, parsedChain) => {
|
|
1450
1450
|
const boundary = manager.boundaryIdx;
|
|
1451
1451
|
const gapSlots = manager._gapSlots;
|
|
1452
|
+
// Explicit null/undefined/'' guard BEFORE Number(): Number(null) === 0
|
|
1453
|
+
// is finite and would defeat this bail-out, running the refill scan on
|
|
1454
|
+
// a bogus boundary 0 (and a null gapSlots would default to 0 through
|
|
1455
|
+
// getSellStartIdx).
|
|
1456
|
+
if (boundary === null || boundary === undefined || boundary === '')
|
|
1457
|
+
return;
|
|
1458
|
+
if (gapSlots === null || gapSlots === undefined || gapSlots === '')
|
|
1459
|
+
return;
|
|
1452
1460
|
if (!Number.isFinite(Number(boundary)) || !Number.isFinite(Number(gapSlots)))
|
|
1453
1461
|
return;
|
|
1454
1462
|
const chainPrice = parsedChain?.price;
|
|
@@ -1627,14 +1635,14 @@ async function _reconcileStartupSide({ orderType, targetCount, chainSideOrders,
|
|
|
1627
1635
|
.map((co) => ({ chain: co, parsed: parseChainOrder(co, manager.assets) }))
|
|
1628
1636
|
.filter((x) => x.parsed !== null)
|
|
1629
1637
|
.sort(sortExcessCancelComparator);
|
|
1630
|
-
//
|
|
1631
|
-
// candidates at
|
|
1632
|
-
if (
|
|
1638
|
+
// Edge ladder: edge-priced orphans cancel last (they are adoption
|
|
1639
|
+
// candidates at edge prices, not first-to-cut).
|
|
1640
|
+
if (edgeOrderIds && edgeOrderIds.size > 0) {
|
|
1633
1641
|
const sidePrecision = orderType === ORDER_TYPES.SELL
|
|
1634
1642
|
? manager.assets?.assetA?.precision
|
|
1635
1643
|
: manager.assets?.assetB?.precision;
|
|
1636
1644
|
const edgePrices = [];
|
|
1637
|
-
for (const eid of
|
|
1645
|
+
for (const eid of edgeOrderIds) {
|
|
1638
1646
|
const slot = manager.orders.get(eid);
|
|
1639
1647
|
if (slot && Number.isFinite(Number(slot.price)))
|
|
1640
1648
|
edgePrices.push(Number(slot.price));
|
|
@@ -1666,9 +1674,9 @@ async function _reconcileStartupSide({ orderType, targetCount, chainSideOrders,
|
|
|
1666
1674
|
// matched (grid-known) slots. Computed once and shared by both the
|
|
1667
1675
|
// planOnly and execute branches so planning can never drift from
|
|
1668
1676
|
// execution: unmatched orphans cancel first, matched surplus after,
|
|
1669
|
-
//
|
|
1677
|
+
// edge order slots last (static insurance). Slot-N gated: fork-kept
|
|
1670
1678
|
// shelf/manual orders (non-slot-N ids, e.g. deep-*) are never excess
|
|
1671
|
-
// candidates —
|
|
1679
|
+
// candidates — edgeOrderIdSet already excludes them, so without this
|
|
1672
1680
|
// gate a live shelf heads the cheapest-first sort and is wiped on the
|
|
1673
1681
|
// next boot (issue #27 follow-up). No-op upstream (grids only mint
|
|
1674
1682
|
// slot-N).
|
|
@@ -1676,11 +1684,11 @@ async function _reconcileStartupSide({ orderType, targetCount, chainSideOrders,
|
|
|
1676
1684
|
.filter((o) => o && o.orderId)
|
|
1677
1685
|
.filter((o) => parseSlotIndex(o?.id) !== null)
|
|
1678
1686
|
.sort(sortMatchedCancelComparator);
|
|
1679
|
-
//
|
|
1680
|
-
if (
|
|
1687
|
+
// Edge ladder: matched edge slots cancel last (static insurance).
|
|
1688
|
+
if (edgeOrderIds && edgeOrderIds.size > 0) {
|
|
1681
1689
|
matchedExcess.sort((a, b) => {
|
|
1682
|
-
const fa =
|
|
1683
|
-
const fb =
|
|
1690
|
+
const fa = edgeOrderIds.has(a.id) ? 1 : 0;
|
|
1691
|
+
const fb = edgeOrderIds.has(b.id) ? 1 : 0;
|
|
1684
1692
|
return fa - fb;
|
|
1685
1693
|
});
|
|
1686
1694
|
}
|
|
@@ -1712,7 +1720,7 @@ async function _reconcileStartupSide({ orderType, targetCount, chainSideOrders,
|
|
|
1712
1720
|
// could never converge to its additive window+edge target (live
|
|
1713
1721
|
// 12 vs target 8 sat static across every restart). Same priority
|
|
1714
1722
|
// as the execute branch: unmatched first (above), matched after,
|
|
1715
|
-
//
|
|
1723
|
+
// edge order last (matchedExcess ordering).
|
|
1716
1724
|
for (const o of matchedExcess) {
|
|
1717
1725
|
if (cancelCount <= 0)
|
|
1718
1726
|
break;
|
|
@@ -72,12 +72,38 @@ declare const utils: {
|
|
|
72
72
|
accountTotals: import("../types.js").AccountTotals | null;
|
|
73
73
|
}): Promise<boolean>;
|
|
74
74
|
restoreGapEvacStreaks(manager: import("../types.js").OrderManagerLike, persisted: unknown): number;
|
|
75
|
+
resolveSpreadFreshnessMs(manager: import("../types.js").OrderManagerLike): number;
|
|
76
|
+
resolveSpreadCrossingFloor(manager: import("../types.js").OrderManagerLike): number | null;
|
|
77
|
+
refreshLiveMarketPrice(manager: import("../types.js").OrderManagerLike, BitShares: unknown): Promise<number | null>;
|
|
78
|
+
maybeRefreshLiveMarketPrice(manager: import("../types.js").OrderManagerLike, BitShares: unknown, options?: {
|
|
79
|
+
now?: number;
|
|
80
|
+
}): Promise<number | null>;
|
|
81
|
+
evaluateSpreadCorrectionReadiness(manager: import("../types.js").OrderManagerLike, options?: {
|
|
82
|
+
now?: number;
|
|
83
|
+
onChainOrders?: {
|
|
84
|
+
buys: unknown[];
|
|
85
|
+
sells: unknown[];
|
|
86
|
+
} | null;
|
|
87
|
+
}): system.SpreadCorrectionReadiness;
|
|
88
|
+
resolveSpreadMarketReference(manager: import("../types.js").OrderManagerLike): number | null;
|
|
89
|
+
resolveLastFillGuardReference(manager: import("../types.js").OrderManagerLike): {
|
|
90
|
+
price: number | null;
|
|
91
|
+
type: string | null;
|
|
92
|
+
};
|
|
93
|
+
restoreLastMarketFill(manager: import("../types.js").OrderManagerLike, persisted: unknown, options?: {
|
|
94
|
+
now?: number;
|
|
95
|
+
}): boolean;
|
|
75
96
|
normalizeLastFillPivot(row: unknown): {
|
|
76
97
|
price: number;
|
|
77
98
|
type: string;
|
|
78
99
|
fillsAt: number;
|
|
79
100
|
genesisHash: string;
|
|
80
101
|
} | null;
|
|
102
|
+
normalizeLastMarketFill(row: unknown): {
|
|
103
|
+
price: number;
|
|
104
|
+
type: string;
|
|
105
|
+
fillsAt: number;
|
|
106
|
+
} | null;
|
|
81
107
|
setLastFillPivot(manager: import("../types.js").OrderManagerLike, type: string, price: unknown, provenance: "fill" | "book", atMs?: number): boolean;
|
|
82
108
|
resetLastFillPivot(manager: import("../types.js").OrderManagerLike, reason?: string): boolean;
|
|
83
109
|
restoreLastFillPivot(manager: import("../types.js").OrderManagerLike, persisted: unknown, options?: {
|
|
@@ -122,6 +148,7 @@ declare const utils: {
|
|
|
122
148
|
resolveAccountRef(manager: import("../types.js").OrderManagerLike, account: string): string | null;
|
|
123
149
|
deepFreeze<T>(obj: T): T;
|
|
124
150
|
cloneMap<K, V>(map: Map<K, V>): Map<K, V>;
|
|
151
|
+
fireStructuralResync(bot: import("../types.js").BotLike, reason: string, details: Record<string, unknown>, errorLabel: string, level?: string): void;
|
|
125
152
|
parseJsonWithComments(raw: string): Record<string, unknown>;
|
|
126
153
|
applyPersistedPendingCrawls(bot: import("../types.js").BotLike, options?: {
|
|
127
154
|
log?: (message: string, level?: string) => void;
|
|
@@ -199,10 +226,10 @@ declare const utils: {
|
|
|
199
226
|
buildDelta: typeof order.buildDelta;
|
|
200
227
|
deriveTargetBoundary: typeof order.deriveTargetBoundary;
|
|
201
228
|
isShiftEligibleFill: typeof order.isShiftEligibleFill;
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
229
|
+
resolveEdgeCount: typeof order.resolveEdgeCount;
|
|
230
|
+
resolveEdgeOrders: typeof order.resolveEdgeOrders;
|
|
231
|
+
selectEdgeSlots: typeof order.selectEdgeSlots;
|
|
232
|
+
getCoreOrdersTotal: typeof order.getCoreOrdersTotal;
|
|
206
233
|
getSideBudget: typeof order.getSideBudget;
|
|
207
234
|
calculateBudgetedSizes: typeof order.calculateBudgetedSizes;
|
|
208
235
|
buildCreateOpFingerprint: typeof order.buildCreateOpFingerprint;
|
|
@@ -213,13 +240,13 @@ declare const utils: {
|
|
|
213
240
|
chainOrderUnchangedFromCache: typeof order.chainOrderUnchangedFromCache;
|
|
214
241
|
detectCrossedBookPlan: typeof order.detectCrossedBookPlan;
|
|
215
242
|
collectKnownOnChainOrderIds: typeof order.collectKnownOnChainOrderIds;
|
|
216
|
-
|
|
243
|
+
edgeOrderIdSet: typeof order.edgeOrderIdSet;
|
|
217
244
|
liveWindowIdSet: typeof order.liveWindowIdSet;
|
|
218
245
|
checkGridPriceInvariant: typeof order.checkGridPriceInvariant;
|
|
219
246
|
reportGridPriceInvariant: typeof order.reportGridPriceInvariant;
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
247
|
+
resolveEdgeAnchorPrice: typeof order.resolveEdgeAnchorPrice;
|
|
248
|
+
resolveLiveEdgeAnchorPrice: typeof order.resolveLiveEdgeAnchorPrice;
|
|
249
|
+
compareEdge: typeof order.compareEdge;
|
|
223
250
|
collectRefillSlotIds: typeof order.collectRefillSlotIds;
|
|
224
251
|
recordOrderPlacement: typeof order.recordOrderPlacement;
|
|
225
252
|
isFreshlyPlacedOrder: typeof order.isFreshlyPlacedOrder;
|
|
@@ -83,10 +83,6 @@ declare class Logger {
|
|
|
83
83
|
* @param {string} [category='DEXBot'] - Logger category/prefix
|
|
84
84
|
* @param {Object} [options]
|
|
85
85
|
* @param {boolean} [options.quiet] - Suppress console output
|
|
86
|
-
* @param {boolean} [options.quietUnderPm2=false] - Legacy opt-in to suppress
|
|
87
|
-
* console output under PM2. Keep this false in normal operation: under
|
|
88
|
-
* PM2 stdout is the only sink (direct file writes are suppressed), so
|
|
89
|
-
* auto-quieting drops every log line.
|
|
90
86
|
* @param {string} [options.logFile] - Optional path to log file
|
|
91
87
|
* @param {string} [options.level='info'] - Log level
|
|
92
88
|
* @param {Object} [options.configOverride] - Override LOGGING_CONFIG
|
|
@@ -94,7 +90,6 @@ declare class Logger {
|
|
|
94
90
|
*/
|
|
95
91
|
constructor(category?: string, options?: {
|
|
96
92
|
quiet?: boolean;
|
|
97
|
-
quietUnderPm2?: boolean;
|
|
98
93
|
logFile?: string;
|
|
99
94
|
level?: string;
|
|
100
95
|
configOverride?: LoggerConfig;
|
|
@@ -179,9 +174,7 @@ declare function isPm2Runtime(): boolean;
|
|
|
179
174
|
* PM2-managed file.
|
|
180
175
|
*/
|
|
181
176
|
declare function isPm2LogCaptureActive(): boolean;
|
|
182
|
-
declare function createPm2AwareLogger(category: string, options?:
|
|
183
|
-
quietUnderPm2?: boolean;
|
|
184
|
-
}): Logger;
|
|
177
|
+
declare function createPm2AwareLogger(category: string, options?: ConstructorParameters<typeof Logger>[1]): Logger;
|
|
185
178
|
export { createPm2AwareLogger, isPm2Runtime, isPm2LogCaptureActive, setGlobalConsoleLevel, getGlobalConsoleLevel };
|
|
186
179
|
export default Logger;
|
|
187
180
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -105,10 +105,6 @@ class Logger {
|
|
|
105
105
|
* @param {string} [category='DEXBot'] - Logger category/prefix
|
|
106
106
|
* @param {Object} [options]
|
|
107
107
|
* @param {boolean} [options.quiet] - Suppress console output
|
|
108
|
-
* @param {boolean} [options.quietUnderPm2=false] - Legacy opt-in to suppress
|
|
109
|
-
* console output under PM2. Keep this false in normal operation: under
|
|
110
|
-
* PM2 stdout is the only sink (direct file writes are suppressed), so
|
|
111
|
-
* auto-quieting drops every log line.
|
|
112
108
|
* @param {string} [options.logFile] - Optional path to log file
|
|
113
109
|
* @param {string} [options.level='info'] - Log level
|
|
114
110
|
* @param {Object} [options.configOverride] - Override LOGGING_CONFIG
|
|
@@ -116,15 +112,10 @@ class Logger {
|
|
|
116
112
|
*/
|
|
117
113
|
constructor(category = 'DEXBot', options = {}) {
|
|
118
114
|
this.category = category;
|
|
119
|
-
const isUnderPm2 = !!Config.pm_exec_path;
|
|
120
115
|
this.logFile = options.logFile || null;
|
|
121
116
|
if (options.quiet !== undefined) {
|
|
122
117
|
this.quiet = options.quiet;
|
|
123
118
|
}
|
|
124
|
-
else if (options.quietUnderPm2 === true && isUnderPm2) {
|
|
125
|
-
// Legacy escape hatch: explicit opt-in to the old silent behaviour.
|
|
126
|
-
this.quiet = true;
|
|
127
|
-
}
|
|
128
119
|
else {
|
|
129
120
|
// Non-PM2 runs with a logFile write to the file only, so console is
|
|
130
121
|
// quiet to avoid duplication. Under PM2 the file sink is suppressed
|
|
@@ -553,7 +544,7 @@ class Logger {
|
|
|
553
544
|
if (!this.config.display?.statusSummary?.enabled && !forceOutput)
|
|
554
545
|
return;
|
|
555
546
|
const market = manager.marketName || manager.config?.market || 'unknown';
|
|
556
|
-
const
|
|
547
|
+
const liveOrders = manager.getOrdersByTypeAndState?.(null, ORDER_STATES.ACTIVE) || [];
|
|
557
548
|
const partialOrders = manager.getOrdersByTypeAndState?.(null, ORDER_STATES.PARTIAL) || [];
|
|
558
549
|
const virtualOrders = manager.getOrdersByTypeAndState?.(null, ORDER_STATES.VIRTUAL) || [];
|
|
559
550
|
const buyName = manager.config?.assetB?.symbol || manager.config?.assetB || 'quote';
|
|
@@ -579,7 +570,7 @@ class Logger {
|
|
|
579
570
|
`virtual.grid: ${buy}Buy ${Format.formatAmountByPrecision(virtualBuy, buyPrecision)}${reset} ${buyName} | ${sell}Sell ${Format.formatAmountByPrecision(virtualSell, sellPrecision)}${reset} ${sellName}`,
|
|
580
571
|
`committed.grid: ${buy}Buy ${Format.formatAmountByPrecision(committedGridBuy, buyPrecision)}${reset} ${buyName} | ${sell}Sell ${Format.formatAmountByPrecision(committedGridSell, sellPrecision)}${reset} ${sellName}`,
|
|
581
572
|
`committed.chain: ${buy}Buy ${Format.formatAmountByPrecision(committedChainBuy, buyPrecision)}${reset} ${buyName} | ${sell}Sell ${Format.formatAmountByPrecision(committedChainSell, sellPrecision)}${reset} ${sellName}`,
|
|
582
|
-
`Orders: Virtual ${virtualOrders.length} | Active ${
|
|
573
|
+
`Orders: Virtual ${virtualOrders.length} | Active ${liveOrders.length} | Partial ${partialOrders.length}`,
|
|
583
574
|
`Spreads: ${manager.initialSpreadCount > 0 ? `${manager.currentSpreadCount}/${manager.initialSpreadCount} (gap)` : 'n/a (gap)'}`,
|
|
584
575
|
];
|
|
585
576
|
if (typeof manager.calculateCurrentSpread === 'function') {
|
|
@@ -77,7 +77,7 @@ interface COWExecuteParams {
|
|
|
77
77
|
excludeIds?: Set<string>;
|
|
78
78
|
gapSlots?: number | null;
|
|
79
79
|
evacStreaks?: Map<string, number> | null;
|
|
80
|
-
|
|
80
|
+
edgeAnchors?: {
|
|
81
81
|
buy?: number | null;
|
|
82
82
|
sell?: number | null;
|
|
83
83
|
} | null;
|
|
@@ -93,7 +93,7 @@ declare class COWRebalanceEngine {
|
|
|
93
93
|
assets: AssetPair | null;
|
|
94
94
|
config: GridConfig;
|
|
95
95
|
});
|
|
96
|
-
execute({ masterGrid, gridVersion, boundaryIdx, funds, manager, fills, excludeIds, gapSlots, evacStreaks,
|
|
96
|
+
execute({ masterGrid, gridVersion, boundaryIdx, funds, manager, fills, excludeIds, gapSlots, evacStreaks, edgeAnchors }: COWExecuteParams): Promise<RebalanceResult>;
|
|
97
97
|
}
|
|
98
98
|
declare class OrderManager implements OrderManagerLike {
|
|
99
99
|
config: GridConfig;
|
|
@@ -131,10 +131,7 @@ declare class OrderManager implements OrderManagerLike {
|
|
|
131
131
|
lastTriggeredAt: number;
|
|
132
132
|
};
|
|
133
133
|
};
|
|
134
|
-
private
|
|
135
|
-
private _ordersByStateCache;
|
|
136
|
-
private _ordersByTypeCacheVersion;
|
|
137
|
-
private _ordersByStateCacheVersion;
|
|
134
|
+
private _orderIdIndexes;
|
|
138
135
|
/**
|
|
139
136
|
* Lazy-compute order-IDs grouped by type.
|
|
140
137
|
*
|
|
@@ -156,6 +153,8 @@ declare class OrderManager implements OrderManagerLike {
|
|
|
156
153
|
*/
|
|
157
154
|
get _ordersByState(): Record<string, Set<string>>;
|
|
158
155
|
set _ordersByState(val: Record<string, Set<string>>);
|
|
156
|
+
/** Rebuild an order-id index for `field` over `keys`, memoized per `_gridVersion`. */
|
|
157
|
+
private _getOrderIdIndex;
|
|
159
158
|
initialSpreadCount: number;
|
|
160
159
|
currentSpreadCount: number;
|
|
161
160
|
outOfSpread: number;
|
|
@@ -221,6 +220,13 @@ declare class OrderManager implements OrderManagerLike {
|
|
|
221
220
|
_lastFilledType: string | null;
|
|
222
221
|
_lastFilledAt: number;
|
|
223
222
|
lastFillPivotSource: 'fill' | 'book' | null;
|
|
223
|
+
_lastMarketFillPrice: number | null;
|
|
224
|
+
_lastMarketFillType: string | null;
|
|
225
|
+
_lastMarketFillAt: number;
|
|
226
|
+
_liveMarketPrice: number | null;
|
|
227
|
+
_liveMarketPriceAt: number;
|
|
228
|
+
_liveMarketPriceAttemptedAt: number;
|
|
229
|
+
_lastSyncAt: number;
|
|
224
230
|
_deferredRebalanceAt: number;
|
|
225
231
|
_lastHeldPlanSignature: {
|
|
226
232
|
boundaryIdx: number | null;
|
|
@@ -228,7 +234,6 @@ declare class OrderManager implements OrderManagerLike {
|
|
|
228
234
|
fillsAt: number | null;
|
|
229
235
|
} | null;
|
|
230
236
|
_heldPlanSuppressionCount: number;
|
|
231
|
-
_onBroadcastRegionEnd?: () => void;
|
|
232
237
|
_onBroadcastRegionEndListeners: Array<() => void>;
|
|
233
238
|
_lastBoundaryHoldResyncAt: number;
|
|
234
239
|
_gapEvacStreaks: Map<string, number>;
|
|
@@ -339,17 +344,15 @@ declare class OrderManager implements OrderManagerLike {
|
|
|
339
344
|
* without rescheduling, so this is the only wake-up for fills enqueued
|
|
340
345
|
* during a region; the watchdog path must fire it too or a hung broadcast's
|
|
341
346
|
* queued fills wait for the next fill event.
|
|
342
|
-
* Fans out to
|
|
343
|
-
*
|
|
344
|
-
*
|
|
345
|
-
* into a finally/watchdog frame.
|
|
347
|
+
* Fans out to every listener registered via addBroadcastRegionEndListener:
|
|
348
|
+
* a second wirer must never silently displace the fill-queue drain.
|
|
349
|
+
* Guarded so a listener error never escapes into a finally/watchdog frame.
|
|
346
350
|
* @returns {void}
|
|
347
351
|
*/
|
|
348
352
|
_fireBroadcastRegionEnd(): void;
|
|
349
353
|
/**
|
|
350
|
-
* Register
|
|
351
|
-
*
|
|
352
|
-
* registrations of the same function reference are ignored.
|
|
354
|
+
* Register a broadcast-region-end listener. Duplicate registrations of the
|
|
355
|
+
* same function reference are ignored.
|
|
353
356
|
* @param {() => void} listener
|
|
354
357
|
* @returns {void}
|
|
355
358
|
*/
|
|
@@ -764,7 +767,7 @@ declare class OrderManager implements OrderManagerLike {
|
|
|
764
767
|
}>) | null): Promise<{
|
|
765
768
|
ordersPlaced: number;
|
|
766
769
|
partialsMoved: number;
|
|
767
|
-
|
|
770
|
+
stall?: import("../types.js").SpreadCorrectionStall;
|
|
768
771
|
}>;
|
|
769
772
|
/**
|
|
770
773
|
* @param {Function} batchCb - Batch callback
|