dexbot 1.6.5 → 1.6.7
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 +76 -4
- package/README.md +108 -36
- 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 +82 -83
- 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 +108 -44
- package/dist/modules/account_bots.js.map +1 -1
- package/dist/modules/account_orders.d.ts +20 -2
- package/dist/modules/account_orders.d.ts.map +1 -1
- package/dist/modules/account_orders.js +63 -3
- package/dist/modules/account_orders.js.map +1 -1
- package/dist/modules/bitshares-native/chain_client.d.ts +10 -0
- package/dist/modules/bitshares-native/chain_client.d.ts.map +1 -1
- package/dist/modules/bitshares-native/chain_client.js +197 -28
- package/dist/modules/bitshares-native/chain_client.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/bitshares-native/subscriptions.d.ts.map +1 -1
- package/dist/modules/bitshares-native/subscriptions.js +312 -10
- package/dist/modules/bitshares-native/subscriptions.js.map +1 -1
- package/dist/modules/bitshares-native/transport.d.ts +1 -0
- package/dist/modules/bitshares-native/transport.d.ts.map +1 -1
- package/dist/modules/bitshares-native/transport.js +97 -3
- package/dist/modules/bitshares-native/transport.js.map +1 -1
- package/dist/modules/bitshares_client.d.ts +20 -0
- package/dist/modules/bitshares_client.d.ts.map +1 -1
- package/dist/modules/bitshares_client.js +29 -0
- package/dist/modules/bitshares_client.js.map +1 -1
- package/dist/modules/chain_keys.d.ts +37 -22
- package/dist/modules/chain_keys.d.ts.map +1 -1
- package/dist/modules/chain_keys.js +145 -44
- package/dist/modules/chain_keys.js.map +1 -1
- package/dist/modules/cli_start_onboarding.d.ts +10 -0
- package/dist/modules/cli_start_onboarding.d.ts.map +1 -0
- package/dist/modules/cli_start_onboarding.js +15 -0
- package/dist/modules/cli_start_onboarding.js.map +1 -0
- package/dist/modules/cli_start_output.d.ts +6 -0
- package/dist/modules/cli_start_output.d.ts.map +1 -0
- package/dist/modules/cli_start_output.js +8 -0
- package/dist/modules/cli_start_output.js.map +1 -0
- package/dist/modules/constants.d.ts +13 -0
- package/dist/modules/constants.d.ts.map +1 -1
- package/dist/modules/constants.js +103 -1
- package/dist/modules/constants.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 +62 -10
- package/dist/modules/dexbot_cow_runtime.js.map +1 -1
- package/dist/modules/dexbot_fill_runtime.d.ts +6 -1
- package/dist/modules/dexbot_fill_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_fill_runtime.js +22 -3
- package/dist/modules/dexbot_fill_runtime.js.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts +24 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.js +45 -1
- package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
- package/dist/modules/dexbot_state_recovery.d.ts.map +1 -1
- package/dist/modules/dexbot_state_recovery.js +13 -1
- package/dist/modules/dexbot_state_recovery.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 +76 -44
- 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 +29 -3
- package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
- package/dist/modules/order/logger.d.ts +12 -2
- package/dist/modules/order/logger.d.ts.map +1 -1
- package/dist/modules/order/logger.js +29 -7
- package/dist/modules/order/logger.js.map +1 -1
- package/dist/modules/order/manager.d.ts +49 -8
- package/dist/modules/order/manager.d.ts.map +1 -1
- package/dist/modules/order/manager.js +72 -34
- 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 +200 -33
- package/dist/modules/order/utils/order.js.map +1 -1
- package/dist/modules/order/utils/system.d.ts +97 -0
- package/dist/modules/order/utils/system.d.ts.map +1 -1
- package/dist/modules/order/utils/system.js +274 -2
- package/dist/modules/order/utils/system.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/modules/paths.d.ts +7 -1
- package/dist/modules/paths.d.ts.map +1 -1
- package/dist/modules/paths.js +10 -3
- package/dist/modules/paths.js.map +1 -1
- package/dist/modules/utils/text_width.d.ts +19 -0
- package/dist/modules/utils/text_width.d.ts.map +1 -0
- package/dist/modules/utils/text_width.js +97 -0
- package/dist/modules/utils/text_width.js.map +1 -0
- package/dist/pm2.d.ts.map +1 -1
- package/dist/pm2.js +95 -18
- package/dist/pm2.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.js +62 -13
- package/dist/scripts/update.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/dist/unlock.d.ts +14 -2
- package/dist/unlock.d.ts.map +1 -1
- package/dist/unlock.js +73 -4
- package/dist/unlock.js.map +1 -1
- package/docs/BITSHARES_ONBOARDING.md +9 -6
- package/docs/COW_INVARIANTS.md +9 -0
- package/docs/CREDENTIAL_SECURITY.md +26 -0
- package/docs/DEXBOT_COMPARISON.md +11 -11
- package/docs/EVOLUTION.md +9 -7
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
- package/docs/GRID_PRICE_INVARIANT.md +573 -0
- package/docs/GRID_RECALCULATION.md +1 -1
- package/docs/GRID_RECONCILE.md +60 -39
- package/docs/LOGGING.md +17 -2
- package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +555 -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 +8 -4
- 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
package/docs/WORKFLOW.md
CHANGED
|
@@ -240,25 +240,31 @@ the canonical name is preferred in scripts and docs.
|
|
|
240
240
|
|---------|---------|---------|
|
|
241
241
|
| `dexbot test <bot>` | — | Run a single bot in live mode (one-shot; not a dry run) |
|
|
242
242
|
| `dexbot drystart <bot>` | — | Same as `test` but forces dry-run execution |
|
|
243
|
-
| `dexbot reset <bot>` | — | Trigger a grid reset (applies live or on next start) |
|
|
243
|
+
| `dexbot reset <bot>` | — | Trigger a grid reset (applies live or on next start; `reset all` for all) |
|
|
244
244
|
| `dexbot default` | `defaults` | Reset settings to defaults (deletes generated settings files) |
|
|
245
245
|
| `dexbot disable <bot>` | — | Mark a bot inactive in config (`disable all` for all) |
|
|
246
246
|
| `dexbot enable <bot>` | — | Mark a bot active in config (`enable all` for all) |
|
|
247
|
-
| `dexbot key` | `
|
|
248
|
-
| `dexbot bot` | `
|
|
247
|
+
| `dexbot key` | `keys` | Launch the chain key helper (`modules/chain_keys.ts`) |
|
|
248
|
+
| `dexbot bot` | `bots` | Launch the interactive bot configurator |
|
|
249
249
|
| `dexbot pm2` | — | Start all active bots via PM2 |
|
|
250
250
|
| `dexbot update` | — | Update DEXBot2 from the repository and restart active bots |
|
|
251
251
|
| `dexbot export <bot>` | — | Export bot trades/settings to CSV/JSON for local analysis/ |
|
|
252
|
-
| `dexbot order` | `orders` | Analyze persisted order grids (spread, increment, funds) |
|
|
252
|
+
| `dexbot order` | `orders` | Analyze persisted order grids (spread, increment, funds); `--export` for HTML |
|
|
253
253
|
| `dexbot order [<bot>]` | — | Analyze only the specified bot's order grid |
|
|
254
254
|
| `dexbot credit` | — | Live summed MPA + borrowed-credit positions per asset per bot (`[<bot>]`) |
|
|
255
|
-
| `dexbot
|
|
255
|
+
| `dexbot tv <target>` | — | TradingView 1h chart for `<bot|pool-id|AssetA/AssetB>` over `--month N` (default 3) |
|
|
256
|
+
| `dexbot dw <target>` | — | Dynamic-weight research chart: same targets/flags as `tv` |
|
|
257
|
+
| `dexbot status` | `stat`, `stats` | Unified runtime health — daemon, adapter, bots |
|
|
256
258
|
| `dexbot start` | `unlock` | Run credential daemon + bot (equivalent to running the `unlock` runtime, `dist/unlock.js`) |
|
|
257
|
-
| `dexbot stop`
|
|
259
|
+
| `dexbot stop` | `stp`, `stopall` | Stop the monolithic runtime (unlock mode) |
|
|
258
260
|
| `dexbot reload` | `reloadall` | Reload the monolithic runtime without touching the credential daemon (unlock mode) |
|
|
259
261
|
| `dexbot restart` | `restartall` | Restart the monolithic runtime (unlock mode, re-unlocks credential daemon) |
|
|
260
262
|
| `dexbot delete` | — | Shut down and clean up the monolithic runtime (unlock mode) |
|
|
261
263
|
| `dexbot clear` | — | Remove all log files from the logs directory (`<profiles>/logs`) |
|
|
264
|
+
| `dexbot clear-orders` | — | Remove all persisted order files (`<profiles>/orders`) |
|
|
265
|
+
| `dexbot clear-market-adapter` | — | Remove market adapter data, state, and logs |
|
|
266
|
+
| `dexbot clear-all` | — | Remove orders, logs, market adapter, and claw files (all of the above) |
|
|
267
|
+
| `dexbot help` | — | Print the full CLI reference (grouped by Runtime/Trading/Config/Analysis/Files) |
|
|
262
268
|
|
|
263
269
|
## NPM Scripts for Branch Synchronization
|
|
264
270
|
|
package/docs/architecture.md
CHANGED
|
@@ -22,7 +22,7 @@ DEXBot2 is a grid trading bot for the BitShares blockchain. It maintains a geome
|
|
|
22
22
|
DEXBot2 prioritizes **simplicity and operational efficiency** over complex partial-handling mechanics:
|
|
23
23
|
|
|
24
24
|
1. **Constant Spread**: The spread zone width remains fixed at `targetSpreadPercent`, eliminating dynamic inflation triggers.
|
|
25
|
-
2. **
|
|
25
|
+
2. **Immediate Dust Cancellation**: Sub-threshold partials are cancelled on-chain as soon as detection runs; surviving non-dust partials are handled by ordinary fund-driven rebalancing without complex merge/split logic.
|
|
26
26
|
3. **Minimal Blockchain Interaction**: Fund-driven rebalancing occurs once per fill batch, not per-partial. Grid generation uses only available funds—no forced allocations.
|
|
27
27
|
4. **Closed-Loop Market Dynamics**: The boundary-crawl mechanism naturally handles price movement and fill flows without special-case logic.
|
|
28
28
|
5. **Powerful Maintenance Tools**: Periodic grid regeneration, recovery retries, and fund invariant verification keep the system healthy over long operations.
|
|
@@ -56,7 +56,7 @@ graph TB
|
|
|
56
56
|
MASTERGRID[Master Grid - immutable/frozen<br/>slot-id, price, size, state<br/>orderId, blockchain, grid, proceeds]
|
|
57
57
|
TWOPASS[SyncEngine<br/>2-pass: grid-to-chain then chain-to-grid<br/>match orderId, detect partials, flag stale]
|
|
58
58
|
FUNDS["Accounting - SSOT for funds<br/>available, virtual, committed<br/>btsFeesOwed<br/>Avail = max 0 ChainFree minus Virtual minus Fees"]
|
|
59
|
-
TARGET[Strategy Engine<br/>calculateTargetGrid<br/>boundary-crawl pivot<br/>partial
|
|
59
|
+
TARGET[Strategy Engine<br/>calculateTargetGrid<br/>boundary-crawl pivot<br/>partial correction, rotation]
|
|
60
60
|
WORKGRID[WorkingGrid - COW copy<br/>all mutations here only<br/>commit to Master on confirmation]
|
|
61
61
|
FILLQUEUE[Fill Queue<br/>AsyncLock + dedup 5-60 min]
|
|
62
62
|
BATCHER[Fixed-Cap Batcher<br/>queue within cap: unified batch<br/>queue above cap: chunk at cap size<br/>cap = gapSlots + 1]
|
|
@@ -443,7 +443,7 @@ The fill pipeline handles incoming filled orders efficiently through fixed-cap b
|
|
|
443
443
|
|
|
444
444
|
Scenario source: 29-fill burst during the Feb 7 market crash, modeled at
|
|
445
445
|
roughly 3 seconds per broadcast; see
|
|
446
|
-
[`FUND_MOVEMENT_AND_ACCOUNTING.md`](FUND_MOVEMENT_AND_ACCOUNTING.md#
|
|
446
|
+
[`FUND_MOVEMENT_AND_ACCOUNTING.md`](FUND_MOVEMENT_AND_ACCOUNTING.md#15-fill-batch-processing--timeline).
|
|
447
447
|
|
|
448
448
|
| Metric | Legacy (1-at-a-time) | Fixed-Cap Batching | Improvement |
|
|
449
449
|
|--------|---------------------|-------------------|-------------|
|
|
@@ -464,46 +464,53 @@ Instead of complex partial handling, spread corrections are **conservative and f
|
|
|
464
464
|
- Target spread width stays **constant** at `targetSpreadPercent`
|
|
465
465
|
- Corrections scale with **actual available funds**, not arbitrary slot budgets
|
|
466
466
|
- No dynamic spread inflation based on partial consolidation flags
|
|
467
|
-
-
|
|
467
|
+
- Safe window-contiguous candidate ordering (with an edge-first fallback) prevents cross-side placement
|
|
468
468
|
|
|
469
469
|
### Algorithm
|
|
470
470
|
|
|
471
|
-
**Location**: `modules/order/
|
|
471
|
+
**Location**: `modules/order/grid.ts::prepareSpreadCorrectionOrders()`, selected by
|
|
472
|
+
`modules/order/grid.ts::determineOrderSideByFunds()`.
|
|
472
473
|
|
|
473
|
-
The
|
|
474
|
+
The correction path is fund-only and never manufactures budget by shrinking a resting order:
|
|
474
475
|
|
|
475
476
|
```
|
|
476
|
-
1. Detect that
|
|
477
|
-
2.
|
|
478
|
-
3.
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
6.
|
|
477
|
+
1. Detect that the live window is wider than targetSpreadPercent.
|
|
478
|
+
2. Select up to `outOfSpread` eligible holes in safe window/gap order.
|
|
479
|
+
3. If the funded edge holds a non-dust PARTIAL, optionally top it up, but only
|
|
480
|
+
when `ideal - current` is positive and free funds can cover the increase.
|
|
481
|
+
4. Create replacements from free available/chainFree funds; contiguous gap-slot
|
|
482
|
+
promotion may extend the window while preserving MIN_SPREAD_ORDERS and the
|
|
483
|
+
opposite placed rail.
|
|
484
|
+
5. If free funds cannot cover every target, place/top up the affordable prefix,
|
|
485
|
+
stop without shrinking inventory, and log the fund-constrained remainder.
|
|
486
|
+
6. If neither side has free funds, skip correction and let the maintenance
|
|
487
|
+
runtime refresh balances and open orders rather than recycle stale inventory.
|
|
486
488
|
```
|
|
487
489
|
|
|
490
|
+
Detected dust partials never enter this path: `cancelDustOrders()` cancels them
|
|
491
|
+
on-chain immediately, and the five-minute health check is only a restart safety net.
|
|
492
|
+
|
|
488
493
|
### Fund-Safe Constraints
|
|
489
494
|
|
|
490
495
|
Spread corrections respect these hard limits:
|
|
491
496
|
|
|
492
497
|
```javascript
|
|
493
498
|
// In modules/constants.ts (GRID_LIMITS)
|
|
494
|
-
MIN_SPREAD_ORDERS: 2, //
|
|
499
|
+
MIN_SPREAD_ORDERS: 2, // Preserve the minimum empty gap reserve
|
|
495
500
|
|
|
496
|
-
//
|
|
497
|
-
//
|
|
501
|
+
// `outOfSpread` supplies the requested slot count. Execution is bounded by
|
|
502
|
+
// safe candidate selection, healthy minimum sizes, and actual free funds.
|
|
503
|
+
const availableFund = Math.max(0, Math.min(
|
|
504
|
+
manager.funds.available[side],
|
|
505
|
+
manager.accountTotals[side === 'buy' ? 'buyFree' : 'sellFree']
|
|
506
|
+
));
|
|
498
507
|
|
|
499
|
-
// Each
|
|
500
|
-
|
|
501
|
-
const affordableOrderCount = Math.floor(availableFunds / minHealthySize);
|
|
502
|
-
const correctionOrders = Math.min(missingSlots, affordableOrderCount);
|
|
508
|
+
// Each target is created or topped up only while remainingBudget covers it.
|
|
509
|
+
// No resting ACTIVE/PARTIAL order is shrunk to fund the correction.
|
|
503
510
|
```
|
|
504
511
|
|
|
505
512
|
**Benefits**:
|
|
506
|
-
- ✅ No
|
|
513
|
+
- ✅ No inventory recycling from stale-size snapshots
|
|
507
514
|
- ✅ Constant, predictable spread width
|
|
508
515
|
- ✅ Funds always respected (no forced allocation)
|
|
509
516
|
- ✅ Natural smoothing over multiple rebalance cycles
|
|
@@ -591,12 +598,11 @@ if (mgr.outOfSpread) {
|
|
|
591
598
|
### After (Numeric Distance)
|
|
592
599
|
|
|
593
600
|
```javascript
|
|
594
|
-
// New approach:
|
|
595
|
-
mgr.outOfSpread = 3; //
|
|
601
|
+
// New approach: requested missing slots derived from the live geometry
|
|
602
|
+
mgr.outOfSpread = 3; // three slots beyond the target spread
|
|
596
603
|
|
|
597
|
-
//
|
|
598
|
-
|
|
599
|
-
const replacementSlots = Math.min(spreadDistance, MAX_CORRECTION_SLOTS);
|
|
604
|
+
// The grid engine bounds actual work by eligible candidates, MIN_SPREAD_ORDERS,
|
|
605
|
+
// healthy sizes, and available free funds. There is no MAX_CORRECTION_SLOTS cap.
|
|
600
606
|
```
|
|
601
607
|
|
|
602
608
|
**Benefit**: Enables scaled corrections based on actual severity.
|
|
@@ -706,7 +712,7 @@ stateDiagram-v2
|
|
|
706
712
|
|
|
707
713
|
note right of PARTIAL
|
|
708
714
|
Partially filled on-chain
|
|
709
|
-
|
|
715
|
+
Dust is cancelled immediately; non-dust is corrected in rebalance
|
|
710
716
|
end note
|
|
711
717
|
```
|
|
712
718
|
|
|
@@ -881,7 +887,7 @@ sequenceDiagram
|
|
|
881
887
|
Strat-->>Mgr: target grid
|
|
882
888
|
Mgr->>Mgr: Apply rotations via WorkingGrid
|
|
883
889
|
Mgr->>Acct: Deduct BTS fees during recalculateFunds
|
|
884
|
-
Mgr->>Mgr:
|
|
890
|
+
Mgr->>Mgr: Cancel detected dust partials immediately
|
|
885
891
|
```
|
|
886
892
|
|
|
887
893
|
### 2. Order Rotation (Crawl Mechanism)
|
|
@@ -1059,7 +1065,7 @@ The system has been optimized to use a "memory-driven" model for order updates,
|
|
|
1059
1065
|
- **Faster reaction time**: No waiting for blockchain queries during order updates
|
|
1060
1066
|
- **Reduced API load**: Fewer fetches, less network congestion
|
|
1061
1067
|
- **Mathematical precision**: Integer-based tracking prevents float precision errors
|
|
1062
|
-
- *See [FUND_MOVEMENT_AND_ACCOUNTING.md § 5.5](FUND_MOVEMENT_AND_ACCOUNTING.md#55-precision--quantization
|
|
1068
|
+
- *See [FUND_MOVEMENT_AND_ACCOUNTING.md § 5.5](FUND_MOVEMENT_AND_ACCOUNTING.md#55-precision--quantization) for quantization utilities and best practices*
|
|
1063
1069
|
- **Fallback safety**: Automatic recovery if memory state becomes inconsistent
|
|
1064
1070
|
|
|
1065
1071
|
### Performance Impact
|
|
@@ -1155,8 +1161,6 @@ graph LR
|
|
|
1155
1161
|
B -->|Real-world Scenarios| B3["Fills/FEE Tests"]
|
|
1156
1162
|
|
|
1157
1163
|
C -->|Dynamic Weight| C1["dynamic_weight"]
|
|
1158
|
-
C -->|Derivative Trap| C2["derivative_signal"]
|
|
1159
|
-
C -->|Momentum Gate| C3["momentum_gate"]
|
|
1160
1164
|
|
|
1161
1165
|
D -->|CR Planner| D1["cr_planner"]
|
|
1162
1166
|
D -->|Credit Runtime| D2["credit_runtime"]
|
|
@@ -1189,13 +1193,12 @@ node dist/tests/test_dexbot_credit_wiring.js
|
|
|
1189
1193
|
- ✅ Edge cases covered (zero funds, max orders, etc.)
|
|
1190
1194
|
- ✅ Concurrent operations tested with locks
|
|
1191
1195
|
- ✅ State transitions validated end-to-end
|
|
1192
|
-
- ✅ Signal pipelines tested (dynamic weight
|
|
1196
|
+
- ✅ Signal pipelines tested (dynamic weight)
|
|
1193
1197
|
- ✅ Credit/debt runtime tested (CR planner, MPA wiring)
|
|
1194
1198
|
|
|
1195
1199
|
**Test Suite Evolution:**
|
|
1196
1200
|
- 50+ test cases for signal intelligence and credit runtime
|
|
1197
1201
|
- Dynamic weight override and market adapter signal gate tests
|
|
1198
|
-
- Derivative momentum gate and signal trap regression tests
|
|
1199
1202
|
- Credit/debt tests with CR planner and MPA wiring validation
|
|
1200
1203
|
|
|
1201
1204
|
### Testing Best Practices
|
|
@@ -1323,8 +1326,7 @@ The strategy engine has been significantly strengthened with improvements to fun
|
|
|
1323
1326
|
**2. Dust Partial Handling**
|
|
1324
1327
|
- Improved dust detection algorithm prevents false positives
|
|
1325
1328
|
- Detects dust as `< 5% of ideal order size`
|
|
1326
|
-
-
|
|
1327
|
-
- **Auto-Cancellation**: `_cancelDustOrders()` cancels dust partials on-chain immediately on detection — no delay, no timer maps, no retry budgets. Cancel is attempted post-fill (inside fill lock) and every 5-min health check (safety net).
|
|
1329
|
+
- **Immediate Cancellation**: `_cancelDustOrders()` cancels dust partials on-chain when detection runs — no delay, timer map, or consolidation cycle. Detection runs after fills/sync, and a 5-minute health check is the restart safety net.
|
|
1328
1330
|
|
|
1329
1331
|
**3. Strict Order Size Constraints**
|
|
1330
1332
|
- Orders validated to not exceed available funds
|
package/docs/developer_guide.md
CHANGED
|
@@ -129,8 +129,6 @@ A **phantom order** is an order in ACTIVE/PARTIAL state WITHOUT a valid `orderId
|
|
|
129
129
|
| **Kalman Confirmation** | Kalman-filtered trend signal blended with AMA slope for smoother weight transitions |
|
|
130
130
|
| **Symmetric Shift** | Volatility-driven downward weight penalty applied equally to both sides (ATR-based) |
|
|
131
131
|
| **Asymmetric Offset** | Directional weight shift (buy-heavy or sell-heavy) driven by AMA/Kalman trend |
|
|
132
|
-
| **Derivative Signal** | SMA/MACD/RSI-based entry bias and momentum gate for optional strategy filtering |
|
|
133
|
-
| **Momentum Gate** | N-bar commitment tracking that confirms derivative signals before acting |
|
|
134
132
|
| **GridPrice** | Price anchor for grid math; can be numeric, `"pool"`, `"book"`, or AMA keyword (`"ama"`, `"ama1"`–`"ama4"`) |
|
|
135
133
|
|
|
136
134
|
### Grid Concepts
|
|
@@ -165,7 +163,7 @@ A **phantom order** is an order in ACTIVE/PARTIAL state WITHOUT a valid `orderId
|
|
|
165
163
|
| Term | Meaning |
|
|
166
164
|
|------|---------|
|
|
167
165
|
| **Rotation** | Moving an order from one price level to another |
|
|
168
|
-
| **Consolidation** | Absorbing dust partials into
|
|
166
|
+
| **Consolidation** | Absorbing surviving non-dust partials into ordinary fund-driven rebalancing. Detected dust is cancelled immediately and never waits for a rebuild. |
|
|
169
167
|
| **Rebalancing** | Adjusting order sizes based on current funds |
|
|
170
168
|
| **Global Side Capping** | Scaling order sizes when insufficient funds |
|
|
171
169
|
| **Atomic Check-and-Deduct** | Verify funds + deduct in single operation |
|
|
@@ -277,7 +275,7 @@ const correctedPrice = quantizeFloat(derivedPrice, 8);
|
|
|
277
275
|
const normalized = normalizeInt(currentSizeInt, assetPrecision);
|
|
278
276
|
```
|
|
279
277
|
|
|
280
|
-
**See [FUND_MOVEMENT_AND_ACCOUNTING.md § 5.5](FUND_MOVEMENT_AND_ACCOUNTING.md#55-precision--quantization
|
|
278
|
+
**See [FUND_MOVEMENT_AND_ACCOUNTING.md § 5.5](FUND_MOVEMENT_AND_ACCOUNTING.md#55-precision--quantization) for complete quantization guide and edge case handling.**
|
|
281
279
|
|
|
282
280
|
---
|
|
283
281
|
|
|
@@ -620,7 +618,7 @@ const minHealthySize = getMinOrderSize(ORDER_TYPES.BUY, assets, 1.0);
|
|
|
620
618
|
if (isOrderHealthy(order, minHealthySize)) {
|
|
621
619
|
// Order is valid for placement/rotation
|
|
622
620
|
} else {
|
|
623
|
-
// Order is dust -
|
|
621
|
+
// Order is dust - skip it here; cancelDustOrders() handles it on-chain
|
|
624
622
|
}
|
|
625
623
|
```
|
|
626
624
|
|
|
@@ -737,7 +735,7 @@ _verifyFundInvariants(...)
|
|
|
737
735
|
- Process filled orders
|
|
738
736
|
- Identify shortages and surpluses
|
|
739
737
|
- Execute order rotations
|
|
740
|
-
- Handle
|
|
738
|
+
- Handle surviving non-dust partials during rebalance
|
|
741
739
|
|
|
742
740
|
**Critical Methods**:
|
|
743
741
|
```javascript
|
|
@@ -1211,8 +1209,6 @@ Located in `tests/` (with `helpers/` subdirectory):
|
|
|
1211
1209
|
- `test_bts_fee_logic.ts` - BTS fee deduction and settlement
|
|
1212
1210
|
- `test_market_adapter_signal_gates.ts` - Market adapter signal validation
|
|
1213
1211
|
- `test_dynamic_weight_override_wiring.ts` - Dynamic weight config wiring
|
|
1214
|
-
- `test_derivative_signal_trap_regression.ts` - Derivative signal trap tests
|
|
1215
|
-
- `test_derivative_momentum_gate.ts` - Momentum gate tests
|
|
1216
1212
|
- `test_cr_planner.ts` - Collateral ratio planner tests
|
|
1217
1213
|
- `test_dexbot_credit_wiring.ts` - Credit runtime integration tests
|
|
1218
1214
|
- `test_credential_daemon.ts` / `test_credential_session_cache.ts` - Credential security tests
|
package/market_adapter/README.md
CHANGED
|
@@ -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 bot` → `6) Adapter` |
|
|
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) | `6) Adapter` → Weight |
|
|
27
|
-
| Widen/tighten grid bounds by trend | [Grid Range Scaling](#grid-range-scaling) | `6) Adapter` → Range |
|
|
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) | `6) Adapter` flags |
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
|
|
@@ -309,7 +310,7 @@ Dry-run log lines include `[DRY RUN]` or `[suppressed, dry-run]`.
|
|
|
309
310
|
| Task | Command |
|
|
310
311
|
|------|---------|
|
|
311
312
|
| Enable/inspect Price, Weight, Range for a bot | `dexbot bot` → `2) Modify bot` → `6) Adapter` |
|
|
312
|
-
| Remove a deleted bot's entry | Automatic — `dexbot bot` → `3) Delete` also drops its whitelist key |
|
|
313
|
+
| Remove a deleted bot's entry | Automatic — `dexbot bot` → `3) Delete bot` also drops its whitelist key |
|
|
313
314
|
| Probe public CEX availability | `node dist/market_adapter/inputs/fetch_cex_synthetic_data.js --exchange auto --check-only` |
|
|
314
315
|
| Seed synthetic cross candles | `node dist/market_adapter/inputs/fetch_cex_synthetic_data.js --exchange auto --bot-key <bot-key>` |
|
|
315
316
|
| Run one adapter cycle | `node dist/market_adapter/market_adapter.js --once` |
|
|
@@ -348,7 +349,7 @@ match the bot's eventual `botKey`.
|
|
|
348
349
|
- Check `lastDeltaPercent` vs `thresholdPercent`.
|
|
349
350
|
- Check `staleData` and `staleAgeHours`.
|
|
350
351
|
- **Confirm the bot is whitelisted.** Non-whitelisted bots only log and do not write triggers.
|
|
351
|
-
- Confirm the bot's whitelist entry has `"ama": true` (`dexbot bot` → `6) Adapter` shows it as **Price**).
|
|
352
|
+
- Confirm the bot's whitelist entry has `"ama": true` (`dexbot bot` → `2) Modify bot` → `6) Adapter` shows it as **Price**).
|
|
352
353
|
- Run `node dist/market_adapter/market_adapter.js --once --deltaPercent <lower-value>` for a one-cycle threshold test.
|
|
353
354
|
|
|
354
355
|
### Trigger fires too often
|
|
@@ -586,6 +587,9 @@ market_adapter/
|
|
|
586
587
|
|-- inputs/
|
|
587
588
|
| |-- kibana_source.ts Elasticsearch LP data source
|
|
588
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
|
|
589
593
|
| `-- fetch_cex_synthetic_data.ts public CEX synthetic-candle seed importer
|
|
590
594
|
|-- utils/
|
|
591
595
|
| |-- chain.ts blockchain query helpers
|
|
@@ -604,7 +608,7 @@ market_adapter/
|
|
|
604
608
|
### Whitelist Semantics
|
|
605
609
|
|
|
606
610
|
`profiles/market_adapter_whitelist.json` controls live writes. It is edited
|
|
607
|
-
per bot in the bot editor (`dexbot bot` → `6) Adapter`), which reads and
|
|
611
|
+
per bot in the bot editor (`dexbot bot` → `2) Modify bot` → `6) Adapter`), which reads and
|
|
608
612
|
writes this same file:
|
|
609
613
|
|
|
610
614
|
```json
|
|
@@ -828,9 +832,9 @@ suppress writes via `unresolved_candle_gaps` until repaired on a future cycle.
|
|
|
828
832
|
The adapter prunes old candles to the required AMA window and acts only on
|
|
829
833
|
closed 1h candles.
|
|
830
834
|
|
|
831
|
-
#### Shared
|
|
835
|
+
#### Shared Month-Shard Cache and Fetch Robustness
|
|
832
836
|
|
|
833
|
-
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.
|
|
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.
|
|
834
838
|
|
|
835
839
|
#### AMA Warmup Window — Why Candle Length Matters
|
|
836
840
|
|
package/modules/README.md
CHANGED
|
@@ -163,7 +163,7 @@ External consumers — other parts of DEXBot2 interact with modules through thes
|
|
|
163
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.
|
|
164
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.
|
|
165
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.
|
|
166
|
-
- **
|
|
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.
|
|
167
167
|
|
|
168
168
|
## Related
|
|
169
169
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dexbot",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.7",
|
|
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",
|
|
@@ -86,7 +90,6 @@
|
|
|
86
90
|
"market-adapter:fetch-cex-synthetic": "npm run build && node dist/market_adapter/inputs/fetch_cex_synthetic_data.js",
|
|
87
91
|
"analysis:tradingview": "npm run build && node dist/analysis/tradingview/analyze_tradingview.js",
|
|
88
92
|
"ama:chart:lp-local": "npm run build && node dist/analysis/ama_fitting/generate_unified_comparison_chart.js",
|
|
89
|
-
"analysis:derivatives": "npm run build && node dist/analysis/analyze_derivatives.js",
|
|
90
93
|
"analysis:trade-pnl": "npm run build && node dist/analysis/trade_profitability.js",
|
|
91
94
|
"analysis:grid-check": "npm run build && node dist/analysis/grid_correction_check.js",
|
|
92
95
|
"analysis:resolve-accounts": "npm run build && node dist/analysis/resolve_bot_accounts.js",
|
|
@@ -95,15 +98,16 @@
|
|
|
95
98
|
"native:ecc-invariants": "npm run build && npm run build:tests && node dist/tests/test_native_ecc.js",
|
|
96
99
|
"native:corpus": "npm run build && node dist/scripts/generate_mainnet_corpus_report.js",
|
|
97
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",
|
|
98
102
|
"version:sync": "npm run build && node dist/scripts/sync-version.js",
|
|
99
103
|
"version:check": "npm run build && node dist/scripts/sync-version.js --check",
|
|
100
104
|
"verify:browser-bundle": "npm run build && node dist/scripts/verify-browser-bundle.js",
|
|
101
105
|
"test": "npm run build && npm run build:tests && npm run build --prefix claw && node dist/scripts/run-tests.js",
|
|
102
106
|
"test:live": "RUN_LIVE_BITSHARES_TESTS=1 npm run build && npm run build:tests && npm run build --prefix claw && node dist/scripts/run-tests.js",
|
|
103
107
|
"clean": "node scripts/clean-dist.js",
|
|
104
|
-
"build": "tsc && chmod +x dist/dexbot.js dist/bot.js dist/unlock.js dist/pm2.js dist/credential-daemon.js",
|
|
108
|
+
"build": "echo \"tsc is compiling ...\" && tsc && chmod +x dist/dexbot.js dist/bot.js dist/unlock.js dist/pm2.js dist/credential-daemon.js",
|
|
105
109
|
"build:clean": "npm run clean && npm run build",
|
|
106
|
-
"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",
|
|
107
111
|
"typecheck": "tsc --noEmit",
|
|
108
112
|
"typecheck:tests": "tsc -p tsconfig.tests.json --noEmit",
|
|
109
113
|
"build:watch": "tsc --watch",
|
package/scripts/README.md
CHANGED
|
@@ -341,7 +341,6 @@ The following scripts allow you to call `dexbot` commands directly from the `scr
|
|
|
341
341
|
| Command | Purpose |
|
|
342
342
|
|:---|:---|
|
|
343
343
|
| `npm run market-adapter:fetch-cex-synthetic` | Fetch CEX synthetic data for market adapter |
|
|
344
|
-
| `npm run analysis:derivatives` | Derivative analysis report |
|
|
345
344
|
| `npm run analysis:tradingview` | TradingView-style chart export |
|
|
346
345
|
| `npm run analysis:trade-pnl` | Trade PnL analysis from fill data |
|
|
347
346
|
| `npm run ama:chart:lp-local` | Generate local LP comparison chart |
|
|
@@ -410,14 +409,6 @@ npm run lp:chart -- --data <lp-export.json>
|
|
|
410
409
|
npm run ama:chart:lp-local -- --data <lp-export.json>
|
|
411
410
|
```
|
|
412
411
|
|
|
413
|
-
### Derivative Trend Analysis
|
|
414
|
-
**File:** `analysis/analyze_derivatives.ts`
|
|
415
|
-
**Purpose:** Generate the derivative analysis report.
|
|
416
|
-
```bash
|
|
417
|
-
# Generate the derivative analysis report
|
|
418
|
-
npm run analysis:derivatives -- --source json --file <file.json>
|
|
419
|
-
```
|
|
420
|
-
|
|
421
412
|
---
|
|
422
413
|
|
|
423
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-open \`dexbot bot\` → 6) Adapter 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.5",
|
|
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
|
-
}
|