dexbot 1.6.9 → 1.6.10

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 (47) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/analysis/README.md +1 -1
  3. package/analysis/tradingview/README.md +14 -9
  4. package/claw/modules/chain_queries.ts +9 -4
  5. package/claw/modules/claw_bridge.ts +9 -9
  6. package/claw/package.json +1 -1
  7. package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
  8. package/claw/runtimes/openclaw-plugin/package.json +1 -1
  9. package/dist/analysis/ama_fitting/optimizer_high_resolution.js +2 -1
  10. package/dist/analysis/bot_fitting/backtest_ama_sweep.js +2 -2
  11. package/dist/analysis/bot_fitting/backtest_bot_fitting.js +4 -4
  12. package/dist/analysis/bot_key_utils.js +14 -4
  13. package/dist/analysis/tradingview/analyze_tradingview.d.ts +0 -3
  14. package/dist/analysis/tradingview/analyze_tradingview.js +3 -14
  15. package/dist/analysis/tradingview/grid_reset_sim.d.ts +11 -1
  16. package/dist/analysis/tradingview/grid_reset_sim.js +22 -9
  17. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +178 -32
  18. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +8 -3
  19. package/dist/dexbot.js +13 -8
  20. package/dist/market_adapter/core/strategies/ama_slope_model.d.ts +2 -2
  21. package/dist/market_adapter/core/strategies/ama_slope_model.js +12 -10
  22. package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts +41 -14
  23. package/dist/market_adapter/core/strategies/dynamic_weight_series.js +138 -30
  24. package/dist/market_adapter/lp_chart_strategy_loader.js +2 -1
  25. package/dist/market_adapter/utils/chain.d.ts +1 -1
  26. package/dist/market_adapter/utils/chain.js +8 -6
  27. package/dist/modules/account_bots.js +5 -4
  28. package/dist/modules/bitshares-native/resolvers.js +5 -0
  29. package/dist/modules/bot_settings.js +13 -1
  30. package/dist/modules/chain_orders.js +2 -1
  31. package/dist/modules/constants.d.ts +6 -0
  32. package/dist/modules/constants.js +23 -1
  33. package/dist/modules/credential_policy.js +4 -1
  34. package/dist/modules/credit_runtime.js +5 -1
  35. package/dist/modules/order/utils/system.js +11 -1
  36. package/dist/modules/utils/asset_symbols.d.ts +59 -0
  37. package/dist/modules/utils/asset_symbols.js +128 -0
  38. package/dist/scripts/analyze-credit.js +10 -7
  39. package/dist/scripts/chart_command.js +12 -4
  40. package/dist/scripts/verify-browser-bundle.js +8 -0
  41. package/docs/DEXBOT_COMPARISON.md +3 -3
  42. package/docs/EVOLUTION.md +9 -8
  43. package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
  44. package/docs/GRID_RECALCULATION.md +22 -3
  45. package/docs/README.md +1 -1
  46. package/market_adapter/README.md +2 -2
  47. package/package.json +1 -1
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Central asset-symbol / asset-ref normalization.
3
+ *
4
+ * BitShares stores asset symbols canonically UPPERCASE, so the assetA and
5
+ * assetB symbols of a bot pair are always UPPERCASE on chain.
6
+ * Nodes accept a lowercase lookup and answer it without error, so a lowercase
7
+ * symbol never fails — it just travels on as lowercase into everything built
8
+ * from it: the `symbol` field we attach to resolved assets, chart titles,
9
+ * cache-file names, Kibana query terms, and strict in-process comparisons such
10
+ * as the core-asset side check `assetA === 'CORE'`. That is a
11
+ * silent-wrong-answer class of bug, not a loud
12
+ * one, so the conversion is done ONCE here and applied at every boundary that
13
+ * accepts a pair from a human (CLI prompts, `dexbot tv`/`dw` targets) or hands
14
+ * a symbol to the chain (`lookup_asset_symbols`).
15
+ *
16
+ * Rules:
17
+ * - Asset OBJECT IDs ("1.3.x") are not symbols: they are returned verbatim so
18
+ * ref-routing callers (get_assets vs lookup_asset_symbols) keep working.
19
+ * - Everything else is trimmed and uppercased.
20
+ * - Non-strings / empty input normalize to '' (never "undefined"/"null").
21
+ *
22
+ * Browser-safe: no node built-ins.
23
+ */
24
+ /** BitShares asset object id, e.g. "1.3.0" (the core asset) or "1.3.529". */
25
+ const ASSET_OBJECT_ID_PATTERN = /^1\.3\.\d+$/;
26
+ /** True when the value is a BitShares asset object id, not a symbol. */
27
+ export function isAssetObjectId(value) {
28
+ return ASSET_OBJECT_ID_PATTERN.test(String(value ?? '').trim());
29
+ }
30
+ /**
31
+ * Canonicalize an asset symbol (or pass an asset object id through untouched).
32
+ * This is the single conversion used before a symbol reaches the blockchain
33
+ * and before it is compared, cached, or rendered.
34
+ */
35
+ export function normalizeAssetSymbol(value) {
36
+ if (value === null || value === undefined)
37
+ return '';
38
+ const text = String(value).trim();
39
+ if (!text)
40
+ return '';
41
+ if (ASSET_OBJECT_ID_PATTERN.test(text))
42
+ return text;
43
+ return text.toUpperCase();
44
+ }
45
+ /**
46
+ * Same as {@link normalizeAssetSymbol}; reads better at call sites that pass a
47
+ * mixed "id or symbol" reference (credit runtime, credential policy, pools).
48
+ */
49
+ export function normalizeAssetRef(value) {
50
+ return normalizeAssetSymbol(value);
51
+ }
52
+ /** Case- and whitespace-insensitive asset-symbol equality. */
53
+ export function isSameAssetSymbol(a, b) {
54
+ const na = normalizeAssetSymbol(a);
55
+ const nb = normalizeAssetSymbol(b);
56
+ return na !== '' && na === nb;
57
+ }
58
+ /**
59
+ * Split an "assetA/assetB" CLI target into the two normalized symbols.
60
+ * Whitespace around either leg is dropped and both legs are uppercased, so
61
+ * "assetb/asseta" and "ASSETB / ASSETA" produce the same assetA/assetB pair.
62
+ * @returns exactly two symbols, or [] when the target is not a usable pair.
63
+ */
64
+ export function splitPairTarget(target) {
65
+ return String(target ?? '')
66
+ .split('/')
67
+ .map((part) => normalizeAssetSymbol(part))
68
+ .filter((part) => part !== '');
69
+ }
70
+ // ── Config-level canonicalization (the one place that knows the key names) ────
71
+ /** bots.json keys holding an asset SYMBOL at the top level of a bot entry. */
72
+ const BOT_ASSET_SYMBOL_KEYS = ['assetA', 'assetB'];
73
+ /** `debtPolicy.lending[]` keys holding an asset SYMBOL. */
74
+ const LENDING_ASSET_SYMBOL_KEYS = ['asset', 'collateralAsset'];
75
+ /**
76
+ * Canonicalize the asset symbols of a bot config entry, recursively into
77
+ * `debtPolicy.lending[]`. This is the single definition of WHICH config keys
78
+ * hold symbols, shared by every config reader:
79
+ * - `modules/bot_settings.normalizeBotEntry` (production read funnel)
80
+ * - `analysis/bot_key_utils.loadBotMeta` (analysis/tools read funnel)
81
+ *
82
+ * Returns the SAME reference when there is nothing to canonicalize, so the
83
+ * common already-uppercase case costs one pass and no allocation, and a
84
+ * hand-edited lowercase entry never leaks into a chain call, a comparison or
85
+ * a rendered label. The input is never mutated.
86
+ */
87
+ export function canonicalizeBotAssetSymbols(entry) {
88
+ if (!entry || typeof entry !== 'object')
89
+ return entry;
90
+ let changed = false;
91
+ const out = { ...entry };
92
+ for (const key of BOT_ASSET_SYMBOL_KEYS) {
93
+ if (typeof out[key] === 'string') {
94
+ const canonical = normalizeAssetSymbol(out[key]);
95
+ if (canonical !== out[key]) {
96
+ out[key] = canonical;
97
+ changed = true;
98
+ }
99
+ }
100
+ }
101
+ if ('debtPolicy' in out) {
102
+ const policy = out.debtPolicy;
103
+ if (policy && typeof policy === 'object' && Array.isArray(policy.lending)) {
104
+ let lendingChanged = false;
105
+ const lending = policy.lending.map((item) => {
106
+ if (!item || typeof item !== 'object')
107
+ return item;
108
+ const canonicalItem = { ...item };
109
+ for (const key of LENDING_ASSET_SYMBOL_KEYS) {
110
+ if (typeof canonicalItem[key] === 'string') {
111
+ const canonical = normalizeAssetSymbol(canonicalItem[key]);
112
+ if (canonical !== canonicalItem[key]) {
113
+ canonicalItem[key] = canonical;
114
+ lendingChanged = true;
115
+ }
116
+ }
117
+ }
118
+ return canonicalItem;
119
+ });
120
+ if (lendingChanged) {
121
+ out.debtPolicy = { ...policy, lending };
122
+ changed = true;
123
+ }
124
+ }
125
+ }
126
+ return (changed ? out : entry);
127
+ }
128
+ //# sourceMappingURL=asset_symbols.js.map
@@ -33,6 +33,7 @@ const { FEE_PARAMETERS } = require('../modules/constants');
33
33
  const { PATHS } = require('../modules/paths');
34
34
  const { getErrorMessage } = require('../modules/utils/errors');
35
35
  const { sanitizeKey } = require('../modules/utils/sanitize_key');
36
+ const { normalizeAssetRef, normalizeAssetSymbol, isSameAssetSymbol } = require('../modules/utils/asset_symbols');
36
37
  const { loadSettingsFile, resolveRawBotEntries, normalizeBotEntries } = require('../modules/bot_settings');
37
38
  import { pathToFileURL } from 'node:url';
38
39
  // Terminal colors: centralized palette (modules/cli_colors.ts), shared with
@@ -239,7 +240,9 @@ async function main() {
239
240
  return (await assetInfo(assetId)).symbol;
240
241
  }
241
242
  async function resolveLendingRef(ref) {
242
- const s = String(ref);
243
+ // Refs come from bots.json debtPolicy.lending AND from --mpa/--collateral
244
+ // filters; canonicalize so a lowercase filter still matches the pair.
245
+ const s = normalizeAssetRef(ref);
243
246
  if (/^1\.3\.\d+$/.test(s)) {
244
247
  try {
245
248
  return { id: s, symbol: await symbolOf(s) };
@@ -387,9 +390,9 @@ async function main() {
387
390
  const resolvedMpa = await Promise.all(mpaFilterRefs.map(resolveLendingRef));
388
391
  const resolvedCredit = await Promise.all(creditFilterRefs.map(resolveLendingRef));
389
392
  const mpaIds = new Set(resolvedMpa.map((r) => r.id).filter(Boolean));
390
- const mpaSyms = new Set(resolvedMpa.map((r) => r.symbol.toUpperCase()));
393
+ const mpaSyms = new Set(resolvedMpa.map((r) => normalizeAssetSymbol(r.symbol)));
391
394
  const creditIds = new Set(resolvedCredit.map((r) => r.id).filter(Boolean));
392
- const creditSyms = new Set(resolvedCredit.map((r) => r.symbol.toUpperCase()));
395
+ const creditSyms = new Set(resolvedCredit.map((r) => normalizeAssetSymbol(r.symbol)));
393
396
  const filterActive = unionRefs.length > 0;
394
397
  async function debtMatches(debtAssetId, ids, syms) {
395
398
  if (!filterActive)
@@ -399,7 +402,7 @@ async function main() {
399
402
  if (ids.has(debtAssetId))
400
403
  return true;
401
404
  try {
402
- const sym = (await symbolOf(debtAssetId)).toUpperCase();
405
+ const sym = normalizeAssetSymbol(await symbolOf(debtAssetId));
403
406
  return syms.has(sym);
404
407
  }
405
408
  catch {
@@ -421,7 +424,7 @@ async function main() {
421
424
  symOk = true;
422
425
  else if (debtId) {
423
426
  try {
424
- symOk = creditSyms.has((await symbolOf(debtId)).toUpperCase());
427
+ symOk = creditSyms.has(normalizeAssetSymbol(await symbolOf(debtId)));
425
428
  }
426
429
  catch {
427
430
  symOk = false;
@@ -528,7 +531,7 @@ async function main() {
528
531
  });
529
532
  }
530
533
  const pairIdKeys = new Set(creditPairs.filter((p) => p.debtId && p.collId).map((p) => `${p.debtId}←${p.collId}`));
531
- const pairSymKeys = new Set(creditPairs.map((p) => `${p.debtSym.toUpperCase()}←${p.collSym.toUpperCase()}`));
534
+ const pairSymKeys = new Set(creditPairs.map((p) => `${normalizeAssetSymbol(p.debtSym)}←${normalizeAssetSymbol(p.collSym)}`));
532
535
  // Offer objects for the deals' conversion rates (debt per collateral).
533
536
  const dealOfferIds = creditDeals.map((d) => d?.offer_id).filter(Boolean).map(String);
534
537
  const offerById = await fetchOfferObjects(dealOfferIds);
@@ -643,7 +646,7 @@ async function main() {
643
646
  const feeDenom = Number(FEE_PARAMETERS?.GRAPHENE_FEE_RATE_DENOM) || 1000000;
644
647
  const walletRaw = await fetchWalletRaw(account);
645
648
  const matchPair = (pair, r) => (pair.debtId !== null && r.debtId !== null && pair.debtId === r.debtId && pair.collId !== null && r.collId !== null && pair.collId === r.collId) ||
646
- (pair.debtSym.toUpperCase() === r.debtSym.toUpperCase() && pair.collSym.toUpperCase() === r.collSym.toUpperCase());
649
+ (isSameAssetSymbol(pair.debtSym, r.debtSym) && isSameAssetSymbol(pair.collSym, r.collSym));
647
650
  if (avgCr !== null) {
648
651
  // Label in orange to distinguish from Curr. CR; value keeps the
649
652
  // original health color (single shared max → green/red, mixed or
@@ -32,6 +32,7 @@ const __dirname = path.dirname(__filename);
32
32
  import { loadBotMeta, loadBotSettings, computeBotKey } from '../analysis/bot_key_utils.js';
33
33
  import { PATHS } from '../modules/paths.js';
34
34
  import { normalizePoolId, resolveAsset, findPoolByAssets } from '../market_adapter/utils/chain.js';
35
+ import { normalizeAssetSymbol, splitPairTarget } from '../modules/utils/asset_symbols.js';
35
36
  import { fetchCandlesSequentially, outputPath } from '../market_adapter/inputs/fetch_lp_data.js';
36
37
  import { fetchMarketCandlesSequentially } from '../market_adapter/inputs/fetch_book_data.js';
37
38
  import { fetchFeedCandlesSequentially } from '../market_adapter/inputs/kibana_feed_source.js';
@@ -73,6 +74,7 @@ function printUsage(cmd = 'tv') {
73
74
  console.log(' <bot> Bot name or key from profiles/bots.json');
74
75
  console.log(' <pool-id> Liquidity pool id, e.g. 133 or 1.19.133 (always pool candles)');
75
76
  console.log(' AssetA/AssetB Pair symbols, e.g. TOKENA/TOKENB (pool-first, orderbook fallback)');
77
+ console.log(' Case-insensitive: assetA/assetB is uppercased before it reaches the chain');
76
78
  console.log(' MPA pairs (e.g. BTS/HONEST.USD) can chart price-feed history via --feed');
77
79
  console.log('');
78
80
  console.log('Options:');
@@ -87,6 +89,9 @@ async function resolveMpaBacking(mpaSymbol, bitsharesClient) {
87
89
  const db = bitsharesClient.BitShares?.db;
88
90
  if (!db || typeof db.lookup_asset_symbols !== 'function')
89
91
  return null;
92
+ // Canonical UPPERCASE symbol for the chain call and for every message
93
+ // below, so a lowercase assetA/assetB pair is reported UPPERCASE.
94
+ mpaSymbol = normalizeAssetSymbol(mpaSymbol);
90
95
  let mpa = null;
91
96
  try {
92
97
  const found = await db.lookup_asset_symbols([mpaSymbol]);
@@ -325,7 +330,10 @@ async function run(cmd) {
325
330
  const botHit = findBotByTarget(target);
326
331
  const poolTarget = !botHit && isPoolIdTarget(target);
327
332
  const pairTarget = !botHit && !poolTarget && target.includes('/');
328
- const pairParts = pairTarget ? target.split('/').map((s) => s.trim()).filter(Boolean) : [];
333
+ // A pair target may be typed in any case ("assetb/asseta"); the legs are
334
+ // canonicalized here so the chain call, the cache keys, the chart title and
335
+ // the exported HTML all speak the same UPPERCASE symbols.
336
+ const pairParts = pairTarget ? splitPairTarget(target) : [];
329
337
  if (!botHit && !poolTarget && !pairTarget) {
330
338
  const settings = loadBotSettings();
331
339
  const entries = Array.isArray(settings?.bots) ? settings.bots : [];
@@ -333,7 +341,7 @@ async function run(cmd) {
333
341
  throw new Error(`Unknown target "${target}". Use a bot name/key${keys.length ? ` (${keys.slice(0, 8).join(', ')}${keys.length > 8 ? ', …' : ''})` : ''}, a pool id (e.g. 133), or AssetA/AssetB.`);
334
342
  }
335
343
  if (pairTarget && pairParts.length !== 2)
336
- throw new Error(`Invalid pair "${target}". Use AssetA/AssetB, e.g. TOKENA/TOKENB`);
344
+ throw new Error(`Invalid pair "${target}". Use AssetA/AssetB, e.g. TOKENA/TOKENB (case is normalized to uppercase)`);
337
345
  const bitsharesClient = await import('../modules/bitshares_client.js');
338
346
  const { waitForConnected } = bitsharesClient;
339
347
  await waitForConnected();
@@ -349,8 +357,8 @@ async function run(cmd) {
349
357
  if (botHit) {
350
358
  botKey = botHit.botKey;
351
359
  botMeta = botHit.meta;
352
- const symA = botMeta.assetA;
353
- const symB = botMeta.assetB;
360
+ const symA = normalizeAssetSymbol(botMeta.assetA);
361
+ const symB = normalizeAssetSymbol(botMeta.assetB);
354
362
  if (!symA || !symB)
355
363
  throw new Error(`Bot '${target}' has no assetA/assetB pair in profiles/bots.json`);
356
364
  const [metaA, metaB] = await Promise.all([resolveAsset(symA, bitsharesClient), resolveAsset(symB, bitsharesClient)]);
@@ -176,6 +176,14 @@ const TESTS = [
176
176
  expectFail: false,
177
177
  externalizeNodeBuiltins: true,
178
178
  },
179
+ {
180
+ // The canonical AMA-slope estimator; guards the browser-safe surface now
181
+ // that this module imports modules/constants.ts.
182
+ label: 'market_adapter/core/strategies/dynamic_weight_series.ts (browser-safe)',
183
+ entry: 'market_adapter/core/strategies/dynamic_weight_series.ts',
184
+ expectFail: false,
185
+ externalizeNodeBuiltins: true,
186
+ },
179
187
  {
180
188
  label: 'modules/bitshares-native/serial/serializer.ts (browser-safe)',
181
189
  entry: 'modules/bitshares-native/serial/serializer.ts',
@@ -1,7 +1,7 @@
1
1
  # DEXBot vs DEXBot2 — Detailed Comparison Report
2
2
 
3
3
  > **Date:** 2026-09-02 *(metrics refreshed against local source trees)*
4
- > **Scope:** Full architectural, functional, and operational comparison between the original [DEXBot](https://github.com/Codaone/DEXBot) (Python, v1.0.0) and DEXBot2 (TypeScript, v1.6.9).
4
+ > **Scope:** Full architectural, functional, and operational comparison between the original [DEXBot](https://github.com/Codaone/DEXBot) (Python, v1.0.0) and DEXBot2 (TypeScript, v1.6.10).
5
5
  > **Audience:** Developers, contributors, and operators evaluating or migrating between the two projects.
6
6
 
7
7
  ---
@@ -36,7 +36,7 @@
36
36
 
37
37
  | Attribute | DEXBot (original) | DEXBot2 |
38
38
  |---|---|---|
39
- | **Release Track** | 1.0.0 | v1.6.9 |
39
+ | **Release Track** | 1.0.0 | v1.6.10 |
40
40
  | **Language** | Python 3.6+ | TypeScript 5.x |
41
41
  | **Status** | Released 1.0.0, unmaintained | Active development |
42
42
  | **Last Repo Activity** | May 23, 2020 | 2026-09-02 |
@@ -776,7 +776,7 @@ Where:
776
776
 
777
777
  | Metric | DEXBot | DEXBot2 |
778
778
  |---|---|---|
779
- | **Release Track** | 1.0.0 | v1.6.9 |
779
+ | **Release Track** | 1.0.0 | v1.6.10 |
780
780
  | **Active Since** | ~2018 | December 2025 |
781
781
  | **Last Commit** | May 23, 2020 | 2026-09-02 |
782
782
  | **Total Commits** | 2281 | 2,125 (v1.4.25) |
package/docs/EVOLUTION.md CHANGED
@@ -2,14 +2,14 @@
2
2
 
3
3
  ## Executive Summary
4
4
 
5
- DEXBot2 is a sophisticated decentralized exchange trading bot for the BitShares blockchain. This report documents the complete evolution of the project from its inception in December 2025 through the current 1.6.9 release.
5
+ DEXBot2 is a sophisticated decentralized exchange trading bot for the BitShares blockchain. This report documents the complete evolution of the project from its inception in December 2025 through the current 1.6.10 release.
6
6
 
7
7
  ### Key Milestones
8
8
  - **Project Inception**: December 2, 2025
9
- - **Growth Phase**: 2,306 commits over ~9 active months
9
+ - **Growth Phase**: 2,315 commits over ~9 active months
10
10
  - **Code Maturity**: Evolution from basic utilities to a ~100,000+ LoC intelligent TypeScript system
11
11
  - **Stability**: Progression from manual testing to a suite of 305 automated test files
12
- - **Releases**: 141 version entries in the changelog (v0.1.0 to v1.6.9)
12
+ - **Releases**: 142 version entries in the changelog (v0.1.0 to v1.6.10)
13
13
 
14
14
  > **Post-1.0.0 "why":** the thematic story behind the hardening releases — root cause, recurring
15
15
  > bug families, and lessons — lives in
@@ -149,7 +149,7 @@ Evolved from a basic README to a comprehensive framework (50+ docs entries, 80%+
149
149
 
150
150
  ## Version History
151
151
 
152
- Compact, era-level view; commit counts are `git rev-list --count <tag>..<tag>` over the current history (2026-09-30), so the column sums to 2,200 — the 106 commits before the `v0.1.0` tag are not attributed to an era (2,200 + 106 = 2,306). Per-release detail lives in [CHANGELOG.md](../CHANGELOG.md); the thematic post-1.0.0 story in [ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md](ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md).
152
+ Compact, era-level view; commit counts are `git rev-list --count <tag>..<tag>` over the current history (2026-10-01), so the column sums to 2,209 — the 106 commits before the `v0.1.0` tag are not attributed to an era (2,209 + 106 = 2,315). Per-release detail lives in [CHANGELOG.md](../CHANGELOG.md); the thematic post-1.0.0 story in [ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md](ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md).
153
153
 
154
154
  | Era | Commits | Theme |
155
155
  |-----|--------:|-------|
@@ -165,13 +165,14 @@ Compact, era-level view; commit counts are `git rev-list --count <tag>..<tag>` o
165
165
  | v1.6.4 → v1.6.5 | 16 | Editor-managed whitelist flags, centralized bot defaults/settings, log-symmetric range tilt, AMA gridPrice normalization, Pool/Health cues, AMA-slope Δ knob, dynamic-weight CLI, update self-heal, RMS log tagging |
166
166
  | v1.6.5 → v1.6.6 | 13 | Stale-cancellation guard hardening, editor/CLI realignment, poolRef aliases + startPrice priority, legacy SMA/MACD/RSI analyzer archived, run-relative candle-cache migration dropped, dist-freshness exclude fix |
167
167
  | v1.6.6 → v1.6.7 | 11 | Session/fill-channel recovery, clean-process ecosystem regen, onboarding redirect and key-manager link fixes, LAST-FILL-GUARD pivot persistence |
168
- | v1.6.7 → v1.6.8 | 12 | Correction-drain budget + broadcast-deferral bounds, PM2 log capture + rotation, passive version notice, genesis-ladder refusal, reserve window exclusion, legacy tolerance-matcher removal, npm-tarball trim, TV grid-reset replay, bounded Kibana tail refresh, 1.4x range-threshold widening |
168
+ | v1.6.7 → v1.6.8 | 14 | Correction-drain budget + broadcast-deferral bounds, PM2 log capture + rotation, passive version notice, genesis-ladder refusal, reserve window exclusion, legacy tolerance-matcher removal, npm-tarball trim, TV grid-reset replay, bounded Kibana tail refresh, 1.4x range-threshold widening |
169
169
  | v1.6.8 → v1.6.9 | 6 | Market-adapter cycle-CPU cuts, candle-boundary off-hour idle, spread-correction spread-tightening guard |
170
+ | v1.6.9 → v1.6.10 | 7 | Huber-robust AMA slope, asset-pair uppercase canonicalization, TradingView indicator ownership (auto opt-in, span bounds) and chart-view preservation |
170
171
 
171
172
  ---
172
173
 
173
174
  **Report Originally Generated**: February 19, 2026
174
- **Last Updated**: September 30, 2026
175
- **Total Commits**: 2,306
176
- **Date Range**: December 2, 2025 – September 30, 2026
175
+ **Last Updated**: October 1, 2026
176
+ **Total Commits**: 2,315
177
+ **Date Range**: December 2, 2025 – October 1, 2026
177
178
  **Repository**: DEXBot2 (BitShares DEX Trading Bot)
@@ -801,4 +801,4 @@ To prevent "Time-of-Check to Time-of-Use" errors:
801
801
  **TOCTOU protection in `processFillAccounting`.** `_buildBtsDeferredRefundAdjustment` reads `btsFeeState` from `mgr.orders` while the order lock is held — the lock is acquired before accounting runs, and the POST-RESET and BOOTSTRAP tracked-fill accounting paths follow the same locking pattern.
802
802
 
803
803
  ---
804
- *Technical Reference for DEXBot2 v1.6.9 release*
804
+ *Technical Reference for DEXBot2 v1.6.10 release*
@@ -283,9 +283,28 @@ The snapshot fields involved are:
283
283
  `profiles/general.settings.json` and editable via `dexbot bot` → `1) Grid
284
284
  Drift` (`AMA-Slope Δ`). An explicit `amaSlopeDeltaThresholdPercent` in
285
285
  `profiles/market_adapter_settings.json` bypasses the factor and is used
286
- directly as an average percent-per-bar threshold.
287
-
288
- AMA slope values are stored and compared as average percent per bar. Older
286
+ directly as a percent-per-bar threshold (the same unit as the slope value
287
+ described below — no averaging is implied by the unit).
288
+
289
+ AMA slope values are stored and compared in percent per bar. The value itself
290
+ is a **Huber-robust linear regression of `ln(AMA)` over the lookback window**
291
+ (`computeHuberWindowSlopePct` in
292
+ `core/strategies/dynamic_weight_series.ts`; its tuning lives in
293
+ `MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_HUBER`) — a smooth, robust fit whose influence
294
+ function is bounded, so one outlier bar cannot drag it, which is what a plain
295
+ mean (and the older two-point endpoint difference it is equivalent to) would do.
296
+ Because the fit reports the log-return, a reading is ~`ln(1+r)` rather than the
297
+ arithmetic `r`: negligible at the sub-0.1 %/bar magnitudes the defaults use, but
298
+ ~3% lower at a 6%/bar saturation (`ln(1.06)*100 = 5.83`). A pre-existing user
299
+ override of `amaSlope.maxSlopePct` or `neutralZonePct` was tuned against the
300
+ arithmetic reading, so treat a saturated override as a hair tighter than before.
301
+
302
+ Changing the estimator changes the stored value: after a deploy, the first
303
+ cycle compares a new-algorithm reading against the baseline persisted by the
304
+ previous one (`botState.gridRangeScalingAmaSlope`). The magnitudes agree
305
+ closely, so the delta stays under the reset gate on ~98% of bars — a rare,
306
+ single extra recenter for whitelisted bots. No version marker is persisted to
307
+ suppress it. Older
289
308
  settings that used cumulative percent over the full lookback can either be
290
309
  divided by `amaSlope.lookbackBars`, or marked with
291
310
  `"amaSlopePercentMode": "window"` in `profiles/market_adapter_settings.json`
package/docs/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  This directory contains the comprehensive technical documentation for the DEXBot2 trading bot. It is designed to guide developers from high-level architecture down to the nuances of fund accounting and state management.
4
4
 
5
- **Version context:** v1.6.9 (released).
5
+ **Version context:** v1.6.10 (released).
6
6
 
7
7
  ---
8
8
 
@@ -688,7 +688,7 @@ This uses `dynamicWeights.trend`, `dynamicWeights.slopeOffset`, and
688
688
  weight shift. The whitelist flag is `asymmetricBounds`.
689
689
 
690
690
  ```
691
- slope = average AMA slope percent per bar over the lookback window
691
+ slope = Huber-robust regression of ln(AMA) over the lookback window, in percent per bar
692
692
  slopeOffset = slope normalized to the configured dynamic-weight slope cap
693
693
  asymmetry = min(|slopeOffset| / maxSlopeOffset, 1) × maxAsymmetryFactor
694
694
 
@@ -805,7 +805,7 @@ Main override knobs live in `profiles/market_adapter_settings.json`:
805
805
  | `alpha` | AMA vs Kalman blend |
806
806
  | `dw` | Kalman displacement weighting |
807
807
  | `gain` | Output amplitude |
808
- | `amaSlopePercentMode` | Slope override units: `perBar` for average percent per bar, or `window`/unset for legacy cumulative percent over the lookback |
808
+ | `amaSlopePercentMode` | Slope override units: `perBar` for percent per bar, or `window`/unset for legacy cumulative percent over the lookback |
809
809
  | `amaSlope.lookbackBars` | AMA slope lookback; slope is averaged per bar over this window |
810
810
  | `amaSlope.neutralZonePct` | Dead band around flat average AMA slope |
811
811
  | `amaSlope.maxSlopePct` | Average AMA slope saturation |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dexbot",
3
- "version": "1.6.9",
3
+ "version": "1.6.10",
4
4
  "description": "The first open source trading bot with zero runtime dependencies and a fully adaptive market making strategy.",
5
5
  "main": "dist/modules/dexbot_class.js",
6
6
  "exports": {