dexbot 1.6.4 → 1.6.6

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 (240) hide show
  1. package/CHANGELOG.md +75 -3
  2. package/README.md +109 -40
  3. package/analysis/README.md +19 -17
  4. package/analysis/account_resolver.ts +1 -11
  5. package/analysis/analyze_dynamic_weight.ts +9 -3
  6. package/analysis/bot_usage/kibana_bot_queries.ts +1 -1
  7. package/analysis/chain_pool.ts +1 -1
  8. package/analysis/fills_source.ts +0 -6
  9. package/analysis/grid_correction_check.ts +20 -26
  10. package/analysis/resolve_source.ts +1 -1
  11. package/analysis/trade_profitability.ts +2 -5
  12. package/analysis/tradingview/analyze_tradingview.ts +5 -0
  13. package/analysis/tradingview/tradingview_uplot_chart_generator.ts +2 -2
  14. package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +35 -2
  15. package/analysis/trend_detection/README.md +1 -3
  16. package/analysis/trend_detection/dynamic_weight_chart_generator.ts +82 -10
  17. package/analysis/trend_detection/package.json +1 -1
  18. package/claw/modules/dexbot_profiles.ts +4 -3
  19. package/claw/package.json +1 -1
  20. package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
  21. package/claw/runtimes/openclaw-plugin/package.json +1 -1
  22. package/claw/tests/test_claw_mcp_transport.ts +2 -2
  23. package/claw/tests/test_dexbot_profiles.ts +18 -1
  24. package/dist/analysis/account_resolver.d.ts +1 -4
  25. package/dist/analysis/account_resolver.d.ts.map +1 -1
  26. package/dist/analysis/account_resolver.js +1 -1
  27. package/dist/analysis/account_resolver.js.map +1 -1
  28. package/dist/analysis/analyze_dynamic_weight.js +9 -3
  29. package/dist/analysis/analyze_dynamic_weight.js.map +1 -1
  30. package/dist/analysis/bot_usage/kibana_bot_queries.d.ts +1 -2
  31. package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +1 -1
  32. package/dist/analysis/bot_usage/kibana_bot_queries.js +1 -1
  33. package/dist/analysis/bot_usage/kibana_bot_queries.js.map +1 -1
  34. package/dist/analysis/chain_pool.d.ts +1 -3
  35. package/dist/analysis/chain_pool.d.ts.map +1 -1
  36. package/dist/analysis/chain_pool.js +1 -1
  37. package/dist/analysis/chain_pool.js.map +1 -1
  38. package/dist/analysis/fills_source.d.ts +1 -51
  39. package/dist/analysis/fills_source.d.ts.map +1 -1
  40. package/dist/analysis/fills_source.js +1 -1
  41. package/dist/analysis/fills_source.js.map +1 -1
  42. package/dist/analysis/grid_correction_check.d.ts +2 -3
  43. package/dist/analysis/grid_correction_check.d.ts.map +1 -1
  44. package/dist/analysis/grid_correction_check.js +18 -26
  45. package/dist/analysis/grid_correction_check.js.map +1 -1
  46. package/dist/analysis/resolve_source.d.ts +1 -1
  47. package/dist/analysis/resolve_source.d.ts.map +1 -1
  48. package/dist/analysis/trade_profitability.d.ts.map +1 -1
  49. package/dist/analysis/trade_profitability.js +2 -7
  50. package/dist/analysis/trade_profitability.js.map +1 -1
  51. package/dist/analysis/tradingview/analyze_tradingview.d.ts.map +1 -1
  52. package/dist/analysis/tradingview/analyze_tradingview.js +5 -0
  53. package/dist/analysis/tradingview/analyze_tradingview.js.map +1 -1
  54. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +2 -2
  55. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +1 -1
  56. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +82 -10
  57. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +1 -1
  58. package/dist/dexbot.d.ts.map +1 -1
  59. package/dist/dexbot.js +85 -140
  60. package/dist/dexbot.js.map +1 -1
  61. package/dist/market_adapter/core/asymmetric_bounds.d.ts +2 -2
  62. package/dist/market_adapter/core/asymmetric_bounds.d.ts.map +1 -1
  63. package/dist/market_adapter/core/asymmetric_bounds.js +15 -12
  64. package/dist/market_adapter/core/asymmetric_bounds.js.map +1 -1
  65. package/dist/market_adapter/core/kibana_candles.d.ts +1 -15
  66. package/dist/market_adapter/core/kibana_candles.d.ts.map +1 -1
  67. package/dist/market_adapter/core/kibana_candles.js +1 -1
  68. package/dist/market_adapter/core/kibana_candles.js.map +1 -1
  69. package/dist/market_adapter/inputs/fetch_lp_data.d.ts +1 -35
  70. package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -1
  71. package/dist/market_adapter/inputs/fetch_lp_data.js +10 -54
  72. package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -1
  73. package/dist/market_adapter/inputs/kibana_feed_source.d.ts +1 -8
  74. package/dist/market_adapter/inputs/kibana_feed_source.d.ts.map +1 -1
  75. package/dist/market_adapter/inputs/kibana_feed_source.js +1 -1
  76. package/dist/market_adapter/inputs/kibana_feed_source.js.map +1 -1
  77. package/dist/market_adapter/inputs/window_cache.d.ts +2 -63
  78. package/dist/market_adapter/inputs/window_cache.d.ts.map +1 -1
  79. package/dist/market_adapter/inputs/window_cache.js +22 -102
  80. package/dist/market_adapter/inputs/window_cache.js.map +1 -1
  81. package/dist/market_adapter/interval_utils.d.ts +1 -1
  82. package/dist/market_adapter/interval_utils.js +1 -1
  83. package/dist/modules/account_bots.d.ts +70 -6
  84. package/dist/modules/account_bots.d.ts.map +1 -1
  85. package/dist/modules/account_bots.js +353 -149
  86. package/dist/modules/account_bots.js.map +1 -1
  87. package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +1 -1
  88. package/dist/modules/bitshares-native/crypto/ecc.browser.js +0 -31
  89. package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +1 -1
  90. package/dist/modules/bot_defaults.d.ts +98 -0
  91. package/dist/modules/bot_defaults.d.ts.map +1 -0
  92. package/dist/modules/bot_defaults.js +169 -0
  93. package/dist/modules/bot_defaults.js.map +1 -0
  94. package/dist/modules/bot_settings.d.ts.map +1 -1
  95. package/dist/modules/bot_settings.js +4 -1
  96. package/dist/modules/bot_settings.js.map +1 -1
  97. package/dist/modules/config.d.ts +1 -0
  98. package/dist/modules/config.d.ts.map +1 -1
  99. package/dist/modules/config.js +1 -0
  100. package/dist/modules/config.js.map +1 -1
  101. package/dist/modules/constants.d.ts +11 -2
  102. package/dist/modules/constants.d.ts.map +1 -1
  103. package/dist/modules/constants.js +40 -27
  104. package/dist/modules/constants.js.map +1 -1
  105. package/dist/modules/credit_runtime.d.ts +0 -2
  106. package/dist/modules/credit_runtime.d.ts.map +1 -1
  107. package/dist/modules/credit_runtime.js +1 -10
  108. package/dist/modules/credit_runtime.js.map +1 -1
  109. package/dist/modules/dexbot_class.d.ts +13 -10
  110. package/dist/modules/dexbot_class.d.ts.map +1 -1
  111. package/dist/modules/dexbot_class.js +0 -9
  112. package/dist/modules/dexbot_class.js.map +1 -1
  113. package/dist/modules/dexbot_cow_runtime.d.ts +13 -0
  114. package/dist/modules/dexbot_cow_runtime.d.ts.map +1 -1
  115. package/dist/modules/dexbot_cow_runtime.js +13 -1
  116. package/dist/modules/dexbot_cow_runtime.js.map +1 -1
  117. package/dist/modules/dexbot_maintenance_runtime.d.ts +1 -1
  118. package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
  119. package/dist/modules/dexbot_maintenance_runtime.js +9 -4
  120. package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
  121. package/dist/modules/launcher/adapter_requirement.js +1 -1
  122. package/dist/modules/launcher/launch_modes.d.ts +17 -1
  123. package/dist/modules/launcher/launch_modes.d.ts.map +1 -1
  124. package/dist/modules/launcher/launch_modes.js +18 -1
  125. package/dist/modules/launcher/launch_modes.js.map +1 -1
  126. package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -1
  127. package/dist/modules/launcher/monolithic_runtime.js +8 -1
  128. package/dist/modules/launcher/monolithic_runtime.js.map +1 -1
  129. package/dist/modules/market_adapter_whitelist.d.ts +40 -1
  130. package/dist/modules/market_adapter_whitelist.d.ts.map +1 -1
  131. package/dist/modules/market_adapter_whitelist.js +161 -11
  132. package/dist/modules/market_adapter_whitelist.js.map +1 -1
  133. package/dist/modules/order/accounting.d.ts +4 -18
  134. package/dist/modules/order/accounting.d.ts.map +1 -1
  135. package/dist/modules/order/accounting.js +4 -34
  136. package/dist/modules/order/accounting.js.map +1 -1
  137. package/dist/modules/order/export.d.ts +9 -12
  138. package/dist/modules/order/export.d.ts.map +1 -1
  139. package/dist/modules/order/export.js +9 -12
  140. package/dist/modules/order/export.js.map +1 -1
  141. package/dist/modules/order/grid.d.ts +44 -40
  142. package/dist/modules/order/grid.d.ts.map +1 -1
  143. package/dist/modules/order/grid.js +66 -48
  144. package/dist/modules/order/grid.js.map +1 -1
  145. package/dist/modules/order/grid_reconcile.d.ts.map +1 -1
  146. package/dist/modules/order/grid_reconcile.js +111 -20
  147. package/dist/modules/order/grid_reconcile.js.map +1 -1
  148. package/dist/modules/order/grid_reconcile_internal.d.ts +5 -3
  149. package/dist/modules/order/grid_reconcile_internal.d.ts.map +1 -1
  150. package/dist/modules/order/grid_reconcile_internal.js +18 -3
  151. package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
  152. package/dist/modules/order/manager.d.ts +0 -8
  153. package/dist/modules/order/manager.d.ts.map +1 -1
  154. package/dist/modules/order/manager.js +3 -12
  155. package/dist/modules/order/manager.js.map +1 -1
  156. package/dist/modules/order/utils/order.d.ts +22 -7
  157. package/dist/modules/order/utils/order.d.ts.map +1 -1
  158. package/dist/modules/order/utils/order.js +103 -21
  159. package/dist/modules/order/utils/order.js.map +1 -1
  160. package/dist/modules/order/utils/system.d.ts +5 -1
  161. package/dist/modules/order/utils/system.d.ts.map +1 -1
  162. package/dist/modules/order/utils/system.js +5 -2
  163. package/dist/modules/order/utils/system.js.map +1 -1
  164. package/dist/modules/order/utils/withPoolRef.d.ts +12 -0
  165. package/dist/modules/order/utils/withPoolRef.d.ts.map +1 -1
  166. package/dist/modules/order/utils/withPoolRef.js +17 -0
  167. package/dist/modules/order/utils/withPoolRef.js.map +1 -1
  168. package/dist/modules/order/working_grid.d.ts +8 -13
  169. package/dist/modules/order/working_grid.d.ts.map +1 -1
  170. package/dist/modules/order/working_grid.js +8 -29
  171. package/dist/modules/order/working_grid.js.map +1 -1
  172. package/dist/modules/settings_merge.d.ts +10 -1
  173. package/dist/modules/settings_merge.d.ts.map +1 -1
  174. package/dist/modules/settings_merge.js +27 -17
  175. package/dist/modules/settings_merge.js.map +1 -1
  176. package/dist/modules/validate_profiles.d.ts.map +1 -1
  177. package/dist/modules/validate_profiles.js +4 -3
  178. package/dist/modules/validate_profiles.js.map +1 -1
  179. package/dist/scripts/chart_command.d.ts +48 -0
  180. package/dist/scripts/chart_command.d.ts.map +1 -0
  181. package/dist/scripts/chart_command.js +504 -0
  182. package/dist/scripts/chart_command.js.map +1 -0
  183. package/dist/scripts/dw.d.ts +3 -0
  184. package/dist/scripts/dw.d.ts.map +1 -0
  185. package/dist/scripts/dw.js +30 -0
  186. package/dist/scripts/dw.js.map +1 -0
  187. package/dist/scripts/sync-version.js +0 -22
  188. package/dist/scripts/sync-version.js.map +1 -1
  189. package/dist/scripts/tv.d.ts +1 -31
  190. package/dist/scripts/tv.d.ts.map +1 -1
  191. package/dist/scripts/tv.js +10 -463
  192. package/dist/scripts/tv.js.map +1 -1
  193. package/dist/scripts/update.js +99 -62
  194. package/dist/scripts/update.js.map +1 -1
  195. package/dist/scripts/update_dist_freshness.d.ts +58 -0
  196. package/dist/scripts/update_dist_freshness.d.ts.map +1 -0
  197. package/dist/scripts/update_dist_freshness.js +144 -0
  198. package/dist/scripts/update_dist_freshness.js.map +1 -0
  199. package/dist/unlock.js +1 -1
  200. package/dist/unlock.js.map +1 -1
  201. package/docs/BITSHARES_ONBOARDING.md +16 -10
  202. package/docs/COW_INVARIANTS.md +1 -0
  203. package/docs/DEXBOT_COMPARISON.md +11 -11
  204. package/docs/EVOLUTION.md +9 -7
  205. package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +4 -4
  206. package/docs/GRID_PRICE_INVARIANT.md +518 -0
  207. package/docs/GRID_RECALCULATION.md +20 -24
  208. package/docs/GRID_RECONCILE.md +62 -41
  209. package/docs/LOGGING.md +1 -0
  210. package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +556 -0
  211. package/docs/README.md +18 -18
  212. package/docs/WORKFLOW.md +13 -8
  213. package/docs/architecture.md +42 -40
  214. package/docs/developer_guide.md +5 -8
  215. package/market_adapter/README.md +45 -65
  216. package/modules/README.md +3 -2
  217. package/package.json +7 -4
  218. package/scripts/README.md +18 -34
  219. package/scripts/reset-settings.sh +1 -1
  220. package/analysis/ama_fitting/package.json +0 -12
  221. package/analysis/analyze_derivatives.ts +0 -320
  222. package/analysis/derivative_chart_generator.ts +0 -874
  223. package/analysis/trend_detection/SIGNAL_DOCUMENTATION.md +0 -403
  224. package/analysis/trend_detection/derivative_analyzer.ts +0 -1059
  225. package/dist/analysis/analyze_derivatives.d.ts +0 -68
  226. package/dist/analysis/analyze_derivatives.d.ts.map +0 -1
  227. package/dist/analysis/analyze_derivatives.js +0 -287
  228. package/dist/analysis/analyze_derivatives.js.map +0 -1
  229. package/dist/analysis/derivative_chart_generator.d.ts +0 -12
  230. package/dist/analysis/derivative_chart_generator.d.ts.map +0 -1
  231. package/dist/analysis/derivative_chart_generator.js +0 -891
  232. package/dist/analysis/derivative_chart_generator.js.map +0 -1
  233. package/dist/analysis/trend_detection/derivative_analyzer.d.ts +0 -248
  234. package/dist/analysis/trend_detection/derivative_analyzer.d.ts.map +0 -1
  235. package/dist/analysis/trend_detection/derivative_analyzer.js +0 -910
  236. package/dist/analysis/trend_detection/derivative_analyzer.js.map +0 -1
  237. package/dist/scripts/generate_market_adapter_whitelist.d.ts +0 -15
  238. package/dist/scripts/generate_market_adapter_whitelist.d.ts.map +0 -1
  239. package/dist/scripts/generate_market_adapter_whitelist.js +0 -191
  240. package/dist/scripts/generate_market_adapter_whitelist.js.map +0 -1
@@ -21,13 +21,13 @@ The live signal layer for AMA-priced bots. It reads candles, computes the AMA ce
21
21
 
22
22
  | If you want to… | Read this | Key command |
23
23
  |-----------------|-----------|-------------|
24
- | Enable AMA pricing for a bot | [Quick Start](#quick-start) | `dexbot white` |
24
+ | Enable AMA pricing for a bot | [Quick Start](#quick-start) | `dexbot bot` → `2) Modify bot` → `6) Adapter` |
25
25
  | Change how often the grid rebuilds | [Trigger Threshold](#trigger-threshold) | edit `AMA_DELTA_THRESHOLD_PERCENT` |
26
- | Tune buy/sell weight bias | [Asymmetric Weight Shift](#asymmetric-weight-shift) | whitelist `dynamicWeight: true` |
27
- | Widen/tighten grid bounds by trend | [Grid Range Scaling](#grid-range-scaling) | whitelist `asymmetricBounds: true` |
26
+ | Tune buy/sell weight bias | [Asymmetric Weight Shift](#asymmetric-weight-shift) | `dexbot bot` → `2) Modify bot` → `6) Adapter` → Weight |
27
+ | Widen/tighten grid bounds by trend | [Grid Range Scaling](#grid-range-scaling) | `dexbot bot` → `2) Modify bot` → `6) Adapter` → Range |
28
28
  | Override settings for one pair or bot | [Settings and Overrides](#settings-and-overrides) | edit `profiles/market_adapter_settings.json` |
29
29
  | Run the adapter standalone or test dry-run | [Live Writes and Dry-Run](#live-writes-and-dry-run) | `node dist/market_adapter/market_adapter.js --dryRun` |
30
- | Debug a bot not being processed | [Troubleshooting](#troubleshooting) | `dexbot white` |
30
+ | Debug a bot not being processed | [Troubleshooting](#troubleshooting) | `dexbot bot` → `2) Modify bot` → `6) Adapter` flags |
31
31
  | Understand the signal pipeline or module layout | [Technical Reference](#technical-reference) | — |
32
32
 
33
33
  ## Big Picture
@@ -50,9 +50,10 @@ applies the symmetric penalty.
50
50
 
51
51
  ### 1. Enable AMA
52
52
 
53
- Set `gridPrice` to `ama`, `ama1`, `ama2`, `ama3`, or `ama4` in
54
- `profiles/bots.json` or through `dexbot bot`. Use `ama` for the pair's
55
- default preset.
53
+ New bots default to `gridPrice: "ama3"`. Change it in `profiles/bots.json`
54
+ or through `dexbot bot` to `ama`, `ama1`, `ama2`, `ama3`, or `ama4`. `ama1`
55
+ reacts fastest, `ama4` is the slowest and steadiest (higher numbers smooth
56
+ more), and `ama` uses the pair's default preset.
56
57
 
57
58
  `startPrice` selects the candle source:
58
59
 
@@ -64,47 +65,23 @@ default preset.
64
65
 
65
66
  When fetching candles (`pool` or `book`), the adapter requires a full historical window. The oldest `erPeriod` candles are used for an initial SMA (Simple Moving Average) warmup phase to seed the AMA and establish the first Efficiency Ratio (ER) calculation. See [AMA Warmup Window](#ama-warmup-window--why-candle-length-matters) for technical details.
66
67
 
67
- ### 2. Whitelist Live Writes
68
+ ### 2. Enable Live Writes
68
69
 
69
- Generate the whitelist from AMA-enabled bots. Without a whitelist entry, the
70
- adapter still computes state, but live grid snapshots and recalc triggers stay
71
- in dry-run mode.
70
+ Open the bot editor — `dexbot bot` → `2) Modify bot` → pick the bot →
71
+ `6) Adapter` — and set the three per-bot flags:
72
72
 
73
- ```bash
74
- dexbot white
75
- ```
76
-
77
- This writes `profiles/market_adapter_whitelist.json`, where each bot's AMA,
78
- dynamic-weight, and range-scaling flags can be inspected or adjusted.
79
-
80
- By default, newly generated entries whitelist AMA pricing only, keeping both
81
- dynamic weights and range scaling (asymmetric bounds) disabled. To opt newly
82
- generated entries into dynamic weights:
83
-
84
- ```bash
85
- dexbot white --dynamic-weight
86
- ```
87
-
88
- To opt newly generated entries into range scaling:
73
+ | Flag | Whitelist key | Effect |
74
+ |------|---------------|--------|
75
+ | **Price** | `ama` | Allows live `dynamicgrid.json` and recalc-trigger writes. Without it the adapter still computes state, but live output stays in dry-run. |
76
+ | **Weight** | `dynamicWeight` | Opt-in dynamic buy/sell weights. |
77
+ | **Range** | `asymmetricBounds` | Opt-in AMA-slope range scaling. |
89
78
 
90
- ```bash
91
- dexbot white --asymmetric-bounds
92
- ```
93
-
94
- To overwrite an existing entry (existing entries are otherwise preserved):
95
-
96
- ```bash
97
- dexbot white --dynamic-weight --bot <botKey>
98
- dexbot white --asymmetric-bounds --bot <botKey>
99
- ```
100
-
101
- `--bot` implies overwrite for that key only; without it, `dexbot white` only adds missing bots.
102
-
103
- Remove stale whitelist entries (bots no longer in `bots.json`):
104
-
105
- ```bash
106
- dexbot white --prune
107
- ```
79
+ The flags are stored per bot in `profiles/market_adapter_whitelist.json`;
80
+ re-open the section any time to inspect or change them. Boolean prompts
81
+ accept `y`/`yes`/`true` and `n`/`no`/`false`; Enter keeps the current value.
82
+ Renaming a bot carries its flags to the new key, deleting a bot removes its
83
+ entry, and all-off flags are saved as an explicit `false` entry so the flags
84
+ never silently fall back to defaults.
108
85
 
109
86
  ### 3. Start DEXBot2
110
87
 
@@ -156,10 +133,8 @@ whitelist gate:
156
133
 
157
134
  This is separate from dynamic buy/sell weighting. Both grid-range effects are
158
135
  enabled only when `asymmetricBounds: true` is set in
159
- `profiles/market_adapter_whitelist.json`. Range scaling is opt-in: `dexbot white`
160
- generates AMA-only entries by default, so enable it with
161
- `dexbot white --asymmetric-bounds` (new bots) or
162
- `dexbot white --asymmetric-bounds --bot <botKey>` (existing entry).
136
+ `profiles/market_adapter_whitelist.json`. Range scaling is opt-in: enable it
137
+ per bot with `dexbot bot` → `2) Modify bot` → `6) Adapter` → **Range**.
163
138
 
164
139
  Technical formula and tuning details are in
165
140
  [Grid Range Scaling Model](#grid-range-scaling-model).
@@ -334,11 +309,8 @@ Dry-run log lines include `[DRY RUN]` or `[suppressed, dry-run]`.
334
309
 
335
310
  | Task | Command |
336
311
  |------|---------|
337
- | Generate whitelist | `dexbot white` |
338
- | Opt new whitelist entries into dynamic weights | `dexbot white --dynamic-weight` |
339
- | Opt new whitelist entries into range scaling | `dexbot white --asymmetric-bounds` |
340
- | Overwrite existing entry for a specific bot | `dexbot white --dynamic-weight --bot <botKey>` \| `dexbot white --asymmetric-bounds --bot <botKey>` |
341
- | Prune stale whitelist entries (bots removed from bots.json) | `dexbot white --prune` |
312
+ | Enable/inspect Price, Weight, Range for a bot | `dexbot bot` → `2) Modify bot` → `6) Adapter` |
313
+ | Remove a deleted bot's entry | Automatic — `dexbot bot` → `3) Delete bot` also drops its whitelist key |
342
314
  | Probe public CEX availability | `node dist/market_adapter/inputs/fetch_cex_synthetic_data.js --exchange auto --check-only` |
343
315
  | Seed synthetic cross candles | `node dist/market_adapter/inputs/fetch_cex_synthetic_data.js --exchange auto --bot-key <bot-key>` |
344
316
  | Run one adapter cycle | `node dist/market_adapter/market_adapter.js --once` |
@@ -368,7 +340,7 @@ match the bot's eventual `botKey`.
368
340
  ### Bot is not processed
369
341
 
370
342
  - Confirm `gridPrice` is `ama`, `ama1`, `ama2`, `ama3`, or `ama4`.
371
- - Regenerate the whitelist with `dexbot white`.
343
+ - Open `dexbot bot` → `2) Modify bot` → `6) Adapter` and confirm **Price** is `true`.
372
344
  - Confirm the expected `botKey` exists in `profiles/market_adapter_whitelist.json`.
373
345
  - If `startPrice` is numeric, the adapter will not fetch pool/book candles for that bot. Use `startPrice` only for a fixed anchor in that case; `gridPrice` remains a separate grid setting.
374
346
 
@@ -377,7 +349,7 @@ match the bot's eventual `botKey`.
377
349
  - Check `lastDeltaPercent` vs `thresholdPercent`.
378
350
  - Check `staleData` and `staleAgeHours`.
379
351
  - **Confirm the bot is whitelisted.** Non-whitelisted bots only log and do not write triggers.
380
- - Confirm the bot's whitelist entry has `"ama": true`.
352
+ - Confirm the bot's whitelist entry has `"ama": true` (`dexbot bot` → `2) Modify bot` → `6) Adapter` shows it as **Price**).
381
353
  - Run `node dist/market_adapter/market_adapter.js --once --deltaPercent <lower-value>` for a one-cycle threshold test.
382
354
 
383
355
  ### Trigger fires too often
@@ -615,6 +587,9 @@ market_adapter/
615
587
  |-- inputs/
616
588
  | |-- kibana_source.ts Elasticsearch LP data source
617
589
  | |-- fetch_lp_data.ts historical LP candle exporter
590
+ | |-- fetch_book_data.ts order-book candle exporter
591
+ | |-- kibana_feed_source.ts MPA feed candle source
592
+ | |-- window_cache.ts shared month-shard candle cache
618
593
  | `-- fetch_cex_synthetic_data.ts public CEX synthetic-candle seed importer
619
594
  |-- utils/
620
595
  | |-- chain.ts blockchain query helpers
@@ -632,7 +607,9 @@ market_adapter/
632
607
 
633
608
  ### Whitelist Semantics
634
609
 
635
- `profiles/market_adapter_whitelist.json` controls live writes:
610
+ `profiles/market_adapter_whitelist.json` controls live writes. It is edited
611
+ per bot in the bot editor (`dexbot bot` → `2) Modify bot` → `6) Adapter`), which reads and
612
+ writes this same file:
636
613
 
637
614
  ```json
638
615
  {
@@ -667,8 +644,11 @@ AMA slope -> live market/start-price offset, capped at half spread
667
644
 
668
645
  During a grid rebuild, the bot loads the latest dynamic grid snapshot and uses
669
646
  the AMA slope diagnostics to tilt the configured `minPrice` and `maxPrice`
670
- around the AMA center. An uptrend widens the upper bound and tightens the lower
671
- bound; a downtrend widens the lower bound and tightens the upper bound.
647
+ around the AMA center. A reciprocal (log-symmetric) tilt scales both bounds by
648
+ the same factor: an uptrend shifts the whole band up by `1 + asymmetry`, a
649
+ downtrend shifts it down by `1 / (1 + asymmetry)`. The trend side therefore
650
+ extends while the opposite side tightens toward the center, while total log
651
+ width (and slot count) is preserved.
672
652
 
673
653
  The same `asymmetricBounds` whitelist also enables `gridPriceOffsetPct`: a
674
654
  slope-ratio offset applied only to the live `startPrice` used for initial
@@ -686,15 +666,15 @@ slopeOffset = slope normalized to the configured dynamic-weight slope cap
686
666
  asymmetry = min(|slopeOffset| / maxSlopeOffset, 1) × maxAsymmetryFactor
687
667
 
688
668
  Downtrend: minPrice = center / (M × (1 + asymmetry))
689
- maxPrice = center × (M × (1 - asymmetry))
669
+ maxPrice = (center × M) / (1 + asymmetry)
690
670
 
691
671
  Uptrend: maxPrice = center × (M × (1 + asymmetry))
692
- minPrice = center / (M × (1 - asymmetry))
672
+ minPrice = (center / M) × (1 + asymmetry)
693
673
 
694
674
  Neutral: symmetric bounds (asymmetry = 0)
695
675
  ```
696
676
 
697
- `ASYMMETRIC_BOUNDS_MAX_ASYMMETRY_FACTOR` defaults to `0.35`; `0` disables the
677
+ `ASYMMETRIC_BOUNDS_MAX_ASYMMETRY_FACTOR` defaults to `0.333`; `0` disables the
698
678
  tilt. `ASYMMETRIC_BOUNDS_MIN_SCALE_SLOTS` defaults to `10` and sets the minimum
699
679
  number of price levels the *tightened* side of a range-scaled grid must keep
700
680
  between the grid center and its bound (measured in `incrementPercent` steps);
@@ -710,7 +690,7 @@ Both are configurable per bot or per market via
710
690
  {
711
691
  "globals": {
712
692
  "asymmetricBounds": {
713
- "maxAsymmetryFactor": 0.35,
693
+ "maxAsymmetryFactor": 0.333,
714
694
  "minScaleSlots": 10
715
695
  }
716
696
  },
@@ -852,9 +832,9 @@ suppress writes via `unresolved_candle_gaps` until repaired on a future cycle.
852
832
  The adapter prunes old candles to the required AMA window and acts only on
853
833
  closed 1h candles.
854
834
 
855
- #### Shared Chunk Cache and Fetch Robustness
835
+ #### Shared Month-Shard Cache and Fetch Robustness
856
836
 
857
- Pool, book, and feed candle fetches share one cache entry point (`runCachedWindows` in `market_adapter/inputs/window_cache.ts`): candles live in fixed calendar-month shards (`<base>.shard_YYYY-MM.json`, UTC) whose names never shift, so a run loads only the shards overlapping its requested range, queries only genuinely missing buckets plus a bounded 48h tail refresh, and rewrites only shards that gained buckets or query coverage — pure-reuse runs perform zero writes and zero deletes. Shard metas record the ranges actually queried (`meta.queriedRanges`, monotonically unioned). A missing range is pruned only when recorded query coverage genuinely covers it — the absence of local buckets alone never certifies history as empty. Partial windows merge into the run output but are never persisted. Legacy run-relative `*.chunk_*` files are still read: overlapping ones are absorbed into the shards (buckets + coverage) and retired once every bucket provably lives in a shard, while disjoint ones are never loaded and never deleted — narrow runs cannot wipe older history by construction. Every range fetch runs through `fetchRangeWithRetry` (per-range attempts + linear backoff + abort-signal timeout; the LP path keeps a 4-attempt budget), one-shot Kibana queries retry transient errors (3 attempts), paged fetchers cap at `kibanaMaxPages` (500), and bidirectional fetches tolerate a one-direction failure.
837
+ Pool, book, and feed candle fetches share one cache entry point (`runCachedWindows` in `market_adapter/inputs/window_cache.ts`): candles live in fixed calendar-month shards (`<base>.shard_YYYY-MM.json`, UTC) whose names never shift, so a run loads only the shards overlapping its requested range, queries only genuinely missing buckets plus a bounded 48h tail refresh, and rewrites only shards that gained buckets or query coverage — pure-reuse runs perform zero writes and zero deletes. Shard metas record the ranges actually queried (`meta.queriedRanges`, monotonically unioned). A missing range is pruned only when recorded query coverage genuinely covers it — the absence of local buckets alone never certifies history as empty. Partial windows merge into the run output but are never persisted. Stable month shards are the only supported cache format; obsolete run-relative cache files are ignored. Every range fetch runs through `fetchRangeWithRetry` (per-range attempts + linear backoff + abort-signal timeout; the LP path keeps a 4-attempt budget), one-shot Kibana queries retry transient errors (3 attempts), paged fetchers cap at `kibanaMaxPages` (500), and bidirectional fetches tolerate a one-direction failure.
858
838
 
859
839
  #### AMA Warmup Window — Why Candle Length Matters
860
840
 
package/modules/README.md CHANGED
@@ -8,7 +8,7 @@ Everything below covers bot lifecycle, order management, blockchain connectivity
8
8
 
9
9
  If you're new to the codebase, read these files in order (~20 minutes):
10
10
 
11
- 1. **`constants.ts`** — all tuning parameters and defaults live here; gives you a map of the system's knobs
11
+ 1. **`constants.ts`** — all tuning parameters and defaults live here; gives you a map of the system's knobs, and `buildDefaultGeneralSettings()` builds the canonical default `general.settings.json` document (first-run, editor fallback, local-overrides merge all share it)
12
12
  2. **`dexbot_class.ts`** — the top-level orchestrator; shows how bot startup, fill processing, and maintenance connect
13
13
  3. **`order/manager.ts`** — the central controller for the grid; read the constructor and `_applySafeRebalanceCOW()`
14
14
  4. **`order/grid.ts`** — how the geometric grid is generated and sized
@@ -36,6 +36,7 @@ modules/
36
36
  ├── credential_policy.ts signing policy validation
37
37
  ├── credential_session_cache.ts encrypted session cache
38
38
  ├── constants.ts central config and tuning params
39
+ ├── bot_defaults.ts bot defaults seeder (draft/entry/runtime-config modes)
39
40
  ├── config.ts load-time process.env snapshot
40
41
  ├── env.ts isBrowser/hasProcess detection
41
42
  ├── runtime.ts process abstraction singleton
@@ -162,7 +163,7 @@ External consumers — other parts of DEXBot2 interact with modules through thes
162
163
  - **Fund-driven sizing, fill-driven boundary** — available funds set order sizing and budget allocation, not the boundary position; no forced allocations. The boundary moves only through boundary crawl on fills or spread promotion onto orders placed in the same atomic batch.
163
164
  - **Replay-safe accounting** — fill processing in `dexbot_fill_runtime.ts` uses `processed_fill_store.ts` to prevent double-counting. If the bot restarts mid-fill, it can safely replay without creating duplicate orders.
164
165
  - **Daemon-backed signing** — the credential daemon holds decrypted keys; modules never handle raw private keys. If the main bot crashes, keys stay encrypted on disk — only the small daemon process sees them.
165
- - **Fixed-cap batch processing** — fill batches are capped (default 4) to keep blockchain broadcasts predictable. Even if 20 fills arrive at once, they're processed in small chunks to avoid overwhelming the chain.
166
+ - **Gap-slot batch processing** — each fill batch and broadcast is capped at the current grid's gap-slot count + 1. A queue at or below that depth is processed as one unified batch; deeper queues are chunked at the same deterministic cap.
166
167
 
167
168
  ## Related
168
169
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dexbot",
3
- "version": "1.6.4",
3
+ "version": "1.6.6",
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": {
@@ -14,6 +14,7 @@
14
14
  },
15
15
  "files": [
16
16
  "dist",
17
+ "!dist/analysis/legacy",
17
18
  "ecosystem.config.cjs",
18
19
  "scripts/bots",
19
20
  "scripts/clean-dist.js",
@@ -40,8 +41,10 @@
40
41
  "docs/CREDENTIAL_SECURITY.md",
41
42
  "docs/GRID_RECALCULATION.md",
42
43
  "docs/GRID_RECONCILE.md",
44
+ "docs/GRID_PRICE_INVARIANT.md",
43
45
  "docs/LOGGING.md",
44
46
  "docs/MPA_CREDIT_USAGE.md",
47
+ "docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md",
45
48
  "docs/COPY_ON_WRITE_MASTER_PLAN.md",
46
49
  "docs/COW_INVARIANTS.md",
47
50
  "docs/FUND_MOVEMENT_AND_ACCOUNTING.md",
@@ -56,6 +59,7 @@
56
59
  "modules/README.md",
57
60
  "analysis",
58
61
  "!analysis/charts",
62
+ "!analysis/legacy",
59
63
  "tests/README.md",
60
64
  "CHANGELOG.md",
61
65
  "README.md",
@@ -83,11 +87,9 @@
83
87
  "pdev": "bash scripts/pdev.sh",
84
88
  "ptest": "bash scripts/ptest.sh",
85
89
  "lp:chart": "npm run build && node dist/scripts/generate_lp_chart.js",
86
- "market-adapter:whitelist": "npm run build && node dist/scripts/generate_market_adapter_whitelist.js",
87
90
  "market-adapter:fetch-cex-synthetic": "npm run build && node dist/market_adapter/inputs/fetch_cex_synthetic_data.js",
88
91
  "analysis:tradingview": "npm run build && node dist/analysis/tradingview/analyze_tradingview.js",
89
92
  "ama:chart:lp-local": "npm run build && node dist/analysis/ama_fitting/generate_unified_comparison_chart.js",
90
- "analysis:derivatives": "npm run build && node dist/analysis/analyze_derivatives.js",
91
93
  "analysis:trade-pnl": "npm run build && node dist/analysis/trade_profitability.js",
92
94
  "analysis:grid-check": "npm run build && node dist/analysis/grid_correction_check.js",
93
95
  "analysis:resolve-accounts": "npm run build && node dist/analysis/resolve_bot_accounts.js",
@@ -96,6 +98,7 @@
96
98
  "native:ecc-invariants": "npm run build && npm run build:tests && node dist/tests/test_native_ecc.js",
97
99
  "native:corpus": "npm run build && node dist/scripts/generate_mainnet_corpus_report.js",
98
100
  "test:credit-renewal": "npm run build && node dist/scripts/test-credit-renewal.js",
101
+ "test:legacy": "npm run build && npm run build:tests && node dist/analysis/legacy/tests/test_derivative_chart.js && node dist/analysis/legacy/tests/test_derivative_entry_bias.js && node dist/analysis/legacy/tests/test_derivative_momentum_gate.js && node dist/analysis/legacy/tests/test_derivative_signal_trap_regression.js",
99
102
  "version:sync": "npm run build && node dist/scripts/sync-version.js",
100
103
  "version:check": "npm run build && node dist/scripts/sync-version.js --check",
101
104
  "verify:browser-bundle": "npm run build && node dist/scripts/verify-browser-bundle.js",
@@ -104,7 +107,7 @@
104
107
  "clean": "node scripts/clean-dist.js",
105
108
  "build": "tsc && chmod +x dist/dexbot.js dist/bot.js dist/unlock.js dist/pm2.js dist/credential-daemon.js",
106
109
  "build:clean": "npm run clean && npm run build",
107
- "build:tests": "tsc -p tsconfig.tests.json && cp tests/package.json dist/tests/package.json && cp tests/helpers/esm_mock_hooks.mjs tests/helpers/esm_mock_loader.mjs dist/tests/helpers/",
110
+ "build:tests": "tsc -p tsconfig.tests.json && cp tests/package.json dist/tests/package.json && cp tests/helpers/esm_mock_hooks.mjs tests/helpers/esm_mock_loader.mjs dist/tests/helpers/ && mkdir -p dist/analysis/legacy/tests && cp analysis/legacy/tests/package.json dist/analysis/legacy/tests/package.json",
108
111
  "typecheck": "tsc --noEmit",
109
112
  "typecheck:tests": "tsc -p tsconfig.tests.json --noEmit",
110
113
  "build:watch": "tsc --watch",
package/scripts/README.md CHANGED
@@ -93,29 +93,6 @@ bash scripts/reset-settings.sh
93
93
  node dist/scripts/validate_bots.js
94
94
  ```
95
95
 
96
- ### Market Adapter Whitelist Generation
97
- **File:** `generate_market_adapter_whitelist.ts`
98
- **Purpose:** Generate `profiles/market_adapter_whitelist.json` from bots whose `gridPrice` uses AMA mode.
99
- ```bash
100
- # Add missing AMA bots from profiles/bots.json to profiles/market_adapter_whitelist.json.
101
- # Existing entries are preserved; new entries enable AMA only and leave dynamicWeight and range scaling disabled.
102
- dexbot white
103
-
104
- # Add missing AMA bots with dynamicWeight enabled for newly generated entries
105
- dexbot white --dynamic-weight
106
-
107
- # Add missing AMA bots with range scaling (asymmetricBounds) enabled for newly generated entries
108
- dexbot white --asymmetric-bounds
109
-
110
- # Overwrite existing entry for a specific bot (implies overwrite for that key only; other bots unchanged)
111
- dexbot white --dynamic-weight --bot <botKey>
112
- dexbot white --asymmetric-bounds --bot <botKey>
113
-
114
- # Remove whitelist entries for bots no longer in profiles/bots.json
115
- dexbot white --prune
116
-
117
- ```
118
-
119
96
  ### Grid Divergence Audit
120
97
  **File:** `divergence-calc.ts`
121
98
  **Purpose:** Measure the "drift" between in-memory grid and disk state using RMS divergence metric.
@@ -363,9 +340,7 @@ The following scripts allow you to call `dexbot` commands directly from the `scr
363
340
  ### Analysis
364
341
  | Command | Purpose |
365
342
  |:---|:---|
366
- | `npm run market-adapter:whitelist` | Generate/update whitelist from AMA-configured bots |
367
343
  | `npm run market-adapter:fetch-cex-synthetic` | Fetch CEX synthetic data for market adapter |
368
- | `npm run analysis:derivatives` | Derivative analysis report |
369
344
  | `npm run analysis:tradingview` | TradingView-style chart export |
370
345
  | `npm run analysis:trade-pnl` | Trade PnL analysis from fill data |
371
346
  | `npm run ama:chart:lp-local` | Generate local LP comparison chart |
@@ -385,8 +360,10 @@ The following scripts allow you to call `dexbot` commands directly from the `scr
385
360
 
386
361
  ## 📈 CHART GENERATION
387
362
 
363
+ `dexbot tv` and `dexbot dw` share ONE fetch pipeline ([`chart_command.ts`](chart_command.ts)): identical target resolution, source routing, cached candle chunks, and temp-file handoff — only the renderer registration (`RENDERERS` table) differs.
364
+
388
365
  ### TradingView (`dexbot tv`)
389
- **File:** `tv.ts`
366
+ **File:** `tv.ts` (thin entry; shared pipeline: `chart_command.ts`)
390
367
  **Purpose:** One-step TradingView-style 1h chart for a bot (with AMA + order overlay), pool, or pair. Fetches candles in monthly Kibana chunks (pool-first with order-book fallback; `--feed` for MPA price-feed history), then renders via `analysis/tradingview/`. Bot charts pick up the order overlay from `profiles/orders/<botKey>.json` automatically.
391
368
  **Output:** `analysis/charts/tv_<bot|pool_<id>|<a>_<b>>_1h_<N>m.html` (`_feed` suffix for feed charts)
392
369
  ```bash
@@ -399,6 +376,21 @@ dexbot tv TOKENA/TOKENB --month 1 --chart analysis/charts/custom.html
399
376
  dexbot tv BTS/HONEST.USD --feed --month 1
400
377
  ```
401
378
 
379
+ ### Dynamic Weight (`dexbot dw`) — advanced
380
+ **File:** `dw.ts` (thin entry; shared pipeline: `chart_command.ts`)
381
+ **Purpose:** Identical one-step pipeline to `dexbot tv` (same targets, `--month`, `--feed/--pool/--book`, same cached monthly candle chunks) — the only difference is the renderer: it writes the dynamic-weight research chart via `analysis/analyze_dynamic_weight.ts` (AMA slope + Kalman blend, Hurst/PE regime gate) instead of a TradingView chart. For weight-tuning research, not general charting.
382
+ **Output:** `analysis/charts/dw_<bot|pool_<id>|<a>_<b>>_1h_<N>m.html` (`_feed` suffix for feed charts)
383
+ ```bash
384
+ # Bot chart (default: 3 months)
385
+ dexbot dw <bot>
386
+ # Pool or pair, custom window
387
+ dexbot dw 133 --month 6
388
+ dexbot dw TOKENA/TOKENB --month 1 --chart analysis/charts/custom.html
389
+ # MPA price-feed history instead of market candles (opt-in)
390
+ dexbot dw BTS/HONEST.USD --feed --month 1
391
+ ```
392
+ Research knobs (`--alpha`, `--gain`, `--dw`, `--lb`, `--clip`) stay on the analyzer itself — call `node dist/analysis/analyze_dynamic_weight.js` directly for parameter sweeps (see `analysis/README.md`).
393
+
402
394
  ### LP Chart
403
395
  **File:** `generate_lp_chart.ts`
404
396
  **Purpose:** Generate the standard uPlot LP chart output.
@@ -417,14 +409,6 @@ npm run lp:chart -- --data <lp-export.json>
417
409
  npm run ama:chart:lp-local -- --data <lp-export.json>
418
410
  ```
419
411
 
420
- ### Derivative Trend Analysis
421
- **File:** `analysis/analyze_derivatives.ts`
422
- **Purpose:** Generate the derivative analysis report.
423
- ```bash
424
- # Generate the derivative analysis report
425
- npm run analysis:derivatives -- --source json --file <file.json>
426
- ```
427
-
428
412
  ---
429
413
 
430
414
  ## 📚 DOCUMENTATION REFERENCES
@@ -108,7 +108,7 @@ if [ "$REMAINING" -eq 0 ]; then
108
108
  log_info ""
109
109
  log_info "Next steps:"
110
110
  log_info "- Re-run \`dexbot bot\` to recreate general settings if needed"
111
- log_info "- Re-run \`npm run market-adapter:whitelist\` if your AMA bot set changed"
111
+ log_info "- Re-open \`dexbot bot\` → 2) Modify bot → 6) Adapter if your AMA bot set changed"
112
112
  log_info "- Re-fit market profiles only if you want custom AMA presets again"
113
113
  else
114
114
  log_warning "Cleanup incomplete. Remaining settings files: $REMAINING"
@@ -1,12 +0,0 @@
1
- {
2
- "name": "ama_fitting",
3
- "version": "1.6.4",
4
- "description": "Tools for fitting AMA parameters to market data",
5
- "main": "../../dist/analysis/ama_fitting/optimizer_high_resolution.js",
6
- "scripts": {
7
- "optimize": "npm --prefix ../.. run build && node ../../dist/analysis/ama_fitting/optimizer_high_resolution.js",
8
- "chart:lp-local": "npm --prefix ../.. run build && node ../../dist/analysis/ama_fitting/generate_unified_comparison_chart.js"
9
- },
10
- "dependencies": {},
11
- "type": "module"
12
- }