dexbot 1.6.10 → 1.6.12
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 +50 -3
- package/README.md +3 -1
- package/analysis/README.md +51 -11
- package/analysis/bot_fitting/README.md +12 -0
- package/analysis/tradingview/README.md +3 -3
- package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +11 -37
- package/analysis/trend_detection/README.md +31 -0
- package/claw/docs/DEXBOT2_TUNING_CHEAT_SHEET.md +4 -3
- package/claw/modules/chain_broadcast.ts +7 -1
- package/claw/modules/claw_launcher.ts +1 -1
- package/claw/modules/launcher_mode_detector.ts +9 -2
- package/claw/package.json +1 -1
- package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
- package/claw/runtimes/openclaw-plugin/package.json +1 -1
- package/dist/analysis/account_resolver.d.ts +1 -1
- package/dist/analysis/account_resolver.js +15 -2
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.js +3 -4
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +2 -7
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js +0 -1
- package/dist/analysis/ama_fitting/fetch_lp_candles.js +4 -4
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts +20 -4
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js +9 -6
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js +16 -12
- package/dist/analysis/analyze_args.d.ts +31 -0
- package/dist/analysis/analyze_args.js +41 -0
- package/dist/analysis/analyze_dynamic_weight.js +7 -20
- package/dist/analysis/analyze_kalman.js +7 -17
- package/dist/analysis/analyze_regime.js +7 -17
- package/dist/analysis/analyze_regime_windows.js +8 -18
- package/dist/analysis/analyze_risk_profile.js +8 -18
- package/dist/analysis/analyze_trade_heatmap.js +7 -17
- package/dist/analysis/analyze_volatility.js +7 -17
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts +220 -12
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js +55 -10
- package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts +34 -4
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js +72 -66
- package/dist/analysis/bot_fitting/backtest_lookback_drawdown.d.ts +21 -0
- package/dist/analysis/bot_fitting/backtest_lookback_drawdown.js +315 -0
- package/dist/analysis/bot_fitting/shared_utils.d.ts +7 -7
- package/dist/analysis/bot_fitting/shared_utils.js +2 -2
- package/dist/analysis/bot_key_utils.d.ts +18 -10
- package/dist/analysis/bot_key_utils.js +10 -17
- package/dist/analysis/bot_usage/discover_bot_accounts.js +44 -47
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts +1 -21
- package/dist/analysis/chain_pool.d.ts +3 -1
- package/dist/analysis/chart_ui.d.ts +5 -2
- package/dist/analysis/chart_ui.js +6 -3
- package/dist/analysis/chart_utils.d.ts +5 -5
- package/dist/analysis/chart_utils.js +9 -0
- package/dist/analysis/fills_cache.d.ts +64 -0
- package/dist/analysis/fills_cache.js +254 -0
- package/dist/analysis/fills_source.d.ts +2 -2
- package/dist/analysis/fills_source.js +19 -14
- package/dist/analysis/grid_correction_check.d.ts +1 -1
- package/dist/analysis/grid_correction_check.js +12 -11
- package/dist/analysis/math_utils.d.ts +7 -6
- package/dist/analysis/math_utils.js +5 -8
- package/dist/analysis/pnl_report.d.ts +39 -0
- package/dist/analysis/pnl_report.js +325 -0
- package/dist/analysis/price_sources.d.ts +8 -8
- package/dist/analysis/price_sources.js +5 -4
- package/dist/analysis/resolve_bot_accounts.js +2 -2
- package/dist/analysis/resolve_source.d.ts +1 -2
- package/dist/analysis/trade_profitability.d.ts +32 -2
- package/dist/analysis/trade_profitability.js +232 -106
- package/dist/analysis/tradingview/analyze_tradingview.d.ts +17 -6
- package/dist/analysis/tradingview/analyze_tradingview.js +9 -10
- package/dist/analysis/tradingview/grid_reset_config.d.ts +42 -31
- package/dist/analysis/tradingview/grid_reset_config.js +35 -6
- package/dist/analysis/tradingview/grid_reset_sim.d.ts +75 -8
- package/dist/analysis/tradingview/grid_reset_sim.js +42 -5
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts +69 -4
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +20 -20
- package/dist/analysis/trend_detection/backtest_ama_slope_huber.d.ts +102 -0
- package/dist/analysis/trend_detection/backtest_ama_slope_huber.js +725 -0
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts +63 -1
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +27 -112
- package/dist/analysis/trend_detection/huber_scale_variants.d.ts +40 -0
- package/dist/analysis/trend_detection/huber_scale_variants.js +176 -0
- package/dist/analysis/trend_detection/kalman_chart_generator.d.ts +30 -1
- package/dist/analysis/trend_detection/kalman_chart_generator.js +3 -3
- package/dist/analysis/trend_detection/regime_chart_generator.d.ts +31 -1
- package/dist/analysis/trend_detection/regime_chart_generator.js +2 -2
- package/dist/analysis/trend_detection/volatility_chart_generator.d.ts +33 -1
- package/dist/credential-daemon.js +34 -20
- package/dist/dexbot.js +17 -14
- package/dist/market_adapter/candle_utils.d.ts +22 -18
- package/dist/market_adapter/candle_utils.js +24 -20
- package/dist/market_adapter/core/asymmetric_bounds.d.ts +13 -4
- package/dist/market_adapter/core/config_normalizers.d.ts +3 -3
- package/dist/market_adapter/core/kibana_candles.d.ts +53 -18
- package/dist/market_adapter/core/kibana_candles.js +9 -7
- package/dist/market_adapter/core/kibana_client.d.ts +9 -1
- package/dist/market_adapter/core/kibana_client.js +8 -7
- package/dist/market_adapter/core/kibana_market_candles.d.ts +3 -2
- package/dist/market_adapter/core/market_adapter_service.d.ts +297 -115
- package/dist/market_adapter/core/market_adapter_service.js +184 -101
- package/dist/market_adapter/core/strategies/ama.d.ts +10 -2
- package/dist/market_adapter/core/strategies/ama.js +7 -32
- package/dist/market_adapter/core/strategies/ama_slope_model.d.ts +14 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.js +12 -34
- package/dist/market_adapter/core/strategies/atr/calculator.d.ts +7 -2
- package/dist/market_adapter/core/strategies/atr/calculator.js +2 -34
- package/dist/market_adapter/core/strategies/collateral_manager.d.ts +7 -1
- package/dist/market_adapter/core/strategies/collateral_manager.js +0 -22
- package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts +36 -8
- package/dist/market_adapter/core/strategies/dynamic_weight_series.js +9 -9
- package/dist/market_adapter/core/strategies/regime_gate.d.ts +24 -15
- package/dist/market_adapter/core/strategies/regime_gate.js +4 -31
- package/dist/market_adapter/core/strategies/regime_interp.d.ts +7 -1
- package/dist/market_adapter/core/strategies/regime_interp.js +14 -22
- package/dist/market_adapter/core/strategies/volatility_shift.d.ts +11 -1
- package/dist/market_adapter/core/strategies/volatility_shift.js +0 -13
- package/dist/market_adapter/inputs/cex_candle_parsing.d.ts +29 -0
- package/dist/market_adapter/inputs/cex_candle_parsing.js +52 -0
- package/dist/market_adapter/inputs/fetch_book_data.d.ts +20 -4
- package/dist/market_adapter/inputs/fetch_book_data.js +3 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +97 -226
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +42 -7
- package/dist/market_adapter/inputs/fetch_lp_data.js +22 -15
- package/dist/market_adapter/inputs/kibana_feed_source.d.ts +74 -15
- package/dist/market_adapter/inputs/kibana_feed_source.js +29 -22
- package/dist/market_adapter/inputs/kibana_source.d.ts +25 -3
- package/dist/market_adapter/inputs/kibana_source.js +2 -2
- package/dist/market_adapter/inputs/window_cache.d.ts +99 -94
- package/dist/market_adapter/inputs/window_cache.js +8 -8
- package/dist/market_adapter/interval_utils.d.ts +4 -4
- package/dist/market_adapter/log_format.d.ts +6 -6
- package/dist/market_adapter/log_format.js +28 -22
- package/dist/market_adapter/lp_chart_core.d.ts +22 -1
- package/dist/market_adapter/lp_chart_core.js +26 -192
- package/dist/market_adapter/lp_chart_runner.d.ts +7 -7
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts +41 -6
- package/dist/market_adapter/lp_chart_strategy_loader.js +8 -7
- package/dist/market_adapter/market_adapter.d.ts +94 -33
- package/dist/market_adapter/market_adapter.js +69 -75
- package/dist/market_adapter/utils/adapter_client.d.ts +3 -3
- package/dist/market_adapter/utils/adapter_client.js +2 -2
- package/dist/market_adapter/utils/atomic_write.d.ts +8 -1
- package/dist/market_adapter/utils/chain.d.ts +50 -41
- package/dist/market_adapter/utils/chain.js +40 -46
- package/dist/market_adapter/utils/data_discovery.d.ts +4 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts +12 -3
- package/dist/market_adapter/utils/file_json_cache.d.ts +2 -2
- package/dist/market_adapter/utils/file_lock.d.ts +28 -14
- package/dist/market_adapter/utils/file_lock.js +36 -32
- package/dist/market_adapter/utils/native_history.d.ts +9 -2
- package/dist/market_adapter/utils/native_history.js +35 -28
- package/dist/modules/account_bots.d.ts +577 -21
- package/dist/modules/account_bots.js +182 -158
- package/dist/modules/account_orders.d.ts +66 -30
- package/dist/modules/account_orders.js +22 -20
- package/dist/modules/authority_resolver.d.ts +12 -2
- package/dist/modules/authority_resolver.js +15 -8
- package/dist/modules/bitshares-native/chain_client.d.ts +38 -3
- package/dist/modules/bitshares-native/chain_client.js +45 -46
- package/dist/modules/bitshares-native/crypto/ecc.browser.js +11 -171
- package/dist/modules/bitshares-native/crypto/ecc.js +13 -176
- package/dist/modules/bitshares-native/crypto/ecc_core.d.ts +33 -0
- package/dist/modules/bitshares-native/crypto/ecc_core.js +213 -0
- package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts +2 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.js +1 -13
- package/dist/modules/bitshares-native/index.d.ts +1 -1
- package/dist/modules/bitshares-native/lru_cache.d.ts +7 -7
- package/dist/modules/bitshares-native/resolvers.d.ts +18 -6
- package/dist/modules/bitshares-native/serial/lazy_buffer.d.ts +4 -0
- package/dist/modules/bitshares-native/serial/lazy_buffer.js +21 -0
- package/dist/modules/bitshares-native/serial/operations.d.ts +1 -1
- package/dist/modules/bitshares-native/serial/serializer.d.ts +16 -12
- package/dist/modules/bitshares-native/serial/serializer.js +7 -13
- package/dist/modules/bitshares-native/serial/types.d.ts +25 -16
- package/dist/modules/bitshares-native/serial/types.js +55 -62
- package/dist/modules/bitshares-native/signing_client.d.ts +32 -2
- package/dist/modules/bitshares-native/signing_client.js +19 -14
- package/dist/modules/bitshares-native/subscriptions.d.ts +81 -1
- package/dist/modules/bitshares-native/subscriptions.js +12 -12
- package/dist/modules/bitshares-native/transport.d.ts +5 -4
- package/dist/modules/bitshares-native/transport.js +5 -4
- package/dist/modules/bitshares-native/tx/builder.d.ts +40 -5
- package/dist/modules/bitshares-native/tx/builder.js +4 -3
- package/dist/modules/bitshares-native/tx/tx_cache.d.ts +4 -4
- package/dist/modules/bitshares_client.d.ts +45 -13
- package/dist/modules/bitshares_client.js +28 -19
- package/dist/modules/bot_defaults.d.ts +6 -15
- package/dist/modules/bot_defaults.js +1 -5
- package/dist/modules/bot_settings.d.ts +44 -10
- package/dist/modules/bot_settings.js +11 -8
- package/dist/modules/bots_file_lock.d.ts +6 -6
- package/dist/modules/bots_file_lock.js +16 -12
- package/dist/modules/broadcast_failure.d.ts +2 -2
- package/dist/modules/broadcast_failure.js +5 -4
- package/dist/modules/chain_keys.d.ts +42 -40
- package/dist/modules/chain_keys.js +53 -45
- package/dist/modules/chain_orders.d.ts +93 -59
- package/dist/modules/chain_orders.js +31 -23
- package/dist/modules/constants.d.ts +530 -32
- package/dist/modules/constants.js +52 -60
- package/dist/modules/cr_planner.d.ts +40 -2
- package/dist/modules/credential_policy.d.ts +68 -8
- package/dist/modules/credential_policy.js +37 -31
- package/dist/modules/credential_session_cache.d.ts +2 -2
- package/dist/modules/credit_pricing.d.ts +42 -6
- package/dist/modules/credit_pricing.js +44 -30
- package/dist/modules/credit_runtime.d.ts +276 -118
- package/dist/modules/credit_runtime.js +462 -165
- package/dist/modules/crypto/browser_provider.js +6 -4
- package/dist/modules/crypto/node_provider.js +1 -1
- package/dist/modules/crypto/pure_scrypt.js +35 -4
- package/dist/modules/crypto/pure_secp256k1.js +72 -26
- package/dist/modules/crypto/sync.d.ts +9 -9
- package/dist/modules/crypto/sync.js +16 -9
- package/dist/modules/dexbot_class.d.ts +195 -139
- package/dist/modules/dexbot_class.js +78 -28
- package/dist/modules/dexbot_cow_runtime.d.ts +167 -87
- package/dist/modules/dexbot_cow_runtime.js +248 -206
- package/dist/modules/dexbot_credential_client.d.ts +19 -11
- package/dist/modules/dexbot_fill_runtime.d.ts +63 -48
- package/dist/modules/dexbot_fill_runtime.js +48 -41
- package/dist/modules/dexbot_maintenance_runtime.d.ts +109 -70
- package/dist/modules/dexbot_maintenance_runtime.js +117 -80
- package/dist/modules/dexbot_startup_runtime.d.ts +11 -10
- package/dist/modules/dexbot_startup_runtime.js +43 -43
- package/dist/modules/dexbot_state_recovery.d.ts +13 -12
- package/dist/modules/dexbot_state_recovery.js +18 -13
- package/dist/modules/fund_registry.d.ts +4 -2
- package/dist/modules/fund_registry.js +10 -10
- package/dist/modules/general_settings.d.ts +30 -4
- package/dist/modules/graceful_shutdown.d.ts +3 -3
- package/dist/modules/graceful_shutdown.js +2 -2
- package/dist/modules/grid_price_source.d.ts +1 -1
- package/dist/modules/key_store.d.ts +14 -8
- package/dist/modules/key_store.js +7 -6
- package/dist/modules/launcher/adapter_requirement.d.ts +11 -5
- package/dist/modules/launcher/adapter_requirement.js +5 -5
- package/dist/modules/launcher/bot_supervisor.d.ts +106 -24
- package/dist/modules/launcher/bot_supervisor.js +12 -11
- package/dist/modules/launcher/credential_bootstrap.d.ts +1 -1
- package/dist/modules/launcher/credential_bootstrap.js +1 -1
- package/dist/modules/launcher/credential_daemon.d.ts +4 -4
- package/dist/modules/launcher/credential_daemon.js +2 -2
- package/dist/modules/launcher/credential_secret.d.ts +1 -1
- package/dist/modules/launcher/foreign_cred_daemon.d.ts +2 -2
- package/dist/modules/launcher/market_adapter_runtime.d.ts +61 -6
- package/dist/modules/launcher/market_adapter_watchdog.d.ts +10 -2
- package/dist/modules/launcher/market_adapter_watchdog.js +4 -0
- package/dist/modules/launcher/monolithic_runtime.d.ts +18 -16
- package/dist/modules/launcher/status_reporting.d.ts +22 -14
- package/dist/modules/launcher/supervisor_control.d.ts +8 -1
- package/dist/modules/launcher/supervisor_control.js +4 -2
- package/dist/modules/market_adapter_whitelist.d.ts +9 -3
- package/dist/modules/market_adapter_whitelist.js +15 -3
- package/dist/modules/node_manager.d.ts +41 -11
- package/dist/modules/node_manager.js +5 -4
- package/dist/modules/order/accounting.d.ts +53 -24
- package/dist/modules/order/accounting.js +40 -14
- package/dist/modules/order/async_lock.d.ts +5 -2
- package/dist/modules/order/async_lock.js +1 -1
- package/dist/modules/order/export.d.ts +7 -6
- package/dist/modules/order/export.js +1 -7
- package/dist/modules/order/format.d.ts +39 -19
- package/dist/modules/order/format.js +62 -16
- package/dist/modules/order/genesis_policy.d.ts +21 -18
- package/dist/modules/order/genesis_policy.js +12 -8
- package/dist/modules/order/grid.d.ts +142 -36
- package/dist/modules/order/grid.js +148 -123
- package/dist/modules/order/grid_reconcile.d.ts +21 -20
- package/dist/modules/order/grid_reconcile.js +13 -12
- package/dist/modules/order/grid_reconcile_internal.d.ts +85 -72
- package/dist/modules/order/grid_reconcile_internal.js +28 -19
- package/dist/modules/order/index.d.ts +263 -1
- package/dist/modules/order/logger.d.ts +45 -11
- package/dist/modules/order/logger.js +38 -40
- package/dist/modules/order/logger_state.d.ts +4 -4
- package/dist/modules/order/manager.d.ts +226 -180
- package/dist/modules/order/manager.js +101 -83
- package/dist/modules/order/processed_fill_store.d.ts +18 -3
- package/dist/modules/order/processed_fill_store.js +16 -27
- package/dist/modules/order/strategy.d.ts +21 -13
- package/dist/modules/order/strategy.js +5 -6
- package/dist/modules/order/sync_engine.d.ts +91 -33
- package/dist/modules/order/sync_engine.js +99 -54
- package/dist/modules/order/utils/math.d.ts +157 -102
- package/dist/modules/order/utils/math.js +77 -38
- package/dist/modules/order/utils/order.d.ts +326 -106
- package/dist/modules/order/utils/order.js +200 -99
- package/dist/modules/order/utils/slot.d.ts +1 -1
- package/dist/modules/order/utils/system.d.ts +176 -26
- package/dist/modules/order/utils/system.js +86 -69
- package/dist/modules/order/utils/validate.d.ts +89 -41
- package/dist/modules/order/utils/validate.js +24 -22
- package/dist/modules/order/utils/withPoolRef.d.ts +4 -3
- package/dist/modules/order/utils/withPoolRef.js +18 -12
- package/dist/modules/order/working_grid.d.ts +14 -13
- package/dist/modules/paths.d.ts +3 -4
- package/dist/modules/paths.js +3 -27
- package/dist/modules/process_discovery.d.ts +1 -1
- package/dist/modules/process_discovery.js +2 -1
- package/dist/modules/runtime.d.ts +7 -3
- package/dist/modules/runtime.js +4 -3
- package/dist/modules/runtime_settings.d.ts +15 -10
- package/dist/modules/runtime_settings.js +30 -24
- package/dist/modules/settings_merge.d.ts +29 -3
- package/dist/modules/settings_merge.js +56 -78
- package/dist/modules/socket_json_client.d.ts +7 -4
- package/dist/modules/storage/browser_adapter.d.ts +38 -53
- package/dist/modules/storage/browser_adapter.js +7 -30
- package/dist/modules/storage/index.d.ts +1 -1
- package/dist/modules/storage/node_adapter.d.ts +45 -27
- package/dist/modules/storage/node_adapter.js +9 -9
- package/dist/modules/storage/types.d.ts +5 -4
- package/dist/modules/types.d.ts +1071 -2
- package/dist/modules/types.js +4 -1
- package/dist/modules/utils/asset_symbols.d.ts +2 -1
- package/dist/modules/utils/asset_symbols.js +2 -1
- package/dist/modules/utils/errors.d.ts +9 -0
- package/dist/modules/utils/errors.js +23 -1
- package/dist/modules/utils/time_range.d.ts +4 -0
- package/dist/modules/utils/time_range.js +18 -0
- package/dist/modules/validate_profiles.js +53 -43
- package/dist/modules/version_notice.d.ts +14 -3
- package/dist/modules/version_notice.js +6 -4
- package/dist/pm2.d.ts +29 -27
- package/dist/pm2.js +5 -5
- package/dist/scripts/analyze-credit.d.ts +2 -1
- package/dist/scripts/analyze-credit.js +23 -24
- package/dist/scripts/analyze-orders.d.ts +77 -9
- package/dist/scripts/analyze-orders.js +66 -84
- package/dist/scripts/chart_command.d.ts +27 -18
- package/dist/scripts/chart_command.js +16 -15
- package/dist/scripts/check_any.d.ts +18 -0
- package/dist/scripts/check_any.js +126 -0
- package/dist/scripts/diagnose-pool-history.js +12 -7
- package/dist/scripts/pnl.d.ts +3 -0
- package/dist/scripts/pnl.js +40 -0
- package/dist/scripts/print_grid.js +0 -1
- package/dist/scripts/run-tests.js +39 -7
- package/dist/scripts/runner.js +1 -1
- package/dist/scripts/test-credit-renewal.js +30 -21
- package/dist/scripts/update.d.ts +10 -5
- package/dist/scripts/update.js +168 -103
- package/dist/scripts/update_dist_freshness.js +1 -0
- package/dist/scripts/update_layout.d.ts +61 -0
- package/dist/scripts/update_layout.js +180 -0
- package/dist/scripts/validate_bots.js +2 -1
- package/dist/scripts/verify-browser-bundle.js +8 -0
- package/dist/unlock.d.ts +28 -3
- package/dist/unlock.js +72 -10
- package/docs/BITSHARES_ONBOARDING.md +2 -0
- package/docs/COPY_ON_WRITE_MASTER_PLAN.md +1 -1
- package/docs/COW_INVARIANTS.md +13 -6
- package/docs/DEXBOT_COMPARISON.md +8 -8
- package/docs/EVOLUTION.md +12 -10
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +5 -5
- package/docs/GRID_RECALCULATION.md +15 -16
- package/docs/GRID_RECONCILE.md +14 -3
- package/docs/LIFECYCLE.md +11 -11
- package/docs/MPA_CREDIT_USAGE.md +22 -3
- package/docs/README.md +15 -4
- package/docs/WORKFLOW.md +1 -0
- package/docs/architecture.md +12 -9
- package/docs/developer_guide.md +6 -6
- package/market_adapter/README.md +9 -26
- package/modules/README.md +4 -1
- package/package.json +4 -1
- package/scripts/README.md +14 -0
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* private copy of this decision tree, of the chain lookup and of the node
|
|
11
11
|
* handling — all of it lives here now.
|
|
12
12
|
*/
|
|
13
|
-
import {
|
|
13
|
+
import { getErrorMessage } from '../modules/utils/errors.js';
|
|
14
|
+
import { findBotKeyByAccountRef, loadBotMeta, persistBotAccountId, resolveBotKey } from './bot_key_utils.js';
|
|
14
15
|
import { withReadOnlyClient } from './chain_pool.js';
|
|
15
16
|
const ACCOUNT_ID_RE = /^1\.2\.\d+$/;
|
|
16
17
|
/** Default lookup: ephemeral read-only client over the built-in node pool. */
|
|
@@ -22,7 +23,7 @@ async function lookupNameOnChain(name) {
|
|
|
22
23
|
});
|
|
23
24
|
}
|
|
24
25
|
catch (e) {
|
|
25
|
-
console.warn(` [warn] Account resolution failed: ${e
|
|
26
|
+
console.warn(` [warn] Account resolution failed: ${getErrorMessage(e)}`);
|
|
26
27
|
return null;
|
|
27
28
|
}
|
|
28
29
|
}
|
|
@@ -112,6 +113,18 @@ async function resolveAccountRef(accountRef, options = {}) {
|
|
|
112
113
|
if (ACCOUNT_ID_RE.test(ref)) {
|
|
113
114
|
return { accountId: ref, botKey: null, botMeta: null, source: 'typed-id', reason: null };
|
|
114
115
|
}
|
|
116
|
+
// Local profile first: a bot whose profile name/key matches the reference
|
|
117
|
+
// resolves through its stored accountId/preferredAccount without any chain
|
|
118
|
+
// lookup. This is what lets `dexbot pnl <bot>` work offline and avoids
|
|
119
|
+
// treating a bot name as a chain account name.
|
|
120
|
+
try {
|
|
121
|
+
const botKey = resolveBotKey(ref, options.botsFile);
|
|
122
|
+
if (botKey)
|
|
123
|
+
return resolveBotAccount(botKey, options);
|
|
124
|
+
}
|
|
125
|
+
catch (_) {
|
|
126
|
+
// bots.json issues must never break resolution; fall through to chain.
|
|
127
|
+
}
|
|
115
128
|
// A bot claiming this name is the persist target; its preferredAccount is
|
|
116
129
|
// the same name, so resolveBotAccount owns the whole decision tree.
|
|
117
130
|
let match = null;
|
|
@@ -49,14 +49,13 @@ function trackRepositions(amaValues, thresholdPct, warmup) {
|
|
|
49
49
|
const avg = steps.length > 0 ? steps.reduce((a, b) => a + b, 0) / steps.length : 0;
|
|
50
50
|
return { events, steps, min, max, avg };
|
|
51
51
|
}
|
|
52
|
-
// ── Load data ─────────────────────────────────────────────────────────────────
|
|
53
52
|
function loadData(filePath) {
|
|
54
53
|
const json = readJSON(filePath);
|
|
55
|
-
const candles = json.candles ?? json;
|
|
54
|
+
const candles = (json.candles ?? json);
|
|
56
55
|
return {
|
|
57
56
|
candles: candles
|
|
58
57
|
.map((c) => normalizeCandle(c))
|
|
59
|
-
.filter(
|
|
58
|
+
.filter((c) => c != null)
|
|
60
59
|
.map((c) => ({ timestamp: c.time * 1000, close: c.close })),
|
|
61
60
|
meta: json.meta ?? null,
|
|
62
61
|
};
|
|
@@ -94,7 +93,7 @@ function run() {
|
|
|
94
93
|
? `LP Pool ${meta.pool}`
|
|
95
94
|
: path.basename(dataFile, '.json');
|
|
96
95
|
const interval = meta?.intervalSeconds
|
|
97
|
-
? `${meta.intervalSeconds / 3600}h`
|
|
96
|
+
? `${Number(meta.intervalSeconds) / 3600}h`
|
|
98
97
|
: '?h';
|
|
99
98
|
console.log('');
|
|
100
99
|
console.log('════════════════════════════════════════════════════════════════════════════════');
|
|
@@ -105,7 +105,6 @@ Options:
|
|
|
105
105
|
--help Show this help
|
|
106
106
|
`);
|
|
107
107
|
}
|
|
108
|
-
// ── Metrics ─────────────────────────────────────────────────────────────────────
|
|
109
108
|
function calcTotalAmaMovement(amaValues, erPeriod) {
|
|
110
109
|
const skip = erPeriod + 1;
|
|
111
110
|
let total = 0;
|
|
@@ -184,7 +183,7 @@ function findStartLambda(metricCache, maxSlow, lambdaEnd) {
|
|
|
184
183
|
return hi;
|
|
185
184
|
}
|
|
186
185
|
// ── HTML Chart (λ → Slow) ──────────────────────────────────────────────────────
|
|
187
|
-
function generateChartHtml(results, metricCache, fixEr, fixFast, dataLabel
|
|
186
|
+
function generateChartHtml(results, metricCache, fixEr, fixFast, dataLabel) {
|
|
188
187
|
const xs = results.map((r) => r.lambda);
|
|
189
188
|
const ys = results.map((r) => r.slow);
|
|
190
189
|
const dist = results.map((r) => r.distance);
|
|
@@ -238,12 +237,8 @@ ${uplotInlineTags()}
|
|
|
238
237
|
const slow = ${JSON.stringify(ys)};
|
|
239
238
|
const dist = ${JSON.stringify(dist)};
|
|
240
239
|
const move = ${JSON.stringify(move)};
|
|
241
|
-
const amaPts = ${JSON.stringify(amaAnnotations)};
|
|
242
240
|
const cacheSlow = ${JSON.stringify(cacheSlow)};
|
|
243
241
|
const cacheMove = ${JSON.stringify(cacheMove)};
|
|
244
|
-
const revSlow = slow.slice().reverse();
|
|
245
|
-
const revMove = move.slice().reverse();
|
|
246
|
-
const revDist = dist.slice().reverse();
|
|
247
242
|
|
|
248
243
|
const slowOpts = {
|
|
249
244
|
width: 1100, height: 440,
|
|
@@ -372,7 +367,7 @@ async function run() {
|
|
|
372
367
|
const chartName = cfg.outFile || path.join(PATHS.ANALYSIS.CHARTS_DIR, `lambda_vs_slow_er${cfg.fixEr}_fast${cfg.fixFast}_${cfg.lambdaSteps}steps.html`);
|
|
373
368
|
const chartPath = path.resolve(chartName);
|
|
374
369
|
ensureDir(path.dirname(chartPath));
|
|
375
|
-
const html = generateChartHtml(results, metricCache, cfg.fixEr, cfg.fixFast, dataLabel
|
|
370
|
+
const html = generateChartHtml(results, metricCache, cfg.fixEr, cfg.fixFast, dataLabel);
|
|
376
371
|
fs.writeFileSync(chartPath, html, 'utf8');
|
|
377
372
|
console.log(`\n Chart: ${path.relative(process.cwd(), chartPath)}`);
|
|
378
373
|
console.log('');
|
|
@@ -123,7 +123,6 @@ function main() {
|
|
|
123
123
|
console.log(`--- ER distribution (erPeriod=${erP}) ---`);
|
|
124
124
|
console.log(` p5 ${p5} p50 ${p50} p95 ${p95} avg ${refAvgER.toFixed(4)}`);
|
|
125
125
|
console.log('');
|
|
126
|
-
// ── Per-AMA analysis (compute once, cache results) ─────────────────
|
|
127
126
|
const results = [];
|
|
128
127
|
// Validate erPeriod / fastPeriod consistency for meaningful naiveSC comparison
|
|
129
128
|
const erPeriods = new Set();
|
|
@@ -123,17 +123,17 @@ function validateArgs(args) {
|
|
|
123
123
|
throw new Error('--pool is required');
|
|
124
124
|
if (!args.assetAId)
|
|
125
125
|
throw new Error('--assetAId is required');
|
|
126
|
-
if (!Number.isFinite(args.assetAPrecision))
|
|
126
|
+
if (!Number.isFinite(Number(args.assetAPrecision)))
|
|
127
127
|
throw new Error('--assetAPrecision is required');
|
|
128
128
|
if (!args.assetBId)
|
|
129
129
|
throw new Error('--assetBId is required');
|
|
130
|
-
if (!Number.isFinite(args.assetBPrecision))
|
|
130
|
+
if (!Number.isFinite(Number(args.assetBPrecision)))
|
|
131
131
|
throw new Error('--assetBPrecision is required');
|
|
132
|
-
if (!Number.isFinite(args.hours) || args.hours <= 0)
|
|
132
|
+
if (!Number.isFinite(Number(args.hours)) || Number(args.hours) <= 0)
|
|
133
133
|
throw new Error('--hours must be > 0');
|
|
134
134
|
// Reject unknown/NaN intervals here instead of letting NaN flow silently
|
|
135
135
|
// into Kibana range queries (production throws on unsupported intervals).
|
|
136
|
-
if (!Number.isFinite(args.intervalSeconds) || args.intervalSeconds <= 0) {
|
|
136
|
+
if (!Number.isFinite(Number(args.intervalSeconds)) || Number(args.intervalSeconds) <= 0) {
|
|
137
137
|
throw new Error('Unsupported --interval: use one of 1m, 5m, 15m, 1h, 4h, 1d or a positive number of seconds');
|
|
138
138
|
}
|
|
139
139
|
}
|
|
@@ -13,11 +13,27 @@ declare function parseArgs(argv: string[]): {
|
|
|
13
13
|
quiet: boolean;
|
|
14
14
|
help: boolean;
|
|
15
15
|
};
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
interface GenerateChartOptions {
|
|
17
|
+
logger?: {
|
|
18
|
+
log: (...args: unknown[]) => void;
|
|
19
|
+
};
|
|
20
|
+
dataFile?: string | null;
|
|
21
|
+
outFile?: string | null;
|
|
22
|
+
strategies?: typeof DEFAULT_STRATEGIES;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}
|
|
25
|
+
declare function generateChart(options?: GenerateChartOptions): {
|
|
26
|
+
dataFile: string;
|
|
18
27
|
outFile: string;
|
|
19
|
-
amaResults:
|
|
20
|
-
|
|
28
|
+
amaResults: (Record<string, unknown> & {
|
|
29
|
+
values: number[];
|
|
30
|
+
})[];
|
|
31
|
+
meta: {
|
|
32
|
+
assetA: {};
|
|
33
|
+
assetB: {};
|
|
34
|
+
intervalSeconds: {};
|
|
35
|
+
fetchedAt: {};
|
|
36
|
+
};
|
|
21
37
|
candleArrays: number[][];
|
|
22
38
|
};
|
|
23
39
|
declare function run(argv?: string[]): void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
import { getErrorMessage } from '../../modules/utils/errors.js';
|
|
2
3
|
import fs from 'node:fs';
|
|
3
4
|
import path from 'node:path';
|
|
4
5
|
import { pathToFileURL } from 'node:url';
|
|
@@ -72,14 +73,16 @@ function loadCandles(dataFile) {
|
|
|
72
73
|
const candleArrays = normalized.map(c => [c.time * 1000, c.open, c.high, c.low, c.close, c.volume]);
|
|
73
74
|
return { dataFile: resolved, meta, candleObjects, candleArrays };
|
|
74
75
|
}
|
|
75
|
-
// ── Output path ────────────────────────────────────────────────────────────────
|
|
76
76
|
function defaultChartPath(meta) {
|
|
77
|
-
const
|
|
78
|
-
|
|
77
|
+
const intervalSeconds = Number(meta?.intervalSeconds);
|
|
78
|
+
const intervalLabel = Number.isFinite(intervalSeconds) && intervalSeconds > 0
|
|
79
|
+
? toIntervalLabel(intervalSeconds)
|
|
79
80
|
: '1h';
|
|
81
|
+
const assetA = meta?.assetA;
|
|
82
|
+
const assetB = meta?.assetB;
|
|
80
83
|
const suffix = meta?.pool
|
|
81
84
|
? `pool_${String(meta.pool).replace('1.19.', '')}`
|
|
82
|
-
: `${
|
|
85
|
+
: `${assetA?.symbol || 'unknown'}_${assetB?.symbol || 'pair'}`;
|
|
83
86
|
return path.join(CHARTS_DIR, `lp_chart_${suffix}_${intervalLabel}_UNIFIED_COMPARISON.html`);
|
|
84
87
|
}
|
|
85
88
|
// ── Help ───────────────────────────────────────────────────────────────────────
|
|
@@ -99,7 +102,7 @@ Options:
|
|
|
99
102
|
|
|
100
103
|
Notes:
|
|
101
104
|
- If --data is omitted, the newest lp_pool_*.json under market_adapter/data/lp is used.
|
|
102
|
-
- Accepts
|
|
105
|
+
- Accepts several candle JSON shapes: flat [[ts,o,h,l,c,v],...], {candles: [...]}, or {data: [...]}.
|
|
103
106
|
- Separate from Kibana fetching — use fetch_lp_candles.ts to pull data first.
|
|
104
107
|
`);
|
|
105
108
|
}
|
|
@@ -192,7 +195,7 @@ function run(argv = process.argv.slice(2)) {
|
|
|
192
195
|
});
|
|
193
196
|
}
|
|
194
197
|
catch (e) {
|
|
195
|
-
console.error('Error:', e
|
|
198
|
+
console.error('Error:', getErrorMessage(e));
|
|
196
199
|
process.exitCode = 1;
|
|
197
200
|
}
|
|
198
201
|
}
|
|
@@ -74,7 +74,7 @@ function geometricRange(min, max, count, quantum = null) {
|
|
|
74
74
|
}
|
|
75
75
|
return [...new Set(out)].sort((a, b) => a - b);
|
|
76
76
|
}
|
|
77
|
-
function buildDimension(
|
|
77
|
+
function buildDimension(cfg) {
|
|
78
78
|
const min = Number(cfg.min);
|
|
79
79
|
const max = Number(cfg.max);
|
|
80
80
|
const step = Number(cfg.step);
|
|
@@ -262,13 +262,13 @@ function getAmaObjectivesFromArgs(args) {
|
|
|
262
262
|
const objectives = cloneObjectives();
|
|
263
263
|
for (const o of objectives) {
|
|
264
264
|
const id = o.key.toLowerCase();
|
|
265
|
-
const cap = args[`${id}Cap`];
|
|
265
|
+
const cap = Number(args[`${id}Cap`]);
|
|
266
266
|
if (Number.isFinite(cap))
|
|
267
267
|
o.distanceCapQuantile = cap;
|
|
268
268
|
if (!Number.isFinite(o.distanceCapQuantile) || o.distanceCapQuantile <= 0 || o.distanceCapQuantile > 1) {
|
|
269
269
|
throw new Error(`Invalid cap for ${o.key}: ${o.distanceCapQuantile}. Use 0 < cap <= 1`);
|
|
270
270
|
}
|
|
271
|
-
const w = args[`${id}Weight`];
|
|
271
|
+
const w = Number(args[`${id}Weight`]);
|
|
272
272
|
if (Number.isFinite(w)) {
|
|
273
273
|
if (w <= 0)
|
|
274
274
|
throw new Error(`${o.key} distanceWeight must be positive, got ${w}`);
|
|
@@ -278,7 +278,10 @@ function getAmaObjectivesFromArgs(args) {
|
|
|
278
278
|
return objectives;
|
|
279
279
|
}
|
|
280
280
|
function ensureValidRange(label, cfg) {
|
|
281
|
-
const
|
|
281
|
+
const min = Number(cfg.min);
|
|
282
|
+
const max = Number(cfg.max);
|
|
283
|
+
const step = Number(cfg.step);
|
|
284
|
+
const count = Number(cfg.count);
|
|
282
285
|
if (!Number.isFinite(min) || !Number.isFinite(max) || max < min) {
|
|
283
286
|
throw new Error(`Invalid ${label} range: min=${min}, max=${max}`);
|
|
284
287
|
}
|
|
@@ -290,7 +293,7 @@ function ensureValidRange(label, cfg) {
|
|
|
290
293
|
}
|
|
291
294
|
function boundaryFlags(winner, erValues, fastValues, slowValues, fixedEr = null, fixedFast = null) {
|
|
292
295
|
if (!winner)
|
|
293
|
-
return { er: null, fast: null, slow: null,
|
|
296
|
+
return { er: null, fast: null, slow: null, onBoundary: false };
|
|
294
297
|
const eps = 1e-9;
|
|
295
298
|
const minEr = erValues[0], maxEr = erValues[erValues.length - 1];
|
|
296
299
|
const minFast = fastValues[0], maxFast = fastValues[fastValues.length - 1];
|
|
@@ -298,7 +301,7 @@ function boundaryFlags(winner, erValues, fastValues, slowValues, fixedEr = null,
|
|
|
298
301
|
const er = Number.isFinite(fixedEr) ? null : (Math.abs(winner.er - minEr) < eps ? 'min' : (Math.abs(winner.er - maxEr) < eps ? 'max' : null));
|
|
299
302
|
const fast = Number.isFinite(fixedFast) ? null : (Math.abs(winner.fast - minFast) < eps ? 'min' : (Math.abs(winner.fast - maxFast) < eps ? 'max' : null));
|
|
300
303
|
const slow = Math.abs(winner.slow - minSlow) < eps ? 'min' : (Math.abs(winner.slow - maxSlow) < eps ? 'max' : null);
|
|
301
|
-
return { er, fast, slow,
|
|
304
|
+
return { er, fast, slow, onBoundary: !!(er || fast || slow) };
|
|
302
305
|
}
|
|
303
306
|
// ── Data loaders ──────────────────────────────────────────────────────────────
|
|
304
307
|
function normalizeSymbol(value) {
|
|
@@ -514,9 +517,9 @@ async function run() {
|
|
|
514
517
|
ensureValidRange('ER', args.er);
|
|
515
518
|
ensureValidRange('Fast', args.fast);
|
|
516
519
|
ensureValidRange('Slow', args.slow);
|
|
517
|
-
const erDim = buildDimension(
|
|
518
|
-
const fastDim = buildDimension(
|
|
519
|
-
const slowDim = buildDimension(
|
|
520
|
+
const erDim = buildDimension(args.er);
|
|
521
|
+
const fastDim = buildDimension(args.fast);
|
|
522
|
+
const slowDim = buildDimension(args.slow);
|
|
520
523
|
const ER_VALUES = Number.isFinite(args.fixedEr) ? [args.fixedEr] : erDim.values;
|
|
521
524
|
const FAST_VALUES = Number.isFinite(args.fixedFast) ? [args.fixedFast] : fastDim.values;
|
|
522
525
|
const SLOW_VALUES_AREA = slowDim.values;
|
|
@@ -677,7 +680,7 @@ async function run() {
|
|
|
677
680
|
console.log(' Boundary Check');
|
|
678
681
|
console.log('────────────────────────────────────────────────────────────────────────────────');
|
|
679
682
|
for (const [name, b] of Object.entries(boundarySummary)) {
|
|
680
|
-
const txt = b.
|
|
683
|
+
const txt = b.onBoundary ? `ER:${b.er || '-'} Fast:${b.fast || '-'} Slow:${b.slow || '-'}` : 'none';
|
|
681
684
|
console.log(`${name.padEnd(24)} ${txt}`);
|
|
682
685
|
}
|
|
683
686
|
console.log();
|
|
@@ -772,8 +775,9 @@ async function run() {
|
|
|
772
775
|
}
|
|
773
776
|
}
|
|
774
777
|
if (!isMainThread) {
|
|
775
|
-
|
|
776
|
-
|
|
778
|
+
const workerMessage = workerData;
|
|
779
|
+
if (workerMessage?.type === 'search_shard') {
|
|
780
|
+
const result = runSearchShard(workerMessage.payload, (p) => {
|
|
777
781
|
parentPort.postMessage({ type: 'progress', ...p });
|
|
778
782
|
});
|
|
779
783
|
parentPort.postMessage({ type: 'done', result });
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared command-line parsing for the analysis runners.
|
|
3
|
+
*
|
|
4
|
+
* Every analysis CLI accepts the same base flags (`--source`, `--bot-key`,
|
|
5
|
+
* `--file`, `--list-bots`, `--quiet`) plus its own tool-specific options. The
|
|
6
|
+
* helpers here own the shared base so each `parseArgs` only has to describe the
|
|
7
|
+
* flags it adds.
|
|
8
|
+
*/
|
|
9
|
+
import type { SourceConfig } from './resolve_source.js';
|
|
10
|
+
/** Fields every analysis CLI config shares. */
|
|
11
|
+
export interface AnalysisBaseConfig {
|
|
12
|
+
source: {
|
|
13
|
+
type: string;
|
|
14
|
+
config: SourceConfig;
|
|
15
|
+
};
|
|
16
|
+
quiet: boolean;
|
|
17
|
+
listBots: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** Fresh base config for the common `--source market_adapter --bot-key <key>` flow. */
|
|
20
|
+
export declare function baseAnalysisConfig(): AnalysisBaseConfig;
|
|
21
|
+
/**
|
|
22
|
+
* Consume one of the flags shared by every analysis CLI
|
|
23
|
+
* (`--source`, `--bot-key`, `--file`, `--list-bots`, `--quiet`).
|
|
24
|
+
*
|
|
25
|
+
* @param next returns the next argv token and advances the caller's index,
|
|
26
|
+
* e.g. `() => args[++i]`.
|
|
27
|
+
* @returns true when the flag was recognized (and any value consumed), so the
|
|
28
|
+
* caller can `continue` to the next token.
|
|
29
|
+
*/
|
|
30
|
+
export declare function consumeCommonAnalysisArg(arg: string, next: () => string, config: AnalysisBaseConfig): boolean;
|
|
31
|
+
//# sourceMappingURL=analyze_args.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/** Fresh base config for the common `--source market_adapter --bot-key <key>` flow. */
|
|
3
|
+
export function baseAnalysisConfig() {
|
|
4
|
+
return {
|
|
5
|
+
source: { type: 'market_adapter', config: { botKey: '' } },
|
|
6
|
+
quiet: false,
|
|
7
|
+
listBots: false,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Consume one of the flags shared by every analysis CLI
|
|
12
|
+
* (`--source`, `--bot-key`, `--file`, `--list-bots`, `--quiet`).
|
|
13
|
+
*
|
|
14
|
+
* @param next returns the next argv token and advances the caller's index,
|
|
15
|
+
* e.g. `() => args[++i]`.
|
|
16
|
+
* @returns true when the flag was recognized (and any value consumed), so the
|
|
17
|
+
* caller can `continue` to the next token.
|
|
18
|
+
*/
|
|
19
|
+
export function consumeCommonAnalysisArg(arg, next, config) {
|
|
20
|
+
switch (arg) {
|
|
21
|
+
case '--source':
|
|
22
|
+
config.source.type = next();
|
|
23
|
+
return true;
|
|
24
|
+
case '--bot-key':
|
|
25
|
+
config.source.config.botKey = next();
|
|
26
|
+
return true;
|
|
27
|
+
case '--file':
|
|
28
|
+
config.source.config.filePath = next();
|
|
29
|
+
config.source.type = 'json';
|
|
30
|
+
return true;
|
|
31
|
+
case '--list-bots':
|
|
32
|
+
config.listBots = true;
|
|
33
|
+
return true;
|
|
34
|
+
case '--quiet':
|
|
35
|
+
config.quiet = true;
|
|
36
|
+
return true;
|
|
37
|
+
default:
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=analyze_args.js.map
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* --source json \
|
|
12
12
|
* --file market_adapter/data/lp/<path>/<to>/<lp-candles>.json
|
|
13
13
|
*/
|
|
14
|
+
import { getErrorMessage } from '../modules/utils/errors.js';
|
|
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';
|
|
@@ -23,6 +24,7 @@ import { PATHS } from '../modules/paths.js';
|
|
|
23
24
|
import { writeChartFile, toFileUrl } from './chart_utils.js';
|
|
24
25
|
import { getCandleClose } from './math_utils.js';
|
|
25
26
|
import { resolveSource, listAvailableBots } from './resolve_source.js';
|
|
27
|
+
import { baseAnalysisConfig, consumeCommonAnalysisArg } from './analyze_args.js';
|
|
26
28
|
// AMA Slope weight calculation config — use DEFAULTS from market adapter
|
|
27
29
|
const AMA_WEIGHT_CONFIG = {
|
|
28
30
|
lookbackBars: MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_LOOKBACK_BARS,
|
|
@@ -46,27 +48,19 @@ const { HURST_CONFIG, PE_CONFIG } = MARKET_ADAPTER;
|
|
|
46
48
|
function parseArgs() {
|
|
47
49
|
const args = process.argv.slice(2);
|
|
48
50
|
const config = {
|
|
49
|
-
|
|
51
|
+
...baseAnalysisConfig(),
|
|
50
52
|
chartFile: path.join(PATHS.ANALYSIS.CHARTS_DIR, 'dynamic_weight_chart.html'),
|
|
51
53
|
title: null,
|
|
52
54
|
alpha: MARKET_ADAPTER.DYNAMIC_WEIGHT_ALPHA,
|
|
53
55
|
gain: MARKET_ADAPTER.DYNAMIC_WEIGHT_GAIN,
|
|
54
56
|
dispWeight: MARKET_ADAPTER.DYNAMIC_WEIGHT_DW,
|
|
55
57
|
clipPct: MARKET_ADAPTER.DYNAMIC_WEIGHT_CLIP_PERCENTILE,
|
|
56
|
-
quiet: false,
|
|
57
|
-
listBots: false,
|
|
58
58
|
};
|
|
59
59
|
for (let i = 0; i < args.length; i++) {
|
|
60
60
|
const arg = args[i];
|
|
61
|
-
if (arg
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
config.source.config.botKey = args[++i];
|
|
65
|
-
else if (arg === '--file') {
|
|
66
|
-
config.source.config.filePath = args[++i];
|
|
67
|
-
config.source.type = 'json';
|
|
68
|
-
}
|
|
69
|
-
else if (arg === '--chart')
|
|
61
|
+
if (consumeCommonAnalysisArg(arg, () => args[++i], config))
|
|
62
|
+
continue;
|
|
63
|
+
if (arg === '--chart')
|
|
70
64
|
config.chartFile = args[++i];
|
|
71
65
|
else if (arg === '--title')
|
|
72
66
|
config.title = args[++i] ?? null;
|
|
@@ -78,14 +72,8 @@ function parseArgs() {
|
|
|
78
72
|
config.dispWeight = parseFloat(args[++i]);
|
|
79
73
|
else if (arg === '--lb')
|
|
80
74
|
config.lookbackBars = parseInt(args[++i], 10);
|
|
81
|
-
else if (arg === '--ema')
|
|
82
|
-
config.amaEmaSpan = parseInt(args[++i], 10);
|
|
83
75
|
else if (arg === '--clip')
|
|
84
76
|
config.clipPct = parseFloat(args[++i]);
|
|
85
|
-
else if (arg === '--list-bots')
|
|
86
|
-
config.listBots = true;
|
|
87
|
-
else if (arg === '--quiet')
|
|
88
|
-
config.quiet = true;
|
|
89
77
|
}
|
|
90
78
|
return config;
|
|
91
79
|
}
|
|
@@ -182,7 +170,6 @@ async function main() {
|
|
|
182
170
|
...AMA_WEIGHT_CONFIG,
|
|
183
171
|
lookbackBars: config.lookbackBars ?? AMA_WEIGHT_CONFIG.lookbackBars,
|
|
184
172
|
},
|
|
185
|
-
amaEmaSpan: config.amaEmaSpan,
|
|
186
173
|
alpha: config.alpha,
|
|
187
174
|
gain: config.gain,
|
|
188
175
|
dispWeight: config.dispWeight,
|
|
@@ -211,7 +198,7 @@ async function main() {
|
|
|
211
198
|
console.log(`\n[DynamicWeight] ✓ Chart saved. Open chart: (${toFileUrl(config.chartFile)})`);
|
|
212
199
|
}
|
|
213
200
|
catch (err) {
|
|
214
|
-
console.error(`[DynamicWeight] Error: ${err
|
|
201
|
+
console.error(`[DynamicWeight] Error: ${getErrorMessage(err)}`);
|
|
215
202
|
process.exit(1);
|
|
216
203
|
}
|
|
217
204
|
}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* --source json \
|
|
11
11
|
* --file market_adapter/data/lp/<path>/<to>/<lp-candles>.json
|
|
12
12
|
*/
|
|
13
|
+
import { getErrorMessage } from '../modules/utils/errors.js';
|
|
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';
|
|
@@ -20,10 +21,11 @@ import { getCandleClose } from './math_utils.js';
|
|
|
20
21
|
import { writeChartFile } from './chart_utils.js';
|
|
21
22
|
import { PATHS } from '../modules/paths.js';
|
|
22
23
|
import { resolveSource, listAvailableBots } from './resolve_source.js';
|
|
24
|
+
import { baseAnalysisConfig, consumeCommonAnalysisArg } from './analyze_args.js';
|
|
23
25
|
function parseArgs() {
|
|
24
26
|
const args = process.argv.slice(2);
|
|
25
27
|
const config = {
|
|
26
|
-
|
|
28
|
+
...baseAnalysisConfig(),
|
|
27
29
|
// Defaults resolve to the live MARKET_ADAPTER Kalman constants so
|
|
28
30
|
// runs are directly comparable with production (qTactical 0.01,
|
|
29
31
|
// qModal 0.0001 — NOT a single shared Q for both filters).
|
|
@@ -32,20 +34,12 @@ function parseArgs() {
|
|
|
32
34
|
qModal: null,
|
|
33
35
|
qNoise: null,
|
|
34
36
|
chartFile: path.join(PATHS.ANALYSIS.CHARTS_DIR, 'kalman_chart.html'),
|
|
35
|
-
quiet: false,
|
|
36
|
-
listBots: false,
|
|
37
37
|
};
|
|
38
38
|
for (let i = 0; i < args.length; i++) {
|
|
39
39
|
const arg = args[i];
|
|
40
|
-
if (arg
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
config.source.config.botKey = args[++i];
|
|
44
|
-
else if (arg === '--file') {
|
|
45
|
-
config.source.config.filePath = args[++i];
|
|
46
|
-
config.source.type = 'json';
|
|
47
|
-
}
|
|
48
|
-
else if (arg === '--r')
|
|
40
|
+
if (consumeCommonAnalysisArg(arg, () => args[++i], config))
|
|
41
|
+
continue;
|
|
42
|
+
if (arg === '--r')
|
|
49
43
|
config.rNoise = parseFloat(args[++i]);
|
|
50
44
|
else if (arg === '--q')
|
|
51
45
|
config.qNoise = parseFloat(args[++i]);
|
|
@@ -55,10 +49,6 @@ function parseArgs() {
|
|
|
55
49
|
config.qModal = parseFloat(args[++i]);
|
|
56
50
|
else if (arg === '--chart')
|
|
57
51
|
config.chartFile = args[++i];
|
|
58
|
-
else if (arg === '--list-bots')
|
|
59
|
-
config.listBots = true;
|
|
60
|
-
else if (arg === '--quiet')
|
|
61
|
-
config.quiet = true;
|
|
62
52
|
}
|
|
63
53
|
return config;
|
|
64
54
|
}
|
|
@@ -137,7 +127,7 @@ async function main() {
|
|
|
137
127
|
console.log(`[Kalman] ✓ Chart saved to ${config.chartFile}`);
|
|
138
128
|
}
|
|
139
129
|
catch (err) {
|
|
140
|
-
console.error(`[Kalman] Error: ${err
|
|
130
|
+
console.error(`[Kalman] Error: ${getErrorMessage(err)}`);
|
|
141
131
|
process.exit(1);
|
|
142
132
|
}
|
|
143
133
|
}
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* --source json \
|
|
18
18
|
* --file market_adapter/data/lp/<path>/<to>/<lp-candles>.json
|
|
19
19
|
*/
|
|
20
|
+
import { getErrorMessage } from '../modules/utils/errors.js';
|
|
20
21
|
import path from 'node:path';
|
|
21
22
|
import { MARKET_ADAPTER } from '../modules/constants.js';
|
|
22
23
|
import { PATHS } from '../modules/paths.js';
|
|
@@ -27,30 +28,23 @@ import { calculateAMA } from '../market_adapter/core/strategies/ama.js';
|
|
|
27
28
|
import { writeChartFile } from './chart_utils.js';
|
|
28
29
|
import { getCandleClose } from './math_utils.js';
|
|
29
30
|
import { resolveSource, listAvailableBots } from './resolve_source.js';
|
|
31
|
+
import { baseAnalysisConfig, consumeCommonAnalysisArg } from './analyze_args.js';
|
|
30
32
|
const HURST_CONFIG = MARKET_ADAPTER.HURST_CONFIG;
|
|
31
33
|
const PE_CONFIG = MARKET_ADAPTER.PE_CONFIG;
|
|
32
34
|
function parseArgs() {
|
|
33
35
|
const args = process.argv.slice(2);
|
|
34
36
|
const config = {
|
|
35
|
-
|
|
37
|
+
...baseAnalysisConfig(),
|
|
36
38
|
chartFile: path.join(PATHS.ANALYSIS.CHARTS_DIR, 'regime_chart.html'),
|
|
37
39
|
hurstWindow: HURST_CONFIG.window,
|
|
38
40
|
peWindow: PE_CONFIG.window,
|
|
39
41
|
peM: PE_CONFIG.m,
|
|
40
|
-
quiet: false,
|
|
41
|
-
listBots: false,
|
|
42
42
|
};
|
|
43
43
|
for (let i = 0; i < args.length; i++) {
|
|
44
44
|
const arg = args[i];
|
|
45
|
-
if (arg
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
config.source.config.botKey = args[++i];
|
|
49
|
-
else if (arg === '--file') {
|
|
50
|
-
config.source.config.filePath = args[++i];
|
|
51
|
-
config.source.type = 'json';
|
|
52
|
-
}
|
|
53
|
-
else if (arg === '--chart')
|
|
45
|
+
if (consumeCommonAnalysisArg(arg, () => args[++i], config))
|
|
46
|
+
continue;
|
|
47
|
+
if (arg === '--chart')
|
|
54
48
|
config.chartFile = args[++i];
|
|
55
49
|
else if (arg === '--hurst-window')
|
|
56
50
|
config.hurstWindow = parseInt(args[++i], 10);
|
|
@@ -58,10 +52,6 @@ function parseArgs() {
|
|
|
58
52
|
config.peWindow = parseInt(args[++i], 10);
|
|
59
53
|
else if (arg === '--pe-m')
|
|
60
54
|
config.peM = parseInt(args[++i], 10);
|
|
61
|
-
else if (arg === '--list-bots')
|
|
62
|
-
config.listBots = true;
|
|
63
|
-
else if (arg === '--quiet')
|
|
64
|
-
config.quiet = true;
|
|
65
55
|
}
|
|
66
56
|
return config;
|
|
67
57
|
}
|
|
@@ -133,7 +123,7 @@ async function main() {
|
|
|
133
123
|
console.log(`[Regime] \u2713 Chart saved to ${config.chartFile}`);
|
|
134
124
|
}
|
|
135
125
|
catch (err) {
|
|
136
|
-
console.error(`[Regime] Error: ${err
|
|
126
|
+
console.error(`[Regime] Error: ${getErrorMessage(err)}`);
|
|
137
127
|
process.exit(1);
|
|
138
128
|
}
|
|
139
129
|
}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* --source json \
|
|
17
17
|
* --file market_adapter/data/lp/<path>/<to>/<lp-candles>.json
|
|
18
18
|
*/
|
|
19
|
+
import { getErrorMessage } from '../modules/utils/errors.js';
|
|
19
20
|
import path from 'node:path';
|
|
20
21
|
import { HurstAnalyzer, classifyHurst } from './trend_detection/hurst_analyzer.js';
|
|
21
22
|
import { PermutationEntropyAnalyzer } from './trend_detection/permutation_entropy_analyzer.js';
|
|
@@ -25,6 +26,7 @@ import { writeChartFile } from './chart_utils.js';
|
|
|
25
26
|
import { getCandleClose } from './math_utils.js';
|
|
26
27
|
import { roundTo } from '../modules/order/utils/math.js';
|
|
27
28
|
import { resolveSource, listAvailableBots } from './resolve_source.js';
|
|
29
|
+
import { baseAnalysisConfig, consumeCommonAnalysisArg } from './analyze_args.js';
|
|
28
30
|
const HURST_CONFIG = MARKET_ADAPTER.HURST_CONFIG;
|
|
29
31
|
const PE_CONFIG = MARKET_ADAPTER.PE_CONFIG;
|
|
30
32
|
const HURST_CENTER = HURST_CONFIG.window;
|
|
@@ -48,27 +50,15 @@ const PE_DELAY = PE_CONFIG.delay;
|
|
|
48
50
|
function parseArgs() {
|
|
49
51
|
const args = process.argv.slice(2);
|
|
50
52
|
const config = {
|
|
51
|
-
|
|
53
|
+
...baseAnalysisConfig(),
|
|
52
54
|
chartFile: path.join(PATHS.ANALYSIS.CHARTS_DIR, 'regime_windows_heatmap.html'),
|
|
53
|
-
quiet: false,
|
|
54
|
-
listBots: false,
|
|
55
55
|
};
|
|
56
56
|
for (let i = 0; i < args.length; i++) {
|
|
57
57
|
const arg = args[i];
|
|
58
|
-
if (arg
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
config.source.config.botKey = args[++i];
|
|
62
|
-
else if (arg === '--file') {
|
|
63
|
-
config.source.config.filePath = args[++i];
|
|
64
|
-
config.source.type = 'json';
|
|
65
|
-
}
|
|
66
|
-
else if (arg === '--chart')
|
|
58
|
+
if (consumeCommonAnalysisArg(arg, () => args[++i], config))
|
|
59
|
+
continue;
|
|
60
|
+
if (arg === '--chart')
|
|
67
61
|
config.chartFile = args[++i];
|
|
68
|
-
else if (arg === '--list-bots')
|
|
69
|
-
config.listBots = true;
|
|
70
|
-
else if (arg === '--quiet')
|
|
71
|
-
config.quiet = true;
|
|
72
62
|
}
|
|
73
63
|
return config;
|
|
74
64
|
}
|
|
@@ -164,7 +154,7 @@ function scoreWindowPair(prices, hurstWindow, peWindow) {
|
|
|
164
154
|
function computeComposite(allResults) {
|
|
165
155
|
const n = allResults.length;
|
|
166
156
|
if (n === 0)
|
|
167
|
-
return
|
|
157
|
+
return [];
|
|
168
158
|
const stabilityVals = allResults.map((r) => r._stabilityRaw);
|
|
169
159
|
const entropyVals = allResults.map((r) => r._entropyRaw);
|
|
170
160
|
const structuredVals = allResults.map((r) => r._structuredRaw);
|
|
@@ -415,7 +405,7 @@ async function main() {
|
|
|
415
405
|
console.log(`[RegimeWindows] ✓ Chart saved to ${config.chartFile}`);
|
|
416
406
|
}
|
|
417
407
|
catch (err) {
|
|
418
|
-
console.error(`[RegimeWindows] Error: ${err
|
|
408
|
+
console.error(`[RegimeWindows] Error: ${getErrorMessage(err)}`);
|
|
419
409
|
process.exit(1);
|
|
420
410
|
}
|
|
421
411
|
}
|