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
@@ -1,4 +1,5 @@
1
1
  'use strict';
2
+ import { MARKET_ADAPTER } from '../../../modules/constants.js';
2
3
  /**
3
4
  * Dynamic weight per-bar series — canonical implementation shared by the live
4
5
  * market adapter service, the research test harness, and the browser-embedded
@@ -9,12 +10,14 @@
9
10
  * confirmation latch — the exact shape both the live `_computeDynamicWeights`
10
11
  * and the interactive research chart render.
11
12
  *
12
- * This module is intentionally fully self-contained (no imports): the chart
13
- * generator embeds its exact source into generated HTML via fn.toString(), so
14
- * every consumer runs one logic path. The pure helper computeAverageAmaSlopePct
15
- * is re-exported by strategies/ama_slope_model.ts so Node callers keep their
16
- * existing import path.
13
+ * The pure functions below stay self-contained so the chart generators can embed
14
+ * their exact source via fn.toString(). The one shared config they read — the
15
+ * canonical Huber-slope parameters — is centralised in
16
+ * MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_HUBER and aliased here as AMA_SLOPE_HUBER;
17
+ * generated HTML declares the same const from the same constant. Node callers
18
+ * keep their existing import path through strategies/ama_slope_model.ts.
17
19
  */
20
+ const AMA_SLOPE_HUBER = MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_HUBER;
18
21
  function computeAverageAmaSlopePct(current, past, lookbackBars) {
19
22
  const safeLookbackBars = Number.isFinite(lookbackBars) && lookbackBars > 0
20
23
  ? Math.ceil(lookbackBars)
@@ -24,6 +27,121 @@ function computeAverageAmaSlopePct(current, past, lookbackBars) {
24
27
  }
25
28
  return ((current - past) / past * 100) / safeLookbackBars;
26
29
  }
30
+ /**
31
+ * Per-bar AMA trend in %/bar over `lookbackBars`, fitted as a Huber-robust
32
+ * linear regression of ln(AMA) against bar index (uniform weights, no kernel).
33
+ *
34
+ * This is the canonical slope used by the live adapter (dynamic weight series,
35
+ * AMA slope model, both clip paths), the grid-reset replay and the research
36
+ * charts, which embed this exact source via `embedFunctionSources`. One
37
+ * definition, one set of numbers — do not re-implement it per caller. Selected
38
+ * experimentally on a real 1h pool: it is the smoothest robust option measured
39
+ * (second-difference energy ~25x lower than the median's, max |dSlope|
40
+ * comparable to the two-point endpoint), because its influence function is
41
+ * continuous and bounded rather than an order statistic.
42
+ *
43
+ * The fit is local linear over `lookbackBars` intervals (bars+1 points, the same
44
+ * 16h span the endpoint uses), so a window-wide regime change tilts the line
45
+ * continuously instead of waiting for a majority, and a lone off-trend spike is
46
+ * bounded rather than given full endpoint weight. Output is the log-return per
47
+ * bar x 100. That differs from the arithmetic per-bar return by ~beta^2/2,
48
+ * which is negligible at the sub-0.1 %/bar magnitudes the defaults use (order
49
+ * 1e-9 at 0.1 %/bar) but grows quadratically with the reading — ln(1.06)*100 =
50
+ * 5.83, ~3% below a 6%/bar arithmetic rate. A pre-existing user override of
51
+ * maxSlopePct / neutralZonePct was tuned against the arithmetic reading, so a
52
+ * saturated override now clamps a hair tighter than before.
53
+ *
54
+ * Persistence note: `slopePct` is a different quantity from any pre-Huber
55
+ * reading (log-return regression vs the old median/endpoint). The first cycle
56
+ * after deploying compares a Huber reading against the still-persisted old
57
+ * baseline (botState.gridRangeScalingAmaSlope); the two magnitudes agree
58
+ * closely, so that delta sits below the reset gate on ~98% of bars (p50
59
+ * 0.00043, p90 0.00277 %/bar) — roughly one whitelisted bot in fifty costs one
60
+ * extra recenter, once. No version marker is persisted to suppress it.
61
+ *
62
+ * Parameters come from MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_HUBER (aliased as
63
+ * AMA_SLOPE_HUBER; injected into generated charts). `hub` is overridable only so
64
+ * tests can prove the values are threaded through — production never passes it.
65
+ *
66
+ * @param amaValues Full AMA series (index-addressable).
67
+ * @param index Bar to measure at (evaluated at the window edge).
68
+ * @param lookbackBars Window length in bars (fixed at 16 for every estimator).
69
+ * @param hub Parameter block; defaults to the centralized constant.
70
+ * @returns %/bar, or null when the window is unusable.
71
+ */
72
+ function computeHuberWindowSlopePct(amaValues, index, lookbackBars, hub = AMA_SLOPE_HUBER) {
73
+ const bars = Number.isFinite(lookbackBars) && Number(lookbackBars) > 0
74
+ ? Math.ceil(Number(lookbackBars))
75
+ : 0;
76
+ if (!Array.isArray(amaValues) || bars < 1)
77
+ return null;
78
+ if (!Number.isFinite(index) || index < bars || index >= amaValues.length)
79
+ return null;
80
+ // Local linear fit needs the full window at both ends; reject non-positive
81
+ // values anywhere in the window (Number(null) is 0) before fitting.
82
+ const y = [];
83
+ for (let k = index - bars; k <= index; k++) {
84
+ const v = Number(amaValues[k]);
85
+ if (!Number.isFinite(v) || v <= 0)
86
+ return null;
87
+ y.push(Math.log(v));
88
+ }
89
+ const n = y.length;
90
+ // Fill any missing field from the canonical constant. Production never passes
91
+ // `hub` (the default is the constant), so this only guards a partial override
92
+ // from silently skipping the IRLS loop or injecting NaN weights.
93
+ const hubC = Number.isFinite(hub?.C) ? hub.C : AMA_SLOPE_HUBER.C;
94
+ const hubIterations = Number.isFinite(hub?.ITERATIONS) ? hub.ITERATIONS : AMA_SLOPE_HUBER.ITERATIONS;
95
+ const hubScaleFloor = Number.isFinite(hub?.SCALE_FLOOR) ? hub.SCALE_FLOOR : AMA_SLOPE_HUBER.SCALE_FLOOR;
96
+ const hubZeroEpsilon = Number.isFinite(hub?.ZERO_EPSILON) ? hub.ZERO_EPSILON : AMA_SLOPE_HUBER.ZERO_EPSILON;
97
+ // Weighted least squares of y on the CENTERED index x_i = i - (n-1)/2. The
98
+ // x-centering keeps the normal equations well-conditioned, but the FULL
99
+ // two-variable solution is required: with non-uniform Huber weights the
100
+ // cross term Sx != 0, so b = Sxy/Sxx alone is not the minimiser (it would
101
+ // not decrease the objective). Kept inline (and therefore self-contained
102
+ // for chart embedding): { a, b } with b the log-slope.
103
+ const xMean = (n - 1) / 2;
104
+ const wls = (w) => {
105
+ let sw = 0, swx = 0, swy = 0, swxx = 0, swxy = 0;
106
+ for (let i = 0; i < n; i++) {
107
+ const xi = i - xMean;
108
+ sw += w[i];
109
+ swx += w[i] * xi;
110
+ swy += w[i] * y[i];
111
+ swxx += w[i] * xi * xi;
112
+ swxy += w[i] * xi * y[i];
113
+ }
114
+ const den = sw * swxx - swx * swx;
115
+ const b = den === 0 ? 0 : (sw * swxy - swx * swy) / den;
116
+ const a = sw === 0 ? 0 : (swy - b * swx) / sw;
117
+ return { a, b };
118
+ };
119
+ let fit = wls(new Array(n).fill(1)); // OLS initialisation
120
+ for (let iter = 0; iter < hubIterations; iter++) {
121
+ const resid = y.map((v, i) => v - (fit.a + fit.b * (i - xMean)));
122
+ const abs = resid.map(Math.abs).sort((p, q) => p - q);
123
+ const mid = abs.length >> 1;
124
+ const mad = abs.length % 2 === 1 ? abs[mid] : (abs[mid - 1] + abs[mid]) / 2;
125
+ // Floor the robust scale. On piecewise-perfect data (a pure ramp, a
126
+ // constant series) the MAD can collapse to ~0, which makes the Huber
127
+ // weights degenerate and the weighted fit unstable; the floor is far
128
+ // below any real per-bar signal (the reset gate is ~7e-5 here).
129
+ const s = Math.max(1.4826 * mad, hubScaleFloor);
130
+ const w = resid.map((r) => Math.min(1, (hubC * s) / Math.max(Math.abs(r), 1e-12)));
131
+ const next = wls(w);
132
+ const moved = Math.abs(next.b - fit.b);
133
+ fit = next;
134
+ if (moved < 1e-12)
135
+ break;
136
+ }
137
+ const slope = fit.b * 100;
138
+ // A constant window has zero true slope, but centred WLS leaves ~1e-14 of
139
+ // rounding, which would flip a zero neutral zone to a trend (UP/DOWN).
140
+ // Snap anything below ZERO_EPSILON (far under the reset gate).
141
+ if (Number.isFinite(slope) && Math.abs(slope) < hubZeroEpsilon)
142
+ return 0;
143
+ return Number.isFinite(slope) ? slope : null;
144
+ }
27
145
  function echoLatchSeries(appliedSeries, preGainSeries, confirmBars) {
28
146
  const n = Array.isArray(appliedSeries) ? appliedSeries.length : 0;
29
147
  const echoedAppliedSeries = new Array(n).fill(0);
@@ -86,9 +204,7 @@ function computeDynamicWeightSeries(inputs) {
86
204
  for (let i = 0; i < n; i++) {
87
205
  if (i < amaReadyBar)
88
206
  continue;
89
- const last = amaValues[i];
90
- const past = amaValues[i - lookbackBars];
91
- const sp = computeAverageAmaSlopePct(last, past, lookbackBars);
207
+ const sp = computeHuberWindowSlopePct(amaValues, i, lookbackBars);
92
208
  if (sp == null)
93
209
  continue;
94
210
  const csp = Math.max(-amaClipThreshold, Math.min(amaClipThreshold, sp));
@@ -182,11 +298,7 @@ function computeAmaSlopeClipThreshold(amaValues, erPeriod, lookbackBars, clipPer
182
298
  return Infinity;
183
299
  const slopes = [];
184
300
  for (let i = readyBars; i < amaValues.length; i++) {
185
- const last = amaValues[i];
186
- const past = amaValues[i - lookbackBars];
187
- if (!Number.isFinite(last) || !Number.isFinite(past))
188
- continue;
189
- const s = computeAverageAmaSlopePct(last, past, lookbackBars);
301
+ const s = computeHuberWindowSlopePct(amaValues, i, lookbackBars);
190
302
  if (Number.isFinite(s))
191
303
  slopes.push(Math.abs(s));
192
304
  }
@@ -223,30 +335,26 @@ function createAmaSlopeClipTracker(erPeriod, lookbackBars, clipPercentile) {
223
335
  return Infinity;
224
336
  const i = buffer.length - 1;
225
337
  if (i >= readyBars) {
226
- const last = buffer[i];
227
- const past = buffer[i - lookbackBars];
228
- if (Number.isFinite(last) && Number.isFinite(past)) {
229
- const s = computeAverageAmaSlopePct(last, past, lookbackBars);
230
- if (Number.isFinite(s)) {
231
- const v = Math.abs(s);
232
- let lo = 0;
233
- let hi = sorted.length;
234
- while (lo < hi) {
235
- const mid = (lo + hi) >> 1;
236
- if (sorted[mid] < v)
237
- lo = mid + 1;
238
- else
239
- hi = mid;
240
- }
241
- sorted.splice(lo, 0, v);
338
+ const s = computeHuberWindowSlopePct(buffer, i, lookbackBars);
339
+ if (Number.isFinite(s)) {
340
+ const v = Math.abs(s);
341
+ let lo = 0;
342
+ let hi = sorted.length;
343
+ while (lo < hi) {
344
+ const mid = (lo + hi) >> 1;
345
+ if (sorted[mid] < v)
346
+ lo = mid + 1;
347
+ else
348
+ hi = mid;
242
349
  }
350
+ sorted.splice(lo, 0, v);
243
351
  }
244
352
  }
245
353
  return percentileFromSorted(sorted, clipPercentile);
246
354
  },
247
355
  };
248
356
  }
249
- export { computeDynamicWeightSeries, computeAverageAmaSlopePct, echoLatchSeries, roundToN, computeAmaSlopeClipThreshold, createAmaSlopeClipTracker,
357
+ export { computeDynamicWeightSeries, computeAverageAmaSlopePct, computeHuberWindowSlopePct, echoLatchSeries, roundToN, computeAmaSlopeClipThreshold, createAmaSlopeClipTracker,
250
358
  // Exported so chart generators can embed the clip tracker's exact
251
359
  // dependency set via fn.toString() (see embedFunctionSources): the tracker
252
360
  // itself calls this, and embedding one without the other breaks the page.
@@ -155,7 +155,7 @@ function computeRequiredCandles(amaConfig = null, cfg = null) {
155
155
  const ama = amaConfig || MARKET_ADAPTER.AMAS[MARKET_ADAPTER.DEFAULT_AMA_KEY] || MARKET_ADAPTER.AMAS.AMA3;
156
156
  if (!ama)
157
157
  return DEFAULT_BOOTSTRAP_LOOKBACK_HOURS;
158
- const warmupBars = getAmaWarmupBars(ama.erPeriod, ama.slowPeriod, cfg?.amaSlope?.lookbackBars ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_LOOKBACK_BARS, ama.fastPeriod, MARKET_ADAPTER.AMA_ER_SMOOTH_FAST_PERIOD);
158
+ const warmupBars = getAmaWarmupBars(ama.erPeriod, ama.slowPeriod, cfg?.amaSlope?.lookbackBars ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_LOOKBACK_BARS, ama.fastPeriod);
159
159
  const analysisKeepCount = warmupBars + 1;
160
160
  return Math.max(DEFAULT_BOOTSTRAP_LOOKBACK_HOURS, analysisKeepCount);
161
161
  }
@@ -1134,7 +1134,6 @@ async function main() {
1134
1134
  erPeriod: botAma.erPeriod,
1135
1135
  fastPeriod: botAma.fastPeriod,
1136
1136
  slowPeriod: botAma.slowPeriod,
1137
- erSmoothPeriod: botAma.erSmoothPeriod ?? null,
1138
1137
  } : null,
1139
1138
  bot: botContext ? {
1140
1139
  name: botContext.bot.name || null,
@@ -18,8 +18,7 @@ function formatLogPair(first, second, digits = 2) {
18
18
  function formatAmaTuple(ama) {
19
19
  if (!ama)
20
20
  return 'n/a';
21
- const erSmoothPeriod = Number.isFinite(Number(ama.erSmoothPeriod)) ? Number(ama.erSmoothPeriod) : 0;
22
- return `${formatLogNumber(ama.erPeriod, 0)}/${formatLogNumber(ama.fastPeriod, 1)}/${formatLogNumber(ama.slowPeriod, 1)}/es${formatLogNumber(erSmoothPeriod, 0)}`;
21
+ return `${formatLogNumber(ama.erPeriod, 0)}/${formatLogNumber(ama.fastPeriod, 1)}/${formatLogNumber(ama.slowPeriod, 1)}`;
23
22
  }
24
23
  function formatAsymmetryFactor(value, digits = 1) {
25
24
  return Number.isFinite(value) ? `${(Number(value) * 100).toFixed(digits)}%` : 'n/a';
@@ -1,7 +1,8 @@
1
1
  'use strict';
2
2
  import { path } from '../modules/path_api.js';
3
3
  import { getStorage } from '../modules/storage/index.js';
4
- import { normalizeAssetSymbol, isExactPair, isSamePair } from './utils/chain.js';
4
+ import { isExactPair, isSamePair } from './utils/chain.js';
5
+ import { normalizeAssetSymbol } from '../modules/utils/asset_symbols.js';
5
6
  import { toIntervalLabel } from './interval_utils.js';
6
7
  import { PATHS } from '../modules/paths.js';
7
8
  const storage = getStorage();
@@ -209,7 +209,6 @@ declare function buildAmaRecord(botAma: any, amaPrice: any): {
209
209
  erPeriod: number;
210
210
  fastPeriod: number;
211
211
  slowPeriod: number;
212
- erSmoothPeriod: number;
213
212
  value: number | null;
214
213
  ok: boolean;
215
214
  }[];
@@ -20,7 +20,7 @@ import { acquireFileLockSync, releaseFileLockSync } from './utils/file_lock.js';
20
20
  import { updateDynamicGridSnapshotSync } from './utils/dynamic_grid_snapshot.js';
21
21
  import { PATHS, getRecalculateTriggerFile } from '../modules/paths.js';
22
22
  import Logger from '../modules/order/logger.js';
23
- import { fixedTo, roundTo } from '../modules/order/utils/math.js';
23
+ import { roundTo } from '../modules/order/utils/math.js';
24
24
  import { usesAmaGridPrice } from '../modules/dexbot_maintenance_runtime.js';
25
25
  import { normalizeAtrPeriod, normalizeMaxVolatilityOffset, normalizeVolatilityThreshold, } from './core/config_normalizers.js';
26
26
  import { resetMarketAdapterWhitelistCache, isBotWhitelisted, isBotDynamicWeightWhitelisted, isBotAsymmetricBoundsWhitelisted, } from '../modules/market_adapter_whitelist.js';
@@ -336,23 +336,6 @@ function findAmaProfileForBot(bot, ctx) {
336
336
  function getAmaPresetForKey(key, profile) {
337
337
  return normalizeAmaPreset(profile?.amas?.[key]) || normalizeAmaPreset(BUILTIN_AMAS[key]) || null;
338
338
  }
339
- function normalizeErSmoothPeriod(raw, fallback = 0) {
340
- const value = Number(raw);
341
- if (value === 0)
342
- return 0;
343
- if (Number.isFinite(value) && value >= 1)
344
- return value;
345
- const fallbackValue = Number(fallback);
346
- return Number.isFinite(fallbackValue) && fallbackValue >= 1 ? fallbackValue : 0;
347
- }
348
- function resolveErSmoothPeriodForBot(bot) {
349
- const raw = (bot && typeof bot.ama === 'object' && bot.ama !== null) ? bot.ama : {};
350
- const globalErSmoothPeriod = normalizeErSmoothPeriod(MARKET_ADAPTER.AMA_ER_SMOOTH_FAST_PERIOD, 0);
351
- if (Object.prototype.hasOwnProperty.call(raw, 'erSmoothPeriod')) {
352
- return normalizeErSmoothPeriod(raw.erSmoothPeriod, globalErSmoothPeriod);
353
- }
354
- return globalErSmoothPeriod;
355
- }
356
339
  function getAmaFromProfilesForBot(bot, ctx, cfg) {
357
340
  const selected = resolveAmaPresetForBot(bot, ctx, cfg);
358
341
  if (!selected)
@@ -363,7 +346,6 @@ function getAmaFromProfilesForBot(bot, ctx, cfg) {
363
346
  erPeriod: selected.erPeriod,
364
347
  fastPeriod: selected.fastPeriod,
365
348
  slowPeriod: selected.slowPeriod,
366
- erSmoothPeriod: selected.erSmoothPeriod,
367
349
  };
368
350
  }
369
351
  /**
@@ -375,7 +357,6 @@ function getAmaFromProfilesForBot(bot, ctx, cfg) {
375
357
  */
376
358
  function resolveAmaPresetForBot(bot, ctx, cfg) {
377
359
  const profile = findAmaProfileForBot(bot, ctx);
378
- const erSmoothPeriod = resolveErSmoothPeriodForBot(bot);
379
360
  if (!profile)
380
361
  return null;
381
362
  const rawGridPrice = String(bot?.gridPrice || '').trim().toLowerCase();
@@ -399,7 +380,6 @@ function resolveAmaPresetForBot(bot, ctx, cfg) {
399
380
  erPeriod: selected.preset.erPeriod,
400
381
  fastPeriod: selected.preset.fastPeriod,
401
382
  slowPeriod: selected.preset.slowPeriod,
402
- erSmoothPeriod,
403
383
  };
404
384
  }
405
385
  function pairAmaKey(key, preset) {
@@ -867,7 +847,6 @@ function computeCandleStaleness(lastCandleTs, maxStaleHours) {
867
847
  */
868
848
  function resolveAmaForBot(bot, ctx = null, cfg = null) {
869
849
  const raw = (bot && typeof bot.ama === 'object' && bot.ama !== null) ? bot.ama : {};
870
- const erSmoothPeriod = resolveErSmoothPeriodForBot(bot);
871
850
  const fromProfiles = getAmaFromProfilesForBot(bot, ctx, cfg);
872
851
  if (fromProfiles)
873
852
  return fromProfiles;
@@ -875,7 +854,6 @@ function resolveAmaForBot(bot, ctx = null, cfg = null) {
875
854
  erPeriod: Number(raw.erPeriod),
876
855
  fastPeriod: Number(raw.fastPeriod),
877
856
  slowPeriod: Number(raw.slowPeriod),
878
- erSmoothPeriod,
879
857
  enabled: true,
880
858
  name: 'custom',
881
859
  };
@@ -941,7 +919,6 @@ function buildAmaRecord(botAma, amaPrice) {
941
919
  const erPeriod = Number(botAma?.erPeriod);
942
920
  const fastPeriod = Number(botAma?.fastPeriod);
943
921
  const slowPeriod = Number(botAma?.slowPeriod);
944
- const erSmoothPeriod = Number(botAma?.erSmoothPeriod);
945
922
  if (!Number.isFinite(erPeriod) || !Number.isFinite(fastPeriod) || !Number.isFinite(slowPeriod)) {
946
923
  return [];
947
924
  }
@@ -951,7 +928,6 @@ function buildAmaRecord(botAma, amaPrice) {
951
928
  erPeriod,
952
929
  fastPeriod,
953
930
  slowPeriod,
954
- erSmoothPeriod: Number.isFinite(erSmoothPeriod) ? erSmoothPeriod : 0,
955
931
  value: Number.isFinite(value) ? value : null,
956
932
  ok: Number.isFinite(value),
957
933
  }];
@@ -1402,8 +1378,7 @@ async function runOnce(cfg, state, contextCache) {
1402
1378
  if (Array.isArray(r.amaComparison) && r.amaComparison.length > 0) {
1403
1379
  const parts = r.amaComparison.map((a) => {
1404
1380
  const val = Number.isFinite(a.value) ? a.value.toFixed(8) : 'n/a';
1405
- const erSmoothText = Number.isFinite(Number(a.erSmoothPeriod)) ? `/es${fixedTo(a.erSmoothPeriod, 0)}` : '';
1406
- return `${a.name}[${a.erPeriod}/${a.fastPeriod}/${a.slowPeriod}${erSmoothText}]=${val}`;
1381
+ return `${a.name}[${a.erPeriod}/${a.fastPeriod}/${a.slowPeriod}]=${val}`;
1407
1382
  });
1408
1383
  log(cfg, ` AMA active: ${parts.join(' | ')}`);
1409
1384
  }
@@ -1,3 +1,4 @@
1
+ import { normalizeAssetSymbol } from '../../modules/utils/asset_symbols.js';
1
2
  declare function getBitsharesClient(): any;
2
3
  declare function setBitsharesClientForTests(client: any): void;
3
4
  declare function resolveAsset(symbol: any, bitsharesClient?: any): Promise<{
@@ -6,7 +7,6 @@ declare function resolveAsset(symbol: any, bitsharesClient?: any): Promise<{
6
7
  symbol: string;
7
8
  }>;
8
9
  declare function findPoolByAssets(assetAId: any, assetBId: any, options?: any): Promise<any>;
9
- declare function normalizeAssetSymbol(value: any): string;
10
10
  declare function isExactPair(a: any, b: any, targetA: any, targetB: any): boolean;
11
11
  declare function isSamePair(a: any, b: any, targetA: any, targetB: any): boolean;
12
12
  declare function isExactPairIds(aId: any, bId: any, targetAId: any, targetBId: any): boolean;
@@ -2,6 +2,7 @@
2
2
  import { createRequire } from 'node:module';
3
3
  const require = createRequire(import.meta.url);
4
4
  import { API_LIMITS } from '../../modules/constants.js';
5
+ import { normalizeAssetSymbol } from '../../modules/utils/asset_symbols.js';
5
6
  let _bitsharesClient = null;
6
7
  function getBitsharesClient() {
7
8
  // lazy require to avoid circular dependencies at module load time
@@ -17,13 +18,17 @@ async function resolveAsset(symbol, bitsharesClient = null) {
17
18
  if (!symbol || typeof symbol !== 'string') {
18
19
  throw new Error(`Cannot resolve asset: invalid or missing symbol "${symbol}"`);
19
20
  }
21
+ // BitShares symbols are canonical UPPERCASE; nodes answer lowercase lookups
22
+ // silently, so normalize here and hand the canonical symbol downstream
23
+ // (cache keys, Kibana terms, chart labels) instead of the raw input.
24
+ const canonical = normalizeAssetSymbol(symbol);
20
25
  const client = bitsharesClient || getBitsharesClient();
21
- const results = await client.BitShares.db.lookup_asset_symbols([symbol]);
26
+ const results = await client.BitShares.db.lookup_asset_symbols([canonical]);
22
27
  const asset = results?.[0];
23
28
  if (!asset?.id || typeof asset.precision !== 'number') {
24
- throw new Error(`Cannot resolve asset "${symbol}": lookup failed`);
29
+ throw new Error(`Cannot resolve asset "${canonical}": lookup failed`);
25
30
  }
26
- return { id: asset.id, precision: asset.precision, symbol };
31
+ return { id: asset.id, precision: asset.precision, symbol: String(asset.symbol || canonical) };
27
32
  }
28
33
  async function findPoolByAssets(assetAId, assetBId, options = {}) {
29
34
  const client = options.bitsharesClient || getBitsharesClient();
@@ -107,9 +112,6 @@ async function findPoolByAssets(assetAId, assetBId, options = {}) {
107
112
  }
108
113
  throw new Error(`No liquidity pool found for ${assetAId}/${assetBId}`);
109
114
  }
110
- function normalizeAssetSymbol(value) {
111
- return String(value || '').trim().toUpperCase();
112
- }
113
115
  function isExactPair(a, b, targetA, targetB) {
114
116
  const na = normalizeAssetSymbol(a);
115
117
  const nb = normalizeAssetSymbol(b);
@@ -99,6 +99,7 @@ import { getWhitelistFlags, setWhitelistFlags, renameWhitelistEntry, removeWhite
99
99
  import { BOT_LIVE_CONFIG_KEYS } from './runtime_settings.js';
100
100
  import { mergeSettings } from './settings_merge.js';
101
101
  import { getErrorMessage } from './utils/errors.js';
102
+ import { normalizeAssetSymbol } from './utils/asset_symbols.js';
102
103
  import { roundToDecimals, parseRelativeMultiplier } from './order/utils/math.js';
103
104
  import { CLI_COLORS } from './cli_colors.js';
104
105
  import { displayWidth, padDisplay } from './utils/text_width.js';
@@ -360,7 +361,7 @@ async function askLogLevel(promptText, defaultValue) {
360
361
  */
361
362
  async function askAsset(promptText, defaultValue) {
362
363
  while (true) {
363
- const displayDefault = defaultValue ? String(defaultValue).toUpperCase() : undefined;
364
+ const displayDefault = defaultValue ? normalizeAssetSymbol(defaultValue) : undefined;
364
365
  const suffix = displayDefault !== undefined && displayDefault !== null ? ` [${displayDefault}]` : '';
365
366
  const answer = await readInput(`${promptText}${suffix}: `);
366
367
  if (answer === '\x1b')
@@ -371,7 +372,7 @@ async function askAsset(promptText, defaultValue) {
371
372
  console.log('Asset name is required.');
372
373
  continue;
373
374
  }
374
- return answer.toUpperCase().trim();
375
+ return normalizeAssetSymbol(answer);
375
376
  }
376
377
  }
377
378
  /**
@@ -383,7 +384,7 @@ async function askAsset(promptText, defaultValue) {
383
384
  */
384
385
  async function askAssetB(promptText, defaultValue, assetA) {
385
386
  while (true) {
386
- const displayDefault = defaultValue ? String(defaultValue).toUpperCase() : undefined;
387
+ const displayDefault = defaultValue ? normalizeAssetSymbol(defaultValue) : undefined;
387
388
  const suffix = displayDefault !== undefined && displayDefault !== null ? ` [${displayDefault}]` : '';
388
389
  const answer = await readInput(`${promptText}${suffix}: `);
389
390
  if (answer === '\x1b')
@@ -394,7 +395,7 @@ async function askAssetB(promptText, defaultValue, assetA) {
394
395
  console.log('Asset name is required.');
395
396
  continue;
396
397
  }
397
- const assetB = answer.toUpperCase().trim();
398
+ const assetB = normalizeAssetSymbol(answer);
398
399
  // Validate that Asset B is different from Asset A
399
400
  if (assetB === assetA) {
400
401
  console.log(`Invalid: Asset B cannot be the same as Asset A (${assetA})`);
@@ -2,6 +2,7 @@
2
2
  import { NATIVE_CLIENT } from '../constants.js';
3
3
  import { LRUCache } from './lru_cache.js';
4
4
  import { getErrorMessage } from '../utils/errors.js';
5
+ import { normalizeAssetRef } from '../utils/asset_symbols.js';
5
6
  const { RESOLVERS } = NATIVE_CLIENT;
6
7
  const ASSET_TTL_MS = RESOLVERS.ASSET_TTL_MS;
7
8
  const ACCOUNT_TTL_MS = RESOLVERS.ACCOUNT_TTL_MS;
@@ -14,6 +15,10 @@ function createResolvers(chainClient) {
14
15
  async function resolveAsset(idOrSymbol) {
15
16
  if (!idOrSymbol)
16
17
  throw new Error('asset id or symbol required');
18
+ // Canonicalize before the cache key and the chain call: a lowercase
19
+ // symbol would otherwise occupy a second cache slot and be echoed back
20
+ // lowercase to every caller.
21
+ idOrSymbol = normalizeAssetRef(idOrSymbol);
17
22
  const cacheKey = `asset:${idOrSymbol}`;
18
23
  const cached = assetCache.get(cacheKey);
19
24
  if (cached)
@@ -7,6 +7,7 @@ import { isSameBotName } from './utils/sanitize_key.js';
7
7
  import { isPositiveNumber, isPositiveNumberOrPercent, toDecimal } from './order/utils/math.js';
8
8
  import { resolveMinCollateralIncreaseThreshold } from './cr_planner.js';
9
9
  import { getErrorMessage } from './utils/errors.js';
10
+ import { canonicalizeBotAssetSymbols } from './utils/asset_symbols.js';
10
11
  const storage = getStorage();
11
12
  const { writeJSON } = storage;
12
13
  function loadSettingsFile(filePath, { silent = false, exitOnError = true } = {}) {
@@ -52,7 +53,18 @@ function normalizeBotEntry(entry, index = 0) {
52
53
  // active default + raw passthrough live in modules/bot_defaults.ts
53
54
  // (shared with the claw copy — one semantics for both).
54
55
  const normalized = seedBotEntry(entry);
55
- return { ...normalized, botIndex: index, botKey: createBotKey(normalized, index) };
56
+ // Asset symbols are canonical UPPERCASE on BitShares. A hand-edited
57
+ // lowercase "assetA": "tokena" is accepted by the chain without error but
58
+ // breaks every strict symbol comparison downstream (e.g. the core-asset
59
+ // side check that reads `assetA === 'CORE'`,
60
+ // getBtsSide, fee/pool cache keys), so canonicalize at this single read
61
+ // funnel — which key names hold a symbol is defined once, in
62
+ // modules/utils/asset_symbols.canonicalizeBotAssetSymbols, shared with
63
+ // analysis/bot_key_utils.loadBotMeta. botKey is unaffected: createBotKey
64
+ // runs the pair through sanitizeKey, which is case-insensitive.
65
+ const out = canonicalizeBotAssetSymbols({ ...normalized, botIndex: index });
66
+ out.botKey = createBotKey(out, index);
67
+ return out;
56
68
  }
57
69
  function normalizeBotEntries(rawEntries) {
58
70
  return rawEntries.map((entry, index) => normalizeBotEntry(entry, index));
@@ -113,6 +113,7 @@ import { BroadcastUncertainError } from './dexbot_credential_client.js';
113
113
  import { classifyBroadcastFailure } from './broadcast_failure.js';
114
114
  import Logger from './order/logger.js';
115
115
  import { getErrorMessage } from './utils/errors.js';
116
+ import { normalizeAssetRef } from './utils/asset_symbols.js';
116
117
  function getNodeManager() { return require('./bitshares_client').getNodeManager(); }
117
118
  const { toFiniteNumber } = Format;
118
119
  const chainOrdersLogger = new Logger('ChainOrders');
@@ -1404,7 +1405,7 @@ async function getOnChainAssetBalances(accountRef, assets, options = {}) {
1404
1405
  try {
1405
1406
  if (!/^1\.3\./.test(String(a))) {
1406
1407
  // symbol -> asset
1407
- const res = await BitShares.db.lookup_asset_symbols([String(a)]).catch(() => null);
1408
+ const res = await BitShares.db.lookup_asset_symbols([normalizeAssetRef(a)]).catch(() => null);
1408
1409
  if (res && res[0] && res[0].id)
1409
1410
  aid = res[0].id;
1410
1411
  }
@@ -202,6 +202,7 @@ declare let TIMING: {
202
202
  SYNC_LOCK_TIMEOUT_MS: number;
203
203
  SYNC_SUSPECT_EMPTY_READ_LIMIT: number;
204
204
  SYNC_EMPTY_READ_CONFIRM_DELAY_MS: number;
205
+ SURPLUS_CANCEL_GRACE_MS: number;
205
206
  CONNECTION_TIMEOUT_MS: number;
206
207
  DAEMON_STARTUP_TIMEOUT_MS: number;
207
208
  RETRY_BACKOFF_CAP_MS: number;
@@ -404,6 +405,14 @@ declare let MARKET_ADAPTER: {
404
405
  DYNAMIC_WEIGHT_AMA_MAX_SLOPE_PCT: number;
405
406
  DYNAMIC_WEIGHT_KALMAN_MAX_SLOPE_PCT: number;
406
407
  DYNAMIC_WEIGHT_AMA_NEUTRAL_ZONE_PCT: number;
408
+ DYNAMIC_WEIGHT_AMA_HUBER: {
409
+ C: number;
410
+ ITERATIONS: number;
411
+ SCALE_FLOOR: number;
412
+ ZERO_EPSILON: number;
413
+ };
414
+ AMA_SLOPE_PERSIST_ENABLED: boolean;
415
+ AMA_SLOPE_PERSIST_BARS: number;
407
416
  DYNAMIC_WEIGHT_ALPHA: number;
408
417
  DYNAMIC_WEIGHT_DW: number;
409
418
  DYNAMIC_WEIGHT_GAIN: number;
@@ -486,7 +495,6 @@ declare let MARKET_ADAPTER: {
486
495
  };
487
496
  AMA_CONVERGENCE_ER_AVG: number;
488
497
  AMA_CONVERGENCE_EPSILON: number;
489
- AMA_ER_SMOOTH_FAST_PERIOD: number;
490
498
  };
491
499
  declare let LOG_LEVEL: string;
492
500
  declare let LOGGING_CONFIG: {
@@ -242,6 +242,14 @@ let TIMING = {
242
242
  // genuinely empty. A contradicted re-read (non-empty) aborts acceptance
243
243
  // and feeds the fresh snapshot to the resync instead.
244
244
  SYNC_EMPTY_READ_CONFIRM_DELAY_MS: 2000,
245
+ // Surplus-cancel grace for freshly placed orders. Spread correction and
246
+ // surplus sweeps run on different count snapshots within one cycle, so a
247
+ // fill landing between them makes the second controller cancel what the
248
+ // first just placed (observed: 4 placed, 3 cancelled seconds later).
249
+ // Orders younger than this are skipped by surplus cancellation and
250
+ // re-evaluated next cycle. Time-bounded by design: genuine misplacements
251
+ // are only delayed, never protected forever.
252
+ SURPLUS_CANCEL_GRACE_MS: 15 * 60 * 1000,
245
253
  // Connection and initialization timeouts
246
254
  CONNECTION_TIMEOUT_MS: 30000, // 30 seconds - BitShares client connection establishment timeout
247
255
  DAEMON_STARTUP_TIMEOUT_MS: 60000, // 60 seconds - Private key daemon startup timeout
@@ -1083,8 +1091,15 @@ let MARKET_ADAPTER = {
1083
1091
  // DYNAMIC_WEIGHT_AMA_LOOKBACK_BARS: Lookback window for measuring AMA trend.
1084
1092
  // Lower values react faster to recent price changes.
1085
1093
  // Higher values smooth the signal and require a more sustained move.
1094
+ // 16 (was 20): the shorter window's slope is ~8% noisier (bar-to-bar wobble
1095
+ // and zero-crossings), which by itself would add slope resets; the
1096
+ // persistence gate (K=3) absorbs that, so resets/day stay matched — 962 vs
1097
+ // 960 on the sample, 0.95/day either way. It buys a cleaner signal where it
1098
+ // matters: AMA group delay 10→8 bars, reversal lag 22→20, and range-tilt
1099
+ // wrong-way 13.7%→12.6%. Measured on the real 1h pools; see
1100
+ // docs/AMA_SLOPE_WINDOW.md.
1086
1101
  // nob: lb (Lookback Bars)
1087
- DYNAMIC_WEIGHT_AMA_LOOKBACK_BARS: 9,
1102
+ DYNAMIC_WEIGHT_AMA_LOOKBACK_BARS: 16,
1088
1103
  // DYNAMIC_WEIGHT_AMA_MAX_SLOPE_PCT: Average per-bar trend size that counts as "full strength" for AMA.
1089
1104
  // Lower values make the AMA channel reach maximum influence more easily.
1090
1105
  // Higher values require a stronger price move before AMA reaches full effect.
@@ -1102,6 +1117,45 @@ let MARKET_ADAPTER = {
1102
1117
  // Lower values make the AMA channel react to smaller moves.
1103
1118
  // nob: nz% (Neutral Zone %)
1104
1119
  DYNAMIC_WEIGHT_AMA_NEUTRAL_ZONE_PCT: 0,
1120
+ // DYNAMIC_WEIGHT_AMA_HUBER: Single source of truth for the canonical AMA-slope
1121
+ // estimator (computeHuberWindowSlopePct in strategy/dynamic_weight_series.ts).
1122
+ // Every consumer — live market adapter, grid-reset replay, bot-fitting
1123
+ // backtests, both browser-embedded research charts — reads these values:
1124
+ // Node callers via the module import, generated HTML via an injected
1125
+ // `const AMA_SLOPE_HUBER = {...}` literal. Change a value here and every
1126
+ // slope computation follows; do not re-declare them per caller.
1127
+ // C Huber tuning constant. Nominal 1.345 ~= 95% Gaussian
1128
+ // efficiency, but the plug-in 1.4826*MAD scale is biased low
1129
+ // (residual degrees of freedom), so the EFFECTIVE C is
1130
+ // ~1.25 at the 16-bar window — more robust, less efficient
1131
+ // than nominal. The detune grows ~1/(bars-1) at short
1132
+ // windows and vanishes at long ones; deliberately NOT
1133
+ // compensated (the bias points the robust way, and a
1134
+ // sqrt(n/(n-2)) correction is decision-neutral). See
1135
+ // analysis/trend_detection/huber_scale_variants.ts.
1136
+ // ITERATIONS IRLS passes (converges in a few at the ~16-bar window)
1137
+ // SCALE_FLOOR Floor for the 1.4826*MAD robust scale, in log units
1138
+ // ZERO_EPSILON Slopes below this (%/bar) snap to exactly 0
1139
+ // nob: n/a (algorithm-internal)
1140
+ DYNAMIC_WEIGHT_AMA_HUBER: {
1141
+ C: 1.345,
1142
+ ITERATIONS: 5,
1143
+ SCALE_FLOOR: 1e-6,
1144
+ ZERO_EPSILON: 1e-9,
1145
+ },
1146
+ // AMA_SLOPE_PERSIST_ENABLED: slope-delta persistence gate (trigger B).
1147
+ // When true, the slope reset requires AMA_SLOPE_PERSIST_BARS consecutive
1148
+ // confirming bars, filtering short-lived excursions. Enabled by default
1149
+ // (was legacy fire-on-first-crossing): measured over the real 1h pools it
1150
+ // cuts resets ~35% and whipsaw ~52%→~17%, leaving lag and range-tilt
1151
+ // unchanged. Per bot/market override via `amaSlope.persistBars` /
1152
+ // `amaSlope.persistEnabled`. See docs/AMA_SLOPE_WINDOW.md.
1153
+ AMA_SLOPE_PERSIST_ENABLED: true,
1154
+ // AMA_SLOPE_PERSIST_BARS: consecutive confirming bars required before the
1155
+ // slope-delta grid reset (trigger B) fires once enabled. 1 = legacy behavior
1156
+ // (no persistence). Filters short-lived slope excursions without adding trend
1157
+ // latency.
1158
+ AMA_SLOPE_PERSIST_BARS: 3,
1105
1159
  // DYNAMIC_WEIGHT_ALPHA: Blend between AMA trend and Kalman trend.
1106
1160
  // 0 = pure Kalman, 1 = pure AMA.
1107
1161
  // Higher values trust AMA more, lower values trust Kalman more.
@@ -1309,14 +1363,6 @@ let MARKET_ADAPTER = {
1309
1363
  // AMA_CONVERGENCE_EPSILON: Target fraction of initialization bias remaining
1310
1364
  // after convergence. 0.01 = 99 % of the initial bias has decayed.
1311
1365
  AMA_CONVERGENCE_EPSILON: 0.01,
1312
- // AMA_ER_SMOOTH_FAST_PERIOD: Fast-period equivalent for smoothing the raw
1313
- // Efficiency Ratio via EMA before it enters the SC formula. Raw ER can spike
1314
- // at regime boundaries (trending ↔ ranging), causing jerky AMA transitions
1315
- // and false grid re-centering triggers.
1316
- // 0 = disabled (raw ER used directly, backward compatible).
1317
- // Enabled alpha = 2 / (AMA_ER_SMOOTH_FAST_PERIOD + 1).
1318
- // Overridable per bot via bots.json inline `ama.erSmoothPeriod` field.
1319
- AMA_ER_SMOOTH_FAST_PERIOD: 0,
1320
1366
  };
1321
1367
  // Logging Level Configuration
1322
1368
  // Options: