dexbot 1.6.5 → 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.
- package/CHANGELOG.md +36 -4
- package/README.md +104 -35
- package/analysis/README.md +11 -16
- package/analysis/account_resolver.ts +1 -11
- package/analysis/bot_usage/kibana_bot_queries.ts +1 -1
- package/analysis/chain_pool.ts +1 -1
- package/analysis/fills_source.ts +0 -6
- package/analysis/grid_correction_check.ts +20 -26
- package/analysis/resolve_source.ts +1 -1
- package/analysis/trade_profitability.ts +2 -5
- package/analysis/trend_detection/README.md +1 -3
- package/analysis/trend_detection/package.json +1 -1
- package/claw/package.json +1 -1
- package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
- package/claw/runtimes/openclaw-plugin/package.json +1 -1
- package/claw/tests/test_claw_mcp_transport.ts +2 -2
- package/dist/analysis/account_resolver.d.ts +1 -4
- package/dist/analysis/account_resolver.d.ts.map +1 -1
- package/dist/analysis/account_resolver.js +1 -1
- package/dist/analysis/account_resolver.js.map +1 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts +1 -2
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +1 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.js +1 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.js.map +1 -1
- package/dist/analysis/chain_pool.d.ts +1 -3
- package/dist/analysis/chain_pool.d.ts.map +1 -1
- package/dist/analysis/chain_pool.js +1 -1
- package/dist/analysis/chain_pool.js.map +1 -1
- package/dist/analysis/fills_source.d.ts +1 -51
- package/dist/analysis/fills_source.d.ts.map +1 -1
- package/dist/analysis/fills_source.js +1 -1
- package/dist/analysis/fills_source.js.map +1 -1
- package/dist/analysis/grid_correction_check.d.ts +2 -3
- package/dist/analysis/grid_correction_check.d.ts.map +1 -1
- package/dist/analysis/grid_correction_check.js +18 -26
- package/dist/analysis/grid_correction_check.js.map +1 -1
- package/dist/analysis/resolve_source.d.ts +1 -1
- package/dist/analysis/resolve_source.d.ts.map +1 -1
- package/dist/analysis/trade_profitability.d.ts.map +1 -1
- package/dist/analysis/trade_profitability.js +2 -7
- package/dist/analysis/trade_profitability.js.map +1 -1
- package/dist/dexbot.d.ts.map +1 -1
- package/dist/dexbot.js +60 -74
- package/dist/dexbot.js.map +1 -1
- package/dist/market_adapter/core/kibana_candles.d.ts +1 -15
- package/dist/market_adapter/core/kibana_candles.d.ts.map +1 -1
- package/dist/market_adapter/core/kibana_candles.js +1 -1
- package/dist/market_adapter/core/kibana_candles.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +1 -35
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js +10 -54
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -1
- package/dist/market_adapter/inputs/kibana_feed_source.d.ts +1 -8
- package/dist/market_adapter/inputs/kibana_feed_source.d.ts.map +1 -1
- package/dist/market_adapter/inputs/kibana_feed_source.js +1 -1
- package/dist/market_adapter/inputs/kibana_feed_source.js.map +1 -1
- package/dist/market_adapter/inputs/window_cache.d.ts +2 -63
- package/dist/market_adapter/inputs/window_cache.d.ts.map +1 -1
- package/dist/market_adapter/inputs/window_cache.js +22 -102
- package/dist/market_adapter/inputs/window_cache.js.map +1 -1
- package/dist/modules/account_bots.d.ts +16 -2
- package/dist/modules/account_bots.d.ts.map +1 -1
- package/dist/modules/account_bots.js +107 -44
- package/dist/modules/account_bots.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.js +0 -31
- package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +1 -1
- package/dist/modules/credit_runtime.d.ts +0 -2
- package/dist/modules/credit_runtime.d.ts.map +1 -1
- package/dist/modules/credit_runtime.js +1 -10
- package/dist/modules/credit_runtime.js.map +1 -1
- package/dist/modules/dexbot_class.d.ts +13 -10
- package/dist/modules/dexbot_class.d.ts.map +1 -1
- package/dist/modules/dexbot_class.js +0 -9
- package/dist/modules/dexbot_class.js.map +1 -1
- package/dist/modules/dexbot_cow_runtime.d.ts +13 -0
- package/dist/modules/dexbot_cow_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_cow_runtime.js +13 -1
- package/dist/modules/dexbot_cow_runtime.js.map +1 -1
- package/dist/modules/order/accounting.d.ts +4 -18
- package/dist/modules/order/accounting.d.ts.map +1 -1
- package/dist/modules/order/accounting.js +4 -34
- package/dist/modules/order/accounting.js.map +1 -1
- package/dist/modules/order/export.d.ts +9 -12
- package/dist/modules/order/export.d.ts.map +1 -1
- package/dist/modules/order/export.js +9 -12
- package/dist/modules/order/export.js.map +1 -1
- package/dist/modules/order/grid.d.ts +35 -40
- package/dist/modules/order/grid.d.ts.map +1 -1
- package/dist/modules/order/grid.js +43 -43
- package/dist/modules/order/grid.js.map +1 -1
- package/dist/modules/order/grid_reconcile.d.ts.map +1 -1
- package/dist/modules/order/grid_reconcile.js +111 -20
- package/dist/modules/order/grid_reconcile.js.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.d.ts +5 -3
- package/dist/modules/order/grid_reconcile_internal.d.ts.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.js +18 -3
- package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
- package/dist/modules/order/manager.d.ts +0 -8
- package/dist/modules/order/manager.d.ts.map +1 -1
- package/dist/modules/order/manager.js +0 -10
- package/dist/modules/order/manager.js.map +1 -1
- package/dist/modules/order/utils/order.d.ts +22 -7
- package/dist/modules/order/utils/order.d.ts.map +1 -1
- package/dist/modules/order/utils/order.js +103 -21
- package/dist/modules/order/utils/order.js.map +1 -1
- package/dist/modules/order/utils/withPoolRef.d.ts +12 -0
- package/dist/modules/order/utils/withPoolRef.d.ts.map +1 -1
- package/dist/modules/order/utils/withPoolRef.js +17 -0
- package/dist/modules/order/utils/withPoolRef.js.map +1 -1
- package/dist/modules/order/working_grid.d.ts +8 -13
- package/dist/modules/order/working_grid.d.ts.map +1 -1
- package/dist/modules/order/working_grid.js +8 -29
- package/dist/modules/order/working_grid.js.map +1 -1
- package/dist/scripts/sync-version.js +0 -22
- package/dist/scripts/sync-version.js.map +1 -1
- package/dist/scripts/update_dist_freshness.d.ts +12 -0
- package/dist/scripts/update_dist_freshness.d.ts.map +1 -1
- package/dist/scripts/update_dist_freshness.js +30 -1
- package/dist/scripts/update_dist_freshness.js.map +1 -1
- package/docs/BITSHARES_ONBOARDING.md +9 -6
- package/docs/COW_INVARIANTS.md +1 -0
- package/docs/DEXBOT_COMPARISON.md +11 -11
- package/docs/EVOLUTION.md +8 -7
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
- package/docs/GRID_PRICE_INVARIANT.md +518 -0
- package/docs/GRID_RECALCULATION.md +1 -1
- package/docs/GRID_RECONCILE.md +60 -39
- package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +556 -0
- package/docs/README.md +3 -3
- package/docs/WORKFLOW.md +12 -6
- package/docs/architecture.md +40 -38
- package/docs/developer_guide.md +4 -8
- package/market_adapter/README.md +16 -12
- package/modules/README.md +1 -1
- package/package.json +7 -3
- package/scripts/README.md +0 -9
- package/scripts/reset-settings.sh +1 -1
- package/analysis/ama_fitting/package.json +0 -12
- package/analysis/analyze_derivatives.ts +0 -320
- package/analysis/derivative_chart_generator.ts +0 -874
- package/analysis/trend_detection/SIGNAL_DOCUMENTATION.md +0 -403
- package/analysis/trend_detection/derivative_analyzer.ts +0 -1059
- package/dist/analysis/analyze_derivatives.d.ts +0 -68
- package/dist/analysis/analyze_derivatives.d.ts.map +0 -1
- package/dist/analysis/analyze_derivatives.js +0 -287
- package/dist/analysis/analyze_derivatives.js.map +0 -1
- package/dist/analysis/derivative_chart_generator.d.ts +0 -12
- package/dist/analysis/derivative_chart_generator.d.ts.map +0 -1
- package/dist/analysis/derivative_chart_generator.js +0 -891
- package/dist/analysis/derivative_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/derivative_analyzer.d.ts +0 -248
- package/dist/analysis/trend_detection/derivative_analyzer.d.ts.map +0 -1
- package/dist/analysis/trend_detection/derivative_analyzer.js +0 -910
- package/dist/analysis/trend_detection/derivative_analyzer.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`.
|