dexbot 1.6.9 → 1.6.11

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 (96) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +1 -0
  3. package/analysis/README.md +50 -12
  4. package/analysis/bot_fitting/README.md +12 -0
  5. package/analysis/tradingview/README.md +15 -10
  6. package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +10 -36
  7. package/analysis/trend_detection/README.md +31 -0
  8. package/claw/modules/chain_queries.ts +9 -4
  9. package/claw/modules/claw_bridge.ts +9 -9
  10. package/claw/package.json +1 -1
  11. package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
  12. package/claw/runtimes/openclaw-plugin/package.json +1 -1
  13. package/dist/analysis/account_resolver.js +13 -1
  14. package/dist/analysis/ama_fitting/optimizer_high_resolution.js +2 -1
  15. package/dist/analysis/analyze_dynamic_weight.js +0 -3
  16. package/dist/analysis/bot_fitting/backtest_ama_sweep.js +52 -8
  17. package/dist/analysis/bot_fitting/backtest_bot_fitting.js +68 -10
  18. package/dist/analysis/bot_fitting/backtest_lookback_drawdown.d.ts +21 -0
  19. package/dist/analysis/bot_fitting/backtest_lookback_drawdown.js +315 -0
  20. package/dist/analysis/bot_key_utils.js +17 -17
  21. package/dist/analysis/fills_cache.d.ts +64 -0
  22. package/dist/analysis/fills_cache.js +254 -0
  23. package/dist/analysis/fills_source.js +5 -2
  24. package/dist/analysis/pnl_report.d.ts +39 -0
  25. package/dist/analysis/pnl_report.js +325 -0
  26. package/dist/analysis/resolve_source.d.ts +0 -1
  27. package/dist/analysis/trade_profitability.d.ts +11 -2
  28. package/dist/analysis/trade_profitability.js +187 -61
  29. package/dist/analysis/tradingview/analyze_tradingview.d.ts +0 -3
  30. package/dist/analysis/tradingview/analyze_tradingview.js +6 -19
  31. package/dist/analysis/tradingview/grid_reset_config.d.ts +2 -0
  32. package/dist/analysis/tradingview/grid_reset_config.js +18 -1
  33. package/dist/analysis/tradingview/grid_reset_sim.d.ts +12 -1
  34. package/dist/analysis/tradingview/grid_reset_sim.js +60 -11
  35. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +180 -33
  36. package/dist/analysis/trend_detection/backtest_ama_slope_huber.d.ts +102 -0
  37. package/dist/analysis/trend_detection/backtest_ama_slope_huber.js +725 -0
  38. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +29 -110
  39. package/dist/analysis/trend_detection/huber_scale_variants.d.ts +34 -0
  40. package/dist/analysis/trend_detection/huber_scale_variants.js +176 -0
  41. package/dist/dexbot.js +19 -11
  42. package/dist/market_adapter/core/market_adapter_service.d.ts +15 -0
  43. package/dist/market_adapter/core/market_adapter_service.js +64 -5
  44. package/dist/market_adapter/core/strategies/ama.d.ts +1 -1
  45. package/dist/market_adapter/core/strategies/ama.js +5 -28
  46. package/dist/market_adapter/core/strategies/ama_slope_model.d.ts +2 -2
  47. package/dist/market_adapter/core/strategies/ama_slope_model.js +12 -10
  48. package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts +41 -14
  49. package/dist/market_adapter/core/strategies/dynamic_weight_series.js +138 -30
  50. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +1 -2
  51. package/dist/market_adapter/log_format.js +1 -2
  52. package/dist/market_adapter/lp_chart_strategy_loader.js +2 -1
  53. package/dist/market_adapter/market_adapter.d.ts +0 -1
  54. package/dist/market_adapter/market_adapter.js +2 -27
  55. package/dist/market_adapter/utils/chain.d.ts +1 -1
  56. package/dist/market_adapter/utils/chain.js +8 -6
  57. package/dist/modules/account_bots.js +5 -4
  58. package/dist/modules/bitshares-native/resolvers.js +5 -0
  59. package/dist/modules/bot_settings.js +13 -1
  60. package/dist/modules/chain_orders.js +2 -1
  61. package/dist/modules/constants.d.ts +9 -1
  62. package/dist/modules/constants.js +55 -9
  63. package/dist/modules/credential_policy.js +4 -1
  64. package/dist/modules/credit_runtime.js +5 -1
  65. package/dist/modules/dexbot_maintenance_runtime.js +12 -0
  66. package/dist/modules/order/accounting.js +25 -0
  67. package/dist/modules/order/format.d.ts +35 -15
  68. package/dist/modules/order/format.js +62 -16
  69. package/dist/modules/order/manager.d.ts +1 -0
  70. package/dist/modules/order/manager.js +22 -1
  71. package/dist/modules/order/sync_engine.js +15 -1
  72. package/dist/modules/order/utils/order.d.ts +21 -1
  73. package/dist/modules/order/utils/order.js +80 -2
  74. package/dist/modules/order/utils/system.js +11 -1
  75. package/dist/modules/paths.d.ts +2 -0
  76. package/dist/modules/paths.js +2 -0
  77. package/dist/modules/utils/asset_symbols.d.ts +59 -0
  78. package/dist/modules/utils/asset_symbols.js +128 -0
  79. package/dist/modules/utils/time_range.d.ts +15 -0
  80. package/dist/modules/utils/time_range.js +18 -0
  81. package/dist/scripts/analyze-credit.js +10 -7
  82. package/dist/scripts/analyze-orders.js +1 -44
  83. package/dist/scripts/chart_command.js +15 -8
  84. package/dist/scripts/pnl.d.ts +3 -0
  85. package/dist/scripts/pnl.js +40 -0
  86. package/dist/scripts/verify-browser-bundle.js +8 -0
  87. package/dist/unlock.js +34 -0
  88. package/docs/DEXBOT_COMPARISON.md +3 -3
  89. package/docs/EVOLUTION.md +12 -10
  90. package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
  91. package/docs/GRID_RECALCULATION.md +33 -17
  92. package/docs/README.md +2 -2
  93. package/docs/WORKFLOW.md +1 -0
  94. package/market_adapter/README.md +6 -28
  95. package/package.json +1 -1
  96. package/scripts/README.md +14 -0
@@ -43,7 +43,7 @@
43
43
  * embedded alongside them (`computeAverageAmaSlopePct`,
44
44
  * `createAmaSlopeClipTracker`, `percentileFromSorted`, `clamp`).
45
45
  */
46
- import { computeAverageAmaSlopePct, createAmaSlopeClipTracker, } from '../../market_adapter/core/strategies/dynamic_weight_series.js';
46
+ import { computeHuberWindowSlopePct, createAmaSlopeClipTracker, } from '../../market_adapter/core/strategies/dynamic_weight_series.js';
47
47
  import { clamp } from '../../modules/order/utils/math.js';
48
48
  // Reset reason codes. NONE = the accepted center is carried over unchanged
49
49
  // (this is the vast majority of bars); the other three are the runtime's
@@ -93,6 +93,21 @@ function gridSimSlopeSignal(slopePct, clipThreshold, cfg) {
93
93
  slopeOffset: clamp(clipped / maxSlopePct, -1, 1) * maxSlopeOffset,
94
94
  };
95
95
  }
96
+ /**
97
+ * Resolve the per-bar slope estimator for a replay.
98
+ *
99
+ * Default is the canonical estimator the live adapter uses
100
+ * (computeHuberWindowSlopePct), so the replay keeps tracking the runtime.
101
+ * `cfg.slopeEstimator` exists so a caller can render a different averaging
102
+ * model without touching this module — it takes the whole series plus the index
103
+ * because windowed estimators need the window, not just the two endpoints.
104
+ */
105
+ function gridSimResolveSlopeEstimator(cfg) {
106
+ const custom = cfg?.slopeEstimator;
107
+ if (typeof custom === 'function')
108
+ return custom;
109
+ return computeHuberWindowSlopePct;
110
+ }
96
111
  /**
97
112
  * Replay the two market-adapter grid-recentering triggers over `amaSeries`
98
113
  * (the chart's 1h AMA series, already in display orientation).
@@ -120,6 +135,10 @@ function simulateGridResetSeries(amaSeries, cfg) {
120
135
  const clipPercentile = Number(cfg?.clipPercentile);
121
136
  const clampMinValue = Number(cfg?.clampMin);
122
137
  const clampMaxValue = Number(cfg?.clampMax);
138
+ // Persistence gate on the slope-delta trigger (trigger B): consecutive
139
+ // confirming bars required before it fires. 1 = legacy behavior (fire on the
140
+ // first threshold crossing); >1 filters short-lived slope excursions.
141
+ const slopePersistBars = gridSimNonNegativeInt(cfg?.slopePersistBars, 1);
123
142
  // Mirrors clampGridPriceToBounds: only absolute bot bounds pin the center,
124
143
  // and each side binds independently (a mixed absolute/"Nx" config clamps
125
144
  // only on the absolute side).
@@ -159,11 +178,13 @@ function simulateGridResetSeries(amaSeries, cfg) {
159
178
  warmupBars,
160
179
  priceDeltaThresholdPercent: priceTriggerArmed ? priceThreshold : null,
161
180
  slopeDeltaThresholdPercent: slopeTriggerArmed ? slopeThreshold : null,
181
+ slopePersistBars,
162
182
  slopeTriggerArmed,
163
183
  },
164
184
  };
165
185
  }
166
186
  const clipTracker = createAmaSlopeClipTracker(erPeriod, lookbackBars, clipPercentile);
187
+ const estimateSlope = gridSimResolveSlopeEstimator(cfg);
167
188
  const readyBars = erPeriod + lookbackBars;
168
189
  let acceptedCenter = null;
169
190
  let acceptedSlope = null;
@@ -173,6 +194,9 @@ function simulateGridResetSeries(amaSeries, cfg) {
173
194
  let resetCount = 0;
174
195
  let priceResets = 0;
175
196
  let slopeResets = 0;
197
+ // Persistence-gate state for trigger B.
198
+ let slopePersistCount = 0;
199
+ let slopePersistDir = 0;
176
200
  for (let i = 0; i < n; i++) {
177
201
  const ama = Number(amaSeries[i]);
178
202
  const hasAma = Number.isFinite(ama) && ama > 0;
@@ -185,13 +209,10 @@ function simulateGridResetSeries(amaSeries, cfg) {
185
209
  // only the range tilt, never reset timing.
186
210
  const clipThreshold = clipTracker.push(hasAma ? ama : NaN);
187
211
  let slopePct = null;
188
- if (i >= readyBars) {
189
- const past = Number(amaSeries[i - lookbackBars]);
190
- if (hasAma && Number.isFinite(past) && past !== 0) {
191
- const s = computeAverageAmaSlopePct(ama, past, lookbackBars);
192
- if (Number.isFinite(s))
193
- slopePct = s;
194
- }
212
+ if (hasAma && i >= readyBars) {
213
+ const s = estimateSlope(amaSeries, i, lookbackBars);
214
+ if (Number.isFinite(s))
215
+ slopePct = s;
195
216
  }
196
217
  slopePctSeries[i] = slopePct;
197
218
  // Bars before AMA warmup carry no accepted state (the adapter keeps
@@ -232,10 +253,37 @@ function simulateGridResetSeries(amaSeries, cfg) {
232
253
  else if (priceTriggerArmed && driftPct[i] >= priceThreshold) {
233
254
  fired = GRID_RESET_PRICE;
234
255
  }
235
- else if (slopeTriggerArmed && slopeDeltaPct[i] != null && slopeDeltaPct[i] >= slopeThreshold) {
236
- fired = GRID_RESET_SLOPE;
256
+ else {
257
+ // Trigger B, now persistence-gated: require the threshold to be
258
+ // crossed for `slopePersistBars` consecutive bars in the same
259
+ // direction before firing. A single-bar excursion never charges the
260
+ // counter; a sustained move is confirmed K bars after onset (up to
261
+ // K-1 bars later than the ungated trigger).
262
+ const delta = slopeDeltaPct[i];
263
+ const candidate = slopeTriggerArmed && delta != null && delta >= slopeThreshold;
264
+ if (!candidate) {
265
+ slopePersistCount = 0;
266
+ slopePersistDir = 0;
267
+ }
268
+ else {
269
+ const dir = acceptedSlope != null && slopePct != null ? Math.sign(slopePct - acceptedSlope) : 0;
270
+ if (slopePersistBars <= 1) {
271
+ fired = GRID_RESET_SLOPE;
272
+ }
273
+ else if (dir !== 0 && dir === slopePersistDir) {
274
+ slopePersistCount++;
275
+ if (slopePersistCount >= slopePersistBars)
276
+ fired = GRID_RESET_SLOPE;
277
+ }
278
+ else {
279
+ slopePersistDir = dir;
280
+ slopePersistCount = 1;
281
+ }
282
+ }
237
283
  }
238
284
  if (fired !== GRID_RESET_NONE) {
285
+ slopePersistCount = 0;
286
+ slopePersistDir = 0;
239
287
  const previousCenter = acceptedCenter;
240
288
  acceptedCenter = currentCenter;
241
289
  // Re-seed the accepted slope on EVERY reset (price and slope alike),
@@ -299,9 +347,10 @@ function simulateGridResetSeries(amaSeries, cfg) {
299
347
  warmupBars,
300
348
  priceDeltaThresholdPercent: priceTriggerArmed ? priceThreshold : null,
301
349
  slopeDeltaThresholdPercent: slopeTriggerArmed ? slopeThreshold : null,
350
+ slopePersistBars,
302
351
  slopeTriggerArmed,
303
352
  },
304
353
  };
305
354
  }
306
- export { simulateGridResetSeries, gridSimSlopeSignal, gridSimPositiveNumber, gridSimNonNegativeInt, GRID_RESET_NONE, GRID_RESET_BOOTSTRAP, GRID_RESET_PRICE, GRID_RESET_SLOPE, };
355
+ export { simulateGridResetSeries, gridSimSlopeSignal, gridSimPositiveNumber, gridSimNonNegativeInt, gridSimResolveSlopeEstimator, GRID_RESET_NONE, GRID_RESET_BOOTSTRAP, GRID_RESET_PRICE, GRID_RESET_SLOPE, };
307
356
  //# sourceMappingURL=grid_reset_sim.js.map
@@ -10,9 +10,16 @@ import { getStorage } from '../../modules/storage/index.js';
10
10
  const { readJSON } = getStorage();
11
11
  import { getErrorMessage } from '../../modules/utils/errors.js';
12
12
  import { parseRelativeMultiplier } from '../../modules/order/utils/math.js';
13
- import { computeAverageAmaSlopePct, computeAmaSlopeClipThreshold, createAmaSlopeClipTracker, percentileFromSorted } from '../../market_adapter/core/strategies/dynamic_weight_series.js';
13
+ import { computeAverageAmaSlopePct, computeHuberWindowSlopePct, computeAmaSlopeClipThreshold, createAmaSlopeClipTracker, percentileFromSorted } from '../../market_adapter/core/strategies/dynamic_weight_series.js';
14
14
  import { resolveBaseBounds, computeAsymmetricBoundsMetrics, applyAsymmetricBounds, applyNarrowingSideGuard, } from '../../market_adapter/core/asymmetric_bounds.js';
15
- import { simulateGridResetSeries, gridSimSlopeSignal, gridSimPositiveNumber, gridSimNonNegativeInt, GRID_RESET_NONE, GRID_RESET_BOOTSTRAP, GRID_RESET_PRICE, GRID_RESET_SLOPE, } from './grid_reset_sim.js';
15
+ import { simulateGridResetSeries, gridSimSlopeSignal, gridSimPositiveNumber, gridSimNonNegativeInt, gridSimResolveSlopeEstimator, GRID_RESET_NONE, GRID_RESET_BOOTSTRAP, GRID_RESET_PRICE, GRID_RESET_SLOPE, } from './grid_reset_sim.js';
16
+ // x-range (span) around the AMA price, in chart x-units. One slider (0.05 step)
17
+ // drives the band, the price-axis fit and the grid-reset sim, so the bounds
18
+ // live here and are interpolated into the generated page (slider markup,
19
+ // state hydration and the two compute paths all clamp to the same numbers).
20
+ const RANGE_SPAN_MIN = 1.3;
21
+ const RANGE_SPAN_MAX = 2.1;
22
+ const RANGE_SPAN_DEFAULT = 1.55;
16
23
  function inferBaseIntervalSeconds(candles, fallback = 3600) {
17
24
  if (!Array.isArray(candles) || candles.length < 2)
18
25
  return fallback;
@@ -136,21 +143,24 @@ function generateHTML(data, title = 'TradingView Style Research') {
136
143
  minScaleSlots: MARKET_ADAPTER.ASYMMETRIC_BOUNDS_MIN_SCALE_SLOTS,
137
144
  clipPercentile: MARKET_ADAPTER.DYNAMIC_WEIGHT_CLIP_PERCENTILE,
138
145
  };
146
+ // Slider bounds for the x-range around AMA live in RANGE_SPAN_MIN/MAX above
147
+ // and are interpolated into the generated page; the clamps here and there
148
+ // must not drift apart.
139
149
  function defaultRangeSpan(input) {
140
150
  const cli = Number(input.rangeSpan);
141
151
  if (Number.isFinite(cli))
142
- return Math.min(2, Math.max(1.2, cli));
152
+ return Math.min(RANGE_SPAN_MAX, Math.max(RANGE_SPAN_MIN, cli));
143
153
  const down = parseRelativeMultiplier(input.grid?.minPrice);
144
154
  const up = parseRelativeMultiplier(input.grid?.maxPrice);
145
155
  if (down != null && down > 1 && up != null && up > 1)
146
- return Math.min(2, Math.max(1.2, (down + up) / 2));
156
+ return Math.min(RANGE_SPAN_MAX, Math.max(RANGE_SPAN_MIN, (down + up) / 2));
147
157
  const vd = Number(input.grid?.minPrice);
148
158
  const vu = Number(input.grid?.maxPrice);
149
159
  if (Number.isFinite(vd) && Number.isFinite(vu) && vd > 0 && vu > vd) {
150
160
  const ref = Math.sqrt(vd * vu);
151
- return Math.min(2, Math.max(1.2, (ref / vd + vu / ref) / 2));
161
+ return Math.min(RANGE_SPAN_MAX, Math.max(RANGE_SPAN_MIN, (ref / vd + vu / ref) / 2));
152
162
  }
153
- return 1.55;
163
+ return RANGE_SPAN_DEFAULT;
154
164
  }
155
165
  const defaults = {
156
166
  smaPeriod: Math.max(1, Math.round(data.smaPeriod ?? 500)),
@@ -160,8 +170,11 @@ function generateHTML(data, title = 'TradingView Style Research') {
160
170
  vwapEnabled: data.vwapEnabled === true,
161
171
  vwapBars: Math.max(5, Math.round(data.vwapBars ?? 500)),
162
172
  priceScale: data.priceScale === 'linear' ? 'linear' : 'log',
163
- rangeEnabled: data.rangeEnabled === true,
164
- rangeScaleEnabled: data.rangeScaleEnabled === true,
173
+ // Range / Scale always start off: they are AMA-derived in-chart toggles
174
+ // with an auto opt-in chain, and the user's choice is persisted per
175
+ // chart in localStorage, so no generation-time default is needed.
176
+ rangeEnabled: false,
177
+ rangeScaleEnabled: false,
165
178
  rangeWidthPct: Number.isFinite(Number(data.rangeWidthPct)) && Number(data.rangeWidthPct) > 0
166
179
  ? Number(data.rangeWidthPct)
167
180
  : 2,
@@ -577,11 +590,11 @@ function generateHTML(data, title = 'TradingView Style Research') {
577
590
  <button type="button" class="reset-btn ama-preset-btn" data-ama-preset="AMA3" title="AMA3 (slow 83.6)">3</button>
578
591
  <button type="button" class="reset-btn ama-preset-btn" data-ama-preset="AMA4" title="AMA4 (slow 96.9)">4</button>
579
592
  </div>
580
- <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">
593
+ <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)">
581
594
  <label><input type="checkbox" id="range-toggle"${defaults.rangeEnabled ? ' checked' : ''}> Range</label>
582
- <label title="Range Scaling: size the band by AMA slope like the grid build (trend side widens, opposite tightens) and fit the price axis to it"><input type="checkbox" id="range-scale-toggle"${defaults.rangeScaleEnabled ? ' checked' : ''}> Scale</label>
583
- <span id="range-grid-wrap" style="display:inline" title="x-range around AMA (1.2x–2.0x)">
584
- <input type="range" id="range-span" min="1.2" max="2" step="0.05" value="${defaults.rangeSpan.toFixed(2)}" style="width:90px;vertical-align:middle">
595
+ <label title="Range Scaling: size the band by AMA slope like the grid build (trend side widens, opposite tightens) and fit the price axis to it. Turning it on also turns on Range and AMA"><input type="checkbox" id="range-scale-toggle"${defaults.rangeScaleEnabled ? ' checked' : ''}> Scale</label>
596
+ <span id="range-grid-wrap" style="display:inline" title="x-range around AMA (${RANGE_SPAN_MIN}x–${RANGE_SPAN_MAX}x)">
597
+ <input type="range" id="range-span" min="${RANGE_SPAN_MIN}" max="${RANGE_SPAN_MAX}" step="0.05" value="${defaults.rangeSpan.toFixed(2)}" style="width:90px;vertical-align:middle">
585
598
  <span id="range-span-val" style="font-size:11px;color:#8b949e;width:40px;display:inline-block;text-align:right">${defaults.rangeSpan.toFixed(2)}x</span>
586
599
  </span>
587
600
  </div>
@@ -653,12 +666,18 @@ function generateHTML(data, title = 'TradingView Style Research') {
653
666
  let currentVwapBars = Number.isFinite(state.vwapBars) ? state.vwapBars : Number(payload.vwapBars || 500);
654
667
  let currentRangeEnabled = state.rangeEnabled ?? !!payload.rangeEnabled;
655
668
  let currentRangeScaleEnabled = state.rangeScaleEnabled ?? !!payload.rangeScaleEnabled;
669
+ // Dependency chain: the band is built from the AMA price, and Scale sizes
670
+ // the band by AMA slope, so Scale needs Range and both need AMA. A
671
+ // persisted state (or CLI default) that enabled Scale without them would
672
+ // render a dead toggle, so re-apply the same auto opt-in on load.
673
+ if (currentRangeScaleEnabled) currentRangeEnabled = true;
674
+ if (currentRangeEnabled || currentRangeScaleEnabled) currentAmaEnabled = true;
656
675
  let currentRangeWidthPct = Number.isFinite(state.rangeWidthPct) && Number(state.rangeWidthPct) > 0
657
676
  ? Number(state.rangeWidthPct)
658
677
  : (Number.isFinite(Number(payload.rangeWidthPct)) && Number(payload.rangeWidthPct) > 0 ? Number(payload.rangeWidthPct) : 2);
659
678
  let currentRangeSpan = Number.isFinite(state.rangeSpan) && Number(state.rangeSpan) > 0
660
- ? Math.min(2, Math.max(1.2, Number(state.rangeSpan)))
661
- : (Number.isFinite(Number(payload.rangeSpan)) && Number(payload.rangeSpan) > 0 ? Math.min(2, Math.max(1.2, Number(payload.rangeSpan))) : 1.55);
679
+ ? Math.min(${RANGE_SPAN_MAX}, Math.max(${RANGE_SPAN_MIN}, Number(state.rangeSpan)))
680
+ : (Number.isFinite(Number(payload.rangeSpan)) && Number(payload.rangeSpan) > 0 ? Math.min(${RANGE_SPAN_MAX}, Math.max(${RANGE_SPAN_MIN}, Number(payload.rangeSpan))) : ${RANGE_SPAN_DEFAULT});
662
681
  let currentOrdersVisible = state.ordersVisible ?? true;
663
682
  // Grid-reset simulation (AMA-price Δ / AMA-slope Δ). Static per
664
683
  // generation: payload.gridSim is null for non-AMA charts, which removes
@@ -718,6 +737,7 @@ function generateHTML(data, title = 'TradingView Style Research') {
718
737
  let pendingRangeRaf = 0;
719
738
  let rangePanelRaf = 0;
720
739
  let yRefitRaf = 0;
740
+ let pendingViewY = null;
721
741
  let xMin = 0;
722
742
  let xMax = 0;
723
743
  let smaWorker = null;
@@ -1477,7 +1497,24 @@ function generateHTML(data, title = 'TradingView Style Research') {
1477
1497
  // red [AMA, upper], green [lower, AMA].
1478
1498
  // Never reads candles, pair-display mapping, or axis/zoom state —
1479
1499
  // inversion and timeframe sampling apply to the AMA first.
1480
- ${embedFunctionSources([computeAverageAmaSlopePct, computeAmaSlopeClipThreshold, resolveBaseBounds, computeAsymmetricBoundsMetrics, applyAsymmetricBounds, applyNarrowingSideGuard, parseRelativeMultiplier, percentileFromSorted, createAmaSlopeClipTracker, gridSimPositiveNumber, gridSimNonNegativeInt, gridSimSlopeSignal, simulateGridResetSeries])}
1500
+ // Canonical Huber-slope parameters, injected from MARKET_ADAPTER so the
1501
+ // embedded estimator runs the same values as the live adapter.
1502
+ const AMA_SLOPE_HUBER = ${serializeJsonForScript(MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_HUBER)};
1503
+ ${embedFunctionSources([computeAverageAmaSlopePct, computeAmaSlopeClipThreshold, resolveBaseBounds, computeAsymmetricBoundsMetrics, applyAsymmetricBounds, applyNarrowingSideGuard, parseRelativeMultiplier, percentileFromSorted, createAmaSlopeClipTracker, gridSimPositiveNumber, gridSimNonNegativeInt, gridSimSlopeSignal, gridSimResolveSlopeEstimator, computeHuberWindowSlopePct, simulateGridResetSeries])}
1504
+ // One slope window for every consumer on this page. The band must not
1505
+ // stay pinned to the shared constant while the replay honours a
1506
+ // bot-configured lookbackBars: that split let the plotted range and the
1507
+ // replayed \u0394s trigger disagree about how far back to measure the
1508
+ // slope. The replay's already-resolved value wins; the constant is the
1509
+ // fallback for charts that carry no grid-sim data (pool/pair charts).
1510
+ function resolveSlopeLookbackBars() {
1511
+ const fromGridSim = Number(gridSimCfg && gridSimCfg.lookbackBars);
1512
+ const fromConstants = Number(payload.rangeSlope && payload.rangeSlope.lookbackBars);
1513
+ const value = Number.isFinite(fromGridSim) && fromGridSim > 0 ? fromGridSim : fromConstants;
1514
+ return Number.isFinite(value) && value > 0
1515
+ ? Math.max(1, Math.round(value))
1516
+ : ${MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_LOOKBACK_BARS};
1517
+ }
1481
1518
  // ── Grid-reset simulation ──
1482
1519
  // Replays the two market-adapter recentering triggers (docs/GRID_RECALCULATION.md
1483
1520
  // §3 AMA Δ / §4 AMA-Slope Δ) over the 1h AMA series: the accepted grid center
@@ -1485,6 +1522,23 @@ function generateHTML(data, title = 'TradingView Style Research') {
1485
1522
  // reset (the advanceTriggeredBotState chain). Thresholds arrive pre-resolved
1486
1523
  // through the live config chain in payload.gridSim. The replay itself is the
1487
1524
  // canonical simulateGridResetSeries() embedded above — not a hand copy.
1525
+ // The chart plots the SAME slope the live adapter computes: the embedded
1526
+ // canonical estimator (computeHuberWindowSlopePct), used for BOTH the
1527
+ // replayed delta-s reset trigger and the plotted band tilt, so the chart
1528
+ // cannot diverge from the runtime or from itself. 'endpoint' (the old
1529
+ // two-point difference: same magnitude, far jitterier) remains a
1530
+ // chart-only comparison mode.
1531
+ const CHART_SLOPE_ESTIMATOR = 'canonical';
1532
+ function resolveChartSlopeEstimator() {
1533
+ if (CHART_SLOPE_ESTIMATOR === 'endpoint') {
1534
+ // Wrap to the seam signature (series, index, bars): the raw
1535
+ // helper takes two endpoints and would be mis-called directly.
1536
+ return function (series, index, bars) {
1537
+ return computeAverageAmaSlopePct(Number(series[index]), Number(series[index - bars]), bars);
1538
+ };
1539
+ }
1540
+ return computeHuberWindowSlopePct;
1541
+ }
1488
1542
  const GRID_RESET_NONE = ${GRID_RESET_NONE};
1489
1543
  const GRID_RESET_BOOTSTRAP = ${GRID_RESET_BOOTSTRAP};
1490
1544
  const GRID_RESET_PRICE = ${GRID_RESET_PRICE};
@@ -1517,7 +1571,16 @@ function generateHTML(data, title = 'TradingView Style Research') {
1517
1571
  const warmupBars = (override != null && Number.isFinite(Number(override)) && Number(override) >= 0)
1518
1572
  ? Math.ceil(Number(override))
1519
1573
  : warmup;
1520
- const cfg = Object.assign({}, gridSimCfg, { warmupBars: warmupBars });
1574
+ // warmupBars stays config-derived (getAmaWarmupBars); lookbackBars
1575
+ // comes straight from gridSimCfg, i.e. from the same resolved value
1576
+ // the Range tilt reads through resolveSlopeLookbackBars(), so both
1577
+ // consumers sample the identical window.
1578
+ const cfg = Object.assign({}, gridSimCfg, {
1579
+ warmupBars: warmupBars,
1580
+ // Same averaging model as the band above, so the replayed Δs
1581
+ // trigger and the plotted tilt keep measuring one quantity.
1582
+ slopeEstimator: resolveChartSlopeEstimator(),
1583
+ });
1521
1584
  return simulateGridResetSeries(baseAma, cfg);
1522
1585
  }
1523
1586
  // Simulated grid range for each bar: the accepted center with the accepted
@@ -1544,7 +1607,7 @@ function generateHTML(data, title = 'TradingView Style Research') {
1544
1607
  ? Number(gridCfg.maxAsymmetryFactor)
1545
1608
  : (Number(gridSimCfg.maxAsymmetryFactor) > 0 ? Number(gridSimCfg.maxAsymmetryFactor) : 0.333);
1546
1609
  const maxSlopeOffset = gridSimPositiveNumber(gridSimCfg.maxSlopeOffset, 0.5);
1547
- const span = Math.min(2, Math.max(1.2, Number(currentRangeSpan) > 0 ? Number(currentRangeSpan) : 1.55));
1610
+ const span = Math.min(${RANGE_SPAN_MAX}, Math.max(${RANGE_SPAN_MIN}, Number(currentRangeSpan) > 0 ? Number(currentRangeSpan) : ${RANGE_SPAN_DEFAULT}));
1548
1611
  // Absolute bot bounds are fixed price levels; relative ("Nx") bounds
1549
1612
  // travel with the accepted center. Each side resolves independently so
1550
1613
  // a mixed absolute/"Nx" config matches the runtime grid build.
@@ -1593,7 +1656,7 @@ function generateHTML(data, title = 'TradingView Style Research') {
1593
1656
  const trend = new Array(n).fill(0);
1594
1657
  const slopeCfg = payload.rangeSlope || {};
1595
1658
  const gridCfg = payload.grid || null;
1596
- const lookback = Math.max(1, Math.round(Number(slopeCfg.lookbackBars) || 9));
1659
+ const lookback = resolveSlopeLookbackBars();
1597
1660
  const maxSlope = Number(slopeCfg.maxSlopePct) > 0 ? Number(slopeCfg.maxSlopePct) : 0.09;
1598
1661
  const neutral = Number(slopeCfg.neutralZonePct) >= 0 ? Number(slopeCfg.neutralZonePct) : 0;
1599
1662
  const maxSlopeOffset = Number(slopeCfg.maxSlopeOffset) > 0 ? Number(slopeCfg.maxSlopeOffset) : 0.5;
@@ -1602,9 +1665,9 @@ function generateHTML(data, title = 'TradingView Style Research') {
1602
1665
  : (Number(slopeCfg.maxAsymmetryFactor) > 0 ? Number(slopeCfg.maxAsymmetryFactor) : 0.333);
1603
1666
  const inc = gridCfg && Number(gridCfg.incrementPercent) > 0 ? Number(gridCfg.incrementPercent) : null;
1604
1667
  const minSlots = Math.floor(Number(gridCfg && gridCfg.minScaleSlots) > 0 ? Number(gridCfg.minScaleSlots) : (Number(slopeCfg.minScaleSlots) || 0));
1605
- // User x-range span (slider 1.2x–2.0x, default 1.55x): the only
1668
+ // User x-range span (slider ${RANGE_SPAN_MIN}x–${RANGE_SPAN_MAX}x, default ${RANGE_SPAN_DEFAULT}x): the only
1606
1669
  // width input — symmetric base min = AMA/span, max = AMA*span.
1607
- const span = Math.min(2, Math.max(1.2, Number(currentRangeSpan) > 0 ? Number(currentRangeSpan) : 1.55));
1670
+ const span = Math.min(${RANGE_SPAN_MAX}, Math.max(${RANGE_SPAN_MIN}, Number(currentRangeSpan) > 0 ? Number(currentRangeSpan) : ${RANGE_SPAN_DEFAULT}));
1608
1671
  // Canonical grid pipeline (ama_slope_model): adaptive percentile
1609
1672
  // clip over the AMA history, then offset + trend — the same numbers
1610
1673
  // the live grid build feeds into applyAsymmetricBounds.
@@ -1615,11 +1678,14 @@ function generateHTML(data, title = 'TradingView Style Research') {
1615
1678
  const clipThreshold = computeAmaSlopeClipThreshold(baseAma, clipEr, lookback, clipPct);
1616
1679
  const slopeScaling = !!currentRangeScaleEnabled;
1617
1680
  if (!currentAmaEnabled || n === 0) return { upper, lower, trend };
1681
+ const bandSlopeEstimator = resolveChartSlopeEstimator();
1618
1682
  for (let i = 0; i < n; i++) {
1619
1683
  const ama = baseAma[i];
1620
- const past = i - lookback >= 0 ? baseAma[i - lookback] : null;
1621
- if (!Number.isFinite(ama) || ama <= 0 || !Number.isFinite(past) || past <= 0) continue;
1622
- const slopePct = computeAverageAmaSlopePct(ama, past, lookback);
1684
+ if (!Number.isFinite(ama) || ama <= 0) continue;
1685
+ // Same estimator object the replay uses, so the band and the
1686
+ // delta-s trigger measure one quantity. The endpoint wrapper and
1687
+ // the windowed estimators both return null on an unusable window.
1688
+ const slopePct = bandSlopeEstimator(baseAma, i, lookback);
1623
1689
  if (slopePct == null || !Number.isFinite(slopePct)) continue;
1624
1690
  const csp = Math.max(-clipThreshold, Math.min(clipThreshold, slopePct));
1625
1691
  const dir = Math.abs(csp) <= neutral ? 0 : (csp > 0 ? 1 : -1);
@@ -1818,6 +1884,17 @@ function generateHTML(data, title = 'TradingView Style Research') {
1818
1884
  refreshLegend();
1819
1885
  saveState();
1820
1886
  }
1887
+ // Range and Scale are AMA-derived: the band min/max come from the AMA
1888
+ // price and Scale additionally reads the AMA slope. Turning either on
1889
+ // therefore opts AMA in as well. One-way only — switching an indicator
1890
+ // off never switches off the ones it depends on. Returns true when AMA
1891
+ // was actually turned on, so the caller can pick the AMA-toggle render
1892
+ // path (full rerender, series added) instead of the keep-view one.
1893
+ function autoOptInAma() {
1894
+ if (currentAmaEnabled) return false;
1895
+ currentAmaEnabled = true;
1896
+ return true;
1897
+ }
1821
1898
  function hideRangeBandImmediate() {
1822
1899
  currentRangeUpper = new Array(currentCandles.length).fill(null);
1823
1900
  currentRangeLower = new Array(currentCandles.length).fill(null);
@@ -3332,7 +3409,7 @@ function generateHTML(data, title = 'TradingView Style Research') {
3332
3409
  currentVwapBars = clamp(Math.round(Number(document.getElementById('vwap-bars').value) || 500), 24, 2000);
3333
3410
  currentRangeEnabled = document.getElementById('range-toggle').checked;
3334
3411
  currentRangeScaleEnabled = document.getElementById('range-scale-toggle').checked;
3335
- currentRangeSpan = Math.min(2, Math.max(1.2, Math.round((Number(document.getElementById('range-span').value) || 1.55) * 20) / 20));
3412
+ currentRangeSpan = Math.min(${RANGE_SPAN_MAX}, Math.max(${RANGE_SPAN_MIN}, Math.round((Number(document.getElementById('range-span').value) || ${RANGE_SPAN_DEFAULT}) * 20) / 20));
3336
3413
  const ordersEl = document.getElementById('orders-toggle');
3337
3414
  if (ordersEl) currentOrdersVisible = ordersEl.checked;
3338
3415
  setControls();
@@ -3355,6 +3432,13 @@ function generateHTML(data, title = 'TradingView Style Research') {
3355
3432
  const nextEnabled = document.getElementById('ama-toggle').checked;
3356
3433
  if (currentAmaEnabled === nextEnabled) return;
3357
3434
  currentAmaEnabled = nextEnabled;
3435
+ if (!currentAmaEnabled) {
3436
+ // AMA is the base of the band and of its slope scaling: the
3437
+ // mirror image of the auto opt-in, so the toggles never sit in
3438
+ // the dead state Scale/Range-without-AMA would be.
3439
+ currentRangeEnabled = false;
3440
+ currentRangeScaleEnabled = false;
3441
+ }
3358
3442
  setControls();
3359
3443
  if (!currentAmaEnabled) {
3360
3444
  hideAmaSeriesImmediate();
@@ -3378,20 +3462,40 @@ function generateHTML(data, title = 'TradingView Style Research') {
3378
3462
  const nextEnabled = document.getElementById('range-toggle').checked;
3379
3463
  if (currentRangeEnabled === nextEnabled) return;
3380
3464
  currentRangeEnabled = nextEnabled;
3381
- setControls();
3382
- if (!currentRangeEnabled) {
3383
- hideRangeBandImmediate();
3465
+ if (currentRangeEnabled) {
3466
+ // Range draws from the AMA price: opting in opts AMA in too.
3467
+ const enabledAma = autoOptInAma();
3468
+ setControls();
3469
+ if (enabledAma) {
3470
+ rerender(false);
3471
+ return;
3472
+ }
3473
+ preserveView(() => rerender(true));
3384
3474
  return;
3385
3475
  }
3386
- rerender(false);
3476
+ setControls();
3477
+ preserveView(hideRangeBandImmediate);
3387
3478
  });
3388
3479
  document.getElementById('range-scale-toggle').addEventListener('change', () => {
3389
3480
  const nextEnabled = document.getElementById('range-scale-toggle').checked;
3390
3481
  if (currentRangeScaleEnabled === nextEnabled) return;
3391
3482
  currentRangeScaleEnabled = nextEnabled;
3392
- manualYRange = null;
3393
- setControls();
3394
- rerender(false);
3483
+ if (currentRangeScaleEnabled) {
3484
+ // Scale is the Range band sized by AMA slope: opt into both.
3485
+ currentRangeEnabled = true;
3486
+ const enabledAma = autoOptInAma();
3487
+ setControls();
3488
+ if (enabledAma) {
3489
+ rerender(false);
3490
+ return;
3491
+ }
3492
+ } else {
3493
+ setControls();
3494
+ }
3495
+ // No manualYRange reset: the price axis keeps the window it had,
3496
+ // so un/setting Scale never refits the view (the band still
3497
+ // draws, the legend readout still updates).
3498
+ preserveView(() => rerender(true));
3395
3499
  });
3396
3500
  ['sma-period', 'ama-er', 'ama-fast', 'ama-slow', 'vwap-bars'].forEach((id) => {
3397
3501
  document.getElementById(id).addEventListener('change', syncInputs);
@@ -3446,7 +3550,7 @@ function generateHTML(data, title = 'TradingView Style Research') {
3446
3550
  document.getElementById('range-span').addEventListener('input', () => {
3447
3551
  const input = document.getElementById('range-span');
3448
3552
  document.getElementById('range-span-val').textContent = Number(input.value).toFixed(2) + 'x';
3449
- syncInputs();
3553
+ preserveView(syncInputs);
3450
3554
  });
3451
3555
 
3452
3556
  // Room to the right past the last bar (~12%): for the market panel
@@ -3593,7 +3697,8 @@ function generateHTML(data, title = 'TradingView Style Research') {
3593
3697
  let html = '<div style="color:#c084fc">sim grid resets: ' + st.resets + ' <span style="color:#f59e0b">\u03941 ' + st.priceResets + '</span> <span style="color:#22d3ee">\u0394s ' + st.slopeResets + '</span></div>';
3594
3698
  html += '<div style="color:#e8eef5">AMA \u0394 ' + (Number.isFinite(priceThr) ? Number(priceThr).toFixed(2) + '%' : '-') + ' <span style="color:#8b949e">(' + fmtSimSource(gridSimCfg.priceSource) + ')</span></div>';
3595
3699
  html += '<div style="color:#e8eef5">Slope \u0394 ' + (Number.isFinite(slopeThr) ? Number(slopeThr).toFixed(4) + '%/bar' : '-')
3596
- + ' <span style="color:#8b949e">(' + fmtSimSource(gridSimCfg.slopeSource) + (st.slopeTriggerArmed ? '' : ', off') + ')</span></div>';
3700
+ + ' <span style="color:#8b949e">(' + fmtSimSource(gridSimCfg.slopeSource) + (st.slopeTriggerArmed ? '' : ', off')
3701
+ + (Number(gridSimCfg.slopePersistBars) > 1 ? ', persist ' + Number(gridSimCfg.slopePersistBars) : '') + ')</span></div>';
3597
3702
  if (st.lastResetIndex != null) {
3598
3703
  const last = currentCandles[Math.max(0, Math.min(currentCandles.length - 1, currentSimLastIdx ?? 0))];
3599
3704
  html += '<div style="color:#8b949e">last ' + (last ? fmtTime(last.time) : '-') + ' (' + st.barsSinceLastReset + ' bars ago)</div>';
@@ -3626,6 +3731,39 @@ function generateHTML(data, title = 'TradingView Style Research') {
3626
3731
  const span = Math.max(1e-12, Math.abs(vis[1] - vis[0]));
3627
3732
  return Math.abs(s.min - vis[0]) / span > 1e-9 || Math.abs(s.max - vis[1]) / span > 1e-9;
3628
3733
  }
3734
+ // Snapshot/restore of the visible window across a control toggle.
3735
+ // Y needs an explicit put back because the auto-fit follows the range
3736
+ // band — switching the band (or Scale) on/off would otherwise refit
3737
+ // the price axis and jump the view under the cursor. The restore is
3738
+ // applied from the same rAF as the refit (and after it) so a toggle
3739
+ // only ever paints the original window, and it does NOT set
3740
+ // manualYRange: panning afterwards still autofits as before.
3741
+ function captureView() {
3742
+ if (!priceChart) return null;
3743
+ const x = priceChart.scales.x || {};
3744
+ const y = priceChart.scales.y || {};
3745
+ const view = {
3746
+ x: Number.isFinite(x.min) && Number.isFinite(x.max) ? { min: x.min, max: x.max } : null,
3747
+ y: Number.isFinite(y.min) && Number.isFinite(y.max) ? { min: y.min, max: y.max } : null,
3748
+ };
3749
+ return view.x || view.y ? view : null;
3750
+ }
3751
+ function preserveView(fn) {
3752
+ const view = captureView();
3753
+ const res = fn();
3754
+ if (!view || !priceChart) return res;
3755
+ // X: re-assert the captured window (rerender/setData already keep
3756
+ // it) so the full view survives whatever path the callback took.
3757
+ if (view.x) {
3758
+ const next = clampRange(view.x.min, view.x.max);
3759
+ if (next) charts.forEach((chart) => chart.batch(() => chart.setScale('x', next)));
3760
+ }
3761
+ if (view.y) {
3762
+ pendingViewY = view.y;
3763
+ scheduleYRefit();
3764
+ }
3765
+ return res;
3766
+ }
3629
3767
  function scheduleYRefit() {
3630
3768
  if (yRefitRaf) return;
3631
3769
  yRefitRaf = requestAnimationFrame(() => {
@@ -3638,6 +3776,15 @@ function generateHTML(data, title = 'TradingView Style Research') {
3638
3776
  const vvis = visibleVolumeRange(volumeChart);
3639
3777
  if (vvis && yRangeDirty(volumeChart, vvis)) volumeChart.setScale('y', { min: vvis[0], max: vvis[1] });
3640
3778
  }
3779
+ // View lock from preserveView(): win over the refit above.
3780
+ const keep = pendingViewY;
3781
+ pendingViewY = null;
3782
+ if (keep && priceChart && Number.isFinite(keep.min) && Number.isFinite(keep.max) && keep.max > keep.min) {
3783
+ const s = priceChart.scales.y || {};
3784
+ if (!Number.isFinite(s.min) || Math.abs(s.min - keep.min) > 1e-12 || Math.abs(s.max - keep.max) > 1e-12) {
3785
+ priceChart.setScale('y', { min: keep.min, max: keep.max });
3786
+ }
3787
+ }
3641
3788
  });
3642
3789
  }
3643
3790
  padXRight();
@@ -0,0 +1,102 @@
1
+ import { type HuberScaleMode, type HuberEstimator } from './huber_scale_variants.js';
2
+ type Candle = {
3
+ time: number;
4
+ open: number;
5
+ high: number;
6
+ low: number;
7
+ close: number;
8
+ volume: number;
9
+ };
10
+ type AmaDef = {
11
+ name: string;
12
+ er: number;
13
+ fast: number;
14
+ slow: number;
15
+ };
16
+ declare function parseArgs(): {
17
+ dataPath: string;
18
+ amaName: string;
19
+ er: number | null;
20
+ fast: number | null;
21
+ slow: number | null;
22
+ lookbacks: number[];
23
+ priceThresholdPct: number;
24
+ slopeThresholdFactor: number;
25
+ slopeEnabled: boolean;
26
+ slopePersistBars: number;
27
+ confirmFraction: number;
28
+ whipsawBars: number;
29
+ scaleMode: HuberScaleMode;
30
+ truthWindowBars: number | null;
31
+ forwardWindowBars: number | null;
32
+ outPath: string | null;
33
+ };
34
+ declare function loadCandles(input: string): {
35
+ candles: Candle[];
36
+ meta: any;
37
+ files: number;
38
+ };
39
+ /**
40
+ * Cross-correlation peak lag between the causal signal and a reference.
41
+ * Returns the smallest non-negative k maximising corr(sig[t], ref[t-k]).
42
+ * A positive lag means `sig` trails `ref` by k bars (the smoother's group delay).
43
+ */
44
+ declare function crossCorrelationLag(sig: (number | null)[], ref: (number | null)[], maxLag: number): {
45
+ lagBars: number;
46
+ corr: number | null;
47
+ };
48
+ /**
49
+ * Median bars between a sign flip in the centred reference slope and the first
50
+ * bar the causal slope confirms the new direction at or above `confirmPct`.
51
+ * `misses` counts flips the causal slope never confirmed inside the window.
52
+ */
53
+ declare function reversalLag(sig: (number | null)[], ref: (number | null)[], maxLag: number, confirmPct: number): {
54
+ lagBars: number | null;
55
+ flips: number;
56
+ misses: number;
57
+ samples: number;
58
+ };
59
+ declare function analyzeLookback(closes: number[], amaValues: number[], lookbackBars: number, amaDef: AmaDef, cfg: ReturnType<typeof parseArgs>, truthArr: (number | null)[], priceTruthArr: (number | null)[], truthHalf: number, estimator?: HuberEstimator): {
60
+ lookbackBars: number;
61
+ huberScaleMode: HuberScaleMode;
62
+ meanOutlierFractionPct: number | null;
63
+ meanHuberScale: number | null;
64
+ priceLagBars: number;
65
+ priceLagCorr: number | null;
66
+ amaLagBars: number;
67
+ amaLagCorr: number | null;
68
+ reversalLagBars: number | null;
69
+ reversalFlips: number;
70
+ reversalMisses: number;
71
+ resets: number;
72
+ resetsTotal: number;
73
+ priceResets: number;
74
+ slopeResets: number;
75
+ resetsPerDay: number;
76
+ avgBarsBetweenResets: number | null;
77
+ medianBarsBetweenResets: number | null;
78
+ p90BarsBetweenResets: number | null;
79
+ minBarsBetweenResets: number | null;
80
+ whipsawResets: number;
81
+ whipsawPct: number;
82
+ gridAgeSinceLastResetBars: number | null;
83
+ meanAbsSlopePct: number;
84
+ slopeStdPct: number;
85
+ slopeWobblePct: number;
86
+ secondDiffEnergy: number;
87
+ zeroCrossPer1k: number;
88
+ saturationPct: number;
89
+ neutralPct: number;
90
+ avgAbsRangeOffset: number;
91
+ offsetActivePct: number;
92
+ forwardWindowBars: number;
93
+ rangeWrongWayPct: number | null;
94
+ rangeTiltActivePct: number | null;
95
+ meanWrongStreakBars: number | null;
96
+ medianAdverseMoveWhileWrongPct: number | null;
97
+ p90AdverseMoveWhileWrongPct: number | null;
98
+ warmupBars: number;
99
+ finiteSlopeBars: number;
100
+ };
101
+ export { loadCandles, crossCorrelationLag, reversalLag, analyzeLookback };
102
+ //# sourceMappingURL=backtest_ama_slope_huber.d.ts.map