dexbot 1.6.16 → 1.6.18

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.
Files changed (124) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/analysis/README.md +10 -9
  3. package/analysis/ama_fitting/README.md +2 -2
  4. package/analysis/bot_fitting/README.md +3 -3
  5. package/analysis/tradingview/README.md +2 -2
  6. package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +1 -1
  7. package/claw/package.json +1 -1
  8. package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
  9. package/claw/runtimes/openclaw-plugin/package.json +1 -1
  10. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +5 -3
  11. package/dist/analysis/analyze_args.d.ts +2 -1
  12. package/dist/analysis/fills_source.d.ts +1 -8
  13. package/dist/analysis/fills_source.js +1 -1
  14. package/dist/analysis/grid_correction_check.d.ts +9 -6
  15. package/dist/analysis/grid_correction_check.js +56 -64
  16. package/dist/analysis/math_utils.d.ts +1 -1
  17. package/dist/analysis/trade_profitability.d.ts +1 -1
  18. package/dist/analysis/tradingview/grid_reset_sim.js +1 -1
  19. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +7 -7
  20. package/dist/analysis/trend_detection/backtest_ama_slope_huber.js +1 -1
  21. package/dist/analysis/trend_detection/huber_scale_variants.d.ts +4 -3
  22. package/dist/market_adapter/cli_args.d.ts +6 -1
  23. package/dist/market_adapter/cli_args.js +16 -2
  24. package/dist/market_adapter/core/kibana_candles.d.ts +5 -1
  25. package/dist/market_adapter/core/kibana_candles.js +3 -1
  26. package/dist/market_adapter/core/strategies/regime_gate.d.ts +7 -1
  27. package/dist/market_adapter/core/strategies/regime_gate.js +3 -1
  28. package/dist/market_adapter/inputs/cex_candle_parsing.d.ts +7 -2
  29. package/dist/market_adapter/inputs/cex_candle_parsing.js +3 -1
  30. package/dist/market_adapter/inputs/fetch_book_data.d.ts +7 -1
  31. package/dist/market_adapter/inputs/fetch_book_data.js +3 -1
  32. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +2 -11
  33. package/dist/market_adapter/inputs/fetch_lp_data.d.ts +26 -1
  34. package/dist/market_adapter/inputs/fetch_lp_data.js +62 -52
  35. package/dist/market_adapter/inputs/kibana_feed_source.d.ts +14 -2
  36. package/dist/market_adapter/inputs/kibana_feed_source.js +14 -1
  37. package/dist/market_adapter/inputs/window_cache.d.ts +14 -3
  38. package/dist/market_adapter/inputs/window_cache.js +14 -1
  39. package/dist/market_adapter/lp_chart_runner.d.ts +12 -9
  40. package/dist/market_adapter/lp_chart_runner.js +3 -1
  41. package/dist/market_adapter/lp_chart_strategy_loader.d.ts +5 -1
  42. package/dist/market_adapter/lp_chart_strategy_loader.js +3 -1
  43. package/dist/market_adapter/market_adapter.d.ts +10 -2
  44. package/dist/market_adapter/market_adapter.js +10 -11
  45. package/dist/market_adapter/utils/chain.d.ts +2 -3
  46. package/dist/market_adapter/utils/file_json_cache.d.ts +5 -1
  47. package/dist/market_adapter/utils/file_json_cache.js +3 -1
  48. package/dist/market_adapter/utils/file_lock.js +1 -1
  49. package/dist/market_adapter/utils/native_history.d.ts +7 -3
  50. package/dist/market_adapter/utils/native_history.js +3 -1
  51. package/dist/market_adapter/utils/pair_orientation.d.ts +2 -2
  52. package/dist/modules/account_bots.d.ts +3 -0
  53. package/dist/modules/bots_file_lock.d.ts +2 -2
  54. package/dist/modules/bots_file_lock.js +2 -2
  55. package/dist/modules/chain_keys.d.ts +1 -1
  56. package/dist/modules/constants.d.ts +6 -0
  57. package/dist/modules/constants.js +37 -6
  58. package/dist/modules/credit_pricing.d.ts +20 -1
  59. package/dist/modules/credit_pricing.js +23 -1
  60. package/dist/modules/credit_runtime.js +33 -16
  61. package/dist/modules/dexbot_class.d.ts +11 -1
  62. package/dist/modules/dexbot_class.js +15 -2
  63. package/dist/modules/dexbot_cow_runtime.d.ts +90 -38
  64. package/dist/modules/dexbot_cow_runtime.js +507 -108
  65. package/dist/modules/dexbot_credential_client.d.ts +5 -0
  66. package/dist/modules/dexbot_maintenance_runtime.js +117 -12
  67. package/dist/modules/dexbot_startup_runtime.js +7 -1
  68. package/dist/modules/graceful_shutdown.d.ts +2 -2
  69. package/dist/modules/graceful_shutdown.js +2 -2
  70. package/dist/modules/launcher/credential_daemon.d.ts +14 -2
  71. package/dist/modules/launcher/credential_daemon.js +60 -26
  72. package/dist/modules/launcher/runtime_mode.d.ts +4 -3
  73. package/dist/modules/node_manager.d.ts +1 -1
  74. package/dist/modules/node_manager.js +1 -1
  75. package/dist/modules/order/accounting.js +2 -1
  76. package/dist/modules/order/export.d.ts +2 -2
  77. package/dist/modules/order/export.js +2 -2
  78. package/dist/modules/order/grid.d.ts +26 -14
  79. package/dist/modules/order/grid.js +416 -73
  80. package/dist/modules/order/grid_reconcile.js +5 -1
  81. package/dist/modules/order/grid_reconcile_internal.js +2 -1
  82. package/dist/modules/order/index.d.ts +22 -1
  83. package/dist/modules/order/manager.d.ts +40 -7
  84. package/dist/modules/order/manager.js +149 -23
  85. package/dist/modules/order/strategy.d.ts +5 -0
  86. package/dist/modules/order/strategy.js +44 -3
  87. package/dist/modules/order/sync_engine.d.ts +12 -1
  88. package/dist/modules/order/sync_engine.js +135 -20
  89. package/dist/modules/order/utils/math.d.ts +49 -10
  90. package/dist/modules/order/utils/math.js +71 -14
  91. package/dist/modules/order/utils/order.d.ts +65 -11
  92. package/dist/modules/order/utils/order.js +198 -28
  93. package/dist/modules/order/utils/system.d.ts +112 -2
  94. package/dist/modules/order/utils/system.js +338 -12
  95. package/dist/modules/order/utils/validate.d.ts +4 -1
  96. package/dist/modules/order/utils/validate.js +9 -2
  97. package/dist/modules/storage/index.d.ts +3 -2
  98. package/dist/modules/storage/index.js +3 -2
  99. package/dist/modules/types.d.ts +44 -2
  100. package/dist/scripts/analyze-credit.js +64 -23
  101. package/dist/scripts/bts_distribution.d.ts +66 -0
  102. package/dist/scripts/bts_distribution.js +2102 -0
  103. package/dist/scripts/token_distribution.d.ts +45 -0
  104. package/dist/scripts/token_distribution.js +1870 -0
  105. package/dist/unlock.js +42 -24
  106. package/docs/COPY_ON_WRITE_MASTER_PLAN.md +1 -1
  107. package/docs/COW_INVARIANTS.md +24 -8
  108. package/docs/DEXBOT_COMPARISON.md +5 -5
  109. package/docs/EVOLUTION.md +10 -8
  110. package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +13 -11
  111. package/docs/GRID_PRICE_INVARIANT.md +29 -3
  112. package/docs/GRID_RECALCULATION.md +3 -3
  113. package/docs/GRID_RECONCILE.md +5 -5
  114. package/docs/LIFECYCLE.md +11 -11
  115. package/docs/LOGGING.md +22 -0
  116. package/docs/MPA_CREDIT_USAGE.md +3 -2
  117. package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +236 -32
  118. package/docs/README.md +1 -1
  119. package/docs/architecture.md +205 -6
  120. package/docs/developer_guide.md +12 -0
  121. package/market_adapter/README.md +11 -6
  122. package/modules/README.md +18 -14
  123. package/package.json +6 -3
  124. package/scripts/README.md +85 -148
@@ -3,21 +3,31 @@
3
3
  /**
4
4
  * LAST-FILL-GUARD CHECK
5
5
  *
6
- * Validates LAST-FILL-GUARD discipline: pivot ± halfIncrement
7
- * Last fill @x with increment i (half=i/2) gates BOTH sides regardless of
8
- * last side — BUY must be < x*(1-half/100), SELL > x*(1+half/100).
9
- * e.g. x=1000, i=0.5% => BUY < 997.5 / SELL > 1002.5.
6
+ * Validates LAST-FILL-GUARD discipline — DIRECTION ONLY, relative to the last
7
+ * fill price (v1.6.16+, retrospective §9.7):
8
+ * BUY blocked if price >= pivot
9
+ * SELL blocked if price <= pivot
10
+ * e.g. pivot 1000 => BUY must be < 1000, SELL must be > 1000.
10
11
  * Cold start (no previous fill) is disabled.
11
- * Intentional offline gaps (documented, acceptable):
12
+ *
13
+ * The older rule judged against `pivot ± increment/2` and ignored the fill
14
+ * side, which blocked a BUY below a SELL fill and a SELL one tick above our
15
+ * cost — i.e. it reported the tightening placements the current engine
16
+ * legitimately makes as violations. Do not reintroduce an increment term here.
17
+ *
18
+ * Intentional offline gaps (documented, acceptable):
12
19
  * - Runtime pivots on _lastFilledPrice/_lastFilledType at decision time; tool
13
20
  * checks consecutive fill pairs. For batch-placed orders (multiple orders
14
21
  * guarded against the same pivot in one COW batch) this diverges — inherent
15
22
  * offline approximation.
16
23
  * - Spread-correction bypass (cowResult.origin === 'spread-correction') is
17
24
  * not simulated — every consecutive pair is checked.
25
+ * - EDGE-pinned insurance fills no longer arm the runtime pivot
26
+ * (recordLastFilledPrices skips them); this reconstruction has no slot
27
+ * identity for a fill, so it cannot classify edge fills and will still
28
+ * judge the pair after one. Expect rare false positives on wick fills.
18
29
  *
19
- * Mirrors modules/dexbot_cow_runtime.ts:isLastFillGuardBlocked 1:1 and
20
- * modules/constants.ts:DEFAULT_CONFIG.incrementPercent fallback (0.5).
30
+ * Mirrors modules/order/utils/system.ts:isLastFillGuardBlocked 1:1.
21
31
  *
22
32
  * Fetches fill_order operations from Kibana (same pipeline as
23
33
  * trade_profitability.ts) and checks for last-fill guard violations.
@@ -41,41 +51,32 @@ import { resolveBotAccount } from './account_resolver.js';
41
51
  import { classifyFill, assetSymbol, fetchAllFills, resolveAssetPrecisions, } from './fills_source.js';
42
52
  const { kibanaSearch, DEFAULT_CONFIG: BASE_CONFIG } = KC;
43
53
  const OP_LIMIT_ORDER_UPDATE = 77;
44
- // ─── LAST-FILL-GUARD helper (1:1 with dexbot_cow_runtime.ts) ─────────────────
54
+ // ─── LAST-FILL-GUARD helper (1:1 with modules/order/utils/system.ts) ────────────
45
55
  /**
46
- * LAST-FILL-GUARD helper — pivot ± halfIncrement (replaces price-tolerance).
47
- * last fill @x with increment i: BUY < x*(1 - i/2/100), SELL > x*(1 + i/2/100)
48
- * e.g. x=1000, i=0.5% => BUY < 997.5, SELL > 1002.5
49
- * Cold (pivot null or lastType null) => disabled.
56
+ * LAST-FILL-GUARD helper — DIRECTION ONLY relative to the last fill price.
57
+ * BUY blocked if price >= pivot
58
+ * SELL blocked if price <= pivot
59
+ * e.g. pivot 1000 => BUY must be < 1000, SELL must be > 1000
60
+ * Cold (pivot null or lastType null) => disabled. Equal price stays blocked
61
+ * (a re-place at the just-filled level).
50
62
  * @param {number} price - Target order price
51
63
  * @param {string} type - buy/sell
52
64
  * @param {number|null} lastPrice - Most recent fill price
53
65
  * @param {string|null} lastType - Most recent fill side (buy/sell)
54
- * @param {number|any} incrementPercent - Grid increment percent (e.g. 0.5). If not finite/<=0 falls back to DEFAULT_CONFIG.
55
66
  * @returns {{blocked: boolean, pivot: number|null, halfInc: number, threshold: number|null}}
56
67
  */
57
- function isLastFillGuardBlocked(price, type, lastPrice, lastType, incrementPercent) {
68
+ function isLastFillGuardBlocked(price, type, lastPrice, lastType) {
58
69
  const numPrice = Number(price);
59
70
  if (!Number.isFinite(numPrice))
60
71
  return { blocked: false, pivot: null };
61
72
  if (lastPrice == null || !Number.isFinite(Number(lastPrice)) || lastType == null)
62
73
  return { blocked: false, pivot: null };
63
74
  const pivot = Number(lastPrice);
64
- let inc = Number(incrementPercent);
65
- if (!Number.isFinite(inc) || inc <= 0) {
66
- inc = Number(C.DEFAULT_CONFIG?.incrementPercent ?? 0.5);
67
- }
68
- if (!Number.isFinite(inc) || inc <= 0)
69
- return { blocked: false, pivot: null };
70
- const halfInc = inc / 2;
71
- const halfPct = halfInc / 100;
72
- const buyThreshold = pivot * (1 - halfPct);
73
- const sellThreshold = pivot * (1 + halfPct);
74
- if (type === 'buy' && numPrice > buyThreshold)
75
- return { blocked: true, pivot, halfInc, threshold: buyThreshold };
76
- if (type === 'sell' && numPrice < sellThreshold)
77
- return { blocked: true, pivot, halfInc, threshold: sellThreshold };
78
- return { blocked: false, pivot: null, halfInc, threshold: null };
75
+ if (type === 'buy' && numPrice >= pivot)
76
+ return { blocked: true, pivot, halfInc: 0, threshold: pivot };
77
+ if (type === 'sell' && numPrice <= pivot)
78
+ return { blocked: true, pivot, halfInc: 0, threshold: pivot };
79
+ return { blocked: false, pivot: null, halfInc: 0, threshold: null };
79
80
  }
80
81
  function resolveIncrementPercent(botMeta, override) {
81
82
  if (override != null && Number.isFinite(override) && override > 0)
@@ -93,11 +94,11 @@ function printHelp() {
93
94
  console.log(`\
94
95
  Usage: node dist/analysis/grid_correction_check.js --bot-key <key> [options]
95
96
 
96
- Validates LAST-FILL-GUARD discipline (pivot ± halfIncrement):
97
- last fill @x with increment i (half=i/2) gates both sides —
98
- BUY must be < x*(1-half/100), SELL > x*(1+half/100).
99
- e.g. x=1000, i=0.5% => BUY < 997.5 / SELL > 1002.5.
100
- Mirrors dexbot_cow_runtime:isLastFillGuardBlocked 1:1.
97
+ Validates LAST-FILL-GUARD discipline (DIRECTION ONLY relative to the last fill):
98
+ BUY must be < last fill price, SELL must be > last fill price.
99
+ Equal price counts as blocked (a re-place at the just-filled level).
100
+ Mirrors modules/order/utils/system:isLastFillGuardBlocked 1:1.
101
+ Cold start (no previous fill) is disabled.
101
102
 
102
103
  Required:
103
104
  --bot-key <key> Bot key (e.g. my-grid-bot) or bot name (use --list-bots)
@@ -112,8 +113,9 @@ Options:
112
113
  --refresh-account Force re-resolution of preferredAccount and update the
113
114
  stored accountId when it changed (default: reuse the
114
115
  stored accountId with no chain lookup)
115
- --increment <pct> Grid increment percent (default: from bot config or ${Number(C.DEFAULT_CONFIG?.incrementPercent ?? 0.5)})
116
- --tolerance <pct> Deprecated alias for --increment (kept for compat, prefer --increment)
116
+ --increment <pct> Grid increment percent, informational only — the
117
+ direction-only guard does not use a band
118
+ (default: from bot config or ${Number(C.DEFAULT_CONFIG?.incrementPercent ?? 0.5)})
117
119
  --per-fill Check at fill granularity (default: per-order aggregated)
118
120
  --include-cross-pair Check consecutive fills across different pairs (default: same pair only)
119
121
  --json <file> Export violations as JSON
@@ -191,15 +193,6 @@ function parseArgs() {
191
193
  case '--increment':
192
194
  opts.incrementPercent = parseFloat(args[++i]);
193
195
  break;
194
- case '--tolerance': {
195
- const v = parseFloat(args[++i]);
196
- // Back-compat: old --tolerance was adverse pct before flagging; now map to increment if user still passes it
197
- // Prefer explicit --increment; don't overwrite if already set
198
- if (opts.incrementPercent == null)
199
- opts.incrementPercent = v > 0 ? v * 2 : null; // heuristic: old tolerance ~ halfInc, so inc ~ 2*tolerance
200
- console.warn(`[warn] --tolerance is deprecated, use --increment <pct> (e.g. --increment ${v > 0 ? (v * 2) : 0.5})`);
201
- break;
202
- }
203
196
  case '--json':
204
197
  opts.json = args[++i];
205
198
  break;
@@ -416,7 +409,7 @@ function aggregateByOrder(trades, updates = []) {
416
409
  return orders.sort((a, b) => a.sequence - b.sequence);
417
410
  }
418
411
  // ─── Violation detection (LAST-FILL-GUARD 1:1) ────────────────────────────────
419
- function detectViolations(items, includeCrossPair, incrementPercent) {
412
+ function detectViolations(items, includeCrossPair) {
420
413
  const violations = [];
421
414
  let checkedTransitions = 0;
422
415
  // Helper for a single chronological sequence (already filtered to one pair or global)
@@ -428,7 +421,7 @@ function detectViolations(items, includeCrossPair, incrementPercent) {
428
421
  if (prev.orderId && prev.orderId === curr.orderId)
429
422
  continue;
430
423
  checkedTransitions++;
431
- const check = isLastFillGuardBlocked(curr.price, curr.direction, prev.price, prev.direction, incrementPercent);
424
+ const check = isLastFillGuardBlocked(curr.price, curr.direction, prev.price, prev.direction);
432
425
  if (check.blocked) {
433
426
  const delta = curr.price - prev.price;
434
427
  const deltaPct = prev.price !== 0 ? (delta / prev.price) * 100 : 0;
@@ -437,13 +430,13 @@ function detectViolations(items, includeCrossPair, incrementPercent) {
437
430
  index: i,
438
431
  pair: `${curr.baseAsset}:${curr.quoteAsset}`,
439
432
  direction: curr.direction,
440
- expected: isSell ? `> ${check.threshold?.toFixed(6)} (pivot ${check.pivot} +${check.halfInc}%)` : `< ${check.threshold?.toFixed(6)} (pivot ${check.pivot} -${check.halfInc}%)`,
433
+ expected: isSell ? `> ${check.threshold?.toFixed(6)} (last fill ${check.pivot})` : `< ${check.threshold?.toFixed(6)} (last fill ${check.pivot})`,
441
434
  prev: prev,
442
435
  curr: curr,
443
436
  priceDelta: delta,
444
437
  priceDeltaPct: deltaPct,
445
438
  pivot: check.pivot,
446
- halfInc: check.halfInc,
439
+ halfInc: 0,
447
440
  threshold: check.threshold,
448
441
  });
449
442
  }
@@ -486,10 +479,11 @@ function printReport(trades, orders, violations, checkedTransitions, skipped, ra
486
479
  pairGroups.set(k, []);
487
480
  pairGroups.get(k).push(t);
488
481
  }
489
- const halfInc = incrementPercent / 2;
482
+ // Direction-only guard: no band. The Violation row keeps halfInc = 0 so the
483
+ // JSON/CSV shape stays stable for existing consumers.
490
484
  console.log('');
491
485
  console.log('═══════════════════════════════════════════════════════════════════');
492
- console.log(' LAST-FILL-GUARD CHECK (pivot ± halfIncrement)');
486
+ console.log(' LAST-FILL-GUARD CHECK (direction only)');
493
487
  console.log('═══════════════════════════════════════════════════════════════════');
494
488
  console.log(` Bot key: ${botKey}${botMeta?.name ? ` (name: ${botMeta.name})` : ''}`);
495
489
  if (botMeta)
@@ -497,8 +491,8 @@ function printReport(trades, orders, violations, checkedTransitions, skipped, ra
497
491
  console.log(` Account: ${accountId}`);
498
492
  console.log(` Range: ${rangeLabel}`);
499
493
  console.log(` Mode: ${perFill ? 'per-fill' : 'per-order (aggregated)'}${includeCrossPair ? ', cross-pair enabled' : ', same-pair only'}`);
500
- console.log(` Increment: ${incrementPercent}% (halfInc ${halfInc}%)`);
501
- console.log(` Guard: BUY < pivot*(1-${halfInc}%) / SELL > pivot*(1+${halfInc}%) — both sides, global pivot`);
494
+ console.log(` Increment: ${incrementPercent}% (informational — the guard is direction-only)`);
495
+ console.log(' Guard: BUY < last fill / SELL > last fill — both sides, global pivot');
502
496
  console.log('');
503
497
  const buyCount = trades.filter(t => t.direction === 'buy').length;
504
498
  const sellCount = trades.filter(t => t.direction === 'sell').length;
@@ -512,7 +506,7 @@ function printReport(trades, orders, violations, checkedTransitions, skipped, ra
512
506
  console.log(` Violations: ${violations.length}${checkedTransitions > 0 ? ` (${((violations.length / checkedTransitions) * 100).toFixed(2)}%)` : ''}`);
513
507
  console.log('');
514
508
  if (violations.length === 0) {
515
- console.log(' ✅ PASS — no LAST-FILL-GUARD violations detected (all BUY < pivot-half, SELL > pivot+half).');
509
+ console.log(' ✅ PASS — no LAST-FILL-GUARD violations detected (all BUY < last fill, all SELL > last fill).');
516
510
  console.log('');
517
511
  if (checkedTransitions === 0) {
518
512
  console.log(' Note: no consecutive transitions in range to check.');
@@ -526,7 +520,7 @@ function printReport(trades, orders, violations, checkedTransitions, skipped, ra
526
520
  // Per-direction breakdown (blocked side = curr direction)
527
521
  const buyV = violations.filter(v => v.direction === 'buy').length;
528
522
  const sellV = violations.filter(v => v.direction === 'sell').length;
529
- console.log(` Breakdown: sell violations: ${sellV} (SELL < pivot+half), buy violations: ${buyV} (BUY > pivot-half)`);
523
+ console.log(` Breakdown: sell violations: ${sellV} (SELL <= last fill), buy violations: ${buyV} (BUY >= last fill)`);
530
524
  console.log('');
531
525
  // Timeline clustering by day
532
526
  const dayBuckets = new Map();
@@ -556,9 +550,9 @@ function printReport(trades, orders, violations, checkedTransitions, skipped, ra
556
550
  }
557
551
  console.log('');
558
552
  // Detailed violation table
559
- console.log(' ── Violations (pivot ± halfIncrement) ──');
553
+ console.log(' ── Violations (direction only) ──');
560
554
  console.log('');
561
- const hdr = ' # Pair Dir Prev Price Curr Price Thr Δ% Half% Prev Time Curr Time Prev Order Curr Order';
555
+ const hdr = ' # Pair Dir Prev Price Curr Price Last Fill Δ% Prev Time Curr Time Prev Order Curr Order';
562
556
  console.log(hdr);
563
557
  console.log(' ' + '─'.repeat(hdr.length - 2));
564
558
  for (let i = 0; i < violations.length; i++) {
@@ -570,24 +564,22 @@ function printReport(trades, orders, violations, checkedTransitions, skipped, ra
570
564
  const thr = fmt(v.threshold, 6).padStart(12);
571
565
  const delta = (v.priceDeltaPct >= 0 ? '+' : '') + v.priceDeltaPct.toFixed(4) + '%';
572
566
  const deltaStr = delta.padStart(9);
573
- const halfStr = (v.halfInc.toFixed(3) + '%').padStart(6);
574
567
  const pTime = (v.prev.time || '').slice(0, 19).replace('T', ' ').padEnd(19);
575
568
  const cTime = (v.curr.time || '').slice(0, 19).replace('T', ' ').padEnd(19);
576
569
  const pOrd = (v.prev.orderId || '-').slice(0, 16).padEnd(16);
577
570
  const cOrd = (v.curr.orderId || '-').slice(0, 16).padEnd(16);
578
571
  const marker = v.direction === 'sell' ? `SELL < ${fmt(v.threshold, 4)}` : `BUY > ${fmt(v.threshold, 4)}`;
579
- console.log(` ${(String(i + 1)).padStart(2)} ${pairLabel} ${dir} ${pPrice} ${cPrice} ${thr} ${deltaStr} ${halfStr} ${pTime} ${cTime} ${pOrd} ${cOrd} ${marker}`);
572
+ console.log(` ${(String(i + 1)).padStart(2)} ${pairLabel} ${dir} ${pPrice} ${cPrice} ${thr} ${deltaStr} ${pTime} ${cTime} ${pOrd} ${cOrd} ${marker}`);
580
573
  }
581
574
  console.log('');
582
- console.log(` Guard: BUY must be < pivot*(1-${halfInc}%), SELL > pivot*(1+${halfInc}%) — blocked if violated (mirrors bot).`);
583
- console.log(` Increment ${incrementPercent}% => halfInc ${halfInc}% — e.g. pivot 1000 => BUY thr ${(1000 * (1 - halfInc / 100)).toFixed(4)}, SELL thr ${(1000 * (1 + halfInc / 100)).toFixed(4)}`);
575
+ console.log(' Guard: BUY must be < the last fill price, SELL > it (equal price blocked) — mirrors bot.');
576
+ console.log(` No band: the grid increment (${incrementPercent}%) is reported for context only.`);
584
577
  console.log('');
585
578
  }
586
579
  function exportJson(filePath, violations, trades, rangeLabel, botKey, accountId, incrementPercent) {
587
580
  const payload = {
588
581
  botKey, accountId, range: rangeLabel,
589
582
  incrementPercent,
590
- halfIncrement: incrementPercent / 2,
591
583
  totalFills: trades.length,
592
584
  violations: violations.map(v => ({
593
585
  pair: `${assetSymbol(v.prev.baseAsset)}/${assetSymbol(v.prev.quoteAsset)}`,
@@ -638,7 +630,7 @@ async function main() {
638
630
  const botMeta = resolvedAccount.botMeta;
639
631
  console.log(`Account: ${accountId}${botMeta ? ` (${botMeta.assetA}/${botMeta.assetB})` : ''}`);
640
632
  const incrementPercent = resolveIncrementPercent(botMeta, opts.incrementPercent);
641
- console.log(`Increment: ${incrementPercent}% (halfInc ${incrementPercent / 2}%)${opts.incrementPercent == null && botMeta?.incrementPercent != null ? ' — from bot config' : opts.incrementPercent != null ? ' — from --increment' : ' — default'}`);
633
+ console.log(`Increment: ${incrementPercent}% (informational; the guard is direction-only)${opts.incrementPercent == null && botMeta?.incrementPercent != null ? ' — from bot config' : opts.incrementPercent != null ? ' — from --increment' : ' — default'}`);
642
634
  console.log(`\nFetching fills and order updates from Kibana...`);
643
635
  const [fills, orderUpdates] = await Promise.all([
644
636
  fetchAllFills({}, accountId, gte, lte),
@@ -677,7 +669,7 @@ async function main() {
677
669
  console.log(` Aggregated into ${orders.length} order epoch(s) (partial fills collapsed; repriced orders kept separate)`);
678
670
  items = orders;
679
671
  }
680
- const { violations, checkedTransitions } = detectViolations(items, opts.includeCrossPair, incrementPercent);
672
+ const { violations, checkedTransitions } = detectViolations(items, opts.includeCrossPair);
681
673
  const ordersForReport = opts.perFill ? null : items;
682
674
  printReport(trades, ordersForReport, violations, checkedTransitions, skipped, label, String(opts.botKey), accountId, botMeta, opts.perFill, opts.includeCrossPair, incrementPercent, gte, lte);
683
675
  if (opts.json)
@@ -72,7 +72,7 @@ declare function geometricRange(min: number, max: number, count: number, { decim
72
72
  * Parse a candle JSON file with format detection:
73
73
  * flat array → {candles: [...]} → {data: [...]}
74
74
  */
75
- export interface CandleFile {
75
+ interface CandleFile {
76
76
  candles: Record<string, unknown>[];
77
77
  meta: Record<string, unknown> | null;
78
78
  }
@@ -146,5 +146,5 @@ declare function computeMetrics(pair: PairAnalysis, window?: WindowRange): Tradi
146
146
  /** Auto-named report file: bot/account + pair filter + requested range. */
147
147
  declare function reportFileName(opts: TradeProfitabilityOptions, accountRef: string, botName: string | null): string;
148
148
  declare function run(argv?: string[]): Promise<void>;
149
- export { analyzePair, classifyFills, computeMetrics, parseArgs, run, reportFileName, TradeFill, FillRecord, RealizedPnl, PairAnalysis, TradingMetrics, WindowRange };
149
+ export { analyzePair, classifyFills, computeMetrics, parseArgs, run, reportFileName, TradeFill, FillRecord, PairAnalysis, TradingMetrics };
150
150
  //# sourceMappingURL=trade_profitability.d.ts.map
@@ -69,7 +69,7 @@ function gridSimNonNegativeInt(value, fallback) {
69
69
  * UNCLIPPED `slopePct`; the clipped value only feeds the range tilt.
70
70
  */
71
71
  function gridSimSlopeSignal(slopePct, clipThreshold, cfg) {
72
- const maxSlopePct = gridSimPositiveNumber(cfg?.maxSlopePct, 0.09);
72
+ const maxSlopePct = gridSimPositiveNumber(cfg?.maxSlopePct, 0.1);
73
73
  const neutralZonePct = Number.isFinite(Number(cfg?.neutralZonePct)) ? Number(cfg.neutralZonePct) : 0;
74
74
  const maxSlopeOffset = gridSimPositiveNumber(cfg?.maxSlopeOffset, 0.5);
75
75
  // null/undefined/NaN all mean "no slope this bar" (computeAmaSlopeWeights'
@@ -637,9 +637,9 @@ function generateHTML(data, title = 'TradingView Style Research') {
637
637
  <button type="button" class="step-btn" id="ama-slow-dec">▼</button>
638
638
  </span>
639
639
  <button type="button" class="reset-btn ama-preset-btn" data-ama-preset="AMA1" title="AMA1 (slow 62.1)">1</button>
640
- <button type="button" class="reset-btn ama-preset-btn" data-ama-preset="AMA2" title="AMA2 (slow 72.0)">2</button>
641
- <button type="button" class="reset-btn ama-preset-btn" data-ama-preset="AMA3" title="AMA3 (slow 83.6)">3</button>
642
- <button type="button" class="reset-btn ama-preset-btn" data-ama-preset="AMA4" title="AMA4 (slow 96.9)">4</button>
640
+ <button type="button" class="reset-btn ama-preset-btn" data-ama-preset="AMA2" title="AMA2 (slow 71.5)">2</button>
641
+ <button type="button" class="reset-btn ama-preset-btn" data-ama-preset="AMA3" title="AMA3 (slow 83.5)">3</button>
642
+ <button type="button" class="reset-btn ama-preset-btn" data-ama-preset="AMA4" title="AMA4 (slow 99.3)">4</button>
643
643
  </div>
644
644
  <div class="indicator" title="Range min/max built only from the live AMA price (red above, green below); Scale sizes it by AMA slope like the grid build. Turning either on also turns on what it needs (Range → AMA, Scale → Range + AMA)">
645
645
  <label><input type="checkbox" id="range-toggle"${defaults.rangeEnabled ? ' checked' : ''}> Range</label>
@@ -1723,7 +1723,7 @@ function generateHTML(data, title = 'TradingView Style Research') {
1723
1723
  const slopeCfg = payload.rangeSlope || {};
1724
1724
  const gridCfg = payload.grid || null;
1725
1725
  const lookback = resolveSlopeLookbackBars();
1726
- const maxSlope = Number(slopeCfg.maxSlopePct) > 0 ? Number(slopeCfg.maxSlopePct) : 0.09;
1726
+ const maxSlope = Number(slopeCfg.maxSlopePct) > 0 ? Number(slopeCfg.maxSlopePct) : 0.1;
1727
1727
  const neutral = Number(slopeCfg.neutralZonePct) >= 0 ? Number(slopeCfg.neutralZonePct) : 0;
1728
1728
  const maxSlopeOffset = Number(slopeCfg.maxSlopeOffset) > 0 ? Number(slopeCfg.maxSlopeOffset) : 0.5;
1729
1729
  const maxAsym = gridCfg && Number(gridCfg.maxAsymmetryFactor) > 0
@@ -3480,7 +3480,7 @@ function generateHTML(data, title = 'TradingView Style Research') {
3480
3480
  document.getElementById('ama-init-offset').disabled = !currentAmaInitOffsetEnabled;
3481
3481
  document.getElementById('ama-init-offset-val').textContent = currentAmaInitOffset + '%';
3482
3482
  currentVwapEnabled = document.getElementById('vwap-toggle').checked;
3483
- currentVwapBars = clamp(Math.round(Number(document.getElementById('vwap-bars').value) || 500), 24, 2000);
3483
+ currentVwapBars = clamp(Math.round(Number(document.getElementById('vwap-bars').value) || 500), 10, 2000);
3484
3484
  currentRangeEnabled = document.getElementById('range-toggle').checked;
3485
3485
  currentRangeScaleEnabled = document.getElementById('range-scale-toggle').checked;
3486
3486
  currentRangeSpan = Math.min(${RANGE_SPAN_MAX}, Math.max(${RANGE_SPAN_MIN}, Math.round((Number(document.getElementById('range-span').value) || ${RANGE_SPAN_DEFAULT}) * 20) / 20));
@@ -3609,8 +3609,8 @@ function generateHTML(data, title = 'TradingView Style Research') {
3609
3609
  addHold(dec, -1);
3610
3610
  addHold(inc, 1);
3611
3611
  }
3612
- makeStepper('sma-period', 1, 1, 0);
3613
- makeStepper('vwap-bars', 1, 24, 0);
3612
+ makeStepper('sma-period', 10, 10, 0);
3613
+ makeStepper('vwap-bars', 10, 10, 0);
3614
3614
  makeStepper('ama-er', 10, 1, 0);
3615
3615
  makeStepper('ama-fast', 0.1, 0.1, 1);
3616
3616
  makeStepper('ama-slow', 1, 0.1, 1);
@@ -196,7 +196,7 @@ function resolveAma(cfg) {
196
196
  if (cfg.er != null || cfg.fast != null || cfg.slow != null) {
197
197
  const er = cfg.er ?? 781;
198
198
  const fast = cfg.fast ?? 5.2;
199
- const slow = cfg.slow ?? 83.6;
199
+ const slow = cfg.slow ?? MA.AMAS.AMA3.slowPeriod;
200
200
  return { name: `custom(er=${er},f=${fast},s=${slow})`, er, fast, slow };
201
201
  }
202
202
  const presets = MA.AMAS;
@@ -1,18 +1,18 @@
1
1
  export type HuberScaleMode = 'none' | 'df' | 'mscale';
2
2
  /** One-bar diagnostic snapshot returned alongside the slope. */
3
- export interface HuberDiagnostics {
3
+ interface HuberDiagnostics {
4
4
  slopePct: number;
5
5
  scale: number;
6
6
  outlierFraction: number;
7
7
  }
8
8
  /** Accumulated stats attached to an estimator built by {@link createHuberEstimator}. */
9
- export interface HuberEstimatorStats {
9
+ interface HuberEstimatorStats {
10
10
  calls: number;
11
11
  outlierFractionSum: number;
12
12
  scaleSum: number;
13
13
  }
14
14
  /** Estimator function shape accepted by simulateGridResetSeries (cfg.slopeEstimator). */
15
- export interface HuberConsts {
15
+ interface HuberConsts {
16
16
  C?: number;
17
17
  ITERATIONS?: number;
18
18
  SCALE_FLOOR?: number;
@@ -37,4 +37,5 @@ export declare function huberSlopeCore(amaValues: unknown, index: number, lookba
37
37
  * accumulating the mean outlier fraction and scale across calls in `.stats`.
38
38
  */
39
39
  export declare function createHuberEstimator(mode?: HuberScaleMode, hub?: HuberConsts): HuberEstimator;
40
+ export {};
40
41
  //# sourceMappingURL=huber_scale_variants.d.ts.map
@@ -7,10 +7,14 @@
7
7
  * register handlers instead of re-listing the same switch cases; the walker
8
8
  * owns value consumption, `--help`/`-h`, and the unknown-flag error.
9
9
  *
10
+ * Values are the next argv token, or the text after `=` in a `--flag=value`
11
+ * token. The `=` form exists because a bare value that itself starts with `--`
12
+ * is rejected as a missing value (`--out --weird` fails, `--out=--weird` works).
13
+ *
10
14
  * Deliberately free of Node globals: callers pass in their own argv and own
11
15
  * the `process.exit` policy via `onHelp`, so this module stays browser-safe.
12
16
  */
13
- export interface CliArgHandlers {
17
+ interface CliArgHandlers {
14
18
  /** Flags that take a value; receives the raw next argv token (never missing or flag-shaped). */
15
19
  value?: Record<string, (raw: string) => void>;
16
20
  /** Flags that take no value. */
@@ -19,4 +23,5 @@ export interface CliArgHandlers {
19
23
  onHelp: () => void;
20
24
  }
21
25
  export declare function walkCliArgs(args: readonly string[], handlers: CliArgHandlers): void;
26
+ export {};
22
27
  //# sourceMappingURL=cli_args.d.ts.map
@@ -1,16 +1,27 @@
1
1
  'use strict';
2
2
  export function walkCliArgs(args, handlers) {
3
3
  for (let i = 0; i < args.length; i++) {
4
- const a = args[i];
4
+ const rawArg = args[i];
5
+ // `--flag=value` keeps a value that itself starts with `--` addressable.
6
+ const eq = rawArg.startsWith('--') ? rawArg.indexOf('=') : -1;
7
+ const inlineValue = eq > 2 ? rawArg.slice(eq + 1) : undefined;
8
+ const a = eq > 2 ? rawArg.slice(0, eq) : rawArg;
5
9
  if (a === '--gridResetFactor') {
6
10
  throw new Error('--gridResetFactor is no longer supported; use --deltaPercent <percent>');
7
11
  }
8
12
  if (a === '--help' || a === '-h') {
13
+ if (inlineValue !== undefined) {
14
+ throw new Error(`Flag ${a} does not take a value`);
15
+ }
9
16
  handlers.onHelp();
10
17
  continue;
11
18
  }
12
19
  const valueHandler = handlers.value?.[a];
13
20
  if (valueHandler) {
21
+ if (inlineValue !== undefined) {
22
+ valueHandler(inlineValue);
23
+ continue;
24
+ }
14
25
  const raw = args[i + 1];
15
26
  if (raw === undefined || raw.startsWith('--')) {
16
27
  throw new Error(`Flag ${a} expects a value; got ${raw === undefined ? 'nothing' : raw}`);
@@ -21,10 +32,13 @@ export function walkCliArgs(args, handlers) {
21
32
  }
22
33
  const flagHandler = handlers.flag?.[a];
23
34
  if (flagHandler) {
35
+ if (inlineValue !== undefined) {
36
+ throw new Error(`Flag ${a} does not take a value`);
37
+ }
24
38
  flagHandler();
25
39
  continue;
26
40
  }
27
- throw new Error(`Unknown argument: ${a}`);
41
+ throw new Error(`Unknown argument: ${rawArg}`);
28
42
  }
29
43
  }
30
44
  //# sourceMappingURL=cli_args.js.map
@@ -81,5 +81,9 @@ declare function resolveRequestedFillRange(cfg: KibanaCandleConfig, nowMs?: numb
81
81
  */
82
82
  declare function fetchKibanaCandles({ opType, fieldMap, assetA, assetB, config, poolId }: KibanaCandlesParams): Promise<number[][]>;
83
83
  declare function fetchKibanaClosePrices(params: KibanaCandlesParams): Promise<number[]>;
84
- export { buildDirectionalDocumentQuery, resolveRequestedFillRange, fetchKibanaCandles, fetchKibanaClosePrices, sourceFieldsForFieldMap, hitSortKey, hitSequence };
84
+ export { buildDirectionalDocumentQuery, resolveRequestedFillRange, fetchKibanaCandles, fetchKibanaClosePrices, hitSortKey, hitSequence };
85
+ /** Internal seams exercised directly by tests. */
86
+ export declare const __test: {
87
+ sourceFieldsForFieldMap: typeof sourceFieldsForFieldMap;
88
+ };
85
89
  //# sourceMappingURL=kibana_candles.d.ts.map
@@ -418,5 +418,7 @@ async function fetchKibanaClosePrices(params) {
418
418
  const candles = await fetchKibanaCandles(params);
419
419
  return candles.map((candle) => candle[4]);
420
420
  }
421
- export { buildDirectionalDocumentQuery, resolveRequestedFillRange, fetchKibanaCandles, fetchKibanaClosePrices, sourceFieldsForFieldMap, hitSortKey, hitSequence };
421
+ export { buildDirectionalDocumentQuery, resolveRequestedFillRange, fetchKibanaCandles, fetchKibanaClosePrices, hitSortKey, hitSequence };
422
+ /** Internal seams exercised directly by tests. */
423
+ export const __test = { sourceFieldsForFieldMap };
422
424
  //# sourceMappingURL=kibana_candles.js.map
@@ -105,5 +105,11 @@ export interface RegimeMultiplierResult {
105
105
  series: number[];
106
106
  }
107
107
  declare function computeRegimeMultiplier(closes: unknown, opts?: RegimeOpts): RegimeMultiplierResult;
108
- export { computeRegimeMultiplier, _resetRegimeCache, _locateResume, _analyzerBufferSize };
108
+ export { computeRegimeMultiplier };
109
+ /** Internal seams exercised directly by tests. */
110
+ export declare const __test: {
111
+ _resetRegimeCache: typeof _resetRegimeCache;
112
+ _locateResume: typeof _locateResume;
113
+ _analyzerBufferSize: typeof _analyzerBufferSize;
114
+ };
109
115
  //# sourceMappingURL=regime_gate.d.ts.map
@@ -294,5 +294,7 @@ function computeRegimeMultiplier(closes, opts = {}) {
294
294
  series: series.map((value) => roundTo(value, 1000)),
295
295
  };
296
296
  }
297
- export { computeRegimeMultiplier, _resetRegimeCache, _locateResume, _analyzerBufferSize };
297
+ export { computeRegimeMultiplier };
298
+ /** Internal seams exercised directly by tests. */
299
+ export const __test = { _resetRegimeCache, _locateResume, _analyzerBufferSize };
298
300
  //# sourceMappingURL=regime_gate.js.map
@@ -7,7 +7,7 @@
7
7
  * a one-liner and guarantees identical handling across exchanges.
8
8
  */
9
9
  export type CandleRow = [number, number, number, number, number, number];
10
- export interface OhlcIndexes {
10
+ interface OhlcIndexes {
11
11
  minLength: number;
12
12
  ts: number;
13
13
  open: number;
@@ -21,9 +21,14 @@ export declare const OHLC_CLOSE_HIGH_LOW: OhlcIndexes;
21
21
  export declare const OHLC_GATE: OhlcIndexes;
22
22
  export declare const OHLC_KRAKEN: OhlcIndexes;
23
23
  /** Normalize a seconds- or milliseconds-epoch timestamp to milliseconds. */
24
- export declare function normalizeTimestamp(raw: unknown): number;
24
+ declare function normalizeTimestamp(raw: unknown): number;
25
25
  export declare function parseCandleRow(row: unknown, idx: OhlcIndexes): CandleRow | null;
26
26
  export declare function parseCandleRows(rows: unknown[], idx: OhlcIndexes): CandleRow[];
27
27
  /** HTX can return objects instead of arrays; map those to the shared shape. */
28
28
  export declare function parseHtxObjectRow(row: unknown): CandleRow | null;
29
+ /** Internal seams exercised directly by tests. */
30
+ export declare const __test: {
31
+ normalizeTimestamp: typeof normalizeTimestamp;
32
+ };
33
+ export {};
29
34
  //# sourceMappingURL=cex_candle_parsing.d.ts.map
@@ -9,7 +9,7 @@ export const OHLC_GATE = { minLength: 7, ts: 0, open: 5, high: 3, low: 4, close:
9
9
  // Kraken OHLC: [tsSeconds, open, high, low, close, vwap, volume, count].
10
10
  export const OHLC_KRAKEN = { minLength: 7, ts: 0, open: 1, high: 2, low: 3, close: 4, volume: 6 };
11
11
  /** Normalize a seconds- or milliseconds-epoch timestamp to milliseconds. */
12
- export function normalizeTimestamp(raw) {
12
+ function normalizeTimestamp(raw) {
13
13
  const ts = Number(raw);
14
14
  if (!Number.isFinite(ts))
15
15
  return Number.NaN;
@@ -49,4 +49,6 @@ export function parseHtxObjectRow(row) {
49
49
  return null;
50
50
  return [ts, open, high, low, close, Number.isFinite(volume) ? volume : 0];
51
51
  }
52
+ /** Internal seams exercised directly by tests. */
53
+ export const __test = { normalizeTimestamp };
52
54
  //# sourceMappingURL=cex_candle_parsing.js.map
@@ -26,5 +26,11 @@ declare function isBookChunkMatch(metaInput: unknown, requestKeyInput: unknown):
26
26
  * @returns {Promise<Array>} [[timestamp_ms, open, high, low, close, volume_A], ...]
27
27
  */
28
28
  declare function fetchMarketCandlesSequentially(assetA: AssetRef, assetB: AssetRef, opts?: BookFetchOpts): Promise<number[][]>;
29
- export { bookCacheKey, bookOutputPath, isBookChunkMatch, fetchMarketCandlesSequentially, };
29
+ export { fetchMarketCandlesSequentially };
30
+ /** Internal seams exercised directly by tests. */
31
+ export declare const __test: {
32
+ bookCacheKey: typeof bookCacheKey;
33
+ bookOutputPath: typeof bookOutputPath;
34
+ isBookChunkMatch: typeof isBookChunkMatch;
35
+ };
30
36
  //# sourceMappingURL=fetch_book_data.d.ts.map
@@ -159,5 +159,7 @@ async function fetchMarketCandlesSequentially(assetA, assetB, opts = {}) {
159
159
  });
160
160
  return flipped ? invertCandleSeries(merged, { volume: 'scale' }) : merged;
161
161
  }
162
- export { bookCacheKey, bookOutputPath, isBookChunkMatch, fetchMarketCandlesSequentially, };
162
+ export { fetchMarketCandlesSequentially };
163
+ /** Internal seams exercised directly by tests. */
164
+ export const __test = { bookCacheKey, bookOutputPath, isBookChunkMatch };
163
165
  //# sourceMappingURL=fetch_book_data.js.map
@@ -613,17 +613,8 @@ function applyBotDerivedConfig(config) {
613
613
  if (!next.quoteProvided && botContext.bot.assetB) {
614
614
  next.quote = normalizeCexAssetSymbol(botContext.bot.assetB);
615
615
  }
616
- const baseCfg = MARKET_ADAPTER_DEFAULTS || {
617
- amaSlope: {
618
- lookbackBars: MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_LOOKBACK_BARS,
619
- },
620
- };
621
- const botCfg = typeof resolveBotCfg === 'function'
622
- ? resolveBotCfg(botContext.bot, baseCfg)
623
- : baseCfg;
624
- const botAma = typeof resolveAmaForBot === 'function'
625
- ? resolveAmaForBot(botContext.bot, null, botCfg)
626
- : null;
616
+ const botCfg = resolveBotCfg(botContext.bot, MARKET_ADAPTER_DEFAULTS);
617
+ const botAma = resolveAmaForBot(botContext.bot, null, botCfg);
627
618
  return { config: next, botContext, botCfg, botAma };
628
619
  }
629
620
  function printHelp() {
@@ -33,6 +33,23 @@ interface BotConfig {
33
33
  assetB?: string;
34
34
  [key: string]: unknown;
35
35
  }
36
+ declare function parseArgs(): {
37
+ poolId: null;
38
+ botName: null;
39
+ precA: null;
40
+ precB: null;
41
+ config: {
42
+ intervalSeconds: number;
43
+ lookbackHours: number;
44
+ apiKey: string | null;
45
+ chunkMonths: number;
46
+ timeRange?: {
47
+ gte?: string;
48
+ lte?: string;
49
+ };
50
+ outPath?: string;
51
+ };
52
+ };
36
53
  declare function outputPath(poolId: unknown, intervalSeconds: number, assetA: AssetRef, assetB: AssetRef): string;
37
54
  declare function applyPrecisionOverrides(assetA: AssetRef, assetB: AssetRef, precA: number | null, precB: number | null): {
38
55
  assetA: AssetRef;
@@ -57,5 +74,13 @@ declare function parseBotsConfig(raw: string, sourceLabel?: string): BotConfig[]
57
74
  * Pick a bot: by name if given, otherwise first active bot with startPrice: "pool".
58
75
  */
59
76
  declare function selectBot(bots: BotConfig[], botName: string | null | undefined): BotConfig;
60
- export { applyPrecisionOverrides, parseBotsConfig, selectBot, fetchCandlesSequentially, outputPath, loadCachedFetchContext };
77
+ export { fetchCandlesSequentially, outputPath };
78
+ /** Internal seams exercised directly by tests. */
79
+ export declare const __test: {
80
+ applyPrecisionOverrides: typeof applyPrecisionOverrides;
81
+ parseBotsConfig: typeof parseBotsConfig;
82
+ selectBot: typeof selectBot;
83
+ loadCachedFetchContext: typeof loadCachedFetchContext;
84
+ parseArgs: typeof parseArgs;
85
+ };
61
86
  //# sourceMappingURL=fetch_lp_data.d.ts.map