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
@@ -1,403 +0,0 @@
1
- # Signal & Indicator Documentation (Legacy)
2
-
3
- **Note:** This documents the legacy SMA/MACD/RSI derivative signal layer. See `kalman_trend_analyzer.ts` for the current trend detection implementation.
4
-
5
- ## Overview
6
-
7
- The derivative analyzer uses four indicators:
8
-
9
- - `SMA` (slow) for macro trend / regime
10
- - `fastSMA` (optional) for short-term direction — used as the trend filter source and fast-SMA commitment gate
11
- - `MACD` for momentum
12
- - `RSI` for exhaustion and counter-trend filtering
13
-
14
- The output signal is one of:
15
-
16
- - `BULL`
17
- - `BULL_WEAK`
18
- - `BEAR`
19
- - `BEAR_WEAK`
20
- - `OVERBOUGHT`
21
- - `OVERSOLD`
22
- - `NEUTRAL`
23
-
24
- There are three independent output layers:
25
-
26
- - `trend` / `rawTrend` / `isConfirmed` come from SMA direction alone. `--confirm` controls only this MA-trend confirmation layer.
27
- - `interpretation` / `interpretationRaw` are the trading-style states (`BULL`, `BEAR`, `OVERBOUGHT`, etc.). `--interp-confirm` and `--interp-hold` control only this signal layer.
28
- - `entryBias` and its boolean helpers are derived execution hints built on top of the final `interpretation` state. They do not change the base signal engine. They classify whether a directional setup is an early weak entry or a proper confirmation once slow and fast SMA alignment is in place.
29
-
30
- ---
31
-
32
- ## Indicators
33
-
34
- ### SMA
35
-
36
- Simple moving average over the configured slow period.
37
-
38
- **Derivative signal**
39
-
40
- ```text
41
- d(SMA)/dt > 0 -> UP
42
- d(SMA)/dt < 0 -> DOWN
43
- d(SMA)/dt = 0 -> NEUTRAL
44
- ```
45
-
46
- **Flag**
47
-
48
- | Flag | Default | Meaning |
49
- |------|---------|---------|
50
- | `--sma N` | 500 | Slow SMA period |
51
-
52
- The slow SMA defines the macro regime. It is the reference line for the price regime gate and the macro disagree cap (see Trend filter).
53
-
54
- ---
55
-
56
- ### fastSMA
57
-
58
- Optional second moving average over a shorter period. When present it takes over from the slow SMA as the primary trend filter direction source and enables two additional signal quality checks.
59
-
60
- **Derivative signal**
61
-
62
- ```text
63
- d(fastSMA)/dt > 0 -> UP
64
- d(fastSMA)/dt < 0 -> DOWN
65
- d(fastSMA)/dt = 0 -> NEUTRAL
66
- ```
67
-
68
- **Flag**
69
-
70
- | Flag | Default | Meaning |
71
- |------|---------|---------|
72
- | `--fast-sma N` | off | Fast SMA period (e.g. 100) |
73
-
74
- When `--fast-sma` is set:
75
-
76
- - The trend filter reads **fastSMA direction** instead of slow SMA direction.
77
- - **Macro disagree cap**: if fastSMA and slow SMA point in opposite directions, a full `BULL`/`BEAR` is capped to `BULL_WEAK`/`BEAR_WEAK`.
78
- - **Fast-SMA commitment gate**: `BULL`/`BEAR` confirmation requires price to have been on the correct side of fastSMA for ≥ `--fast-sma-commitment-bars` consecutive bars (default 2). Failing bars reset the confirmation counter.
79
-
80
- Both the price overlay line and the derivative direction panel in the chart show fastSMA alongside slow SMA.
81
-
82
- ---
83
-
84
- ### MACD
85
-
86
- Momentum indicator built from the normalized MACD line, signal line, and histogram.
87
-
88
- **Interpretation**
89
-
90
- - Histogram > 0: bullish momentum
91
- - Histogram < 0: bearish momentum
92
- - Histogram shrinking: momentum fading
93
- - MACD line > 0: positive regime
94
- - MACD line < 0: negative regime
95
-
96
- **Flags**
97
-
98
- | Flag | Default | Meaning |
99
- |------|---------|---------|
100
- | `--macd-fast N` | 12 | Fast EMA period |
101
- | `--macd-slow N` | 26 | Slow EMA period |
102
- | `--macd-signal N` | 9 | Signal EMA period |
103
- | `--macd-min-hist F` | 0.02 | Minimum histogram magnitude before a directional signal is allowed |
104
-
105
- ---
106
-
107
- ### RSI
108
-
109
- Relative Strength Index used as a confidence modifier and exhaustion gate.
110
-
111
- **Zones**
112
-
113
- | RSI | Meaning |
114
- |-----|---------|
115
- | > `--rsi-extreme` | `OVERBOUGHT` |
116
- | 50 + `--rsi-zone` | Bullish zone |
117
- | 50 - `--rsi-zone` | Bearish zone |
118
- | < 100 - `--rsi-extreme` | `OVERSOLD` |
119
-
120
- **Flags**
121
-
122
- | Flag | Default | Meaning |
123
- |------|---------|---------|
124
- | `--rsi N` | 14 | RSI period |
125
- | `--rsi-zone N` | 10 | Distance from 50 for counter-trend downgrade |
126
- | `--rsi-extreme N` | 90 | Exhaustion threshold |
127
-
128
- RSI no longer hard-gates the base signal. It only downgrades or overrides it.
129
-
130
- ---
131
-
132
- ## Signal Rules
133
-
134
- ### Base direction
135
-
136
- MACD histogram decides the initial directional candidate:
137
-
138
- ```text
139
- hist > macd-min-hist -> BULL candidate
140
- hist < -macd-min-hist -> BEAR candidate
141
- otherwise -> NEUTRAL
142
- ```
143
-
144
- ### Confirmation
145
-
146
- `BULL` and `BEAR` require sustained raw direction before they are confirmed.
147
-
148
- **Flag**
149
-
150
- | Flag | Default | Meaning |
151
- |------|---------|---------|
152
- | `--interp-confirm N` | 3 | Bars required to confirm a raw BULL/BEAR |
153
-
154
- ### Hysteresis
155
-
156
- Confirmed `BULL`/`BEAR` states do not drop immediately on a minor fluctuation.
157
-
158
- **Flag**
159
-
160
- | Flag | Default | Meaning |
161
- |------|---------|---------|
162
- | `--interp-hold N` | 3 | Bars a downgrade must persist before it is applied |
163
-
164
- ### Hard invalidation
165
-
166
- Some regime failures bypass hysteresis completely. A confirmed `BULL`/`BEAR` is dropped immediately when the signal is no longer structurally valid.
167
-
168
- Immediate invalidation triggers:
169
-
170
- - **Post-filter MACD line regime failure** — `BULL` requires MACD line >= `macd-min-hist`; `BEAR` requires MACD line <= `-macd-min-hist`.
171
- - **Macro disagree failure** — when fastSMA and slow SMA disagree strongly enough to trigger the macro cap, a confirmed `BULL`/`BEAR` can no longer be held.
172
- - **Price regime failure** — price loses the buffered slow-SMA regime gate.
173
-
174
- ### RSI overrides
175
-
176
- - `BULL` + RSI > `--rsi-extreme` -> `OVERBOUGHT`
177
- - `BEAR` + RSI < `100 - --rsi-extreme` -> `OVERSOLD`
178
-
179
- ### RSI weakens the signal
180
-
181
- - `BULL` + RSI below the bearish zone and not rising -> `BULL_WEAK`
182
- - `BEAR` + RSI above the bullish zone and not falling -> `BEAR_WEAK`
183
-
184
- ### Trend filter
185
-
186
- The trend filter suppresses counter-trend signals when the fast MA (fastSMA if set, otherwise slow SMA) is clearly pointing the other way.
187
-
188
- **Flags**
189
-
190
- | Flag | Default | Meaning |
191
- |------|---------|---------|
192
- | `--trend-filter` | off | Enable trend direction filter |
193
- | `--trend-filter-min-bars N` | 3 | Fast MA trend must persist this many bars before the filter applies |
194
-
195
- When fastSMA is present, two additional checks run inside the trend filter:
196
-
197
- - **Macro disagree cap** — fastSMA and slow SMA point in opposite directions → full `BULL`/`BEAR` capped to `BULL_WEAK`/`BEAR_WEAK`.
198
- - **Fast-SMA commitment** — `BULL` requires price above fastSMA for ≥ N bars; `BEAR` requires price below fastSMA for ≥ N bars. Failing this downgrades to `BULL_WEAK`/`BEAR_WEAK`.
199
-
200
- ### Momentum gate
201
-
202
- When the trend filter suppresses a directional candidate to `NEUTRAL`, the momentum gate can restore it as weak if MACD and RSI both support the reversal for enough bars.
203
-
204
- **Flags**
205
-
206
- | Flag | Default | Meaning |
207
- |------|---------|---------|
208
- | `--momentum-gate` | off | Enable recovery gate |
209
- | `--momentum-gate-bars N` | 3 | Bars of sustained divergence required |
210
- | `--momentum-gate-rsi-zone F` | 35 | RSI threshold for the divergence check |
211
-
212
- The gate is only checked after a directional state was suppressed by the primary trend filter. It does not create weak signals from an already-neutral MACD/RSI reading.
213
-
214
- ### Price regime gate
215
-
216
- Any directional state (`BULL`, `BULL_WEAK`, `BEAR`, `BEAR_WEAK`) is suppressed if price has not cleared the slow SMA by a small buffer.
217
-
218
- **Flags**
219
-
220
- | Flag | Default | Meaning |
221
- |------|---------|---------|
222
- | `--price-regime-buffer-pct N` | 0.35 | Required clearance from the slow SMA, in percent |
223
- | `--no-price-regime-gate` | off | Disable the gate |
224
-
225
- This is the trap filter that removes shallow bull/bear crosses from the chart.
226
-
227
- The same gate is also treated as a hard invalidation for hysteresis. A confirmed `BULL`/`BEAR` is dropped immediately when the buffered slow-SMA regime is lost.
228
-
229
- ### MACD line regime gate
230
-
231
- Inside the trend filter, the MACD line itself must agree with the regime:
232
-
233
- - `BULL` needs MACD line > 0
234
- - `BEAR` needs MACD line < 0
235
-
236
- There is one extra bearish downgrade:
237
-
238
- - `BEAR` + MACD histogram > 0 -> `BEAR_WEAK`
239
-
240
- ### Post-filter trap suppression
241
-
242
- The final hard gate suppresses any remaining directional state while the MACD line is still too close to the wrong side of zero.
243
-
244
- The threshold is not pure zero. It reuses `--macd-min-hist` as a small regime buffer:
245
-
246
- - `BULL` / `BULL_WEAK` require MACD line >= `macd-min-hist`
247
- - `BEAR` / `BEAR_WEAK` require MACD line <= `-macd-min-hist`
248
-
249
- That means stale bullish or bearish holds are cleared immediately when the regime is invalidated.
250
-
251
- ---
252
-
253
- ## Entry Bias Metadata
254
-
255
- The analyzer also exposes a derived `entryBias` classification for downstream execution logic and chart overlays.
256
-
257
- Possible values:
258
-
259
- - `NONE`
260
- - `EARLY_LONG`
261
- - `CONFIRM_LONG`
262
- - `EARLY_SHORT`
263
- - `CONFIRM_SHORT`
264
-
265
- Boolean helpers are emitted alongside it:
266
-
267
- - `isBullWeakEntry`
268
- - `isBullConfirmation`
269
- - `isBearWeakEntry`
270
- - `isBearConfirmation`
271
-
272
- These fields are computed from the final post-hysteresis `interpretation`, not from raw MACD/RSI candidates.
273
- They are additionally gated by MA alignment:
274
-
275
- - long entry hints require slow SMA `UP` and fast SMA `UP`
276
- - short entry hints require slow SMA `DOWN` and fast SMA `DOWN`
277
-
278
- ### Long-side transitions
279
-
280
- - `NEUTRAL -> BULL_WEAK` => `EARLY_LONG`
281
- - `BULL_WEAK -> BULL` => `CONFIRM_LONG`
282
-
283
- ### Short-side transitions
284
-
285
- - `NEUTRAL -> BEAR_WEAK` => `EARLY_SHORT`
286
- - `BEAR_WEAK -> BEAR` => `CONFIRM_SHORT`
287
-
288
- If a weak setup fails back to `NEUTRAL` or the signal flips to the opposite side, the setup state is cleared.
289
-
290
- ---
291
-
292
- ## Decision Tree
293
-
294
- ```text
295
- |hist| <= macd-min-hist -> NEUTRAL
296
-
297
- BULL candidate:
298
- RSI > extreme -> OVERBOUGHT
299
- RSI weakens bullishly -> BULL_WEAK
300
- MACD line regime disagrees -> BULL_WEAK
301
- trend filter rejects (fastSMA DOWN) -> NEUTRAL
302
- macro disagree cap (fastSMA≠SMA) -> BULL_WEAK
303
- Fast-SMA commitment: price below fastSMA < N bars-> BULL_WEAK
304
- momentum gate restores -> BULL_WEAK
305
- price regime gate rejects -> NEUTRAL
306
- post-filter trap suppression -> NEUTRAL
307
- Fast-SMA commitment not met -> resets confirmation counter
308
- confirmed and held -> BULL
309
-
310
- BEAR candidate:
311
- RSI < 100-extreme -> OVERSOLD
312
- RSI weakens bearishly -> BEAR_WEAK
313
- MACD line regime disagrees -> BEAR_WEAK
314
- trend filter rejects (fastSMA UP) -> NEUTRAL
315
- macro disagree cap (fastSMA≠SMA) -> BEAR_WEAK
316
- Fast-SMA commitment: price above fastSMA < N bars-> BEAR_WEAK
317
- momentum gate restores -> BEAR_WEAK
318
- price regime gate rejects -> NEUTRAL
319
- post-filter trap suppression -> NEUTRAL
320
- Fast-SMA commitment not met -> resets confirmation counter
321
- confirmed and held -> BEAR
322
- ```
323
-
324
- ---
325
-
326
- ## Parameter Reference
327
-
328
- Start with the base indicator set below. These are the parameters that define the
329
- signal model itself. The remaining flags are optional gates or advanced defaults
330
- that only need adjustment when you want to change how strict the signal is.
331
-
332
- ### Base indicator set
333
-
334
- | Flag | Default | Purpose |
335
- |------|---------|---------|
336
- | `--sma N` | 500 | Slow macro regime anchor |
337
- | `--macd-fast N` | 12 | MACD fast EMA period |
338
- | `--macd-slow N` | 26 | MACD slow EMA period |
339
- | `--macd-signal N` | 9 | MACD signal EMA period |
340
- | `--macd-min-hist F` | 0.02 | Minimum histogram magnitude for direction |
341
- | `--rsi N` | 14 | RSI period |
342
-
343
- ### Optional gate knobs
344
-
345
- | Flag | Default | Purpose |
346
- |------|---------|---------|
347
- | `--fast-sma N` | off | Short-term direction source and fast-SMA commitment gate |
348
- | `--trend-filter` | off | Enables counter-trend suppression |
349
- | `--fast-sma-commitment-bars N` | 2 | Requires price to stay beyond fastSMA before confirming |
350
- | `--price-regime-buffer-pct N` | 0.35 | Requires price clearance from slow SMA |
351
-
352
- ### Advanced defaults
353
-
354
- #### Confirmation and hysteresis
355
-
356
- | Flag | Default | Description |
357
- |------|---------|-------------|
358
- | `--confirm N` | 3 | Bars required for trend confirmation |
359
- | `--interp-confirm N` | 3 | Confirmation bars for BULL/BEAR |
360
- | `--interp-hold N` | 3 | Hysteresis bars for downgrades |
361
-
362
- #### Trend filters and gates
363
-
364
- | Flag | Default | Description |
365
- |------|---------|-------------|
366
- | `--trend-filter-min-bars N` | 3 | SMA trend persistence before filtering |
367
- | `--momentum-gate` | off | Enable MACD+RSI recovery gate |
368
- | `--momentum-gate-bars N` | 3 | Momentum gate persistence |
369
- | `--momentum-gate-rsi-zone F` | 35 | RSI divergence threshold |
370
- | `--no-price-regime-gate` | off | Disable slow-SMA regime gate |
371
-
372
- ### Source input
373
-
374
- | Flag | Default | Description |
375
- |------|---------|-------------|
376
- | `--source` | market_adapter | Data source |
377
- | `--file PATH` | — | JSON candle input |
378
- | `--bot-key KEY` | — | Market adapter bot key used to load `market_adapter/state/market_adapter_centers.json` |
379
-
380
- ### Output
381
-
382
- | Flag | Default | Description |
383
- |------|---------|-------------|
384
- | `--chart FILE` | analysis/charts/derivative_chart.html | HTML output path |
385
-
386
- ---
387
-
388
- ## Recommended 1h Setup
389
-
390
- ```bash
391
- node dist/analysis/analyze_derivatives.js \
392
- --source json \
393
- --file market_adapter/data/lp/<pair>/lp_pool_<id>_<interval>.json \
394
- --sma 500 --fast-sma 100 \
395
- --macd-fast 48 --macd-slow 104 --macd-signal 36 --macd-min-hist 0.02 \
396
- --rsi 96 --rsi-extreme 90 --rsi-zone 10 \
397
- --interp-confirm 3 --interp-hold 3 \
398
- --trend-filter --trend-filter-min-bars 3
399
- ```
400
-
401
- If you want fewer shallow traps, keep the price regime gate enabled. If you want to
402
- see every MACD/RSI turn regardless of slow-SMA clearance, disable it with
403
- `--no-price-regime-gate`.