dexbot 1.4.17 → 1.4.19
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 +17 -0
- package/README.md +1 -0
- package/analysis/README.md +43 -43
- package/analysis/ama_fitting/README.md +8 -8
- package/analysis/ama_fitting/package.json +1 -1
- package/analysis/bot_fitting/README.md +4 -4
- package/analysis/bot_fitting/backtest_ama_sweep.ts +1 -1
- package/analysis/bot_usage/discover_bot_accounts.ts +11 -11
- package/analysis/tradingview/README.md +4 -4
- package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +2 -2
- package/analysis/trend_detection/SIGNAL_DOCUMENTATION.md +1 -1
- package/analysis/trend_detection/package.json +1 -1
- package/claw/README.md +45 -45
- package/claw/docs/AI_BOT_LIBRARY_API.md +6 -6
- package/claw/examples/short_mpa_bts_strategy.ts +3 -3
- package/claw/package.json +21 -21
- 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 +2 -2
- package/claw/scripts/claw_skill_md.ts +1 -1
- package/claw/skills/launcher-ops/references/launcher-workflow.md +5 -5
- package/claw/skills/margin-trading/references/honest-asset-list.md +1 -1
- package/claw/skills/memu-memory/SKILL.md +3 -3
- package/claw/tests/test_claw_mcp_transport.ts +2 -2
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.d.ts +3 -0
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.d.ts.map +1 -0
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.js +148 -0
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.js.map +1 -0
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.d.ts +12 -0
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.d.ts.map +1 -0
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +389 -0
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js.map +1 -0
- package/dist/analysis/ama_fitting/calibrate_convergence_er.d.ts +3 -0
- package/dist/analysis/ama_fitting/calibrate_convergence_er.d.ts.map +1 -0
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js +200 -0
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js.map +1 -0
- package/dist/analysis/ama_fitting/fetch_lp_candles.d.ts +3 -0
- package/dist/analysis/ama_fitting/fetch_lp_candles.d.ts.map +1 -0
- package/dist/analysis/ama_fitting/fetch_lp_candles.js +213 -0
- package/dist/analysis/ama_fitting/fetch_lp_candles.js.map +1 -0
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts +25 -0
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts.map +1 -0
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js +247 -0
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js.map +1 -0
- package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts +35 -0
- package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts.map +1 -0
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js +782 -0
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js.map +1 -0
- package/dist/analysis/analyze_derivatives.d.ts +86 -0
- package/dist/analysis/analyze_derivatives.d.ts.map +1 -0
- package/dist/analysis/analyze_derivatives.js +285 -0
- package/dist/analysis/analyze_derivatives.js.map +1 -0
- package/dist/analysis/analyze_dynamic_weight.d.ts +14 -0
- package/dist/analysis/analyze_dynamic_weight.d.ts.map +1 -0
- package/dist/analysis/analyze_dynamic_weight.js +197 -0
- package/dist/analysis/analyze_dynamic_weight.js.map +1 -0
- package/dist/analysis/analyze_kalman.d.ts +13 -0
- package/dist/analysis/analyze_kalman.d.ts.map +1 -0
- package/dist/analysis/analyze_kalman.js +118 -0
- package/dist/analysis/analyze_kalman.js.map +1 -0
- package/dist/analysis/analyze_regime.d.ts +20 -0
- package/dist/analysis/analyze_regime.d.ts.map +1 -0
- package/dist/analysis/analyze_regime.js +139 -0
- package/dist/analysis/analyze_regime.js.map +1 -0
- package/dist/analysis/analyze_regime_windows.d.ts +19 -0
- package/dist/analysis/analyze_regime_windows.d.ts.map +1 -0
- package/dist/analysis/analyze_regime_windows.js +414 -0
- package/dist/analysis/analyze_regime_windows.js.map +1 -0
- package/dist/analysis/analyze_risk_profile.d.ts +3 -0
- package/dist/analysis/analyze_risk_profile.d.ts.map +1 -0
- package/dist/analysis/analyze_risk_profile.js +186 -0
- package/dist/analysis/analyze_risk_profile.js.map +1 -0
- package/dist/analysis/analyze_trade_heatmap.d.ts +3 -0
- package/dist/analysis/analyze_trade_heatmap.d.ts.map +1 -0
- package/dist/analysis/analyze_trade_heatmap.js +358 -0
- package/dist/analysis/analyze_trade_heatmap.js.map +1 -0
- package/dist/analysis/analyze_volatility.d.ts +22 -0
- package/dist/analysis/analyze_volatility.d.ts.map +1 -0
- package/dist/analysis/analyze_volatility.js +165 -0
- package/dist/analysis/analyze_volatility.js.map +1 -0
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts +91 -0
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts.map +1 -0
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js +792 -0
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js.map +1 -0
- package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts +2 -0
- package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts.map +1 -0
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js +380 -0
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js.map +1 -0
- package/dist/analysis/bot_fitting/shared_utils.d.ts +26 -0
- package/dist/analysis/bot_fitting/shared_utils.d.ts.map +1 -0
- package/dist/analysis/bot_fitting/shared_utils.js +42 -0
- package/dist/analysis/bot_fitting/shared_utils.js.map +1 -0
- package/dist/analysis/bot_key_utils.d.ts +11 -0
- package/dist/analysis/bot_key_utils.d.ts.map +1 -0
- package/dist/analysis/bot_key_utils.js +153 -0
- package/dist/analysis/bot_key_utils.js.map +1 -0
- package/dist/analysis/bot_usage/discover_bot_accounts.d.ts +3 -0
- package/dist/analysis/bot_usage/discover_bot_accounts.d.ts.map +1 -0
- package/dist/analysis/bot_usage/discover_bot_accounts.js +499 -0
- package/dist/analysis/bot_usage/discover_bot_accounts.js.map +1 -0
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts +531 -0
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +1 -0
- package/dist/analysis/bot_usage/kibana_bot_queries.js +399 -0
- package/dist/analysis/bot_usage/kibana_bot_queries.js.map +1 -0
- package/dist/analysis/chart_css.d.ts +17 -0
- package/dist/analysis/chart_css.d.ts.map +1 -0
- package/dist/analysis/chart_css.js +49 -0
- package/dist/analysis/chart_css.js.map +1 -0
- package/dist/analysis/chart_ui.d.ts +45 -0
- package/dist/analysis/chart_ui.d.ts.map +1 -0
- package/dist/analysis/chart_ui.js +97 -0
- package/dist/analysis/chart_ui.js.map +1 -0
- package/dist/analysis/chart_utils.d.ts +27 -0
- package/dist/analysis/chart_utils.d.ts.map +1 -0
- package/dist/analysis/chart_utils.js +153 -0
- package/dist/analysis/chart_utils.js.map +1 -0
- package/dist/analysis/derivative_chart_generator.d.ts +12 -0
- package/dist/analysis/derivative_chart_generator.d.ts.map +1 -0
- package/dist/analysis/derivative_chart_generator.js +891 -0
- package/dist/analysis/derivative_chart_generator.js.map +1 -0
- package/dist/analysis/math_utils.d.ts +22 -0
- package/dist/analysis/math_utils.d.ts.map +1 -0
- package/dist/analysis/math_utils.js +43 -0
- package/dist/analysis/math_utils.js.map +1 -0
- package/dist/analysis/price_sources.d.ts +40 -0
- package/dist/analysis/price_sources.d.ts.map +1 -0
- package/dist/analysis/price_sources.js +94 -0
- package/dist/analysis/price_sources.js.map +1 -0
- package/dist/analysis/resolve_source.d.ts +25 -0
- package/dist/analysis/resolve_source.d.ts.map +1 -0
- package/dist/analysis/resolve_source.js +69 -0
- package/dist/analysis/resolve_source.js.map +1 -0
- package/dist/analysis/trade_profitability.d.ts +115 -0
- package/dist/analysis/trade_profitability.d.ts.map +1 -0
- package/dist/analysis/trade_profitability.js +1240 -0
- package/dist/analysis/trade_profitability.js.map +1 -0
- package/dist/analysis/tradingview/analyze_tradingview.d.ts +31 -0
- package/dist/analysis/tradingview/analyze_tradingview.d.ts.map +1 -0
- package/dist/analysis/tradingview/analyze_tradingview.js +146 -0
- package/dist/analysis/tradingview/analyze_tradingview.js.map +1 -0
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts +5 -0
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +1 -0
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +1714 -0
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +1 -0
- package/dist/analysis/trend_detection/derivative_analyzer.d.ts +247 -0
- package/dist/analysis/trend_detection/derivative_analyzer.d.ts.map +1 -0
- package/dist/analysis/trend_detection/derivative_analyzer.js +901 -0
- package/dist/analysis/trend_detection/derivative_analyzer.js.map +1 -0
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts +3 -0
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +1 -0
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +1361 -0
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +1 -0
- package/dist/analysis/trend_detection/hurst_analyzer.d.ts +6 -0
- package/dist/analysis/trend_detection/hurst_analyzer.d.ts.map +1 -0
- package/dist/analysis/trend_detection/hurst_analyzer.js +7 -0
- package/dist/analysis/trend_detection/hurst_analyzer.js.map +1 -0
- package/dist/analysis/trend_detection/kalman_chart_generator.d.ts +3 -0
- package/dist/analysis/trend_detection/kalman_chart_generator.d.ts.map +1 -0
- package/dist/analysis/trend_detection/kalman_chart_generator.js +360 -0
- package/dist/analysis/trend_detection/kalman_chart_generator.js.map +1 -0
- package/dist/analysis/trend_detection/kalman_trend_analyzer.d.ts +8 -0
- package/dist/analysis/trend_detection/kalman_trend_analyzer.d.ts.map +1 -0
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js +8 -0
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js.map +1 -0
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.d.ts +6 -0
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.d.ts.map +1 -0
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js +7 -0
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js.map +1 -0
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.d.ts +6 -0
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.d.ts.map +1 -0
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js +7 -0
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js.map +1 -0
- package/dist/analysis/trend_detection/regime_chart_generator.d.ts +3 -0
- package/dist/analysis/trend_detection/regime_chart_generator.d.ts.map +1 -0
- package/dist/analysis/trend_detection/regime_chart_generator.js +310 -0
- package/dist/analysis/trend_detection/regime_chart_generator.js.map +1 -0
- package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts +2 -0
- package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts.map +1 -0
- package/dist/analysis/trend_detection/tests/test_kalman_trend.js +128 -0
- package/dist/analysis/trend_detection/tests/test_kalman_trend.js.map +1 -0
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts +2 -0
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts.map +1 -0
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js +37 -0
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js.map +1 -0
- package/dist/analysis/trend_detection/volatility_chart_generator.d.ts +3 -0
- package/dist/analysis/trend_detection/volatility_chart_generator.d.ts.map +1 -0
- package/dist/analysis/trend_detection/volatility_chart_generator.js +646 -0
- package/dist/analysis/trend_detection/volatility_chart_generator.js.map +1 -0
- package/dist/bot.js +1 -1
- package/dist/bot.js.map +1 -1
- package/dist/market_adapter/ama_signal_runner.js +1 -1
- package/dist/market_adapter/ama_signal_runner.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +1 -1
- package/dist/modules/account_bots.d.ts +1 -0
- package/dist/modules/account_bots.d.ts.map +1 -1
- package/dist/modules/account_bots.js +27 -5
- package/dist/modules/account_bots.js.map +1 -1
- package/dist/modules/constants.d.ts +1 -0
- package/dist/modules/constants.d.ts.map +1 -1
- package/dist/modules/constants.js +12 -3
- package/dist/modules/constants.js.map +1 -1
- package/dist/modules/dexbot_class.d.ts +22 -0
- package/dist/modules/dexbot_class.d.ts.map +1 -1
- package/dist/modules/dexbot_class.js +27 -1
- package/dist/modules/dexbot_class.js.map +1 -1
- package/dist/modules/dexbot_cow_runtime.d.ts +48 -1
- package/dist/modules/dexbot_cow_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_cow_runtime.js +168 -4
- package/dist/modules/dexbot_cow_runtime.js.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.d.ts.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.js +6 -27
- package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
- package/dist/modules/order/strategy.d.ts.map +1 -1
- package/dist/modules/order/strategy.js +6 -15
- package/dist/modules/order/strategy.js.map +1 -1
- package/dist/modules/order/utils/math.d.ts +29 -1
- package/dist/modules/order/utils/math.d.ts.map +1 -1
- package/dist/modules/order/utils/math.js +46 -1
- package/dist/modules/order/utils/math.js.map +1 -1
- package/dist/modules/order/utils/system.d.ts +2 -0
- package/dist/modules/order/utils/system.d.ts.map +1 -1
- package/dist/modules/order/utils/system.js +30 -2
- package/dist/modules/order/utils/system.js.map +1 -1
- package/dist/modules/runtime_settings.d.ts +1 -0
- package/dist/modules/runtime_settings.d.ts.map +1 -1
- package/dist/modules/runtime_settings.js +13 -2
- package/dist/modules/runtime_settings.js.map +1 -1
- package/dist/scripts/generate_lp_chart.js +1 -1
- package/dist/scripts/test-credit-renewal.js +1 -1
- package/docs/DEXBOT_COMPARISON.md +3 -3
- package/docs/EVOLUTION.md +26 -95
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
- package/docs/GRID_RECALCULATION.md +2 -2
- package/docs/LIFECYCLE.md +207 -0
- package/docs/README.md +9 -1
- package/docs/developer_guide.md +4 -3
- package/market_adapter/README.md +23 -23
- package/package.json +18 -21
- package/scripts/README.md +12 -12
- package/scripts/bots +5 -7
- package/scripts/clear-market-adapter.sh +1 -1
- package/scripts/dexbot +5 -7
- package/scripts/keys +5 -7
- package/scripts/pm2 +5 -7
- package/scripts/unlock +5 -7
- package/scripts/update.js +6 -7
- package/scripts/repo-stats.html +0 -480
package/claw/README.md
CHANGED
|
@@ -31,8 +31,8 @@ Integration layer for BitShares blockchain operations from DEXBot2 and supported
|
|
|
31
31
|
| Track persistent short positions | [Position Manager](#position-manager) | `npm run example:position-manager` |
|
|
32
32
|
| Choose a runtime (OpenClaw, Hermes, NanoBot, etc.) | [Multi-Runtime Support](#multi-runtime-support) | — |
|
|
33
33
|
| Generate skill files for a runtime | [Multi-Runtime Support](#multi-runtime-support) | `npm run <runtime>:skill` |
|
|
34
|
-
| Preview or apply bot setting changes | [Bot Settings](#bot-settings) | `
|
|
35
|
-
| Inspect an on-chain MPA position | [Position Health](#position-health) | `
|
|
34
|
+
| Preview or apply bot setting changes | [Bot Settings](#bot-settings) | `npm run claw:bridge -- bot-settings-preview` |
|
|
35
|
+
| Inspect an on-chain MPA position | [Position Health](#position-health) | `npm run claw:bridge -- mpa-position` |
|
|
36
36
|
| List HONEST asset pricing | [HONEST Asset Report](#honest-asset-report) | `npm run report:honest-assets` |
|
|
37
37
|
|
|
38
38
|
## Install
|
|
@@ -140,7 +140,7 @@ npm run report:honest-assets
|
|
|
140
140
|
JSON output:
|
|
141
141
|
|
|
142
142
|
```bash
|
|
143
|
-
|
|
143
|
+
node ../dist/claw/scripts/honest_assets_report.js --json
|
|
144
144
|
```
|
|
145
145
|
|
|
146
146
|
## Signing And Broadcast
|
|
@@ -209,9 +209,9 @@ For a deeper comparison, see [docs/RUNTIME_COMPARISON.md](docs/RUNTIME_COMPARISO
|
|
|
209
209
|
Use the runtime-neutral bridge command for JSON-friendly local integration:
|
|
210
210
|
|
|
211
211
|
```bash
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
212
|
+
npm run claw:bridge -- manifest
|
|
213
|
+
npm run claw:bridge -- profile-context --payload '{"botRef":"default"}'
|
|
214
|
+
npm run claw:bridge -- market-snapshot --payload '{"baseSymbol":"BTS","quoteSymbol":"USD"}'
|
|
215
215
|
```
|
|
216
216
|
|
|
217
217
|
### Bot Settings
|
|
@@ -219,9 +219,9 @@ tsx scripts/claw_bridge.ts market-snapshot --payload '{"baseSymbol":"BTS","quote
|
|
|
219
219
|
Use the bridge to read, preview, and apply DEXBot2 bot settings through the locked profile adapter:
|
|
220
220
|
|
|
221
221
|
```bash
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
222
|
+
npm run claw:bridge -- bot-settings --payload '{"botRef":"default"}'
|
|
223
|
+
npm run claw:bridge -- bot-settings-preview --payload '{"botRef":"default","patch":{"incrementPercent":0.4,"weightDistribution":{"sell":0.7,"buy":0.4}}}'
|
|
224
|
+
npm run claw:bridge -- bot-settings-apply --payload '{"botRef":"default","patch":{"incrementPercent":0.4,"weightDistribution":{"sell":0.7,"buy":0.4}}}'
|
|
225
225
|
```
|
|
226
226
|
|
|
227
227
|
Settings writes are serialized through the profile lock and the recalc trigger is written atomically, so concurrent bot-setting updates do not clobber each other.
|
|
@@ -273,10 +273,10 @@ OpenFang uses the same shared bridge surface through a local CLI wrapper.
|
|
|
273
273
|
<details><summary>Compatibility command surface (click to expand)</summary>
|
|
274
274
|
|
|
275
275
|
```bash
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
276
|
+
npm run openfang:bridge -- manifest
|
|
277
|
+
npm run openfang:bridge -- profile-context --payload '{"botRef":"default"}'
|
|
278
|
+
npm run openfang:bridge -- market-snapshot --payload '{"baseSymbol":"BTS","quoteSymbol":"USD"}'
|
|
279
|
+
npm run openfang:bridge -- create-limit-order --payload '{"accountName":"your-account","sellAsset":"BTS","receiveAsset":"USD","amountToSell":10,"minToReceive":2}'
|
|
280
280
|
```
|
|
281
281
|
|
|
282
282
|
</details>
|
|
@@ -296,8 +296,8 @@ Add the shared Claw MCP server to `~/.hermes/config.yaml`:
|
|
|
296
296
|
```yaml
|
|
297
297
|
mcp_servers:
|
|
298
298
|
claw:
|
|
299
|
-
command: "
|
|
300
|
-
args: ["/absolute/path/to/claw/scripts/claw_mcp_server.
|
|
299
|
+
command: "node"
|
|
300
|
+
args: ["/absolute/path/to/DEXBot2/dist/claw/scripts/claw_mcp_server.js", "--profile-root", "/absolute/path/to/DEXBot2"]
|
|
301
301
|
```
|
|
302
302
|
|
|
303
303
|
Hermes should use the shared MCP server for live tools and keep the generated `SKILL.md` focused on workflow guidance. The Claw MCP server registers raw tool ids such as `claw_manifest`; if Hermes shows a namespaced label in its UI, use the label shown there.
|
|
@@ -309,7 +309,7 @@ Run the MCP server over stdio:
|
|
|
309
309
|
```bash
|
|
310
310
|
CLAW_ROOT="$(pwd)"
|
|
311
311
|
DEXBOT_ROOT="$(cd .. && pwd)"
|
|
312
|
-
|
|
312
|
+
node ../dist/claw/scripts/claw_mcp_server.js --profile-root "$DEXBOT_ROOT"
|
|
313
313
|
```
|
|
314
314
|
|
|
315
315
|
The stdio transport uses newline-delimited JSON-RPC messages on `stdin` and `stdout`.
|
|
@@ -340,10 +340,10 @@ NanoClaw already ships its own `claw` skill, so keep this bridge skill named `bi
|
|
|
340
340
|
<details><summary>Compatibility command surface (click to expand)</summary>
|
|
341
341
|
|
|
342
342
|
```bash
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
343
|
+
npm run nanoclaw:bridge -- manifest
|
|
344
|
+
npm run nanoclaw:bridge -- profile-context --payload '{"botRef":"default"}'
|
|
345
|
+
npm run nanoclaw:bridge -- market-snapshot --payload '{"baseSymbol":"BTS","quoteSymbol":"USD"}'
|
|
346
|
+
npm run nanoclaw:bridge -- create-limit-order --payload '{"accountName":"your-account","sellAsset":"BTS","receiveAsset":"USD","amountToSell":10,"minToReceive":2}'
|
|
347
347
|
```
|
|
348
348
|
|
|
349
349
|
</details>
|
|
@@ -361,13 +361,13 @@ npm run zeroclaw:skill -- --repo-root "$CLAW_ROOT" --profile-root "$DEXBOT_ROOT"
|
|
|
361
361
|
<details><summary>Compatibility command surface (click to expand)</summary>
|
|
362
362
|
|
|
363
363
|
```bash
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
364
|
+
npm run zeroclaw:bridge -- manifest
|
|
365
|
+
npm run zeroclaw:bridge -- profile-context --payload '{"botRef":"default"}'
|
|
366
|
+
npm run zeroclaw:bridge -- market-snapshot --payload '{"baseSymbol":"BTS","quoteSymbol":"USD"}'
|
|
367
|
+
npm run zeroclaw:bridge -- create-limit-order --payload '{"accountName":"your-account","sellAsset":"BTS","receiveAsset":"USD","amountToSell":10,"minToReceive":2}'
|
|
368
|
+
npm run zeroclaw:bridge -- update-limit-order --payload '{"accountName":"your-account","orderId":"1.7.123","newParams":{"amountToSell":10,"minToReceive":2}}'
|
|
369
|
+
npm run zeroclaw:bridge -- execute-batch --payload '{"accountName":"your-account","operations":[]}'
|
|
370
|
+
npm run zeroclaw:bridge -- borrow-mpa --payload '{"accountName":"your-account","mpaAsset":"HONEST.USD","debtDelta":10,"collateralDelta":25000}'
|
|
371
371
|
```
|
|
372
372
|
|
|
373
373
|
</details>
|
|
@@ -385,13 +385,13 @@ npm run nullclaw:skill -- --repo-root "$CLAW_ROOT" --profile-root "$DEXBOT_ROOT"
|
|
|
385
385
|
<details><summary>Compatibility command surface (click to expand)</summary>
|
|
386
386
|
|
|
387
387
|
```bash
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
388
|
+
npm run nullclaw:bridge -- manifest
|
|
389
|
+
npm run nullclaw:bridge -- profile-context --payload '{"botRef":"default"}'
|
|
390
|
+
npm run nullclaw:bridge -- market-snapshot --payload '{"baseSymbol":"BTS","quoteSymbol":"USD"}'
|
|
391
|
+
npm run nullclaw:bridge -- create-limit-order --payload '{"accountName":"your-account","sellAsset":"BTS","receiveAsset":"USD","amountToSell":10,"minToReceive":2}'
|
|
392
|
+
npm run nullclaw:bridge -- update-limit-order --payload '{"accountName":"your-account","orderId":"1.7.123","newParams":{"amountToSell":10,"minToReceive":2}}'
|
|
393
|
+
npm run nullclaw:bridge -- execute-batch --payload '{"accountName":"your-account","operations":[]}'
|
|
394
|
+
npm run nullclaw:bridge -- borrow-mpa --payload '{"accountName":"your-account","mpaAsset":"HONEST.USD","debtDelta":10,"collateralDelta":25000}'
|
|
395
395
|
```
|
|
396
396
|
|
|
397
397
|
</details>
|
|
@@ -412,7 +412,7 @@ Start the memU MCP server:
|
|
|
412
412
|
```bash
|
|
413
413
|
npm run memu:mcp
|
|
414
414
|
# or
|
|
415
|
-
|
|
415
|
+
node ../dist/claw/scripts/memu_mcp_server.js --memu-dir /path/to/claw/data/memu
|
|
416
416
|
```
|
|
417
417
|
|
|
418
418
|
`--memu-dir` is optional; it defaults to the resolved memU data directory
|
|
@@ -430,18 +430,18 @@ memU MCP server configuration for Hermes:
|
|
|
430
430
|
```yaml
|
|
431
431
|
mcp_servers:
|
|
432
432
|
memu:
|
|
433
|
-
command: "
|
|
434
|
-
args: ["/absolute/path/to/claw/scripts/memu_mcp_server.
|
|
433
|
+
command: "node"
|
|
434
|
+
args: ["/absolute/path/to/DEXBot2/dist/claw/scripts/memu_mcp_server.js", "--memu-dir", "/absolute/path/to/claw/data/memu"]
|
|
435
435
|
```
|
|
436
436
|
|
|
437
437
|
<details><summary>Compatibility command surface (click to expand)</summary>
|
|
438
438
|
|
|
439
439
|
```bash
|
|
440
440
|
# Via claw bridge
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
441
|
+
npm run claw:bridge -- memu-manifest
|
|
442
|
+
npm run claw:bridge -- memu-memorize --payload '{"resourceUrl":"/path/to/conv.txt","modality":"conversation"}'
|
|
443
|
+
npm run claw:bridge -- memu-retrieve --payload '{"queries":[{"role":"user","content":{"text":"What are my trading preferences?"}}]}'
|
|
444
|
+
npm run claw:bridge -- memu-status
|
|
445
445
|
|
|
446
446
|
# Via npm scripts
|
|
447
447
|
npm run memu:status
|
|
@@ -475,7 +475,7 @@ The position health subsystem discovers on-chain debt positions, classifies coll
|
|
|
475
475
|
Inspect one on-chain MPA position:
|
|
476
476
|
|
|
477
477
|
```bash
|
|
478
|
-
|
|
478
|
+
npm run claw:bridge -- mpa-position --payload '{"accountName":"your-account","mpaAsset":"HONEST.USD"}'
|
|
479
479
|
```
|
|
480
480
|
|
|
481
481
|
The decision loop (`modules/decision_loop.ts`) is exposed as a module API. Its `evaluate()` call ties discovery, trend analysis, and health assessment into a single result with prioritized actions.
|
|
@@ -487,19 +487,19 @@ Read, preview, and apply DEXBot2 bot settings through the locked profile adapter
|
|
|
487
487
|
Inspect the default policy:
|
|
488
488
|
|
|
489
489
|
```bash
|
|
490
|
-
|
|
490
|
+
npm run claw:bridge -- bot-settings --payload '{"botRef":"default"}'
|
|
491
491
|
```
|
|
492
492
|
|
|
493
493
|
Preview an update without applying:
|
|
494
494
|
|
|
495
495
|
```bash
|
|
496
|
-
|
|
496
|
+
npm run claw:bridge -- bot-settings-preview --payload '{"botRef":"default","patch":{"weightDistribution":{"sell":0.7,"buy":0.4}}}'
|
|
497
497
|
```
|
|
498
498
|
|
|
499
499
|
Apply the update and write the recalc trigger:
|
|
500
500
|
|
|
501
501
|
```bash
|
|
502
|
-
|
|
502
|
+
npm run claw:bridge -- bot-settings-apply --payload '{"botRef":"default","patch":{"weightDistribution":{"sell":0.7,"buy":0.4}}}'
|
|
503
503
|
```
|
|
504
504
|
|
|
505
505
|
## High-Level Actions
|
|
@@ -86,7 +86,7 @@ The Claw bridge supports the runtimes below. Each runtime shares the DEXBot2 cre
|
|
|
86
86
|
|
|
87
87
|
ZeroClaw should use Claw as a compatibility layer, not as a second signing or credential system.
|
|
88
88
|
|
|
89
|
-
- ZeroClaw can invoke the JSON/CLI bridge via `
|
|
89
|
+
- ZeroClaw can invoke the JSON/CLI bridge via `npm run zeroclaw:bridge`.
|
|
90
90
|
- The manifest lives in [../modules/claw_manifest.ts](../modules/claw_manifest.ts) and is safe to query without starting the BitShares runtime.
|
|
91
91
|
- Claw keeps private-key access inside its existing DEXBot2 credential path.
|
|
92
92
|
- ZeroClaw gets read access to market, profile, HONEST, and order context, plus explicit action entrypoints when it needs to request a trade operation.
|
|
@@ -102,7 +102,7 @@ The bridge surface currently includes:
|
|
|
102
102
|
- BTS-backed short open, take-profit, close, and plan builders
|
|
103
103
|
- MPA position lookup
|
|
104
104
|
|
|
105
|
-
Launcher behavior such as `
|
|
105
|
+
Launcher behavior such as `npm run claw:unlock` and `npm run pm2:claw-only` is documented and maintained separately under `skills/launcher-ops/`.
|
|
106
106
|
|
|
107
107
|
Recommended trust boundary:
|
|
108
108
|
|
|
@@ -122,7 +122,7 @@ cd claw && npm run zeroclaw:skill -- --profile-root /path/to/DEXBot2 --output ~/
|
|
|
122
122
|
|
|
123
123
|
NullClaw uses the same bridge surface, with a native skill path centered on `SKILL.toml` in the workspace.
|
|
124
124
|
|
|
125
|
-
- NullClaw can invoke the JSON/CLI bridge via `
|
|
125
|
+
- NullClaw can invoke the JSON/CLI bridge via `npm run nullclaw:bridge`.
|
|
126
126
|
- The manifest lives in [../modules/claw_manifest.ts](../modules/claw_manifest.ts) and is safe to query without starting the BitShares runtime.
|
|
127
127
|
- Claw keeps private-key access inside its existing DEXBot2 credential path.
|
|
128
128
|
- NullClaw gets the same read access to market, profile, HONEST, and order context, plus explicit action entrypoints when it needs to request a trade operation.
|
|
@@ -137,7 +137,7 @@ cd claw && npm run nullclaw:skill -- --profile-root /path/to/DEXBot2 --output ~/
|
|
|
137
137
|
|
|
138
138
|
NanoClaw uses the same bridge surface, with a native `SKILL.md` path in the workspace skill tree.
|
|
139
139
|
|
|
140
|
-
- NanoClaw can invoke the JSON/CLI bridge via `
|
|
140
|
+
- NanoClaw can invoke the JSON/CLI bridge via `npm run nanoclaw:bridge`.
|
|
141
141
|
- The bridge lives in [../modules/claw_bridge.ts](../modules/claw_bridge.ts) and uses the shared Claw command surface.
|
|
142
142
|
- Keep the generated skill named `bitshares-claw` so it does not collide with NanoClaw's bundled `claw` skill.
|
|
143
143
|
|
|
@@ -151,7 +151,7 @@ cd claw && npm run nanoclaw:skill -- --profile-root /path/to/DEXBot2 --output /p
|
|
|
151
151
|
|
|
152
152
|
OpenFang uses the same bridge surface through a CLI-first wrapper and a workspace skill file.
|
|
153
153
|
|
|
154
|
-
- OpenFang can invoke the JSON/CLI bridge via `
|
|
154
|
+
- OpenFang can invoke the JSON/CLI bridge via `npm run openfang:bridge`.
|
|
155
155
|
- The bridge lives in [../modules/claw_bridge.ts](../modules/claw_bridge.ts) and uses the shared Claw command surface.
|
|
156
156
|
- Keep the generated skill named `bitshares-claw` so it stays separate from runtime-specific OpenFang skills and remains a thin wrapper around the shared CLI bridge.
|
|
157
157
|
|
|
@@ -185,7 +185,7 @@ mcp_servers:
|
|
|
185
185
|
args: ["/absolute/path/to/claw/scripts/claw_mcp_server.js", "--profile-root", "/path/to/DEXBot2"]
|
|
186
186
|
```
|
|
187
187
|
|
|
188
|
-
>
|
|
188
|
+
> The generated skill file emits the `node` + `.js` form so it works against the compiled build (`npm run build`) without `tsx` installed.
|
|
189
189
|
|
|
190
190
|
### OpenClaw Compatibility
|
|
191
191
|
|
|
@@ -66,9 +66,9 @@ function parseArgs(argv: string[]): Record<string, any> {
|
|
|
66
66
|
|
|
67
67
|
function printUsage() {
|
|
68
68
|
console.log('Usage examples:');
|
|
69
|
-
console.log('
|
|
70
|
-
console.log('
|
|
71
|
-
console.log('
|
|
69
|
+
console.log(' node ../dist/claw/examples/short_mpa_bts_strategy.js --mode open --mpa HONEST.USD --debt 10 --collateral 25000 --sell-price 1000');
|
|
70
|
+
console.log(' node ../dist/claw/examples/short_mpa_bts_strategy.js --mode tp --mpa HONEST.USD --cover 10 --buy-price 900');
|
|
71
|
+
console.log(' node ../dist/claw/examples/short_mpa_bts_strategy.js --mode close --mpa HONEST.USD --repay 10 --release-collateral 25000');
|
|
72
72
|
console.log('Add --execute to broadcast transactions. Without it, the script prints the plan only.');
|
|
73
73
|
}
|
|
74
74
|
|
package/claw/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dexbot2-claw",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.19",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "Claw bridge and runtime integration layer for BitShares and DEXBot2.",
|
|
6
6
|
"type": "module",
|
|
@@ -28,30 +28,30 @@
|
|
|
28
28
|
"example:memu-integration": "npm run build && node ../dist/claw/examples/memu_integration_example.js",
|
|
29
29
|
"example:position-manager": "npm run build && node ../dist/claw/examples/position_manager_cli.js",
|
|
30
30
|
"example:short-mpa-bts": "npm run build && node ../dist/claw/examples/short_mpa_bts_strategy.js",
|
|
31
|
-
"claw:bridge": "
|
|
32
|
-
"claw:mcp": "
|
|
33
|
-
"claw:skill": "
|
|
34
|
-
"openfang:bridge": "
|
|
35
|
-
"openfang:skill": "
|
|
36
|
-
"nanobot:skill": "
|
|
37
|
-
"nanoclaw:bridge": "
|
|
38
|
-
"nanoclaw:skill": "
|
|
39
|
-
"picoclaw:skill": "
|
|
40
|
-
"openclaw:skill": "
|
|
41
|
-
"nullclaw:bridge": "
|
|
42
|
-
"nullclaw:skill": "
|
|
43
|
-
"zeroclaw:bridge": "
|
|
44
|
-
"zeroclaw:skill": "
|
|
45
|
-
"hermes:bridge": "
|
|
46
|
-
"hermes:skill": "
|
|
47
|
-
"memu:bridge": "
|
|
48
|
-
"memu:mcp": "
|
|
49
|
-
"memu:skill": "
|
|
31
|
+
"claw:bridge": "npm run build && node ../dist/claw/scripts/claw_bridge.js",
|
|
32
|
+
"claw:mcp": "npm run build && node ../dist/claw/scripts/claw_mcp_server.js",
|
|
33
|
+
"claw:skill": "npm run build && node ../dist/claw/scripts/claw_skill_md.js",
|
|
34
|
+
"openfang:bridge": "npm run build && node ../dist/claw/scripts/claw_bridge.js --runtime openfang",
|
|
35
|
+
"openfang:skill": "npm run build && node ../dist/claw/scripts/claw_skill_md.js --runtime openfang",
|
|
36
|
+
"nanobot:skill": "npm run build && node ../dist/claw/scripts/claw_skill_md.js --runtime nanobot",
|
|
37
|
+
"nanoclaw:bridge": "npm run build && node ../dist/claw/scripts/claw_bridge.js --runtime nanoclaw",
|
|
38
|
+
"nanoclaw:skill": "npm run build && node ../dist/claw/scripts/claw_skill_md.js --runtime nanoclaw",
|
|
39
|
+
"picoclaw:skill": "npm run build && node ../dist/claw/scripts/claw_skill_md.js --runtime picoclaw",
|
|
40
|
+
"openclaw:skill": "npm run build && node ../dist/claw/scripts/claw_skill_md.js --runtime openclaw",
|
|
41
|
+
"nullclaw:bridge": "npm run build && node ../dist/claw/scripts/claw_bridge.js --runtime nullclaw",
|
|
42
|
+
"nullclaw:skill": "npm run build && node ../dist/claw/scripts/claw_skill_md.js --runtime nullclaw",
|
|
43
|
+
"zeroclaw:bridge": "npm run build && node ../dist/claw/scripts/claw_bridge.js --runtime zeroclaw",
|
|
44
|
+
"zeroclaw:skill": "npm run build && node ../dist/claw/scripts/claw_skill_md.js --runtime zeroclaw",
|
|
45
|
+
"hermes:bridge": "npm run build && node ../dist/claw/scripts/claw_bridge.js --runtime hermes",
|
|
46
|
+
"hermes:skill": "npm run build && node ../dist/claw/scripts/claw_skill_md.js --runtime hermes",
|
|
47
|
+
"memu:bridge": "npm run build && node ../dist/claw/scripts/memu_mcp_server.js",
|
|
48
|
+
"memu:mcp": "npm run build && node ../dist/claw/scripts/memu_mcp_server.js",
|
|
49
|
+
"memu:skill": "npm run build && node ../dist/claw/scripts/claw_skill_md.js --runtime memu",
|
|
50
50
|
"memu:status": "npm run build && node --input-type=module -e \"const {runMemuCommand}=await import('../dist/claw/modules/memu_bridge.js');runMemuCommand('status').then(r=>console.log(JSON.stringify(r,null,2))).catch(e=>console.error(e.message))\"",
|
|
51
51
|
"service:position-watch": "npm run build && node ../dist/claw/modules/position_manager_watch.js",
|
|
52
52
|
"pm2:start": "npm run build && pm2 start ecosystem.config.cjs",
|
|
53
53
|
"pm2:stop": "pm2 stop ecosystem.config.cjs",
|
|
54
|
-
"report:honest-assets": "
|
|
54
|
+
"report:honest-assets": "npm run build && node ../dist/claw/scripts/honest_assets_report.js",
|
|
55
55
|
"test": "npm run build && npx tsx tests/test_claw_regressions.ts && npx tsx tests/test_claw_state_store.ts && npx tsx tests/test_dexbot_profiles.ts && npx tsx tests/test_position_manager_watch_health.ts && npx tsx tests/test_claw_bridge.ts && npx tsx tests/test_memu_bridge.ts && npx tsx tests/test_short_mpa_strategy.ts && npx tsx tests/test_position_health.ts && npx tsx tests/test_claw_chain_layer.ts && npx tsx tests/test_claw_domain_logic.ts && npx tsx tests/test_claw_catalog_and_credentials.ts && npx tsx tests/test_claw_data_flow.ts && npx tsx tests/test_position_manager.ts && npx tsx tests/test_claw_skill_generation.ts && npx tsx tests/test_claw_manifest_and_matrix.ts && npx tsx tests/test_claw_mcp_transport.ts && npx tsx tests/test_nullclaw_tmp_integration.ts",
|
|
56
56
|
"check": "npm run build && node --input-type=module -e \"await import('../dist/claw/index.js')\" && node -c ecosystem.config.cjs && node -c ../dist/claw/runtimes/openclaw-plugin/index.js"
|
|
57
57
|
}
|
|
@@ -111,7 +111,7 @@ function parseArgs(argv: any) {
|
|
|
111
111
|
return options;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
function printHelp(scriptPath = '
|
|
114
|
+
function printHelp(scriptPath = 'node dist/claw/scripts/claw_bridge.js') {
|
|
115
115
|
const commandLines = listClawCommandNames().map((command: any) => ` ${command}`);
|
|
116
116
|
|
|
117
117
|
console.log([
|
|
@@ -127,7 +127,7 @@ function describeScriptRuntimeManifest(runtimeName: any, payload = {}) {
|
|
|
127
127
|
return describeRuntimeManifest(runtimeName ? { ...payload, runtimeName } : payload);
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
async function main(runtimeName = null, scriptPath = '
|
|
130
|
+
async function main(runtimeName = null, scriptPath = 'node dist/claw/scripts/claw_bridge.js') {
|
|
131
131
|
const { command, help, payload } = parseArgs(process.argv.slice(2));
|
|
132
132
|
|
|
133
133
|
if (help || !command) {
|
|
@@ -55,7 +55,7 @@ function parseArgs(argv: any) {
|
|
|
55
55
|
function printHelp() {
|
|
56
56
|
console.log([
|
|
57
57
|
'Usage:',
|
|
58
|
-
'
|
|
58
|
+
' node dist/claw/scripts/claw_skill_md.js --runtime <openclaw|hermes|openfang|nanobot|picoclaw|nanoclaw|zeroclaw|nullclaw|memu> [--repo-root PATH] [--profile-root PATH] [--output PATH]',
|
|
59
59
|
'',
|
|
60
60
|
'Outputs a SKILL.md file for the requested runtime.',
|
|
61
61
|
'If --output is omitted, the markdown is written to stdout.'
|
|
@@ -4,11 +4,11 @@ Use this reference for DEXBot2 startup and PM2 orchestration work.
|
|
|
4
4
|
|
|
5
5
|
## Commands
|
|
6
6
|
|
|
7
|
-
- `
|
|
8
|
-
- `
|
|
9
|
-
- `
|
|
10
|
-
- `
|
|
11
|
-
- `
|
|
7
|
+
- `npm run unlock` - single-prompt local startup.
|
|
8
|
+
- `npm run claw:unlock` - credential daemon only, no bot startup.
|
|
9
|
+
- `npm run pm2:unlock` - PM2 startup for all active bots.
|
|
10
|
+
- `npm run pm2:unlock -- <bot-name>` - PM2 startup for one active bot.
|
|
11
|
+
- `npm run pm2:claw-only` - PM2 credential daemon only.
|
|
12
12
|
|
|
13
13
|
## Rules
|
|
14
14
|
|
|
@@ -68,7 +68,7 @@ These use HONEST.BTC as collateral instead of BTS — different collateral dynam
|
|
|
68
68
|
## Live Discovery
|
|
69
69
|
|
|
70
70
|
```bash
|
|
71
|
-
|
|
71
|
+
node ../dist/claw/scripts/honest_assets_report.js --json
|
|
72
72
|
```
|
|
73
73
|
|
|
74
74
|
Filter by `type === 'MPA'` for margin-tradeable assets. The `honest_ecosystem.ts` module's `isMpa()` function checks for `bitasset_data_id`.
|
|
@@ -148,14 +148,14 @@ For Hermes:
|
|
|
148
148
|
```yaml
|
|
149
149
|
mcp_servers:
|
|
150
150
|
memu:
|
|
151
|
-
command: "
|
|
152
|
-
args: ["/path/to/claw/scripts/memu_mcp_server.
|
|
151
|
+
command: "node"
|
|
152
|
+
args: ["/path/to/DEXBot2/dist/claw/scripts/memu_mcp_server.js", "--memu-dir", "/path/to/claw/data/memu"]
|
|
153
153
|
```
|
|
154
154
|
|
|
155
155
|
For NanoBot/PicoClaw:
|
|
156
156
|
|
|
157
157
|
```bash
|
|
158
|
-
|
|
158
|
+
node ../dist/claw/scripts/memu_mcp_server.js --memu-dir /path/to/claw/data/memu
|
|
159
159
|
```
|
|
160
160
|
|
|
161
161
|
## Proactive Memory Patterns
|
|
@@ -31,7 +31,7 @@ async function testParserAcceptsJsonlAcrossChunksAndSingleBuffer() {
|
|
|
31
31
|
capabilities: {},
|
|
32
32
|
clientInfo: {
|
|
33
33
|
name: 'claw-mcp-transport-test',
|
|
34
|
-
version: '1.4.
|
|
34
|
+
version: '1.4.19'
|
|
35
35
|
},
|
|
36
36
|
protocolVersion: '2024-11-05'
|
|
37
37
|
}
|
|
@@ -182,7 +182,7 @@ async function testMainEntrypointHandlesRealProcessInitialize() {
|
|
|
182
182
|
capabilities: {},
|
|
183
183
|
clientInfo: {
|
|
184
184
|
name: 'claw-mcp-transport-test',
|
|
185
|
-
version: '1.4.
|
|
185
|
+
version: '1.4.19'
|
|
186
186
|
},
|
|
187
187
|
protocolVersion: '2024-11-05'
|
|
188
188
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyze_ama_price_changes.d.ts","sourceRoot":"","sources":["../../../analysis/ama_fitting/analyze_ama_price_changes.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { calculateAMA } from '../../market_adapter/core/strategies/ama.js';
|
|
4
|
+
import { getStorage } from '../../modules/storage/index.js';
|
|
5
|
+
const { readJSON } = getStorage();
|
|
6
|
+
import { MARKET_ADAPTER } from '../../modules/constants.js';
|
|
7
|
+
'use strict';
|
|
8
|
+
/**
|
|
9
|
+
* AMA REPOSITION FREQUENCY ANALYSIS
|
|
10
|
+
*
|
|
11
|
+
* Simulates AMA_DELTA_THRESHOLD_PERCENT grid-reposition logic for all four AMA
|
|
12
|
+
* series on LP candle data.
|
|
13
|
+
*
|
|
14
|
+
* Uses the production threshold from MARKET_ADAPTER.AMA_DELTA_THRESHOLD_PERCENT
|
|
15
|
+
* (modules/constants.ts).
|
|
16
|
+
*
|
|
17
|
+
* Usage:
|
|
18
|
+
* tsx analysis/ama_fitting/analyze_ama_price_changes.ts --data <path-to-lp-candles.json> --results <path-to-optimization-results.json>
|
|
19
|
+
*/
|
|
20
|
+
const REPOS_THRESHOLD_PCT = MARKET_ADAPTER.AMA_DELTA_THRESHOLD_PERCENT;
|
|
21
|
+
/**
|
|
22
|
+
* Simulate AMA_DELTA_THRESHOLD_PERCENT reposition logic.
|
|
23
|
+
*
|
|
24
|
+
* Starting from the first post-warmup AMA value, track cumulative drift from
|
|
25
|
+
* the last reposition baseline. When drift ≥ threshold, a reposition fires:
|
|
26
|
+
* record step-count since previous reposition, reset baseline to current AMA.
|
|
27
|
+
*/
|
|
28
|
+
function trackRepositions(amaValues, thresholdPct, warmup) {
|
|
29
|
+
let events = 0;
|
|
30
|
+
const steps = [];
|
|
31
|
+
let baseline = amaValues[warmup];
|
|
32
|
+
let stepCounter = 0;
|
|
33
|
+
for (let i = warmup + 1; i < amaValues.length; i++) {
|
|
34
|
+
const curr = amaValues[i];
|
|
35
|
+
if (baseline === 0)
|
|
36
|
+
continue;
|
|
37
|
+
stepCounter++;
|
|
38
|
+
const driftPct = Math.abs((curr - baseline) / baseline) * 100;
|
|
39
|
+
if (driftPct >= thresholdPct) {
|
|
40
|
+
events++;
|
|
41
|
+
steps.push(stepCounter);
|
|
42
|
+
baseline = curr;
|
|
43
|
+
stepCounter = 0;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const min = steps.length > 0 ? Math.min(...steps) : 0;
|
|
47
|
+
const max = steps.length > 0 ? Math.max(...steps) : 0;
|
|
48
|
+
const avg = steps.length > 0 ? steps.reduce((a, b) => a + b, 0) / steps.length : 0;
|
|
49
|
+
return { events, steps, min, max, avg };
|
|
50
|
+
}
|
|
51
|
+
// ── Load data ─────────────────────────────────────────────────────────────────
|
|
52
|
+
function loadData(filePath) {
|
|
53
|
+
const json = readJSON(filePath);
|
|
54
|
+
const candles = json.candles ?? json;
|
|
55
|
+
return {
|
|
56
|
+
candles: candles.map((c) => ({ timestamp: c[0], close: c[4] })),
|
|
57
|
+
meta: json.meta ?? null,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function loadAmaParams(resultsPath) {
|
|
61
|
+
const json = readJSON(resultsPath);
|
|
62
|
+
const amas = json.meta?.amas;
|
|
63
|
+
if (!amas)
|
|
64
|
+
throw new Error('No amas found in results file');
|
|
65
|
+
return [
|
|
66
|
+
{ key: 'AMA1', label: amas.AMA1.label, er: amas.AMA1.er, fast: amas.AMA1.fast, slow: amas.AMA1.slow },
|
|
67
|
+
{ key: 'AMA2', label: amas.AMA2.label, er: amas.AMA2.er, fast: amas.AMA2.fast, slow: amas.AMA2.slow },
|
|
68
|
+
{ key: 'AMA3', label: amas.AMA3.label, er: amas.AMA3.er, fast: amas.AMA3.fast, slow: amas.AMA3.slow },
|
|
69
|
+
{ key: 'AMA4', label: amas.AMA4.label, er: amas.AMA4.er, fast: amas.AMA4.fast, slow: amas.AMA4.slow },
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
// ── Analysis ──────────────────────────────────────────────────────────────────
|
|
73
|
+
// ── Main ──────────────────────────────────────────────────────────────────────
|
|
74
|
+
function run() {
|
|
75
|
+
const dataArgIdx = process.argv.indexOf('--data');
|
|
76
|
+
const resultsArgIdx = process.argv.indexOf('--results');
|
|
77
|
+
if (dataArgIdx === -1) {
|
|
78
|
+
throw new Error('--data <path-to-lp-candles.json> is required');
|
|
79
|
+
}
|
|
80
|
+
if (resultsArgIdx === -1) {
|
|
81
|
+
throw new Error('--results <path-to-optimization-results.json> is required');
|
|
82
|
+
}
|
|
83
|
+
const dataFile = path.resolve(process.argv[dataArgIdx + 1]);
|
|
84
|
+
const resultsFile = path.resolve(process.argv[resultsArgIdx + 1]);
|
|
85
|
+
const { candles, meta } = loadData(dataFile);
|
|
86
|
+
const amaParams = loadAmaParams(resultsFile);
|
|
87
|
+
const closes = candles.map((c) => c.close);
|
|
88
|
+
const totalSteps = closes.length - 1; // candle-to-candle transitions
|
|
89
|
+
const label = meta?.pool
|
|
90
|
+
? `LP Pool ${meta.pool}`
|
|
91
|
+
: path.basename(dataFile, '.json');
|
|
92
|
+
const interval = meta?.intervalSeconds
|
|
93
|
+
? `${meta.intervalSeconds / 3600}h`
|
|
94
|
+
: '?h';
|
|
95
|
+
console.log('');
|
|
96
|
+
console.log('════════════════════════════════════════════════════════════════════════════════');
|
|
97
|
+
console.log(' AMA Reposition Frequency Analysis (AMA_DELTA_THRESHOLD_PERCENT simulation)');
|
|
98
|
+
console.log('════════════════════════════════════════════════════════════════════════════════');
|
|
99
|
+
console.log(` Dataset: ${label} (${interval} candles)`);
|
|
100
|
+
console.log(` Candles: ${candles.length} → ${totalSteps} steps total`);
|
|
101
|
+
console.log(` Threshold: ${REPOS_THRESHOLD_PCT}% (from MARKET_ADAPTER.AMA_DELTA_THRESHOLD_PERCENT)`);
|
|
102
|
+
console.log('');
|
|
103
|
+
console.log(' Logic: set baseline at warmup end, count steps until AMA drifts ≥ threshold,');
|
|
104
|
+
console.log(' record reposition + reset baseline. Repeat for full live window.');
|
|
105
|
+
console.log('');
|
|
106
|
+
const results = [];
|
|
107
|
+
for (const params of amaParams) {
|
|
108
|
+
const values = calculateAMA(closes, {
|
|
109
|
+
erPeriod: params.er,
|
|
110
|
+
fastPeriod: params.fast,
|
|
111
|
+
slowPeriod: params.slow,
|
|
112
|
+
});
|
|
113
|
+
const r = trackRepositions(values, REPOS_THRESHOLD_PCT, params.er);
|
|
114
|
+
const liveSteps = totalSteps - params.er;
|
|
115
|
+
const freq = liveSteps > 0 ? (r.events / liveSteps * 1000).toFixed(1) : '–';
|
|
116
|
+
const avg = r.events > 0 ? r.avg.toFixed(1) : '–';
|
|
117
|
+
const suffix = String(params.label).replace(/^AMA\d\s*/i, '').replace(/^[-:\s]+/, '').trim();
|
|
118
|
+
const rowLabel = `${params.key} ${suffix}`;
|
|
119
|
+
console.log(` ── ${rowLabel} (warmup: ${params.er} live: ${liveSteps} steps) ──`);
|
|
120
|
+
console.log(` ≥${REPOS_THRESHOLD_PCT}% repositions: ${r.events} avg steps: ${avg} min: ${r.events > 0 ? r.min : '–'} max: ${r.events > 0 ? r.max : '–'} freq: ${freq}/1k steps`);
|
|
121
|
+
console.log('');
|
|
122
|
+
results.push({
|
|
123
|
+
label: rowLabel,
|
|
124
|
+
events: r.events,
|
|
125
|
+
avg: r.avg,
|
|
126
|
+
freq: liveSteps > 0 ? r.events / liveSteps * 1000 : 0,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
console.log(' Note: warmup candles excluded (AMA initializes from SMA of the ER window).');
|
|
130
|
+
console.log('');
|
|
131
|
+
// ── Ranking: fewest repositions ────────────────────────────────────────────
|
|
132
|
+
results.sort((a, b) => a.events - b.events);
|
|
133
|
+
console.log(' Ranking — fewest repositions (least grid changes):');
|
|
134
|
+
console.log('');
|
|
135
|
+
console.log(' ' + '#'.padEnd(4) + 'AMA'.padEnd(20) + 'repositions'.padStart(12) + 'avg steps'.padStart(10) + ' /1000 steps');
|
|
136
|
+
console.log(' ' + '─'.repeat(4 + 20 + 12 + 10 + 12));
|
|
137
|
+
results.forEach((r, i) => {
|
|
138
|
+
console.log(' ' +
|
|
139
|
+
String(i + 1).padEnd(4) +
|
|
140
|
+
r.label.padEnd(20) +
|
|
141
|
+
String(r.events).padStart(12) +
|
|
142
|
+
r.avg.toFixed(1).padStart(10) +
|
|
143
|
+
` ${r.freq.toFixed(1)}`);
|
|
144
|
+
});
|
|
145
|
+
console.log('');
|
|
146
|
+
}
|
|
147
|
+
run();
|
|
148
|
+
//# sourceMappingURL=analyze_ama_price_changes.js.map
|