dexbot 1.4.19 → 1.4.21
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 -0
- package/README.md +22 -12
- package/analysis/ama_fitting/analyze_lambda_vs_slow.ts +2 -2
- package/analysis/ama_fitting/calibrate_convergence_er.ts +1 -1
- package/analysis/ama_fitting/optimizer_high_resolution.ts +2 -1
- package/analysis/ama_fitting/package.json +1 -1
- package/analysis/analyze_derivatives.ts +4 -2
- package/analysis/analyze_dynamic_weight.ts +3 -1
- package/analysis/analyze_kalman.ts +3 -1
- package/analysis/analyze_regime.ts +3 -1
- package/analysis/analyze_regime_windows.ts +3 -1
- package/analysis/analyze_volatility.ts +2 -2
- package/analysis/bot_fitting/backtest_ama_sweep.ts +2 -1
- package/analysis/bot_fitting/backtest_bot_fitting.ts +17 -12
- package/analysis/bot_fitting/shared_utils.ts +1 -1
- package/analysis/bot_key_utils.ts +1 -5
- package/analysis/bot_usage/kibana_bot_queries.ts +1 -256
- package/analysis/chart_css.ts +1 -1
- package/analysis/chart_utils.ts +24 -0
- package/analysis/derivative_chart_generator.ts +3 -2
- package/analysis/math_utils.ts +1 -8
- package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +1 -1
- package/analysis/trend_detection/dynamic_weight_chart_generator.ts +91 -55
- package/analysis/trend_detection/package.json +1 -1
- package/claw/ecosystem.config.cjs +2 -3
- package/claw/examples/claw_profiles_example.ts +4 -1
- package/claw/examples/memu_integration_example.ts +17 -17
- package/claw/modules/chain_actions.ts +51 -54
- package/claw/modules/chain_broadcast.ts +66 -104
- package/claw/modules/claw_bridge.ts +60 -80
- package/claw/modules/claw_catalog.ts +48 -17
- package/claw/modules/claw_infra.ts +1 -5
- package/claw/modules/claw_launcher.ts +47 -49
- package/claw/modules/claw_skill_md.ts +14 -16
- package/claw/modules/credit_runtime_adapter.ts +2 -18
- package/claw/modules/decision_loop.ts +4 -0
- package/claw/modules/dexbot_bridge.ts +1 -1
- package/claw/modules/dexbot_profiles.ts +8 -22
- package/claw/modules/honest_ecosystem.ts +24 -8
- package/claw/modules/launcher_paths.ts +4 -2
- package/claw/modules/liquidity_pools.ts +10 -3
- package/claw/modules/mcp_utils.ts +109 -0
- package/claw/modules/memu_bridge.ts +76 -54
- package/claw/modules/mpa_utils.ts +26 -3
- package/claw/modules/position_discovery.ts +16 -27
- package/claw/modules/position_manager.ts +32 -41
- package/claw/modules/position_manager_watch.ts +3 -2
- package/claw/modules/short_mpa_strategy.ts +1 -9
- package/claw/modules/skill_utils.ts +5 -3
- package/claw/modules/utils.ts +9 -1
- package/claw/package.json +1 -1
- package/claw/runtimes/openclaw-plugin/index.ts +27 -10
- package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
- package/claw/runtimes/openclaw-plugin/package.json +1 -1
- package/claw/scripts/claw_bridge.ts +1 -1
- package/claw/scripts/claw_mcp_server.ts +19 -78
- package/claw/scripts/honest_assets_report.ts +19 -84
- package/claw/scripts/memu_mcp_server.ts +57 -155
- package/claw/tests/test_claw_bridge.ts +6 -2
- package/claw/tests/test_claw_mcp_transport.ts +2 -2
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +2 -2
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js.map +1 -1
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js +1 -1
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js.map +1 -1
- package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts.map +1 -1
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js +2 -1
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js.map +1 -1
- package/dist/analysis/analyze_derivatives.d.ts.map +1 -1
- package/dist/analysis/analyze_derivatives.js +4 -2
- package/dist/analysis/analyze_derivatives.js.map +1 -1
- package/dist/analysis/analyze_dynamic_weight.js +3 -1
- package/dist/analysis/analyze_dynamic_weight.js.map +1 -1
- package/dist/analysis/analyze_kalman.js +3 -1
- package/dist/analysis/analyze_kalman.js.map +1 -1
- package/dist/analysis/analyze_regime.js +3 -1
- package/dist/analysis/analyze_regime.js.map +1 -1
- package/dist/analysis/analyze_regime_windows.js +3 -1
- package/dist/analysis/analyze_regime_windows.js.map +1 -1
- package/dist/analysis/analyze_volatility.js +2 -2
- package/dist/analysis/analyze_volatility.js.map +1 -1
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts.map +1 -1
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js +2 -1
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js.map +1 -1
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js +18 -13
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js.map +1 -1
- package/dist/analysis/bot_fitting/shared_utils.d.ts +1 -12
- package/dist/analysis/bot_fitting/shared_utils.d.ts.map +1 -1
- package/dist/analysis/bot_fitting/shared_utils.js +1 -1
- package/dist/analysis/bot_fitting/shared_utils.js.map +1 -1
- package/dist/analysis/bot_key_utils.d.ts +1 -1
- package/dist/analysis/bot_key_utils.d.ts.map +1 -1
- package/dist/analysis/bot_key_utils.js +1 -5
- package/dist/analysis/bot_key_utils.js.map +1 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts +1 -337
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +1 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.js +1 -241
- package/dist/analysis/bot_usage/kibana_bot_queries.js.map +1 -1
- package/dist/analysis/chart_css.d.ts +1 -15
- package/dist/analysis/chart_css.d.ts.map +1 -1
- package/dist/analysis/chart_css.js +1 -1
- package/dist/analysis/chart_css.js.map +1 -1
- package/dist/analysis/chart_utils.d.ts +0 -3
- package/dist/analysis/chart_utils.d.ts.map +1 -1
- package/dist/analysis/chart_utils.js +25 -0
- package/dist/analysis/chart_utils.js.map +1 -1
- package/dist/analysis/derivative_chart_generator.d.ts.map +1 -1
- package/dist/analysis/derivative_chart_generator.js +3 -2
- package/dist/analysis/derivative_chart_generator.js.map +1 -1
- package/dist/analysis/math_utils.d.ts +3 -5
- package/dist/analysis/math_utils.d.ts.map +1 -1
- package/dist/analysis/math_utils.js +3 -5
- package/dist/analysis/math_utils.js.map +1 -1
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +1 -1
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +82 -50
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +1 -1
- package/dist/bot.js +2 -2
- package/dist/bot.js.map +1 -1
- package/dist/credential-daemon.js +1 -1
- package/dist/credential-daemon.js.map +1 -1
- package/dist/dexbot.d.ts.map +1 -1
- package/dist/dexbot.js +20 -17
- package/dist/dexbot.js.map +1 -1
- package/dist/market_adapter/ama_signal_runner.js +3 -3
- package/dist/market_adapter/core/kibana_client.d.ts +1 -3
- package/dist/market_adapter/core/kibana_client.d.ts.map +1 -1
- package/dist/market_adapter/core/kibana_client.js +1 -1
- package/dist/market_adapter/core/kibana_client.js.map +1 -1
- package/dist/market_adapter/core/market_adapter_service.d.ts +1 -2
- package/dist/market_adapter/core/market_adapter_service.d.ts.map +1 -1
- package/dist/market_adapter/core/market_adapter_service.js +9 -4
- package/dist/market_adapter/core/market_adapter_service.js.map +1 -1
- package/dist/market_adapter/core/strategies/regime_gate.d.ts +1 -2
- package/dist/market_adapter/core/strategies/regime_gate.d.ts.map +1 -1
- package/dist/market_adapter/core/strategies/regime_gate.js +1 -1
- package/dist/market_adapter/core/strategies/regime_gate.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +2 -2
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +5 -5
- package/dist/market_adapter/inputs/fetch_lp_data.js +5 -5
- package/dist/market_adapter/inputs/kibana_source.d.ts +1 -2
- package/dist/market_adapter/inputs/kibana_source.d.ts.map +1 -1
- package/dist/market_adapter/inputs/kibana_source.js +1 -1
- package/dist/market_adapter/inputs/kibana_source.js.map +1 -1
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts +1 -2
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts.map +1 -1
- package/dist/market_adapter/lp_chart_strategy_loader.js +4 -4
- package/dist/market_adapter/lp_chart_strategy_loader.js.map +1 -1
- package/dist/market_adapter/market_adapter.d.ts.map +1 -1
- package/dist/market_adapter/market_adapter.js +2 -1
- package/dist/market_adapter/market_adapter.js.map +1 -1
- package/dist/modules/account_bots.d.ts +3 -0
- package/dist/modules/account_bots.d.ts.map +1 -1
- package/dist/modules/account_bots.js +156 -46
- package/dist/modules/account_bots.js.map +1 -1
- package/dist/modules/account_orders.d.ts +1 -7
- package/dist/modules/account_orders.d.ts.map +1 -1
- package/dist/modules/account_orders.js +9 -17
- package/dist/modules/account_orders.js.map +1 -1
- package/dist/modules/bitshares_client.d.ts +2 -14
- package/dist/modules/bitshares_client.d.ts.map +1 -1
- package/dist/modules/bitshares_client.js +22 -31
- package/dist/modules/bitshares_client.js.map +1 -1
- package/dist/modules/bot_settings.js +1 -1
- package/dist/modules/bot_settings.js.map +1 -1
- package/dist/modules/chain_keys.js +2 -2
- package/dist/modules/chain_keys.js.map +1 -1
- package/dist/modules/chain_orders.d.ts +2 -3
- package/dist/modules/chain_orders.d.ts.map +1 -1
- package/dist/modules/chain_orders.js +8 -25
- package/dist/modules/chain_orders.js.map +1 -1
- package/dist/modules/config.d.ts +2 -0
- package/dist/modules/config.d.ts.map +1 -1
- package/dist/modules/config.js +6 -1
- package/dist/modules/config.js.map +1 -1
- package/dist/modules/constants.d.ts +0 -1
- package/dist/modules/constants.d.ts.map +1 -1
- package/dist/modules/constants.js +1 -5
- package/dist/modules/constants.js.map +1 -1
- package/dist/modules/credential_policy.js +1 -1
- package/dist/modules/credential_policy.js.map +1 -1
- package/dist/modules/dexbot_class.d.ts.map +1 -1
- package/dist/modules/dexbot_class.js +3 -2
- package/dist/modules/dexbot_class.js.map +1 -1
- package/dist/modules/dexbot_cow_runtime.d.ts +0 -7
- package/dist/modules/dexbot_cow_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_cow_runtime.js +95 -0
- package/dist/modules/dexbot_cow_runtime.js.map +1 -1
- package/dist/modules/dexbot_state_recovery.d.ts.map +1 -1
- package/dist/modules/dexbot_state_recovery.js +22 -2
- package/dist/modules/dexbot_state_recovery.js.map +1 -1
- package/dist/modules/fund_registry.d.ts.map +1 -1
- package/dist/modules/fund_registry.js +5 -2
- package/dist/modules/fund_registry.js.map +1 -1
- package/dist/modules/launcher/bot_supervisor.d.ts.map +1 -1
- package/dist/modules/launcher/bot_supervisor.js +6 -7
- package/dist/modules/launcher/bot_supervisor.js.map +1 -1
- package/dist/modules/launcher/foreign_cred_daemon.d.ts.map +1 -1
- package/dist/modules/launcher/foreign_cred_daemon.js +6 -0
- package/dist/modules/launcher/foreign_cred_daemon.js.map +1 -1
- package/dist/modules/launcher/market_adapter_runtime.d.ts +2 -3
- package/dist/modules/launcher/market_adapter_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/market_adapter_runtime.js +7 -15
- package/dist/modules/launcher/market_adapter_runtime.js.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.js +1 -0
- package/dist/modules/launcher/monolithic_runtime.js.map +1 -1
- package/dist/modules/launcher/status_reporting.d.ts +1 -2
- package/dist/modules/launcher/status_reporting.d.ts.map +1 -1
- package/dist/modules/launcher/status_reporting.js +1 -4
- package/dist/modules/launcher/status_reporting.js.map +1 -1
- package/dist/modules/order/accounting.js +2 -2
- package/dist/modules/order/accounting.js.map +1 -1
- package/dist/modules/order/format.d.ts +0 -8
- package/dist/modules/order/format.d.ts.map +1 -1
- package/dist/modules/order/format.js +0 -8
- package/dist/modules/order/format.js.map +1 -1
- package/dist/modules/order/grid.d.ts.map +1 -1
- package/dist/modules/order/grid.js +146 -32
- package/dist/modules/order/grid.js.map +1 -1
- package/dist/modules/order/logger.js +1 -1
- package/dist/modules/order/logger.js.map +1 -1
- package/dist/modules/order/logger_state.d.ts +1 -13
- package/dist/modules/order/logger_state.d.ts.map +1 -1
- package/dist/modules/order/logger_state.js +1 -11
- package/dist/modules/order/logger_state.js.map +1 -1
- package/dist/modules/order/manager.d.ts +13 -0
- package/dist/modules/order/manager.d.ts.map +1 -1
- package/dist/modules/order/manager.js +75 -2
- package/dist/modules/order/manager.js.map +1 -1
- package/dist/modules/order/processed_fill_store.d.ts +0 -5
- package/dist/modules/order/processed_fill_store.d.ts.map +1 -1
- package/dist/modules/order/processed_fill_store.js +1 -12
- package/dist/modules/order/processed_fill_store.js.map +1 -1
- package/dist/modules/order/sync_engine.d.ts.map +1 -1
- package/dist/modules/order/sync_engine.js +10 -3
- package/dist/modules/order/sync_engine.js.map +1 -1
- package/dist/modules/order/utils/math.d.ts +80 -1
- package/dist/modules/order/utils/math.d.ts.map +1 -1
- package/dist/modules/order/utils/math.js +138 -2
- package/dist/modules/order/utils/math.js.map +1 -1
- package/dist/modules/order/utils/order.d.ts.map +1 -1
- package/dist/modules/order/utils/order.js +10 -2
- package/dist/modules/order/utils/order.js.map +1 -1
- package/dist/modules/paths.d.ts +26 -1
- package/dist/modules/paths.d.ts.map +1 -1
- package/dist/modules/paths.js +39 -6
- package/dist/modules/paths.js.map +1 -1
- package/dist/modules/runtime_settings.js +3 -1
- package/dist/modules/runtime_settings.js.map +1 -1
- package/dist/modules/settings_merge.d.ts.map +1 -1
- package/dist/modules/settings_merge.js +3 -1
- package/dist/modules/settings_merge.js.map +1 -1
- package/dist/modules/storage/browser_adapter.d.ts +8 -3
- package/dist/modules/storage/browser_adapter.d.ts.map +1 -1
- package/dist/modules/storage/browser_adapter.js +53 -4
- package/dist/modules/storage/browser_adapter.js.map +1 -1
- package/dist/modules/utils/sanitize_key.d.ts +7 -0
- package/dist/modules/utils/sanitize_key.d.ts.map +1 -0
- package/dist/modules/utils/sanitize_key.js +15 -0
- package/dist/modules/utils/sanitize_key.js.map +1 -0
- package/dist/pm2.js +6 -6
- package/dist/pm2.js.map +1 -1
- package/dist/scripts/analyze-git.js +2 -1
- package/dist/scripts/analyze-git.js.map +1 -1
- package/dist/scripts/analyze-orders.d.ts +2 -2
- package/dist/scripts/analyze-orders.d.ts.map +1 -1
- package/dist/scripts/analyze-orders.js +6 -14
- package/dist/scripts/analyze-orders.js.map +1 -1
- package/dist/scripts/runner.js +1 -1
- package/dist/scripts/runner.js.map +1 -1
- package/dist/scripts/update.js +1 -1
- package/dist/scripts/update.js.map +1 -1
- package/docs/BITSHARES_ONBOARDING.md +63 -18
- package/docs/COPY_ON_WRITE_MASTER_PLAN.md +5 -14
- package/docs/COW_INVARIANTS.md +4 -4
- package/docs/CREDENTIAL_SECURITY.md +0 -11
- package/docs/DEXBOT_COMPARISON.md +11 -11
- package/docs/EVOLUTION.md +12 -10
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +27 -83
- package/docs/GRID_RECALCULATION.md +1 -13
- package/docs/GRID_RECONCILE.md +24 -24
- package/docs/LIFECYCLE.md +4 -4
- package/docs/LOGGING.md +1 -1
- package/docs/MPA_CREDIT_USAGE.md +3 -3
- package/docs/README.md +2 -2
- package/docs/WORKFLOW.md +2 -2
- package/docs/architecture.md +43 -38
- package/docs/developer_guide.md +16 -18
- package/market_adapter/README.md +0 -2
- package/modules/README.md +2 -1
- package/package.json +2 -3
- package/scripts/README.md +1 -1
- package/scripts/lib/dexbot-paths.sh +20 -11
- package/claw/openclaw.plugin.json +0 -13
- package/dist/market_adapter/merge_lp_data.d.ts +0 -3
- package/dist/market_adapter/merge_lp_data.d.ts.map +0 -1
- package/dist/market_adapter/merge_lp_data.js +0 -125
- package/dist/market_adapter/merge_lp_data.js.map +0 -1
- package/dist/market_adapter/utils/paths.d.ts +0 -3
- package/dist/market_adapter/utils/paths.d.ts.map +0 -1
- package/dist/market_adapter/utils/paths.js +0 -5
- package/dist/market_adapter/utils/paths.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.4.21] - 2026-08-24 - Runtime Audit Fixes, Claw Dedup Hardening, Boundary Ceiling Alignment, Editor Color Feedback
|
|
6
|
+
|
|
7
|
+
### 2026-08-23
|
|
8
|
+
|
|
9
|
+
- **Feat(ui)**: red/green highlight for botFunds percentage inputs — extend the price-multiplier live color feedback to the Funding section of the account bots editor: percentage allocations ("100%") render green while fixed absolute amounts render red, matching the existing min/maxPrice multiplier treatment. New `isPercentageString`/`colorPercentageInput` helpers mirror `isMultiplierString`/`colorMultiplierInput` (the local percentage check is stricter than `order/utils/math.ts` so partial input like "x%" never flashes green mid-typing); `askNumberOrPercentage` colors its default suffix and wires the `readInput` colorize option, and the Funding summary line renders Sell/Buy values through the same colorizer (`modules/account_bots.ts`).
|
|
10
|
+
|
|
11
|
+
### 2026-08-24
|
|
12
|
+
|
|
13
|
+
- **Fix**: correct runtime defects found in a modules-wide audit — silent-failure and initialization-order defects could disable safety checks, defeat batching, or poison configuration at load time: `accounting.ts` falls back to `GRID_LIMITS.FUND_INVARIANT_PERCENT_TOLERANCE` when unset (undefined/100 produced NaN and silently disabled the fund invariant); `processed_fill_store.ts` flushes on batch size only when configured (previous `?? 0` comparison made `size >= 0` always true, flushing every write); `sync_engine.ts` tracks per-invocation `fillGuardLowered` so inner and outer finally blocks cannot double-decrement the shared `_fillBatchInFlight` counter under concurrent batches; `bitshares_client.ts` applies the configured node list even when node management is disabled, races node refresh against the remaining wait budget so it cannot overshoot the connection timeout, preserves `lastConnectionError` across disconnects, and reuses the shared `withTimeout` util; `config.ts` `num()` returns the default on empty or non-finite values instead of 0/NaN; `settings_merge.ts` keeps the base value when a raw override for an object section is not an object instead of spreading char-indexed garbage; `fund_registry.ts` clamps `totalAllocatedPct` at zero in `releaseAllocation` and logs loudly before resetting a corrupt registry file; `account_orders.ts` warns on corrupt profile files before falling back to empty state; `credential_policy.ts` uses `Object.hasOwn` for the allowedOps lookup; `dexbot_state_recovery.ts` normalizes stale-id input through a Set; `runtime_settings.ts` warns with bot-name context when market-adapter override resolution fails (`modules/order/accounting.ts`, `modules/order/processed_fill_store.ts`, `modules/order/sync_engine.ts`, `modules/bitshares_client.ts`, `modules/config.ts`, `modules/settings_merge.ts`, `modules/fund_registry.ts`, `modules/account_orders.ts`, `modules/credential_policy.ts`, `modules/dexbot_state_recovery.ts`, `modules/runtime_settings.ts`).
|
|
14
|
+
- **Fix(grid)**: align boundary writers and add a sell-rail ceiling to the commit gate — `deriveTargetBoundary` clamped to length−1 while `calculateFundDrivenBoundary` clamped to N−gapSlots−1, so fill-driven updates could walk the boundary onto or past the SELL rail where `resolveGapBand` re-derives zero-SELL geometry permanently on every cycle. `deriveTargetBoundary` now caps at N−gapSlots−1 matching the fund-driven writer (degenerate geometries fall back to the legacy ceiling preserving the current boundary); `validateBoundaryCommit` rejects proposals past the shared writer ceiling with stable reason `sell_rail_ceiling_exceeded`; `validatePersistedBoundary` inherits the rule so loadGrid restore and `recoverFromPersistedGrid` refuse past-ceiling snapshots and fall through to clean rebuild — legacy persisted snapshots whose boundary sits past the ceiling now trigger the documented rebuild path instead of silently re-legalizing broken geometry (`modules/order/utils/order.ts`, `modules/order/utils/math.ts`, `tests/test_boundary_restore_validation.ts`).
|
|
15
|
+
- **Refactor(claw)**: dedupe shared logic, remove dead code, harden error paths — bug fixes: `position_manager` guards `syncPosition` against unresolved MPA assets and persists close events before the catch-guarded sync; `dexbot_profiles` fixes spread order in `normalizeBotEntries` so active coercion actually applies; `chain_actions.listenForFills` awaits the subscribe promise before registering callbacks so failures surface as errors instead of unhandled rejections; `memu_mcp_server` redacts malformed `--llm-profile`/`--db-config` values in parse errors (secret leak); `claw_launcher.spawnDetached()` waits one macrotask for async spawn errors instead of returning false `started:true`; `mcp_utils` treats stdin EPIPE/EIO as EOF rather than crashing mid-session and maps tools/list catalog failures to −32603; `decision_loop.resetAnalyzers` clears marketPremiums; honest-ecosystem logs live pool-reserve fetch failures and returns null for unhonorable pinned poolRefs; `position_discovery` actually resolves asset triples in parallel; `memu_bridge` adds an EPIPE guard and the openclaw plugin returns isError results. Deduplication: shared `createJsonRpcToolsHandler()`/`jsonRpcError()`, single `validateMemuCommandArgs()` spec, extracted `viaCredentialDaemon()` broadcast path, unified `computeCallOrderAmounts()` call-order math; ~25 unused exports removed across profiles/infra/launcher/ecosystem/bridge modules plus the orphan `claw/openclaw.plugin.json` stale copy (`claw/modules/*`, `claw/scripts/memu_mcp_server.ts`, `claw/openclaw.plugin.json`).
|
|
16
|
+
- **Fix(launcher)**: supervisor and runtime lifecycle corrections — `bot_supervisor.ts` enforces memory limits only for apps that define one (the previous global fallback restarted unlimited apps at MAX_MEMORY_MB) and the status banner prints real per-app limits; `foreign_cred_daemon.ts` SIGKILL path polls liveness until timeout like SIGTERM instead of a single immediate check that could race process exit; `monolithic_runtime.ts` resolves the updater close promise on spawn error (ENOENT left it pending forever and hung the update flow); `market_adapter_runtime.ts` simplifies `isLockStale` to pid-liveness semantics (the mtime branch was unreachable dead logic) (`modules/launcher/bot_supervisor.ts`, `modules/launcher/foreign_cred_daemon.ts`, `modules/launcher/monolithic_runtime.ts`, `modules/launcher/market_adapter_runtime.ts`).
|
|
17
|
+
- **Fix(storage)**: persist deletions, debounce flushes, guard ingest in the browser adapter — deleted files resurrected after reload because unlink never reached IndexedDB; writes required a manual flush call to persist at all; records mutated before the startup load cursor reached them were clobbered by stale IndexedDB state. Deletions are now tracked as tombstones replayed as IndexedDB deletes on flush (cleared only after a successful transaction, so failed flushes replay deletes on the next cycle), mutations schedule a debounced 500ms flush, and the initial load skips tombstoned and locally-mutated keys so pre-load unlinks and writes win over stored records (`modules/storage/browser_adapter.ts`).
|
|
18
|
+
- **Fix(paths)**: stop hardcoding repo-relative `profiles/*` paths in docs and user-facing messages — docs and runtime/error strings still referenced the legacy repo-relative `profiles/logs`, `profiles/bots.json`, and `profiles/keys.json` locations after state resolution moved to the PATHS resolver in v1.4.15/1.4.16, landing npm-install users on paths that do not exist. BITSHARES_ONBOARDING.md rewrites "Where are the logs?" with the resolver-aware location and completes the log-file table (dexbot-cred.log, dexbot-adapter/-error.log, market_adapter.log, dexbot-update/-error.log were undocumented); WORKFLOW.md and scripts/README.md rows corrected; key-vault/bots-not-found/watchdog/update/analyze error messages now print resolver-derived paths; CLI help documents the `<profiles>` resolution rule. No behavioral change: all file I/O already routed through the resolver (`docs/BITSHARES_ONBOARDING.md`, `docs/WORKFLOW.md`, `scripts/README.md`, `credential-daemon.ts`, `modules/chain_keys.ts`, `pm2.ts`, `bot.ts`, `claw/modules/claw_launcher.ts`, `modules/dexbot_class.ts`, `scripts/update.ts`, `dexbot.ts`).
|
|
19
|
+
- **Feat(ui)**: live green/red highlighting for price inputs in the bot editor — extends the bot-editor color feedback to the remaining price fields: startPrice and gridPrice inputs colorize live (green for dynamic sources "pool"/"book"/AMA keywords, red for fixed numeric anchors); null gridPrice resolves through startPrice so the default label inherits the matching color; Active/DryRun flags render green in their healthy state; targetSpreadPercent prompt rounds minimum/validation/input display to 2 decimals instead of surfacing 6-decimal floats (`modules/account_bots.ts`).
|
|
20
|
+
- **Fix(client)**: skip disconnect teardown when the client was never initialized — `disconnectClient()` called `ensureInitialized()`, which lazily built the whole client stack (including the node-config log) just to discard it immediately, e.g. running `dexbot bot` after an idle bot-manager session; it now returns early when not initialized (`modules/bitshares_client.ts`).
|
|
21
|
+
- **Refactor(orders)**: remove the sub-unit price nudge from `buildUpdateOrderOp` — sub-unit price changes that round to the same `min_to_receive` were nudged by one unit to force an update operation; dust orders are cancelled rather than updated now, so the nudge only produced churn broadcasts with no economic effect and masked genuine no-op skips. Unchanged rounded amount+price is treated as no-op returning null; callers count the skip and restore affected slots via `restoreSkippedUpdateSlotsInWorkingGrid` (`modules/chain_orders.ts`).
|
|
22
|
+
- **Refactor**: remove dead code and consolidate duplicated helpers across analysis/market_adapter — delete `market_adapter/merge_lp_data.ts` and `market_adapter/utils/paths.ts` (no importers); prune ~180 lines of unused query builders/wrappers from `analysis/bot_usage/kibana_bot_queries.ts`; un-export zero-consumer symbols (kibana_client INDEX/KIBANA_URL, `normalizeAmaSlopeLookbackBars`, `loadStrategiesFromResults`, kibanaSearch/bilinearInterpolate re-exports, candle high/low/ATR re-exports, internal CSS fragments, `toCandles`); add `modules/utils/sanitize_key.ts` as the single sanitizeKey source; make the candleFileForBot filename template canonical in `analysis/bot_key_utils.ts` eliminating three-way filename drift; fix stale tsx invocation comments to node dist/ paths (`market_adapter/*`, `analysis/*`, `modules/utils/sanitize_key.ts`).
|
|
23
|
+
- **Chore(logging)**: remove dead state-change history and stale docs — logger_state changeHistory/maxHistory fields were written but never read anywhere; drop them plus the phantom audit-trail doc section and the now-unused `GRID_LIMITS.STATE_CHANGE_HISTORY_MAX`; console fund-status output keeps ANSI colors while the file drain strips them as before (`modules/order/logger_state.ts`, `modules/constants.ts`, `modules/order/logger.ts`).
|
|
24
|
+
- **Refactor(ui)**: centralize bot editor ANSI colors into a shared palette — the account-bots editor scattered raw ANSI escape sequences across ~40 lines; a module-level COLORS palette (13 named entries) now routes all ~152 highlight usages, input/error/OFF highlights use bold red matching the Pair line, rendering stays byte-identical for all other colors (`modules/account_bots.ts`).
|
|
25
|
+
- **Docs**: sync tuning guidance between the root README and the BitShares onboarding tutorial — README adds weightDistribution as optional setup step 3 (super-valley..super-mountain legend vocabulary), anchors steps 1–2 on the cycle-profit formula spread − increment − fees and the increment speed/fee tradeoff, documents ama1–ama4 presets in the gridPrice row, and adds a "prefer relative values" callout with editor green/red hints; BITSHARES_ONBOARDING.md mirrors the relative-values guidance, expands its tuning list to match, and fixes the broken prerequisite anchor link (`README.md`, `docs/BITSHARES_ONBOARDING.md`).
|
|
26
|
+
- **Test**: mute intentional failure-path logs in negative-path fixtures — the run diagnostics listed scary FAILED lines that were assertion-passing fixtures exercising failure branches, making real regressions harder to spot; `test_orphan_fill_death_spiral.ts` filters its two expected underfunding warnings and `test_patch17_invariants.ts` mutes expected COW/persist ERROR logs with restore-on-finally semantics; production log wording untouched (`tests/test_orphan_fill_death_spiral.ts`, `tests/test_patch17_invariants.ts`).
|
|
27
|
+
|
|
28
|
+
## [1.4.20] - 2026-08-23 - Grid Boundary Hardening, Recovery Poison Gate, Analysis Path Centralization
|
|
29
|
+
|
|
30
|
+
### 2026-08-22
|
|
31
|
+
|
|
32
|
+
- **Fix(grid)**: harden boundary promotion against gap-floor violations — the spread-correction promotion path could consume every gap slot in a single call (`maxPromotable` computed the opposite rail's span and constrained nothing; `resolveGapBand` re-derived `sellStartIdx` unconditionally from the mutable committed boundary), so any one-time overrun became permanent geometry with no spread floor. Promotion is now capped at band size − MIN_SPREAD_ORDERS (disabled entirely when band ≤ reserve) and the walk hard-stops reserve slots short of the opposite rail edge independent of quota; upstream depth caps (BUY P_s−G−1−B, SELL B−P_b) prevent the slide from stranding placed opposite-rail orders; new `validateBoundaryCommit()` gates commit-time proposals in `_commitWorkingGrid` (rejected proposals keep the last valid boundary); defense-in-depth detectors add pre-broadcast crossed-book refusal (`detectCrossedBookPlan`) and post-commit gap-band intrusion detection → structural resync; new shared `resolveGapSlots()` dedups the `_gapSlots ?? calculateGapSlots(config)` pattern (`modules/order/grid.ts`, `modules/order/utils/math.ts`, `modules/order/manager.ts`, `modules/dexbot_cow_runtime.ts`, `tests/test_spread_boundary_promotion.ts`, `tests/test_spread_check_orchestration.ts`).
|
|
33
|
+
- **Fix(recovery)**: gate persisted boundary restore against overrun poison — a boundary committed and persisted by the pre-fix promotion overrun would legalize itself on every restart: `resolveGapBand` re-derives `sellStartIdx` from whatever value is restored and no runtime gate ran before restore, so structural resync "recovered" straight back into corrupted geometry. New `validatePersistedBoundary()` (stricter than commit-time validation — also rejects in-band placed orders, the poison signature only position-based geometry detects) is applied in `loadGrid` before `_restoreBoundary`; on rejection the structural center is re-derived from slot prices via `calculateIdealBoundary` (unmappable anchors degrade to a boundary-less load the next sync reconciles), and `recoverFromPersistedGrid` refuses poisoned snapshots BEFORE `loadGrid` so resync falls through to a clean `requestGridReset(refreshCenterPrice)` rebuild using config-derived `calculateGapSlots` (`modules/order/utils/math.ts`, `modules/order/grid.ts`, `modules/dexbot_state_recovery.ts`, new `tests/test_boundary_restore_validation.ts`, `tests/test_uncertain_broadcast.ts` fixtures updated).
|
|
34
|
+
- **Feat(analysis)**: centralize dynamic weight chart slider ranges, kalS% default 1.0 — the interactive research chart hardcoded its 16 knob ranges independently in four places each (HTML range attrs, tooltip text, server-side clamps, paste-clamp code), and the amaS% paste clamp had already drifted from its slider span. New `SLIDER_RANGES` constant is the single source of truth feeding HTML attrs, tooltips, payload transport, and every paste/init/latch clamp; kalS% range 0.15–1.5 → 0.5–1.5 with `DYNAMIC_WEIGHT_KALMAN_MAX_SLOPE_PCT` raised 0.8 → 1.0; fixes a TDZ crash (`const SR` declared after first use threw ReferenceError on chart load, leaving all panels blank) (`analysis/trend_detection/dynamic_weight_chart_generator.ts`, `analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md`, `modules/constants.ts`).
|
|
35
|
+
- **Fix(paths)**: centralize analysis output dirs and npm-install path resolution — research/chart tooling wrote generated artifacts into the package tree via `__dirname`/`import.meta.url`/cwd-relative defaults (wiped by `npm update -g`, blocked on read-only prefixes). New `PATHS.ANALYSIS.{DIR,CHARTS_DIR,RESULTS_DIR,ASSETS_DIR}` resolver keeps repo-local outputs only for repo-layout source checkouts and follows the resolved profiles dir otherwise, with a `DEXBOT_ANALYSIS_DIR` env override and `XDG_CONFIG_HOME` support; all chart generators and optimizer/backtest result writers rerouted (auto-discovery scans RESULTS_DIR first with legacy-dir fallback); `writeChartFile` materializes vendored uPlot assets next to relocated charts so relative refs keep resolving; claw profile/skill-doc resolution aligned with `modules/paths.ts` ordering; shell shim npm-package detection switched to exact-parent basename matching; generated charts/repo-stats excluded from the shipped tarball (`modules/paths.ts`, `modules/config.ts`, `analysis/*`, `scripts/lib/dexbot-paths.sh`, `claw/modules/*`, `package.json`).
|
|
36
|
+
|
|
37
|
+
### 2026-08-23
|
|
38
|
+
|
|
39
|
+
- **Fix(market-adapter)**: align dynamic weight clip logic between live service and research chart — the chart dropped zero-slope bars from the AMA clip pool, kept Kalman warmup bars that the live service sliced away, and fed different precision (rounded vs raw) into the velocity smoothing pipeline, so parameter research could mispredict live clipping behavior. The live service now feeds the smoothing pipeline unrounded velocity/displacement percentages and computes the Kalman clip percentile over the full series (no warmup slice); the chart keeps every finite slope including zeros via `Number.isFinite` and builds the payload-level initial smoothed series from raw fields to match the interactive recompute path; CLIP_PCT_MAX knob bound lowered 55 → 20. Note: at clip=10% totals shift ~−0.12% since warmup bars now count toward the percentile pool (`market_adapter/core/market_adapter_service.ts`, `analysis/trend_detection/dynamic_weight_chart_generator.ts`, `tests/test_market_adapter_service.ts`).
|
|
40
|
+
|
|
5
41
|
## [1.4.19] - 2026-08-21 - COW Broadcast Op Cap, Grid Divergence Rail Fix, UI Price Feedback
|
|
6
42
|
|
|
7
43
|
### 2026-08-21
|
package/README.md
CHANGED
|
@@ -147,18 +147,26 @@ Both installs use the same CLI and store all user state — keys, `bots.json`, l
|
|
|
147
147
|
|
|
148
148
|
Keep the default settings first, and tune these:
|
|
149
149
|
|
|
150
|
-
1. **Tune `targetSpreadPercent`** — controls profit room per completed cycle
|
|
151
|
-
wider spread targets more profit per
|
|
150
|
+
1. **Tune `targetSpreadPercent`** — controls profit room per completed cycle:
|
|
151
|
+
profit ≈ `spread - increment - fees`. A wider spread targets more profit per
|
|
152
|
+
cycle but trades less often.
|
|
152
153
|
|
|
153
|
-
2. **Tune `incrementPercent`** — controls
|
|
154
|
+
2. **Tune `incrementPercent`** — controls order steps and order size. Smaller
|
|
154
155
|
increments create more grid levels and smaller orders; larger increments
|
|
155
|
-
create fewer levels and larger orders.
|
|
156
|
+
create fewer levels and larger orders. Smaller increments cycle faster —
|
|
157
|
+
higher profits, but more fees.
|
|
156
158
|
|
|
157
|
-
3. **
|
|
159
|
+
3. **Tune `weightDistribution`** (optional) — per-side sizing control. Higher
|
|
160
|
+
weight = more funds in orders near the market price; lower weight = funds
|
|
161
|
+
shifted toward the grid edge. Range `-1` (super-valley) to `2`
|
|
162
|
+
(super-mountain); the default `{ "sell": 1.0, "buy": 1.0 }` suits most
|
|
163
|
+
setups.
|
|
164
|
+
|
|
165
|
+
4. **Set `gridPrice` to `"ama"`** — so the market adapter can center the grid
|
|
158
166
|
on AMA. Pick a specific preset if desired: `"ama1"` is the fastest,
|
|
159
167
|
`"ama4"` the slowest, and `"ama"` uses the pair's default preset.
|
|
160
168
|
|
|
161
|
-
|
|
169
|
+
5. **Generate the market-adapter whitelist:**
|
|
162
170
|
|
|
163
171
|
```bash
|
|
164
172
|
dexbot white
|
|
@@ -168,9 +176,9 @@ Keep the default settings first, and tune these:
|
|
|
168
176
|
live writes and range scaling. Use `dexbot white --dynamic-weight` for
|
|
169
177
|
newly generated dynamic-weight entries; existing entries are preserved.
|
|
170
178
|
|
|
171
|
-
|
|
179
|
+
6. **Start DEXBot2** with `dexbot start`.
|
|
172
180
|
|
|
173
|
-
|
|
181
|
+
7. **Tune `minPrice` / `maxPrice`** around the market's volatility range. Once
|
|
174
182
|
AMA is active, tighten them around the maximum expected market volatility
|
|
175
183
|
instead of using an unnecessarily wide range.
|
|
176
184
|
|
|
@@ -178,6 +186,8 @@ Keep the default settings first, and tune these:
|
|
|
178
186
|
|
|
179
187
|
Configuration options from `dexbot bot`, stored in `bots.json` in the profiles directory:
|
|
180
188
|
|
|
189
|
+
> **Prefer relative values** — use dynamic price sources where available: `"pool"` (liquidity-pool price) or `"book"` (order-book mid) for `startPrice`, `"ama"` for `gridPrice`, `"2x"`-style multipliers for `minPrice` / `maxPrice`, and `"100%"`-style percentages for funds (`botFunds`). Relative values rescale automatically as the market moves; fixed numbers do not. The bot editor highlights these inputs live: **green** = relative/dynamic (recommended), **red** = fixed absolute value.
|
|
190
|
+
|
|
181
191
|
<details><summary><mark>Full parameter reference (click to expand)</mark></summary>
|
|
182
192
|
|
|
183
193
|
| Parameter | Type | Description |
|
|
@@ -192,10 +202,10 @@ Configuration options from `dexbot bot`, stored in `bots.json` in the profiles d
|
|
|
192
202
|
| **`poolRef`** | string \| null | Optional pinned pool ID for `startPrice: "pool"`. Overrides pool discovery with a direct fetch (e.g. `"1.19.48"` or `"48"`). Useful when the trading pair has no native pool. Default `null`. |
|
|
193
203
|
| **`minPrice`** | num \| str | Lower bound. Default `"2x"` means `gridPrice / 2` when AMA is active, otherwise `startPrice / 2`. |
|
|
194
204
|
| **`maxPrice`** | num \| str | Upper bound. Default `"2x"` means `gridPrice * 2` when AMA is active, otherwise `startPrice * 2`. |
|
|
195
|
-
| **`gridPrice`** | num \| str \| null | Grid reference. Use `"ama"` for the recommended AMA center; `null` falls back to `startPrice`; numeric values use that fixed value. |
|
|
196
|
-
| **`incrementPercent`** | number | Geometric step between
|
|
197
|
-
| **`targetSpreadPercent`** | number | Width of the empty spread zone between buy and sell orders. Default `2` = 2%. |
|
|
198
|
-
| **`weightDistribution`** | object | Advanced sizing control. Default `{ "sell": 1.0, "buy": 1.0 }`; leave unchanged for normal setup. |
|
|
205
|
+
| **`gridPrice`** | num \| str \| null | Grid reference. Use `"ama"` for the recommended AMA center (`"ama"` picks the pair's default preset; `"ama1"`–`"ama4"` pin fastest to slowest); `null` falls back to `startPrice`; numeric values use that fixed value. |
|
|
206
|
+
| **`incrementPercent`** | number | Geometric step between orders. Default `0.5` = 0.5%. |
|
|
207
|
+
| **`targetSpreadPercent`** | number | Width of the empty spread zone between buy and sell orders. Default `2` = 2%. Profit per completed cycle ≈ `spread - increment - fees`. |
|
|
208
|
+
| **`weightDistribution`** | object | Advanced sizing control per side. Range `-1` to `2`: `-1` = super-valley, `0` = valley, `0.5` = neutral, `1` = mountain (default), `2` = super-mountain. Higher weight = more funds in orders near the market price; lower weight = more funds shifted toward the grid edge. Default `{ "sell": 1.0, "buy": 1.0 }`; leave unchanged for normal setup. |
|
|
199
209
|
| **`botFunds`** | object | Capital: `{ "sell": "100%", "buy": 1000 }`. Numbers or percentage strings |
|
|
200
210
|
| **`activeOrders`** | object | Target active orders per side: `{ "sell": 20, "buy": 20 }` |
|
|
201
211
|
|
|
@@ -186,8 +186,8 @@ function generateChartHtml(results: any, metricCache: any, fixEr: any, fixFast:
|
|
|
186
186
|
const cacheSlow = metricCache.map((m: any) => m.slow);
|
|
187
187
|
const cacheMove = metricCache.map((m: any) => m.movement);
|
|
188
188
|
|
|
189
|
-
const uplotCode = fs.readFileSync(path.
|
|
190
|
-
const uplotCSS = fs.readFileSync(path.
|
|
189
|
+
const uplotCode = fs.readFileSync(path.join(PATHS.ANALYSIS.ASSETS_DIR, 'uPlot.iife.min.js'), 'utf8');
|
|
190
|
+
const uplotCSS = fs.readFileSync(path.join(PATHS.ANALYSIS.ASSETS_DIR, 'uPlot.min.css'), 'utf8');
|
|
191
191
|
|
|
192
192
|
const amaAnnotations = [
|
|
193
193
|
{ label: 'AMA1', lambda: 0.0031, slow: 62.1, color: '#ef5350' },
|
|
@@ -84,7 +84,7 @@ function main() {
|
|
|
84
84
|
if (e.code === 'ENOENT') {
|
|
85
85
|
console.error(`Data file not found: ${opts.data}`);
|
|
86
86
|
console.error('Export LP candles first, or point --data at an existing file.');
|
|
87
|
-
console.error('
|
|
87
|
+
console.error(' node dist/market_adapter/inputs/fetch_lp_data.js --pool 133 --precA 4 --precB 5 --interval 1h --lookback 26280h');
|
|
88
88
|
} else if (e instanceof SyntaxError) {
|
|
89
89
|
console.error(`Failed to parse JSON from: ${opts.data}`);
|
|
90
90
|
console.error(e.message);
|
|
@@ -719,7 +719,8 @@ async function run() {
|
|
|
719
719
|
const outName = dataFile
|
|
720
720
|
? `optimization_results_${path.basename(dataFile, '.json')}${lambdaSuffix}.json`
|
|
721
721
|
: `optimization_results_high_resolution${lambdaSuffix}.json`;
|
|
722
|
-
const outPath = path.join(
|
|
722
|
+
const outPath = path.join(PATHS.ANALYSIS.RESULTS_DIR, outName);
|
|
723
|
+
ensureDir(path.dirname(outPath));
|
|
723
724
|
writeJSON(outPath, {
|
|
724
725
|
meta: {
|
|
725
726
|
dataLabel,
|
|
@@ -20,10 +20,12 @@
|
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
|
|
23
|
+
import path from 'node:path';
|
|
23
24
|
import { pathToFileURL } from 'node:url';
|
|
24
25
|
import { DerivativeAnalyzer } from './trend_detection/derivative_analyzer.js';
|
|
25
26
|
import { generateHTML } from './derivative_chart_generator.js';
|
|
26
27
|
import { writeChartFile } from './chart_utils.js';
|
|
28
|
+
import { PATHS } from '../modules/paths.js';
|
|
27
29
|
import { resolveSource, listAvailableBots, type SourceConfig } from './resolve_source.js';
|
|
28
30
|
'use strict';
|
|
29
31
|
|
|
@@ -85,7 +87,7 @@ function parseArgs(): CliConfig {
|
|
|
85
87
|
interpHoldBars: 3,
|
|
86
88
|
rsiZone: 10,
|
|
87
89
|
rsiExtreme: 90,
|
|
88
|
-
chartFile: '
|
|
90
|
+
chartFile: path.join(PATHS.ANALYSIS.CHARTS_DIR, 'derivative_chart.html'),
|
|
89
91
|
quiet: false,
|
|
90
92
|
listBots: false,
|
|
91
93
|
};
|
|
@@ -173,7 +175,7 @@ Analyzer options:
|
|
|
173
175
|
--file PATH JSON candle input
|
|
174
176
|
|
|
175
177
|
Output:
|
|
176
|
-
--chart FILE Chart output path (default: analysis
|
|
178
|
+
--chart FILE Chart output path (default: <analysis charts dir>/derivative_chart.html)
|
|
177
179
|
--list-bots List available bot keys from bots.json
|
|
178
180
|
--quiet Suppress log output
|
|
179
181
|
`);
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* --file market_adapter/data/lp/<path>/<to>/<lp-candles>.json
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
+
import path from 'node:path';
|
|
15
16
|
import { KalmanTrendAnalyzer } from './trend_detection/kalman_trend_analyzer.js';
|
|
16
17
|
import { HurstAnalyzer } from './trend_detection/hurst_analyzer.js';
|
|
17
18
|
import { PermutationEntropyAnalyzer } from './trend_detection/permutation_entropy_analyzer.js';
|
|
@@ -19,6 +20,7 @@ import { generateHTML } from './trend_detection/dynamic_weight_chart_generator.j
|
|
|
19
20
|
import { calculateAMA } from '../market_adapter/core/strategies/ama.js';
|
|
20
21
|
import { computeAmaSlopeWeights } from '../market_adapter/core/strategies/ama_slope_model.js';
|
|
21
22
|
import { MARKET_ADAPTER } from '../modules/constants.js';
|
|
23
|
+
import { PATHS } from '../modules/paths.js';
|
|
22
24
|
import { writeChartFile } from './chart_utils.js';
|
|
23
25
|
import { getCandleClose } from './math_utils.js';
|
|
24
26
|
import { resolveSource, listAvailableBots, type SourceConfig } from './resolve_source.js';
|
|
@@ -64,7 +66,7 @@ function parseArgs() {
|
|
|
64
66
|
dispScaleMinPct?: number;
|
|
65
67
|
} = {
|
|
66
68
|
source: { type: 'market_adapter', config: { botKey: '' } },
|
|
67
|
-
chartFile: '
|
|
69
|
+
chartFile: path.join(PATHS.ANALYSIS.CHARTS_DIR, 'dynamic_weight_chart.html'),
|
|
68
70
|
alpha: MARKET_ADAPTER.DYNAMIC_WEIGHT_ALPHA,
|
|
69
71
|
gain: MARKET_ADAPTER.DYNAMIC_WEIGHT_GAIN,
|
|
70
72
|
dispWeight: MARKET_ADAPTER.DYNAMIC_WEIGHT_DW,
|
|
@@ -11,12 +11,14 @@
|
|
|
11
11
|
* --file market_adapter/data/lp/<path>/<to>/<lp-candles>.json
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
+
import path from 'node:path';
|
|
14
15
|
import { KalmanTrendAnalyzer } from './trend_detection/kalman_trend_analyzer.js';
|
|
15
16
|
import { generateHTML } from './trend_detection/kalman_chart_generator.js';
|
|
16
17
|
import { calculateAMA } from '../market_adapter/core/strategies/ama.js';
|
|
17
18
|
import { computeAverageAmaSlopePct } from '../market_adapter/core/strategies/dynamic_weight_series.js';
|
|
18
19
|
import { getCandleClose } from './math_utils.js';
|
|
19
20
|
import { writeChartFile } from './chart_utils.js';
|
|
21
|
+
import { PATHS } from '../modules/paths.js';
|
|
20
22
|
import { resolveSource, listAvailableBots, type SourceConfig } from './resolve_source.js';
|
|
21
23
|
|
|
22
24
|
'use strict';
|
|
@@ -39,7 +41,7 @@ function parseArgs() {
|
|
|
39
41
|
source: { type: 'market_adapter', config: { botKey: '' } },
|
|
40
42
|
rNoise: 0.05,
|
|
41
43
|
qNoise: 0.005,
|
|
42
|
-
chartFile: '
|
|
44
|
+
chartFile: path.join(PATHS.ANALYSIS.CHARTS_DIR, 'kalman_chart.html'),
|
|
43
45
|
quiet: false,
|
|
44
46
|
listBots: false,
|
|
45
47
|
};
|
|
@@ -18,7 +18,9 @@
|
|
|
18
18
|
* --file market_adapter/data/lp/<path>/<to>/<lp-candles>.json
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
+
import path from 'node:path';
|
|
21
22
|
import { MARKET_ADAPTER } from '../modules/constants.js';
|
|
23
|
+
import { PATHS } from '../modules/paths.js';
|
|
22
24
|
import { HurstAnalyzer } from './trend_detection/hurst_analyzer.js';
|
|
23
25
|
import { PermutationEntropyAnalyzer } from './trend_detection/permutation_entropy_analyzer.js';
|
|
24
26
|
import { generateRegimeHTML } from './trend_detection/regime_chart_generator.js';
|
|
@@ -44,7 +46,7 @@ function parseArgs() {
|
|
|
44
46
|
listBots: boolean;
|
|
45
47
|
} = {
|
|
46
48
|
source: { type: 'market_adapter', config: { botKey: '' } },
|
|
47
|
-
chartFile: '
|
|
49
|
+
chartFile: path.join(PATHS.ANALYSIS.CHARTS_DIR, 'regime_chart.html'),
|
|
48
50
|
hurstWindow: HURST_CONFIG.window,
|
|
49
51
|
peWindow: PE_CONFIG.window,
|
|
50
52
|
peM: PE_CONFIG.m,
|
|
@@ -17,9 +17,11 @@
|
|
|
17
17
|
* --file market_adapter/data/lp/<path>/<to>/<lp-candles>.json
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
+
import path from 'node:path';
|
|
20
21
|
import { HurstAnalyzer } from './trend_detection/hurst_analyzer.js';
|
|
21
22
|
import { PermutationEntropyAnalyzer } from './trend_detection/permutation_entropy_analyzer.js';
|
|
22
23
|
import { MARKET_ADAPTER } from '../modules/constants.js';
|
|
24
|
+
import { PATHS } from '../modules/paths.js';
|
|
23
25
|
import { writeChartFile } from './chart_utils.js';
|
|
24
26
|
import { getCandleClose } from './math_utils.js';
|
|
25
27
|
import { roundTo } from '../modules/order/utils/math.js';
|
|
@@ -59,7 +61,7 @@ function parseArgs() {
|
|
|
59
61
|
listBots: boolean;
|
|
60
62
|
} = {
|
|
61
63
|
source: { type: 'market_adapter', config: { botKey: '' } },
|
|
62
|
-
chartFile: '
|
|
64
|
+
chartFile: path.join(PATHS.ANALYSIS.CHARTS_DIR, 'regime_windows_heatmap.html'),
|
|
63
65
|
quiet: false,
|
|
64
66
|
listBots: false,
|
|
65
67
|
};
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
import path from 'node:path';
|
|
24
|
-
import { fileURLToPath } from 'node:url';
|
|
25
24
|
|
|
26
25
|
import { calculateAMA } from '../market_adapter/core/strategies/ama.js';
|
|
27
26
|
import { computeATRSeries } from '../market_adapter/core/strategies/atr/calculator.js';
|
|
@@ -29,6 +28,7 @@ import { normalizeAtrPeriod } from '../market_adapter/core/config_normalizers.js
|
|
|
29
28
|
import { computeVolatilityShift } from '../market_adapter/core/strategies/volatility_shift.js';
|
|
30
29
|
import { generateHTML } from './trend_detection/volatility_chart_generator.js';
|
|
31
30
|
import { MARKET_ADAPTER } from '../modules/constants.js';
|
|
31
|
+
import { PATHS } from '../modules/paths.js';
|
|
32
32
|
import { getCandleClose } from './math_utils.js';
|
|
33
33
|
import { writeChartFile } from './chart_utils.js';
|
|
34
34
|
import { resolveSource, listAvailableBots, type SourceConfig } from './resolve_source.js';
|
|
@@ -40,7 +40,7 @@ const MIN_WEIGHT = MARKET_ADAPTER.DYNAMIC_WEIGHT_MIN_WEIGHT;
|
|
|
40
40
|
const MAX_WEIGHT = MARKET_ADAPTER.DYNAMIC_WEIGHT_MAX_WEIGHT;
|
|
41
41
|
const DEFAULT_THRESHOLD = MARKET_ADAPTER.DYNAMIC_WEIGHT_SYMMETRIC_SHIFT_THRESHOLD;
|
|
42
42
|
const DEFAULT_CLAMP = MARKET_ADAPTER.DYNAMIC_WEIGHT_SYMMETRIC_SHIFT_CLAMP;
|
|
43
|
-
const DEFAULT_CHART_DIR =
|
|
43
|
+
const DEFAULT_CHART_DIR = PATHS.ANALYSIS.CHARTS_DIR;
|
|
44
44
|
const DEFAULT_CHART_FILE = path.join(DEFAULT_CHART_DIR, 'volatility_chart.html');
|
|
45
45
|
|
|
46
46
|
function computeATRSeriesNormalized(candles: any[], period = DEFAULT_ATR_PERIOD) {
|
|
@@ -7,6 +7,7 @@ import { calculateAMA } from '../../market_adapter/core/strategies/ama.js';
|
|
|
7
7
|
import { range } from '../math_utils.js';
|
|
8
8
|
import { parseListOrRange, loadLpData, fmt } from './shared_utils.js';
|
|
9
9
|
import { getStorage } from '../../modules/storage/index.js';
|
|
10
|
+
import { PATHS } from '../../modules/paths.js';
|
|
10
11
|
const { readJSON, writeJSON } = getStorage();
|
|
11
12
|
'use strict';
|
|
12
13
|
|
|
@@ -759,7 +760,7 @@ async function run() {
|
|
|
759
760
|
|
|
760
761
|
// ── Save JSON ───────────────────────────────────────────────────────────
|
|
761
762
|
const outName = `ama_sweep_results_${path.basename(cfg.dataPath!, '.json')}.json`;
|
|
762
|
-
const outPath = path.join(
|
|
763
|
+
const outPath = path.join(PATHS.ANALYSIS.RESULTS_DIR, outName);
|
|
763
764
|
writeJSON(outPath, {
|
|
764
765
|
meta: {
|
|
765
766
|
generatedAt: new Date().toISOString(),
|
|
@@ -4,6 +4,7 @@ import { calculateAMA } from '../../market_adapter/core/strategies/ama.js';
|
|
|
4
4
|
import { range } from '../math_utils.js';
|
|
5
5
|
import { parseListOrRange, loadLpData, fmt } from './shared_utils.js';
|
|
6
6
|
import { getStorage } from '../../modules/storage/index.js';
|
|
7
|
+
import { PATHS } from '../../modules/paths.js';
|
|
7
8
|
const { ensureDir, readJSON, writeJSON } = getStorage();
|
|
8
9
|
|
|
9
10
|
'use strict';
|
|
@@ -125,28 +126,32 @@ function parseArgs() {
|
|
|
125
126
|
* The optimizer names results `optimization_results_<base>_w<λ1>_<λ2>_<λ3>_<λ4>.json`
|
|
126
127
|
* (per-AMA distance weights appended as a `_w...` suffix). To stay robust against
|
|
127
128
|
* weight overrides, pick the most recently written `optimization_results_<base>_w*.json`
|
|
128
|
-
* in
|
|
129
|
-
* if no suffixed file exists.
|
|
129
|
+
* in the analysis results dir (legacy ama_fitting location still scanned); fall
|
|
130
|
+
* back to the legacy `optimization_results_<base>.json` name if no suffixed file exists.
|
|
130
131
|
*/
|
|
131
132
|
function resolveAutoResultsPath(dataPath: string): string {
|
|
132
133
|
const base = path.basename(dataPath, '.json');
|
|
133
|
-
|
|
134
|
+
// Canonical results dir first, then the legacy ama_fitting location so
|
|
135
|
+
// previously generated files are still discovered.
|
|
136
|
+
const dirs = [PATHS.ANALYSIS.RESULTS_DIR, path.join(PATHS.PROJECT_ROOT, 'analysis', 'ama_fitting')];
|
|
134
137
|
const prefix = `optimization_results_${base}_w`;
|
|
135
138
|
let newest: { file: string; mtimeMs: number } | null = null;
|
|
136
139
|
try {
|
|
137
|
-
for (const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
newest
|
|
140
|
+
for (const dir of dirs) {
|
|
141
|
+
for (const entry of fs.readdirSync(dir)) {
|
|
142
|
+
if (!entry.startsWith(prefix) || !entry.endsWith('.json')) continue;
|
|
143
|
+
const full = path.join(dir, entry);
|
|
144
|
+
const stat = fs.statSync(full);
|
|
145
|
+
if (!newest || stat.mtimeMs > newest.mtimeMs) {
|
|
146
|
+
newest = { file: full, mtimeMs: stat.mtimeMs };
|
|
147
|
+
}
|
|
143
148
|
}
|
|
144
149
|
}
|
|
145
150
|
} catch {
|
|
146
151
|
// dir unreadable — fall through to legacy name check
|
|
147
152
|
}
|
|
148
153
|
if (newest) return newest.file;
|
|
149
|
-
return path.join(
|
|
154
|
+
return path.join(PATHS.ANALYSIS.RESULTS_DIR, `optimization_results_${base}.json`);
|
|
150
155
|
}
|
|
151
156
|
|
|
152
157
|
function loadAmaStrategies(resultsPath: string) {
|
|
@@ -388,8 +393,8 @@ function run() {
|
|
|
388
393
|
console.log();
|
|
389
394
|
|
|
390
395
|
const outName = `bot_fitting_results_${path.basename(cfg.dataPath!, '.json')}.json`;
|
|
391
|
-
const outPath = path.join(
|
|
392
|
-
ensureDir(
|
|
396
|
+
const outPath = path.join(PATHS.ANALYSIS.RESULTS_DIR, outName);
|
|
397
|
+
ensureDir(PATHS.ANALYSIS.RESULTS_DIR);
|
|
393
398
|
writeJSON(outPath, {
|
|
394
399
|
meta: {
|
|
395
400
|
generatedAt: new Date().toISOString(),
|
|
@@ -6,6 +6,7 @@ import { getStorage } from '../modules/storage/index.js';
|
|
|
6
6
|
const { readJSON } = getStorage();
|
|
7
7
|
import { MARKET_ADAPTER } from '../modules/constants.js';
|
|
8
8
|
import { loadMarketProfiles } from './tradingview/tradingview_uplot_chart_generator.js';
|
|
9
|
+
import { sanitizeKey } from '../modules/utils/sanitize_key.js';
|
|
9
10
|
'use strict';
|
|
10
11
|
|
|
11
12
|
|
|
@@ -22,11 +23,6 @@ function loadBotSettings(filePath = PATHS.PROFILES.BOTS_JSON) {
|
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
function sanitizeKey(source: any) {
|
|
26
|
-
if (!source) return 'bot';
|
|
27
|
-
return String(source).trim().toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'bot';
|
|
28
|
-
}
|
|
29
|
-
|
|
30
26
|
function computeBotKey(bot: any, index: number) {
|
|
31
27
|
if (bot && bot.name) {
|
|
32
28
|
return sanitizeKey(bot.name);
|