dexbot 1.6.7 → 1.6.9
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 +73 -1
- package/README.md +3 -3
- package/analysis/README.md +2 -3
- package/analysis/tradingview/README.md +78 -1
- package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +1 -1
- package/claw/package.json +1 -1
- package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
- package/claw/runtimes/openclaw-plugin/package.json +1 -1
- package/dist/analysis/tradingview/analyze_tradingview.d.ts +4 -0
- package/dist/analysis/tradingview/analyze_tradingview.js +55 -0
- package/dist/analysis/tradingview/grid_reset_config.d.ts +61 -0
- package/dist/analysis/tradingview/grid_reset_config.js +235 -0
- package/dist/analysis/tradingview/grid_reset_sim.d.ts +67 -0
- package/dist/analysis/tradingview/grid_reset_sim.js +307 -0
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +419 -3
- package/dist/dexbot.js +55 -16
- package/dist/market_adapter/core/market_adapter_service.d.ts +81 -1
- package/dist/market_adapter/core/market_adapter_service.js +239 -20
- package/dist/market_adapter/core/signals/hurst_analyzer.d.ts +10 -1
- package/dist/market_adapter/core/signals/hurst_analyzer.js +40 -18
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts +26 -2
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js +132 -29
- package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts +8 -1
- package/dist/market_adapter/core/strategies/dynamic_weight_series.js +5 -1
- package/dist/market_adapter/core/strategies/regime_gate.d.ts +61 -3
- package/dist/market_adapter/core/strategies/regime_gate.js +207 -7
- package/dist/market_adapter/inputs/window_cache.d.ts +97 -19
- package/dist/market_adapter/inputs/window_cache.js +302 -48
- package/dist/market_adapter/interval_utils.d.ts +18 -1
- package/dist/market_adapter/interval_utils.js +31 -1
- package/dist/market_adapter/market_adapter.d.ts +158 -2
- package/dist/market_adapter/market_adapter.js +399 -65
- package/dist/market_adapter/test_helpers.d.ts +2 -2
- package/dist/market_adapter/test_helpers.js +2 -2
- package/dist/market_adapter/utils/file_json_cache.d.ts +29 -0
- package/dist/market_adapter/utils/file_json_cache.js +106 -0
- package/dist/modules/account_bots.js +10 -0
- package/dist/modules/account_orders.d.ts +24 -2
- package/dist/modules/account_orders.js +41 -4
- package/dist/modules/bot_settings.js +10 -1
- package/dist/modules/config.d.ts +7 -0
- package/dist/modules/config.js +2 -0
- package/dist/modules/constants.d.ts +16 -4
- package/dist/modules/constants.js +144 -38
- package/dist/modules/dexbot_class.d.ts +6 -76
- package/dist/modules/dexbot_class.js +0 -32
- package/dist/modules/dexbot_cow_runtime.d.ts +3 -58
- package/dist/modules/dexbot_cow_runtime.js +4 -87
- package/dist/modules/dexbot_maintenance_runtime.d.ts +15 -1
- package/dist/modules/dexbot_maintenance_runtime.js +59 -11
- package/dist/modules/dexbot_startup_runtime.js +73 -20
- package/dist/modules/dexbot_state_recovery.d.ts +6 -0
- package/dist/modules/dexbot_state_recovery.js +21 -0
- package/dist/modules/order/async_lock.d.ts +8 -0
- package/dist/modules/order/async_lock.js +15 -0
- package/dist/modules/order/genesis_policy.d.ts +162 -0
- package/dist/modules/order/genesis_policy.js +267 -0
- package/dist/modules/order/grid.js +172 -160
- package/dist/modules/order/grid_reconcile.d.ts +9 -0
- package/dist/modules/order/grid_reconcile.js +13 -4
- package/dist/modules/order/grid_reconcile_internal.js +2 -2
- package/dist/modules/order/manager.d.ts +4 -0
- package/dist/modules/order/manager.js +14 -1
- package/dist/modules/order/sync_engine.d.ts +19 -0
- package/dist/modules/order/sync_engine.js +284 -344
- package/dist/modules/order/utils/math.d.ts +22 -1
- package/dist/modules/order/utils/math.js +64 -1
- package/dist/modules/order/utils/order.d.ts +43 -58
- package/dist/modules/order/utils/order.js +220 -197
- package/dist/modules/order/utils/system.js +8 -1
- package/dist/modules/paths.d.ts +1 -0
- package/dist/modules/paths.js +1 -0
- package/dist/modules/version_notice.d.ts +311 -0
- package/dist/modules/version_notice.js +709 -0
- package/dist/pm2.js +16 -0
- package/dist/unlock.js +28 -0
- package/docs/BITSHARES_ONBOARDING.md +8 -1
- package/docs/COW_INVARIANTS.md +3 -2
- package/docs/DEXBOT_COMPARISON.md +4 -4
- package/docs/EVOLUTION.md +22 -20
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
- package/docs/GRID_PRICE_INVARIANT.md +149 -31
- package/docs/GRID_RECALCULATION.md +18 -2
- package/docs/README.md +3 -1
- package/docs/WORKFLOW.md +16 -5
- package/market_adapter/README.md +29 -1
- package/modules/README.md +18 -1
- package/package.json +13 -5
- package/scripts/README.md +28 -2
- package/scripts/clear-all.sh +13 -4
- package/scripts/clear-logs.sh +13 -4
- package/scripts/clear-market-adapter.sh +6 -0
- package/scripts/clear-orders.sh +5 -0
- package/scripts/lib/dexbot-paths.sh +108 -0
- package/tests/README.md +11 -3
- package/analysis/account_resolver.ts +0 -161
- package/analysis/ama_fitting/analyze_ama_price_changes.ts +0 -155
- package/analysis/ama_fitting/analyze_lambda_vs_slow.ts +0 -404
- package/analysis/ama_fitting/calibrate_convergence_er.ts +0 -201
- package/analysis/ama_fitting/fetch_lp_candles.ts +0 -184
- package/analysis/ama_fitting/generate_unified_comparison_chart.ts +0 -232
- package/analysis/ama_fitting/optimizer_high_resolution.ts +0 -802
- package/analysis/analyze_dynamic_weight.ts +0 -243
- package/analysis/analyze_kalman.ts +0 -157
- package/analysis/analyze_regime.ts +0 -158
- package/analysis/analyze_regime_windows.ts +0 -470
- package/analysis/analyze_risk_profile.ts +0 -199
- package/analysis/analyze_trade_heatmap.ts +0 -362
- package/analysis/analyze_volatility.ts +0 -182
- package/analysis/bot_fitting/backtest_ama_sweep.ts +0 -934
- package/analysis/bot_fitting/backtest_bot_fitting.ts +0 -861
- package/analysis/bot_fitting/shared_utils.ts +0 -52
- package/analysis/bot_key_utils.ts +0 -426
- package/analysis/bot_usage/discover_bot_accounts.ts +0 -635
- package/analysis/bot_usage/kibana_bot_queries.ts +0 -211
- package/analysis/chain_pool.ts +0 -47
- package/analysis/chart_css.ts +0 -62
- package/analysis/chart_ui.ts +0 -105
- package/analysis/chart_utils.ts +0 -210
- package/analysis/fills_source.ts +0 -228
- package/analysis/grid_correction_check.ts +0 -786
- package/analysis/math_utils.ts +0 -53
- package/analysis/price_sources.ts +0 -136
- package/analysis/resolve_bot_accounts.ts +0 -199
- package/analysis/resolve_source.ts +0 -99
- package/analysis/results/ama_sweep_results_lp_pool_133_1h.json +0 -2455
- package/analysis/results/bot_fitting_results_lp_pool_133_1h.json +0 -218
- package/analysis/trade_profitability.ts +0 -1335
- package/analysis/tradingview/analyze_tradingview.ts +0 -280
- package/analysis/tradingview/h-bts_tradingview.html +0 -1570
- package/analysis/tradingview/t-bts_tradingview.html +0 -1570
- package/analysis/tradingview/tradingview_uplot_chart_generator.ts +0 -3268
- package/analysis/trend_detection/dynamic_weight_chart_generator.ts +0 -1481
- package/analysis/trend_detection/hurst_analyzer.ts +0 -7
- package/analysis/trend_detection/kalman_chart_generator.ts +0 -398
- package/analysis/trend_detection/kalman_trend_analyzer.ts +0 -9
- package/analysis/trend_detection/kalman_velocity_smoothing.ts +0 -7
- package/analysis/trend_detection/package.json +0 -23
- package/analysis/trend_detection/permutation_entropy_analyzer.ts +0 -7
- package/analysis/trend_detection/regime_chart_generator.ts +0 -338
- package/analysis/trend_detection/tests/test_kalman_trend.ts +0 -153
- package/analysis/trend_detection/tests/test_kalman_velocity_smoothing.ts +0 -64
- package/analysis/trend_detection/volatility_chart_generator.ts +0 -654
- package/analysis/tsconfig.json +0 -29
- package/claw/tests/package.json +0 -3
- package/claw/tests/test_claw_bridge.ts +0 -570
- package/claw/tests/test_claw_catalog_and_credentials.ts +0 -156
- package/claw/tests/test_claw_chain_layer.ts +0 -739
- package/claw/tests/test_claw_data_flow.ts +0 -525
- package/claw/tests/test_claw_domain_logic.ts +0 -471
- package/claw/tests/test_claw_manifest_and_matrix.ts +0 -222
- package/claw/tests/test_claw_mcp_transport.ts +0 -243
- package/claw/tests/test_claw_regressions.ts +0 -711
- package/claw/tests/test_claw_skill_generation.ts +0 -103
- package/claw/tests/test_claw_state_store.ts +0 -44
- package/claw/tests/test_dexbot_profiles.ts +0 -654
- package/claw/tests/test_memu_bridge.ts +0 -189
- package/claw/tests/test_nullclaw_tmp_integration.ts +0 -57
- package/claw/tests/test_position_health.ts +0 -343
- package/claw/tests/test_position_manager.ts +0 -429
- package/claw/tests/test_position_manager_watch_health.ts +0 -100
- package/claw/tests/test_short_mpa_strategy.ts +0 -232
- package/dist/analysis/account_resolver.d.ts.map +0 -1
- package/dist/analysis/account_resolver.js.map +0 -1
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.js.map +0 -1
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js.map +0 -1
- package/dist/analysis/ama_fitting/calibrate_convergence_er.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js.map +0 -1
- package/dist/analysis/ama_fitting/fetch_lp_candles.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/fetch_lp_candles.js.map +0 -1
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js.map +0 -1
- package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js.map +0 -1
- package/dist/analysis/analyze_dynamic_weight.d.ts.map +0 -1
- package/dist/analysis/analyze_dynamic_weight.js.map +0 -1
- package/dist/analysis/analyze_kalman.d.ts.map +0 -1
- package/dist/analysis/analyze_kalman.js.map +0 -1
- package/dist/analysis/analyze_regime.d.ts.map +0 -1
- package/dist/analysis/analyze_regime.js.map +0 -1
- package/dist/analysis/analyze_regime_windows.d.ts.map +0 -1
- package/dist/analysis/analyze_regime_windows.js.map +0 -1
- package/dist/analysis/analyze_risk_profile.d.ts.map +0 -1
- package/dist/analysis/analyze_risk_profile.js.map +0 -1
- package/dist/analysis/analyze_trade_heatmap.d.ts.map +0 -1
- package/dist/analysis/analyze_trade_heatmap.js.map +0 -1
- package/dist/analysis/analyze_volatility.d.ts.map +0 -1
- package/dist/analysis/analyze_volatility.js.map +0 -1
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts.map +0 -1
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js.map +0 -1
- package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts.map +0 -1
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js.map +0 -1
- package/dist/analysis/bot_fitting/shared_utils.d.ts.map +0 -1
- package/dist/analysis/bot_fitting/shared_utils.js.map +0 -1
- package/dist/analysis/bot_key_utils.d.ts.map +0 -1
- package/dist/analysis/bot_key_utils.js.map +0 -1
- package/dist/analysis/bot_usage/discover_bot_accounts.d.ts.map +0 -1
- package/dist/analysis/bot_usage/discover_bot_accounts.js.map +0 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +0 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.js.map +0 -1
- package/dist/analysis/chain_pool.d.ts.map +0 -1
- package/dist/analysis/chain_pool.js.map +0 -1
- package/dist/analysis/chart_css.d.ts.map +0 -1
- package/dist/analysis/chart_css.js.map +0 -1
- package/dist/analysis/chart_ui.d.ts.map +0 -1
- package/dist/analysis/chart_ui.js.map +0 -1
- package/dist/analysis/chart_utils.d.ts.map +0 -1
- package/dist/analysis/chart_utils.js.map +0 -1
- package/dist/analysis/fills_source.d.ts.map +0 -1
- package/dist/analysis/fills_source.js.map +0 -1
- package/dist/analysis/grid_correction_check.d.ts.map +0 -1
- package/dist/analysis/grid_correction_check.js.map +0 -1
- package/dist/analysis/math_utils.d.ts.map +0 -1
- package/dist/analysis/math_utils.js.map +0 -1
- package/dist/analysis/price_sources.d.ts.map +0 -1
- package/dist/analysis/price_sources.js.map +0 -1
- package/dist/analysis/resolve_bot_accounts.d.ts.map +0 -1
- package/dist/analysis/resolve_bot_accounts.js.map +0 -1
- package/dist/analysis/resolve_source.d.ts.map +0 -1
- package/dist/analysis/resolve_source.js.map +0 -1
- package/dist/analysis/trade_profitability.d.ts.map +0 -1
- package/dist/analysis/trade_profitability.js.map +0 -1
- package/dist/analysis/tradingview/analyze_tradingview.d.ts.map +0 -1
- package/dist/analysis/tradingview/analyze_tradingview.js.map +0 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +0 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/hurst_analyzer.d.ts.map +0 -1
- package/dist/analysis/trend_detection/hurst_analyzer.js.map +0 -1
- package/dist/analysis/trend_detection/kalman_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/kalman_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/kalman_trend_analyzer.d.ts.map +0 -1
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js.map +0 -1
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.d.ts.map +0 -1
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js.map +0 -1
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.d.ts.map +0 -1
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js.map +0 -1
- package/dist/analysis/trend_detection/regime_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/regime_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts +0 -2
- package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts.map +0 -1
- package/dist/analysis/trend_detection/tests/test_kalman_trend.js +0 -128
- package/dist/analysis/trend_detection/tests/test_kalman_trend.js.map +0 -1
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts +0 -2
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts.map +0 -1
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js +0 -37
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js.map +0 -1
- package/dist/analysis/trend_detection/volatility_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/volatility_chart_generator.js.map +0 -1
- package/dist/bot.d.ts.map +0 -1
- package/dist/bot.js.map +0 -1
- package/dist/credential-daemon.d.ts.map +0 -1
- package/dist/credential-daemon.js.map +0 -1
- package/dist/dexbot.d.ts.map +0 -1
- package/dist/dexbot.js.map +0 -1
- package/dist/market_adapter/ama_signal_runner.d.ts.map +0 -1
- package/dist/market_adapter/ama_signal_runner.js.map +0 -1
- package/dist/market_adapter/candle_utils.d.ts.map +0 -1
- package/dist/market_adapter/candle_utils.js.map +0 -1
- package/dist/market_adapter/core/asymmetric_bounds.d.ts.map +0 -1
- package/dist/market_adapter/core/asymmetric_bounds.js.map +0 -1
- package/dist/market_adapter/core/config_normalizers.d.ts.map +0 -1
- package/dist/market_adapter/core/config_normalizers.js.map +0 -1
- package/dist/market_adapter/core/kibana_candles.d.ts.map +0 -1
- package/dist/market_adapter/core/kibana_candles.js.map +0 -1
- package/dist/market_adapter/core/kibana_client.d.ts.map +0 -1
- package/dist/market_adapter/core/kibana_client.js.map +0 -1
- package/dist/market_adapter/core/kibana_market_candles.d.ts.map +0 -1
- package/dist/market_adapter/core/kibana_market_candles.js.map +0 -1
- package/dist/market_adapter/core/market_adapter_service.d.ts.map +0 -1
- package/dist/market_adapter/core/market_adapter_service.js.map +0 -1
- package/dist/market_adapter/core/signals/hurst_analyzer.d.ts.map +0 -1
- package/dist/market_adapter/core/signals/hurst_analyzer.js.map +0 -1
- package/dist/market_adapter/core/signals/kalman_trend_analyzer.d.ts.map +0 -1
- package/dist/market_adapter/core/signals/kalman_trend_analyzer.js.map +0 -1
- package/dist/market_adapter/core/signals/kalman_velocity_smoothing.d.ts.map +0 -1
- package/dist/market_adapter/core/signals/kalman_velocity_smoothing.js.map +0 -1
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts.map +0 -1
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js.map +0 -1
- package/dist/market_adapter/core/strategies/ama.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/ama.js.map +0 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.js.map +0 -1
- package/dist/market_adapter/core/strategies/atr/calculator.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/atr/calculator.js.map +0 -1
- package/dist/market_adapter/core/strategies/collateral_manager.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/collateral_manager.js.map +0 -1
- package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/dynamic_weight_series.js.map +0 -1
- package/dist/market_adapter/core/strategies/regime_gate.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/regime_gate.js.map +0 -1
- package/dist/market_adapter/core/strategies/regime_interp.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/regime_interp.js.map +0 -1
- package/dist/market_adapter/core/strategies/volatility_shift.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/volatility_shift.js.map +0 -1
- package/dist/market_adapter/inputs/fetch_book_data.d.ts.map +0 -1
- package/dist/market_adapter/inputs/fetch_book_data.js.map +0 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.d.ts.map +0 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +0 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +0 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +0 -1
- package/dist/market_adapter/inputs/kibana_feed_source.d.ts.map +0 -1
- package/dist/market_adapter/inputs/kibana_feed_source.js.map +0 -1
- package/dist/market_adapter/inputs/kibana_source.d.ts.map +0 -1
- package/dist/market_adapter/inputs/kibana_source.js.map +0 -1
- package/dist/market_adapter/inputs/window_cache.d.ts.map +0 -1
- package/dist/market_adapter/inputs/window_cache.js.map +0 -1
- package/dist/market_adapter/interval_utils.d.ts.map +0 -1
- package/dist/market_adapter/interval_utils.js.map +0 -1
- package/dist/market_adapter/log_format.d.ts.map +0 -1
- package/dist/market_adapter/log_format.js.map +0 -1
- package/dist/market_adapter/lp_chart_core.d.ts.map +0 -1
- package/dist/market_adapter/lp_chart_core.js.map +0 -1
- package/dist/market_adapter/lp_chart_runner.d.ts.map +0 -1
- package/dist/market_adapter/lp_chart_runner.js.map +0 -1
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts.map +0 -1
- package/dist/market_adapter/lp_chart_strategy_loader.js.map +0 -1
- package/dist/market_adapter/market_adapter.d.ts.map +0 -1
- package/dist/market_adapter/market_adapter.js.map +0 -1
- package/dist/market_adapter/test_helpers.d.ts.map +0 -1
- package/dist/market_adapter/test_helpers.js.map +0 -1
- package/dist/market_adapter/utils/adapter_client.d.ts.map +0 -1
- package/dist/market_adapter/utils/adapter_client.js.map +0 -1
- package/dist/market_adapter/utils/atomic_write.d.ts.map +0 -1
- package/dist/market_adapter/utils/atomic_write.js.map +0 -1
- package/dist/market_adapter/utils/chain.d.ts.map +0 -1
- package/dist/market_adapter/utils/chain.js.map +0 -1
- package/dist/market_adapter/utils/data_discovery.d.ts.map +0 -1
- package/dist/market_adapter/utils/data_discovery.js.map +0 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +0 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +0 -1
- package/dist/market_adapter/utils/file_lock.d.ts.map +0 -1
- package/dist/market_adapter/utils/file_lock.js.map +0 -1
- package/dist/market_adapter/utils/native_history.d.ts.map +0 -1
- package/dist/market_adapter/utils/native_history.js.map +0 -1
- package/dist/modules/account_bots.d.ts.map +0 -1
- package/dist/modules/account_bots.js.map +0 -1
- package/dist/modules/account_orders.d.ts.map +0 -1
- package/dist/modules/account_orders.js.map +0 -1
- package/dist/modules/authority_resolver.d.ts.map +0 -1
- package/dist/modules/authority_resolver.js.map +0 -1
- package/dist/modules/bitshares-native/chain_client.d.ts.map +0 -1
- package/dist/modules/bitshares-native/chain_client.js.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc.d.ts.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc.js.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.js.map +0 -1
- package/dist/modules/bitshares-native/index.d.ts.map +0 -1
- package/dist/modules/bitshares-native/index.js.map +0 -1
- package/dist/modules/bitshares-native/lru_cache.d.ts.map +0 -1
- package/dist/modules/bitshares-native/lru_cache.js.map +0 -1
- package/dist/modules/bitshares-native/resolvers.d.ts.map +0 -1
- package/dist/modules/bitshares-native/resolvers.js.map +0 -1
- package/dist/modules/bitshares-native/serial/chain_constants.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/chain_constants.js.map +0 -1
- package/dist/modules/bitshares-native/serial/index.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/index.js.map +0 -1
- package/dist/modules/bitshares-native/serial/operations.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/operations.js.map +0 -1
- package/dist/modules/bitshares-native/serial/serializer.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/serializer.js.map +0 -1
- package/dist/modules/bitshares-native/serial/types.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/types.js.map +0 -1
- package/dist/modules/bitshares-native/signing_client.d.ts.map +0 -1
- package/dist/modules/bitshares-native/signing_client.js.map +0 -1
- package/dist/modules/bitshares-native/subscriptions.d.ts.map +0 -1
- package/dist/modules/bitshares-native/subscriptions.js.map +0 -1
- package/dist/modules/bitshares-native/transport.d.ts.map +0 -1
- package/dist/modules/bitshares-native/transport.js.map +0 -1
- package/dist/modules/bitshares-native/tx/builder.d.ts.map +0 -1
- package/dist/modules/bitshares-native/tx/builder.js.map +0 -1
- package/dist/modules/bitshares-native/tx/tx_cache.d.ts.map +0 -1
- package/dist/modules/bitshares-native/tx/tx_cache.js.map +0 -1
- package/dist/modules/bitshares_client.d.ts.map +0 -1
- package/dist/modules/bitshares_client.js.map +0 -1
- package/dist/modules/bot_defaults.d.ts.map +0 -1
- package/dist/modules/bot_defaults.js.map +0 -1
- package/dist/modules/bot_settings.d.ts.map +0 -1
- package/dist/modules/bot_settings.js.map +0 -1
- package/dist/modules/bots_file_lock.d.ts.map +0 -1
- package/dist/modules/bots_file_lock.js.map +0 -1
- package/dist/modules/broadcast_failure.d.ts.map +0 -1
- package/dist/modules/broadcast_failure.js.map +0 -1
- package/dist/modules/chain_keys.d.ts.map +0 -1
- package/dist/modules/chain_keys.js.map +0 -1
- package/dist/modules/chain_orders.d.ts.map +0 -1
- package/dist/modules/chain_orders.js.map +0 -1
- package/dist/modules/cli_colors.d.ts.map +0 -1
- package/dist/modules/cli_colors.js.map +0 -1
- package/dist/modules/cli_start_onboarding.d.ts.map +0 -1
- package/dist/modules/cli_start_onboarding.js.map +0 -1
- package/dist/modules/cli_start_output.d.ts.map +0 -1
- package/dist/modules/cli_start_output.js.map +0 -1
- package/dist/modules/config.d.ts.map +0 -1
- package/dist/modules/config.js.map +0 -1
- package/dist/modules/constants.d.ts.map +0 -1
- package/dist/modules/constants.js.map +0 -1
- package/dist/modules/cr_planner.d.ts.map +0 -1
- package/dist/modules/cr_planner.js.map +0 -1
- package/dist/modules/credential_policy.d.ts.map +0 -1
- package/dist/modules/credential_policy.js.map +0 -1
- package/dist/modules/credential_runtime.d.ts.map +0 -1
- package/dist/modules/credential_runtime.js.map +0 -1
- package/dist/modules/credential_session_cache.d.ts.map +0 -1
- package/dist/modules/credential_session_cache.js.map +0 -1
- package/dist/modules/credit_pricing.d.ts.map +0 -1
- package/dist/modules/credit_pricing.js.map +0 -1
- package/dist/modules/credit_runtime.d.ts.map +0 -1
- package/dist/modules/credit_runtime.js.map +0 -1
- package/dist/modules/crypto/browser_provider.d.ts.map +0 -1
- package/dist/modules/crypto/browser_provider.js.map +0 -1
- package/dist/modules/crypto/index.d.ts.map +0 -1
- package/dist/modules/crypto/index.js.map +0 -1
- package/dist/modules/crypto/node_provider.d.ts.map +0 -1
- package/dist/modules/crypto/node_provider.js.map +0 -1
- package/dist/modules/crypto/provider.d.ts.map +0 -1
- package/dist/modules/crypto/provider.js.map +0 -1
- package/dist/modules/crypto/pure_ripemd160.d.ts.map +0 -1
- package/dist/modules/crypto/pure_ripemd160.js.map +0 -1
- package/dist/modules/crypto/pure_scrypt.d.ts.map +0 -1
- package/dist/modules/crypto/pure_scrypt.js.map +0 -1
- package/dist/modules/crypto/pure_secp256k1.d.ts.map +0 -1
- package/dist/modules/crypto/pure_secp256k1.js.map +0 -1
- package/dist/modules/crypto/sync.d.ts.map +0 -1
- package/dist/modules/crypto/sync.js.map +0 -1
- package/dist/modules/daemon_node_health.d.ts.map +0 -1
- package/dist/modules/daemon_node_health.js.map +0 -1
- package/dist/modules/dexbot_class.d.ts.map +0 -1
- package/dist/modules/dexbot_class.js.map +0 -1
- package/dist/modules/dexbot_cow_runtime.d.ts.map +0 -1
- package/dist/modules/dexbot_cow_runtime.js.map +0 -1
- package/dist/modules/dexbot_credential_client.d.ts.map +0 -1
- package/dist/modules/dexbot_credential_client.js.map +0 -1
- package/dist/modules/dexbot_fill_runtime.d.ts.map +0 -1
- package/dist/modules/dexbot_fill_runtime.js.map +0 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +0 -1
- package/dist/modules/dexbot_maintenance_runtime.js.map +0 -1
- package/dist/modules/dexbot_startup_runtime.d.ts.map +0 -1
- package/dist/modules/dexbot_startup_runtime.js.map +0 -1
- package/dist/modules/dexbot_state_recovery.d.ts.map +0 -1
- package/dist/modules/dexbot_state_recovery.js.map +0 -1
- package/dist/modules/env.d.ts.map +0 -1
- package/dist/modules/env.js.map +0 -1
- package/dist/modules/fund_registry.d.ts.map +0 -1
- package/dist/modules/fund_registry.js.map +0 -1
- package/dist/modules/general_settings.d.ts.map +0 -1
- package/dist/modules/general_settings.js.map +0 -1
- package/dist/modules/graceful_shutdown.d.ts.map +0 -1
- package/dist/modules/graceful_shutdown.js.map +0 -1
- package/dist/modules/grid_price_source.d.ts.map +0 -1
- package/dist/modules/grid_price_source.js.map +0 -1
- package/dist/modules/key_store.d.ts.map +0 -1
- package/dist/modules/key_store.js.map +0 -1
- package/dist/modules/launcher/adapter_requirement.d.ts.map +0 -1
- package/dist/modules/launcher/adapter_requirement.js.map +0 -1
- package/dist/modules/launcher/bot_supervisor.d.ts.map +0 -1
- package/dist/modules/launcher/bot_supervisor.js.map +0 -1
- package/dist/modules/launcher/child_env.d.ts.map +0 -1
- package/dist/modules/launcher/child_env.js.map +0 -1
- package/dist/modules/launcher/credential_bootstrap.d.ts.map +0 -1
- package/dist/modules/launcher/credential_bootstrap.js.map +0 -1
- package/dist/modules/launcher/credential_daemon.d.ts.map +0 -1
- package/dist/modules/launcher/credential_daemon.js.map +0 -1
- package/dist/modules/launcher/credential_secret.d.ts.map +0 -1
- package/dist/modules/launcher/credential_secret.js.map +0 -1
- package/dist/modules/launcher/foreign_cred_daemon.d.ts.map +0 -1
- package/dist/modules/launcher/foreign_cred_daemon.js.map +0 -1
- package/dist/modules/launcher/headless_password.d.ts.map +0 -1
- package/dist/modules/launcher/headless_password.js.map +0 -1
- package/dist/modules/launcher/launch_modes.d.ts.map +0 -1
- package/dist/modules/launcher/launch_modes.js.map +0 -1
- package/dist/modules/launcher/market_adapter_runtime.d.ts.map +0 -1
- package/dist/modules/launcher/market_adapter_runtime.js.map +0 -1
- package/dist/modules/launcher/market_adapter_watchdog.d.ts.map +0 -1
- package/dist/modules/launcher/market_adapter_watchdog.js.map +0 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts.map +0 -1
- package/dist/modules/launcher/monolithic_runtime.js.map +0 -1
- package/dist/modules/launcher/runtime_entry.d.ts.map +0 -1
- package/dist/modules/launcher/runtime_entry.js.map +0 -1
- package/dist/modules/launcher/status_reporting.d.ts.map +0 -1
- package/dist/modules/launcher/status_reporting.js.map +0 -1
- package/dist/modules/launcher/supervisor_control.d.ts.map +0 -1
- package/dist/modules/launcher/supervisor_control.js.map +0 -1
- package/dist/modules/market_adapter_whitelist.d.ts.map +0 -1
- package/dist/modules/market_adapter_whitelist.js.map +0 -1
- package/dist/modules/node_connect_policy.d.ts.map +0 -1
- package/dist/modules/node_connect_policy.js.map +0 -1
- package/dist/modules/node_failure_ledger.d.ts.map +0 -1
- package/dist/modules/node_failure_ledger.js.map +0 -1
- package/dist/modules/node_health_cache.d.ts.map +0 -1
- package/dist/modules/node_health_cache.js.map +0 -1
- package/dist/modules/node_manager.d.ts.map +0 -1
- package/dist/modules/node_manager.js.map +0 -1
- package/dist/modules/order/accounting.d.ts.map +0 -1
- package/dist/modules/order/accounting.js.map +0 -1
- package/dist/modules/order/async_lock.d.ts.map +0 -1
- package/dist/modules/order/async_lock.js.map +0 -1
- package/dist/modules/order/export.d.ts.map +0 -1
- package/dist/modules/order/export.js.map +0 -1
- package/dist/modules/order/format.d.ts.map +0 -1
- package/dist/modules/order/format.js.map +0 -1
- package/dist/modules/order/grid.d.ts.map +0 -1
- package/dist/modules/order/grid.js.map +0 -1
- package/dist/modules/order/grid_reconcile.d.ts.map +0 -1
- package/dist/modules/order/grid_reconcile.js.map +0 -1
- package/dist/modules/order/grid_reconcile_internal.d.ts.map +0 -1
- package/dist/modules/order/grid_reconcile_internal.js.map +0 -1
- package/dist/modules/order/index.d.ts.map +0 -1
- package/dist/modules/order/index.js.map +0 -1
- package/dist/modules/order/logger.d.ts.map +0 -1
- package/dist/modules/order/logger.js.map +0 -1
- package/dist/modules/order/logger_state.d.ts.map +0 -1
- package/dist/modules/order/logger_state.js.map +0 -1
- package/dist/modules/order/manager.d.ts.map +0 -1
- package/dist/modules/order/manager.js.map +0 -1
- package/dist/modules/order/processed_fill_store.d.ts.map +0 -1
- package/dist/modules/order/processed_fill_store.js.map +0 -1
- package/dist/modules/order/strategy.d.ts.map +0 -1
- package/dist/modules/order/strategy.js.map +0 -1
- package/dist/modules/order/sync_engine.d.ts.map +0 -1
- package/dist/modules/order/sync_engine.js.map +0 -1
- package/dist/modules/order/utils/math.d.ts.map +0 -1
- package/dist/modules/order/utils/math.js.map +0 -1
- package/dist/modules/order/utils/order.d.ts.map +0 -1
- package/dist/modules/order/utils/order.js.map +0 -1
- package/dist/modules/order/utils/slot.d.ts.map +0 -1
- package/dist/modules/order/utils/slot.js.map +0 -1
- package/dist/modules/order/utils/system.d.ts.map +0 -1
- package/dist/modules/order/utils/system.js.map +0 -1
- package/dist/modules/order/utils/timeout.d.ts.map +0 -1
- package/dist/modules/order/utils/timeout.js.map +0 -1
- package/dist/modules/order/utils/validate.d.ts.map +0 -1
- package/dist/modules/order/utils/validate.js.map +0 -1
- package/dist/modules/order/utils/withPoolRef.d.ts.map +0 -1
- package/dist/modules/order/utils/withPoolRef.js.map +0 -1
- package/dist/modules/order/working_grid.d.ts.map +0 -1
- package/dist/modules/order/working_grid.js.map +0 -1
- package/dist/modules/path_api.d.ts.map +0 -1
- package/dist/modules/path_api.js.map +0 -1
- package/dist/modules/paths.d.ts.map +0 -1
- package/dist/modules/paths.js.map +0 -1
- package/dist/modules/process_discovery.d.ts.map +0 -1
- package/dist/modules/process_discovery.js.map +0 -1
- package/dist/modules/runtime.d.ts.map +0 -1
- package/dist/modules/runtime.js.map +0 -1
- package/dist/modules/runtime_settings.d.ts.map +0 -1
- package/dist/modules/runtime_settings.js.map +0 -1
- package/dist/modules/settings_merge.d.ts.map +0 -1
- package/dist/modules/settings_merge.js.map +0 -1
- package/dist/modules/socket_json_client.d.ts.map +0 -1
- package/dist/modules/socket_json_client.js.map +0 -1
- package/dist/modules/storage/browser_adapter.d.ts.map +0 -1
- package/dist/modules/storage/browser_adapter.js.map +0 -1
- package/dist/modules/storage/index.d.ts.map +0 -1
- package/dist/modules/storage/index.js.map +0 -1
- package/dist/modules/storage/node_adapter.d.ts.map +0 -1
- package/dist/modules/storage/node_adapter.js.map +0 -1
- package/dist/modules/storage/types.d.ts.map +0 -1
- package/dist/modules/storage/types.js.map +0 -1
- package/dist/modules/types.d.ts.map +0 -1
- package/dist/modules/types.js.map +0 -1
- package/dist/modules/utils/base58check.d.ts.map +0 -1
- package/dist/modules/utils/base58check.js.map +0 -1
- package/dist/modules/utils/build_dir.d.ts.map +0 -1
- package/dist/modules/utils/build_dir.js.map +0 -1
- package/dist/modules/utils/chain_logs.d.ts.map +0 -1
- package/dist/modules/utils/chain_logs.js.map +0 -1
- package/dist/modules/utils/errors.d.ts.map +0 -1
- package/dist/modules/utils/errors.js.map +0 -1
- package/dist/modules/utils/sanitize_key.d.ts.map +0 -1
- package/dist/modules/utils/sanitize_key.js.map +0 -1
- package/dist/modules/utils/text_width.d.ts.map +0 -1
- package/dist/modules/utils/text_width.js.map +0 -1
- package/dist/modules/validate_profiles.d.ts.map +0 -1
- package/dist/modules/validate_profiles.js.map +0 -1
- package/dist/pm2.d.ts.map +0 -1
- package/dist/pm2.js.map +0 -1
- package/dist/scripts/analyze-credit.d.ts.map +0 -1
- package/dist/scripts/analyze-credit.js.map +0 -1
- package/dist/scripts/analyze-git.d.ts.map +0 -1
- package/dist/scripts/analyze-git.js.map +0 -1
- package/dist/scripts/analyze-orders.d.ts.map +0 -1
- package/dist/scripts/analyze-orders.js.map +0 -1
- package/dist/scripts/chart_command.d.ts.map +0 -1
- package/dist/scripts/chart_command.js.map +0 -1
- package/dist/scripts/diagnose-kibana-candles.d.ts.map +0 -1
- package/dist/scripts/diagnose-kibana-candles.js.map +0 -1
- package/dist/scripts/diagnose-pool-history.d.ts.map +0 -1
- package/dist/scripts/diagnose-pool-history.js.map +0 -1
- package/dist/scripts/divergence-calc.d.ts.map +0 -1
- package/dist/scripts/divergence-calc.js.map +0 -1
- package/dist/scripts/dw.d.ts.map +0 -1
- package/dist/scripts/dw.js.map +0 -1
- package/dist/scripts/generate_lp_chart.d.ts.map +0 -1
- package/dist/scripts/generate_lp_chart.js.map +0 -1
- package/dist/scripts/generate_mainnet_corpus_report.d.ts.map +0 -1
- package/dist/scripts/generate_mainnet_corpus_report.js.map +0 -1
- package/dist/scripts/native_release_gates.d.ts.map +0 -1
- package/dist/scripts/native_release_gates.js.map +0 -1
- package/dist/scripts/print_grid.d.ts.map +0 -1
- package/dist/scripts/print_grid.js.map +0 -1
- package/dist/scripts/run-tests.d.ts.map +0 -1
- package/dist/scripts/run-tests.js.map +0 -1
- package/dist/scripts/runner.d.ts.map +0 -1
- package/dist/scripts/runner.js.map +0 -1
- package/dist/scripts/sync-version.d.ts.map +0 -1
- package/dist/scripts/sync-version.js.map +0 -1
- package/dist/scripts/test-credit-renewal.d.ts.map +0 -1
- package/dist/scripts/test-credit-renewal.js.map +0 -1
- package/dist/scripts/tv.d.ts.map +0 -1
- package/dist/scripts/tv.js.map +0 -1
- package/dist/scripts/update.d.ts.map +0 -1
- package/dist/scripts/update.js.map +0 -1
- package/dist/scripts/update_dist_freshness.d.ts.map +0 -1
- package/dist/scripts/update_dist_freshness.js.map +0 -1
- package/dist/scripts/validate_bots.d.ts.map +0 -1
- package/dist/scripts/validate_bots.js.map +0 -1
- package/dist/scripts/verify-browser-bundle.d.ts.map +0 -1
- package/dist/scripts/verify-browser-bundle.js.map +0 -1
- package/dist/unlock.d.ts.map +0 -1
- package/dist/unlock.js.map +0 -1
package/dist/dexbot.js
CHANGED
|
@@ -157,7 +157,7 @@ const CLI_EXAMPLES = [
|
|
|
157
157
|
{ title: 'Analyze persisted order grids', command: 'dexbot order', notes: 'Runs the order analyzer across the orders directory (<profiles>/orders) and prints spread/increment/funds/distribution metrics. Add a bot key to render only that bot, and --export for an HTML report.' },
|
|
158
158
|
{ title: 'Show live credit/MPA positions', command: 'dexbot credit', notes: 'Queries get_margin_positions + get_credit_deals_by_borrower per preferredAccount and prints debt/collateral sums plus one Curr. CR line per whitelisted pair (active CR, else borrow-now CR vs funds avail. on the offer) and one Avar. CR line per bot. CR covers only pairs whitelisted in bots.json and listed on the current credit offer. Add a bot key to render only that bot.' },
|
|
159
159
|
{ title: 'TradingView chart for a bot, pool, or pair', command: 'dexbot tv <bot|pool-id|AssetA/AssetB> --month 3', notes: 'Fetches 1h candles for N months (default 3, pool-first with orderbook fallback; --feed charts MPA price-feed history) and writes an auto-named HTML chart.' },
|
|
160
|
-
{ title: 'Clear all bot log files', command: 'dexbot clear', notes: 'Runs scripts/clear-logs.sh to remove log
|
|
160
|
+
{ title: 'Clear all bot log files', command: 'dexbot clear', notes: 'Runs scripts/clear-logs.sh to remove *.log, rotated *.log.N and *.jsonl* from the logs directory (<profiles>/logs), including the credential audit trail daemon-audit.jsonl and its rotated siblings (named in the preview). Offline only: the scripts warn when a live runtime is detected, but a running bot keeps writing to unlinked files and the space is not freed until it restarts; dexbot clear-orders / clear-market-adapter / clear-all are undone within seconds (grid state is re-persisted, the adapter rewrites its state file and lock). Stop first with dexbot stop / dexbot pm2 stop all.' },
|
|
161
161
|
{ title: 'Reset settings to defaults', command: 'dexbot default', notes: 'Runs scripts/reset-settings.sh to delete general.settings.json, market_profiles.json, and market_adapter_settings.json.' }
|
|
162
162
|
];
|
|
163
163
|
const STARTUP_COLORS = {
|
|
@@ -217,10 +217,10 @@ function printCLIUsage() {
|
|
|
217
217
|
['dw <target>', 'Dynamic-weight research chart: same targets/flags as tv (see analysis/).'],
|
|
218
218
|
]],
|
|
219
219
|
['Files', [
|
|
220
|
-
['clear', '
|
|
221
|
-
['clear-orders', '
|
|
222
|
-
['clear-market-adapter', '
|
|
223
|
-
['clear-all', '
|
|
220
|
+
['clear', 'Delete <profiles>/logs/*.log, *.log.N and *.jsonl* (audit trail included). Stop the runtime first.'],
|
|
221
|
+
['clear-orders', 'Delete persisted grid state in <profiles>/orders (regenerated on next start).'],
|
|
222
|
+
['clear-market-adapter', 'Delete market adapter data, state, lock, and adapter logs.'],
|
|
223
|
+
['clear-all', 'All of the above, plus claw data. Stop the runtime first.'],
|
|
224
224
|
]],
|
|
225
225
|
];
|
|
226
226
|
const width = Math.max(...groups.flatMap(([, entries]) => entries.map(([cmd]) => cmd.length))) + 2;
|
|
@@ -1072,8 +1072,52 @@ async function handleCLICommands() {
|
|
|
1072
1072
|
return true;
|
|
1073
1073
|
}
|
|
1074
1074
|
case 'status': {
|
|
1075
|
-
|
|
1075
|
+
// Installed-vs-published version status, from the single shared
|
|
1076
|
+
// renderer in modules/version_notice.ts: green when current, orange
|
|
1077
|
+
// when a newer release exists, gray when the probe cannot answer.
|
|
1078
|
+
//
|
|
1079
|
+
// The probe is STAGED around the report instead of being awaited
|
|
1080
|
+
// inline (see startStagedVersionStatus):
|
|
1081
|
+
// top 1s grace. A valid cache or a quick registry answer lands
|
|
1082
|
+
// inside it and the report never notices the wait.
|
|
1083
|
+
// bottom 1s more for the probe still in flight, then a forced
|
|
1084
|
+
// re-probe with the full NOTICE_STATUS_TIMEOUT_MS budget.
|
|
1085
|
+
// If even that is silent, the verdict says so explicitly
|
|
1086
|
+
// rather than leaving a missing line to be read as
|
|
1087
|
+
// "you are up to date".
|
|
1088
|
+
// So the report costs at most 1s up front, and the verdict is
|
|
1089
|
+
// printed at exactly one terminal point, which no early
|
|
1090
|
+
// `process.exit()` in a branch below can truncate.
|
|
1091
|
+
const { UPDATER } = require('./modules/constants');
|
|
1092
|
+
const { startStagedVersionStatus, printVersionStatusOrHeader } = require('./modules/version_notice');
|
|
1093
|
+
const versionWait = startStagedVersionStatus({
|
|
1094
|
+
graceMs: UPDATER.NOTICE_STAGE_GRACE_MS,
|
|
1095
|
+
timeoutMs: UPDATER.NOTICE_STATUS_TIMEOUT_MS,
|
|
1096
|
+
// DEXBOT_VERSION_CHECK_FORCE=1 re-probes instead of answering
|
|
1097
|
+
// from the cache: the escape hatch when a cached failure is
|
|
1098
|
+
// indistinguishable from a live one.
|
|
1099
|
+
force: Config.DEXBOT_VERSION_CHECK_FORCE,
|
|
1100
|
+
});
|
|
1101
|
+
// Top-of-report grace. The VALUE is unused on purpose, only the
|
|
1102
|
+
// timing matters: `settled` is what gets displayed at the end.
|
|
1103
|
+
await versionWait.quick;
|
|
1076
1104
|
console.log();
|
|
1105
|
+
// The ONE terminal point of this command: every branch below ends
|
|
1106
|
+
// in `finish(...)` instead of `process.exit(...)`, so the deferred
|
|
1107
|
+
// version line is always printed — including on the "no processes"
|
|
1108
|
+
// and delegated-`unlock status` paths, which used to exit before
|
|
1109
|
+
// the probe had anything to say.
|
|
1110
|
+
const finish = async (code) => {
|
|
1111
|
+
// Blank line, then the verdict: it is the last thing the
|
|
1112
|
+
// operator reads, so it gets its own block at the bottom. With
|
|
1113
|
+
// the check switched off, the shared helper falls back to the
|
|
1114
|
+
// bare "DEXBot2 vX.Y.Z" header, so the running build is always
|
|
1115
|
+
// named - the inline path's long-standing behaviour.
|
|
1116
|
+
console.log();
|
|
1117
|
+
printVersionStatusOrHeader(await versionWait.settled, { indent: '', surround: false });
|
|
1118
|
+
process.exit(code);
|
|
1119
|
+
return true;
|
|
1120
|
+
};
|
|
1077
1121
|
const { spawnSync, execSync } = require('child_process');
|
|
1078
1122
|
const MONOLITHIC_PID_FILE = PATHS.PROFILES.MONOLITHIC_PID;
|
|
1079
1123
|
const MONOLITHIC_CRED_PID_FILE = PATHS.PROFILES.MONOLITHIC_CRED_PID;
|
|
@@ -1133,22 +1177,19 @@ async function handleCLICommands() {
|
|
|
1133
1177
|
cwd: PATHS.PROJECT_ROOT,
|
|
1134
1178
|
stdio: 'inherit',
|
|
1135
1179
|
});
|
|
1136
|
-
|
|
1137
|
-
return true;
|
|
1180
|
+
return finish(result.status ?? 0);
|
|
1138
1181
|
}
|
|
1139
1182
|
try {
|
|
1140
1183
|
const output = execSync('pm2 jlist 2>/dev/null', { encoding: 'utf8', timeout: 5000 }).toString().trim();
|
|
1141
1184
|
const jsonStart = output.indexOf('[');
|
|
1142
1185
|
if (jsonStart === -1) {
|
|
1143
1186
|
console.log('No DEXBot2 processes running.');
|
|
1144
|
-
|
|
1145
|
-
return true;
|
|
1187
|
+
return finish(0);
|
|
1146
1188
|
}
|
|
1147
1189
|
const allProcs = JSON.parse(output.slice(jsonStart));
|
|
1148
1190
|
if (!Array.isArray(allProcs) || allProcs.length === 0) {
|
|
1149
1191
|
console.log('No DEXBot2 processes running.');
|
|
1150
|
-
|
|
1151
|
-
return true;
|
|
1192
|
+
return finish(0);
|
|
1152
1193
|
}
|
|
1153
1194
|
const serviceNames = new Set(['dexbot-cred', 'dexbot-adapter', 'dexbot-update']);
|
|
1154
1195
|
const botNames = new Set();
|
|
@@ -1167,8 +1208,7 @@ async function handleCLICommands() {
|
|
|
1167
1208
|
});
|
|
1168
1209
|
if (dexbotProcs.length === 0) {
|
|
1169
1210
|
console.log('No DEXBot2 processes running.');
|
|
1170
|
-
|
|
1171
|
-
return true;
|
|
1211
|
+
return finish(0);
|
|
1172
1212
|
}
|
|
1173
1213
|
console.log('='.repeat(50));
|
|
1174
1214
|
console.log('DEXBot2 PM2 Processes');
|
|
@@ -1219,8 +1259,7 @@ async function handleCLICommands() {
|
|
|
1219
1259
|
catch {
|
|
1220
1260
|
console.log('No DEXBot2 processes running.');
|
|
1221
1261
|
}
|
|
1222
|
-
|
|
1223
|
-
return true;
|
|
1262
|
+
return finish(0);
|
|
1224
1263
|
}
|
|
1225
1264
|
case 'delete':
|
|
1226
1265
|
case 'stop':
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
declare const AMA_SLOPE_PERCENT_MODE_PER_BAR = "perBar";
|
|
2
2
|
declare function normalizeAmaSlopePercentMode(value: any): "perBar" | "window" | null;
|
|
3
3
|
declare function convertSlopePercentToPerBar(value: any, lookbackBars: any, mode: any): number | null;
|
|
4
|
+
/**
|
|
5
|
+
* Standing repair verdict for a PERSISTED STATE entry — the summary the
|
|
6
|
+
* previous cycle wrote. Returns a reason string when repair is still owed,
|
|
7
|
+
* null when the cache is clean.
|
|
8
|
+
*
|
|
9
|
+
* State-side mirror of candleFileCoversClosedBucket: that gate judges the
|
|
10
|
+
* on-disk candle file, this one judges the state summary, and the two must
|
|
11
|
+
* describe the same standing conditions so the startup sleep and the in-cycle
|
|
12
|
+
* skip cannot silently disagree. When a new standing signal is added to one,
|
|
13
|
+
* add it to the other (source/newest-candle checks are file-only and cannot
|
|
14
|
+
* appear here; unresolvedGapCount and the warmup shortfall exist in both).
|
|
15
|
+
*/
|
|
16
|
+
declare function evaluateStateRepairVeto(entry: any): "unresolved_gaps" | "cache_count_unknown" | "cache_below_warmup_target" | null;
|
|
4
17
|
declare class MarketAdapterService {
|
|
5
18
|
deps: any;
|
|
6
19
|
constructor(deps?: any);
|
|
@@ -16,6 +29,73 @@ declare class MarketAdapterService {
|
|
|
16
29
|
* deeper history than the analytical minimum.
|
|
17
30
|
*/
|
|
18
31
|
bootstrapKibanaLookbackHours(cfg: any, keepCount: any): number;
|
|
32
|
+
/**
|
|
33
|
+
* Closed-bucket arithmetic shared by the off-hour skip logic.
|
|
34
|
+
*
|
|
35
|
+
* Thin instance wrapper around the shared bucket helper so the `getNowMs`
|
|
36
|
+
* injection used by tests and embedders keeps working. `intervalSeconds`
|
|
37
|
+
* is validated by the helper: a missing/invalid interval can never
|
|
38
|
+
* masquerade as "nothing new" — it returns null and the caller must fall
|
|
39
|
+
* through to the network path instead of skipping a cycle it cannot
|
|
40
|
+
* evaluate.
|
|
41
|
+
*/
|
|
42
|
+
latestClosedBucketStartMs(intervalSeconds: any, nowMs?: any): number | null;
|
|
43
|
+
/**
|
|
44
|
+
* Off-hour skip check: is there any closed candle this bot has not
|
|
45
|
+
* consumed yet? Runs on persisted state + the wall clock only — no
|
|
46
|
+
* chain RPC, no candle parse. Returns null when the answer cannot be
|
|
47
|
+
* determined (invalid interval, unknown state shape, one-shot mode), in
|
|
48
|
+
* which case the caller must run the full cycle instead of skipping.
|
|
49
|
+
*
|
|
50
|
+
* `once` (the `--once` CLI and the embedded runOnceForAma) always runs the
|
|
51
|
+
* full cycle: those entry points exist to *produce* a result on demand —
|
|
52
|
+
* the signal runner prints the AMA, an operator asks for a fresh cycle —
|
|
53
|
+
* and returning a state-only "skipped" record with null prices would
|
|
54
|
+
* quietly degrade their output. Only the long-running daemon, which has a
|
|
55
|
+
* schedule of its own, may answer "nothing new, skipping".
|
|
56
|
+
*
|
|
57
|
+
* The verdict requires the consumed marker to equal the newest closed
|
|
58
|
+
* bucket exactly. A marker AHEAD of that bucket means the two clocks
|
|
59
|
+
* disagree (clock skew, a state file carried across hosts, a synthetic
|
|
60
|
+
* fixture); skipping there would discard a candle the adapter may not
|
|
61
|
+
* actually have processed, so the conservative answer is always "run".
|
|
62
|
+
*
|
|
63
|
+
* Skipped bots still refresh `lastCycleAt`/`lastCycleSource` in state so
|
|
64
|
+
* monitoring can tell "idle by design" apart from "dead process".
|
|
65
|
+
*/
|
|
66
|
+
shouldSkipBotForClosedCandle(_bot: any, botState: any, intervalSeconds: any, nowMs?: any, cfg?: any): {
|
|
67
|
+
latestClosedBucketStartMs: number;
|
|
68
|
+
previousClosedCandleTs: number;
|
|
69
|
+
} | null;
|
|
70
|
+
/**
|
|
71
|
+
* Does the cached candle file belong to a different market source than the
|
|
72
|
+
* bot is configured for?
|
|
73
|
+
*
|
|
74
|
+
* Single source of truth for the reset rule: the off-hour gate
|
|
75
|
+
* (candleFileCoversClosedBucket) and the full path must agree, otherwise a
|
|
76
|
+
* source switch could be skipped off-hour and the cache would keep serving
|
|
77
|
+
* candles from the old source until the next close forced a full run.
|
|
78
|
+
* The pool/book cross-checks matter for legacy caches that predate
|
|
79
|
+
* `meta.marketSource`: a stored pool id alongside a book-configured bot (or
|
|
80
|
+
* a book cache under a pool bot) is just as much a mismatch.
|
|
81
|
+
*/
|
|
82
|
+
isCandleSourceMismatch(meta: any, marketSource: any): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Does the local candle cache already hold the data for a closed bucket?
|
|
85
|
+
*
|
|
86
|
+
* Second half of the off-hour skip verdict (see
|
|
87
|
+
* shouldSkipBotForClosedCandle): the full cycle repairs history even
|
|
88
|
+
* without a new close (Kibana backfill, gap fill), so skipping is only
|
|
89
|
+
* safe when the cache is healthy for that bucket. False whenever
|
|
90
|
+
* anything needs repair: a source switch, unresolved gaps, an empty or
|
|
91
|
+
* short file (fewer candles than the AMA warmup target — the exact case
|
|
92
|
+
* the backfill path exists for), or a newest candle that predates the
|
|
93
|
+
* bucket.
|
|
94
|
+
*
|
|
95
|
+
* The state-side mirror of the standing conditions (unresolved gaps, warmup
|
|
96
|
+
* shortfall) is evaluateStateRepairVeto above; keep the two in step.
|
|
97
|
+
*/
|
|
98
|
+
candleFileCoversClosedBucket(candles: any, meta: any, marketSource: any, closedBucketStartMs: any, requiredCount?: any): boolean;
|
|
19
99
|
selectClosedCandles(candles: any, intervalSeconds: any, nowMs?: any): {
|
|
20
100
|
closedCandles: any[];
|
|
21
101
|
currentBucketStartMs: null;
|
|
@@ -231,5 +311,5 @@ declare class MarketAdapterService {
|
|
|
231
311
|
};
|
|
232
312
|
processBot(bot: any, state: any, cfg: any, contextCache: any, hooks?: any): Promise<any>;
|
|
233
313
|
}
|
|
234
|
-
export { MarketAdapterService, AMA_SLOPE_PERCENT_MODE_PER_BAR, normalizeAmaSlopePercentMode, convertSlopePercentToPerBar };
|
|
314
|
+
export { MarketAdapterService, AMA_SLOPE_PERCENT_MODE_PER_BAR, normalizeAmaSlopePercentMode, convertSlopePercentToPerBar, evaluateStateRepairVeto };
|
|
235
315
|
//# sourceMappingURL=market_adapter_service.d.ts.map
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { calculateATR } from './strategies/atr/calculator.js';
|
|
3
3
|
import { normalizeMarketSource, hasNumericStartPrice, resolveMarketSourceForBot } from '../utils/chain.js';
|
|
4
4
|
import { computeRegimeMultiplier } from './strategies/regime_gate.js';
|
|
5
|
+
import { noteJsonWritten, readCachedJson } from '../utils/file_json_cache.js';
|
|
5
6
|
import { calculateAMA, getAmaWarmupBars } from './strategies/ama.js';
|
|
6
7
|
import { computeDynamicWeightSeries } from './strategies/dynamic_weight_series.js';
|
|
7
8
|
import { KalmanTrendAnalyzer } from './signals/kalman_trend_analyzer.js';
|
|
@@ -16,6 +17,7 @@ import { normalizeAtrPeriod, normalizeMaxVolatilityOffset, normalizeVolatilityTh
|
|
|
16
17
|
import { buildKalmanVelocitySeries, computeAbsolutePercentileThreshold, } from './signals/kalman_velocity_smoothing.js';
|
|
17
18
|
import { resolveMaxAsymmetryFactor, computeAsymmetricBoundsMetrics, } from './asymmetric_bounds.js';
|
|
18
19
|
import { getErrorMessage } from '../../modules/utils/errors.js';
|
|
20
|
+
import { bucketStartMs, latestClosedBucketStartMs as latestClosedBucket } from '../interval_utils.js';
|
|
19
21
|
const marketAdapterServiceLogger = new Logger('MarketAdapterService');
|
|
20
22
|
const AMA_SLOPE_PERCENT_MODE_PER_BAR = 'perBar';
|
|
21
23
|
const AMA_SLOPE_PERCENT_MODE_WINDOW = 'window';
|
|
@@ -94,6 +96,34 @@ function computeGridPriceOffsetPlan(bot, amaSlope) {
|
|
|
94
96
|
gridPriceOffsetPct,
|
|
95
97
|
};
|
|
96
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Standing repair verdict for a PERSISTED STATE entry — the summary the
|
|
101
|
+
* previous cycle wrote. Returns a reason string when repair is still owed,
|
|
102
|
+
* null when the cache is clean.
|
|
103
|
+
*
|
|
104
|
+
* State-side mirror of candleFileCoversClosedBucket: that gate judges the
|
|
105
|
+
* on-disk candle file, this one judges the state summary, and the two must
|
|
106
|
+
* describe the same standing conditions so the startup sleep and the in-cycle
|
|
107
|
+
* skip cannot silently disagree. When a new standing signal is added to one,
|
|
108
|
+
* add it to the other (source/newest-candle checks are file-only and cannot
|
|
109
|
+
* appear here; unresolvedGapCount and the warmup shortfall exist in both).
|
|
110
|
+
*/
|
|
111
|
+
function evaluateStateRepairVeto(entry) {
|
|
112
|
+
if (Number(entry?.unresolvedGapCount) > 0)
|
|
113
|
+
return 'unresolved_gaps';
|
|
114
|
+
const keepTarget = Number(entry?.rawKeepCount);
|
|
115
|
+
if (!Number.isFinite(keepTarget) || keepTarget <= 0)
|
|
116
|
+
return null;
|
|
117
|
+
const candleCount = Number(entry?.candleCount);
|
|
118
|
+
// Target known but current count unknown is NOT "nothing owed": an
|
|
119
|
+
// older or half-written row would otherwise read as healthy. Veto, and
|
|
120
|
+
// let the next full cycle rewrite the row with both fields.
|
|
121
|
+
if (!Number.isFinite(candleCount))
|
|
122
|
+
return 'cache_count_unknown';
|
|
123
|
+
if (candleCount < keepTarget)
|
|
124
|
+
return 'cache_below_warmup_target';
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
97
127
|
class MarketAdapterService {
|
|
98
128
|
deps;
|
|
99
129
|
constructor(deps = {}) {
|
|
@@ -130,18 +160,123 @@ class MarketAdapterService {
|
|
|
130
160
|
: 1;
|
|
131
161
|
return Math.max(Number(cfg?.bootstrapLookbackHours) || 0, Number(keepCount) * intervalHours);
|
|
132
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Closed-bucket arithmetic shared by the off-hour skip logic.
|
|
165
|
+
*
|
|
166
|
+
* Thin instance wrapper around the shared bucket helper so the `getNowMs`
|
|
167
|
+
* injection used by tests and embedders keeps working. `intervalSeconds`
|
|
168
|
+
* is validated by the helper: a missing/invalid interval can never
|
|
169
|
+
* masquerade as "nothing new" — it returns null and the caller must fall
|
|
170
|
+
* through to the network path instead of skipping a cycle it cannot
|
|
171
|
+
* evaluate.
|
|
172
|
+
*/
|
|
173
|
+
latestClosedBucketStartMs(intervalSeconds, nowMs = this.getNowMs()) {
|
|
174
|
+
return latestClosedBucket(nowMs, intervalSeconds);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Off-hour skip check: is there any closed candle this bot has not
|
|
178
|
+
* consumed yet? Runs on persisted state + the wall clock only — no
|
|
179
|
+
* chain RPC, no candle parse. Returns null when the answer cannot be
|
|
180
|
+
* determined (invalid interval, unknown state shape, one-shot mode), in
|
|
181
|
+
* which case the caller must run the full cycle instead of skipping.
|
|
182
|
+
*
|
|
183
|
+
* `once` (the `--once` CLI and the embedded runOnceForAma) always runs the
|
|
184
|
+
* full cycle: those entry points exist to *produce* a result on demand —
|
|
185
|
+
* the signal runner prints the AMA, an operator asks for a fresh cycle —
|
|
186
|
+
* and returning a state-only "skipped" record with null prices would
|
|
187
|
+
* quietly degrade their output. Only the long-running daemon, which has a
|
|
188
|
+
* schedule of its own, may answer "nothing new, skipping".
|
|
189
|
+
*
|
|
190
|
+
* The verdict requires the consumed marker to equal the newest closed
|
|
191
|
+
* bucket exactly. A marker AHEAD of that bucket means the two clocks
|
|
192
|
+
* disagree (clock skew, a state file carried across hosts, a synthetic
|
|
193
|
+
* fixture); skipping there would discard a candle the adapter may not
|
|
194
|
+
* actually have processed, so the conservative answer is always "run".
|
|
195
|
+
*
|
|
196
|
+
* Skipped bots still refresh `lastCycleAt`/`lastCycleSource` in state so
|
|
197
|
+
* monitoring can tell "idle by design" apart from "dead process".
|
|
198
|
+
*/
|
|
199
|
+
shouldSkipBotForClosedCandle(_bot, botState, intervalSeconds, nowMs = this.getNowMs(), cfg = null) {
|
|
200
|
+
if (cfg?.once)
|
|
201
|
+
return null;
|
|
202
|
+
if (!botState || typeof botState !== 'object' || Array.isArray(botState))
|
|
203
|
+
return null;
|
|
204
|
+
const latestClosed = this.latestClosedBucketStartMs(intervalSeconds, nowMs);
|
|
205
|
+
if (latestClosed === null)
|
|
206
|
+
return null;
|
|
207
|
+
const previousClosedCandleTs = Number(botState.lastClosedCandleTs || 0);
|
|
208
|
+
// No consumed marker yet (fresh state / cleared state): the full
|
|
209
|
+
// cycle must run — bootstrap and warmup checks live there.
|
|
210
|
+
if (!Number.isFinite(previousClosedCandleTs) || previousClosedCandleTs <= 0)
|
|
211
|
+
return null;
|
|
212
|
+
if (latestClosed === previousClosedCandleTs) {
|
|
213
|
+
return { latestClosedBucketStartMs: latestClosed, previousClosedCandleTs };
|
|
214
|
+
}
|
|
215
|
+
return null;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Does the cached candle file belong to a different market source than the
|
|
219
|
+
* bot is configured for?
|
|
220
|
+
*
|
|
221
|
+
* Single source of truth for the reset rule: the off-hour gate
|
|
222
|
+
* (candleFileCoversClosedBucket) and the full path must agree, otherwise a
|
|
223
|
+
* source switch could be skipped off-hour and the cache would keep serving
|
|
224
|
+
* candles from the old source until the next close forced a full run.
|
|
225
|
+
* The pool/book cross-checks matter for legacy caches that predate
|
|
226
|
+
* `meta.marketSource`: a stored pool id alongside a book-configured bot (or
|
|
227
|
+
* a book cache under a pool bot) is just as much a mismatch.
|
|
228
|
+
*/
|
|
229
|
+
isCandleSourceMismatch(meta, marketSource) {
|
|
230
|
+
const storedSource = normalizeMarketSource(meta?.marketSource);
|
|
231
|
+
const hasStoredPoolContext = meta?.pool != null && String(meta.pool).trim() !== '';
|
|
232
|
+
return (!!storedSource && storedSource !== marketSource)
|
|
233
|
+
|| (marketSource === 'book' && hasStoredPoolContext)
|
|
234
|
+
|| (marketSource === 'pool' && storedSource === 'book');
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Does the local candle cache already hold the data for a closed bucket?
|
|
238
|
+
*
|
|
239
|
+
* Second half of the off-hour skip verdict (see
|
|
240
|
+
* shouldSkipBotForClosedCandle): the full cycle repairs history even
|
|
241
|
+
* without a new close (Kibana backfill, gap fill), so skipping is only
|
|
242
|
+
* safe when the cache is healthy for that bucket. False whenever
|
|
243
|
+
* anything needs repair: a source switch, unresolved gaps, an empty or
|
|
244
|
+
* short file (fewer candles than the AMA warmup target — the exact case
|
|
245
|
+
* the backfill path exists for), or a newest candle that predates the
|
|
246
|
+
* bucket.
|
|
247
|
+
*
|
|
248
|
+
* The state-side mirror of the standing conditions (unresolved gaps, warmup
|
|
249
|
+
* shortfall) is evaluateStateRepairVeto above; keep the two in step.
|
|
250
|
+
*/
|
|
251
|
+
candleFileCoversClosedBucket(candles, meta, marketSource, closedBucketStartMs, requiredCount = 0) {
|
|
252
|
+
if (!Number.isFinite(closedBucketStartMs) || closedBucketStartMs <= 0)
|
|
253
|
+
return false;
|
|
254
|
+
if (this.isCandleSourceMismatch(meta, marketSource))
|
|
255
|
+
return false;
|
|
256
|
+
if (Number(meta?.unresolvedGapCount) > 0)
|
|
257
|
+
return false;
|
|
258
|
+
if (!Array.isArray(candles) || candles.length === 0)
|
|
259
|
+
return false;
|
|
260
|
+
// Short history means the warmup/backfill path still has work to do.
|
|
261
|
+
const required = Number(requiredCount);
|
|
262
|
+
if (Number.isFinite(required) && required > 0 && candles.length < required)
|
|
263
|
+
return false;
|
|
264
|
+
const newestTs = Number(candles[candles.length - 1]?.[0]);
|
|
265
|
+
if (!Number.isFinite(newestTs))
|
|
266
|
+
return false;
|
|
267
|
+
return newestTs >= closedBucketStartMs;
|
|
268
|
+
}
|
|
133
269
|
selectClosedCandles(candles, intervalSeconds, nowMs = this.getNowMs()) {
|
|
134
|
-
const
|
|
135
|
-
if (
|
|
270
|
+
const currentBucketStart = bucketStartMs(nowMs, intervalSeconds);
|
|
271
|
+
if (currentBucketStart === null) {
|
|
136
272
|
return {
|
|
137
273
|
closedCandles: Array.isArray(candles) ? candles.slice() : [],
|
|
138
274
|
currentBucketStartMs: null,
|
|
139
275
|
};
|
|
140
276
|
}
|
|
141
|
-
const currentBucketStartMs = Math.floor(Number(nowMs) / bucketMs) * bucketMs;
|
|
142
277
|
const closedCandles = (Array.isArray(candles) ? candles : [])
|
|
143
|
-
.filter((c) => Array.isArray(c) && Number.isFinite(c[0]) && c[0] <
|
|
144
|
-
return { closedCandles, currentBucketStartMs };
|
|
278
|
+
.filter((c) => Array.isArray(c) && Number.isFinite(c[0]) && c[0] < currentBucketStart);
|
|
279
|
+
return { closedCandles, currentBucketStartMs: currentBucketStart };
|
|
145
280
|
}
|
|
146
281
|
buildBotContextSignature(bot) {
|
|
147
282
|
return [
|
|
@@ -500,11 +635,23 @@ class MarketAdapterService {
|
|
|
500
635
|
const currentSlopePct = Number(currentAmaSlope?.slopePct);
|
|
501
636
|
const previousSlopePct = Number(previousAmaSlope?.slopePct);
|
|
502
637
|
const currentReady = !!currentAmaSlope?.isReady && Number.isFinite(currentSlopePct);
|
|
503
|
-
|
|
638
|
+
// A not-ready snapshot (`isReady:false`, slopePct 0) is a truthy object
|
|
639
|
+
// that can be persisted as the reset baseline before AMA warmup. Treat
|
|
640
|
+
// it as "no baseline" so its phantom 0 %/bar cannot later trip the
|
|
641
|
+
// slope trigger on the first real slope. Legacy snapshots without an
|
|
642
|
+
// `isReady` field still count as ready.
|
|
643
|
+
const previousReady = !!previousAmaSlope
|
|
644
|
+
&& previousAmaSlope.isReady !== false
|
|
645
|
+
&& Number.isFinite(previousSlopePct);
|
|
504
646
|
const deltaPercent = currentReady && previousReady
|
|
505
647
|
? Math.abs(currentSlopePct - previousSlopePct)
|
|
506
648
|
: null;
|
|
507
|
-
|
|
649
|
+
// A non-positive threshold means the slope trigger is DISABLED, not
|
|
650
|
+
// "fire on any delta": `deltaPercent >= 0` would otherwise reset the
|
|
651
|
+
// grid every cycle whenever the factor/maxSlopePct config is missing.
|
|
652
|
+
const thresholdCrossed = Number.isFinite(deltaPercent)
|
|
653
|
+
&& thresholdPercent > 0
|
|
654
|
+
&& deltaPercent >= thresholdPercent;
|
|
508
655
|
return {
|
|
509
656
|
thresholdPercent,
|
|
510
657
|
currentSlopePct: Number.isFinite(currentSlopePct) ? currentSlopePct : null,
|
|
@@ -615,6 +762,12 @@ class MarketAdapterService {
|
|
|
615
762
|
regimeTable: cfg.regimeTable,
|
|
616
763
|
hurstZoneBand: cfg.hurstZoneBand,
|
|
617
764
|
peNodes: cfg.peNodes,
|
|
765
|
+
// Stable per-market key: lets the gate resume from the previous
|
|
766
|
+
// cycle's analyzer state instead of replaying the whole history.
|
|
767
|
+
// The gate still recomputes from scratch whenever the cached
|
|
768
|
+
// closes are not a prefix of the incoming window (gap repair,
|
|
769
|
+
// rewritten bar, shortened window) or a parameter changed.
|
|
770
|
+
cacheKey: `${bot?.botKey ?? 'bot'}:${cfg.intervalSeconds}`,
|
|
618
771
|
});
|
|
619
772
|
regimeMultiplier = regimeResult.isReady && Math.abs(regimeResult.multiplier - 1.0) >= absoluteThreshold
|
|
620
773
|
? regimeResult.multiplier
|
|
@@ -931,17 +1084,84 @@ class MarketAdapterService {
|
|
|
931
1084
|
});
|
|
932
1085
|
}
|
|
933
1086
|
const botAma = deps.resolveAmaForBot(bot, ctx, cfg);
|
|
1087
|
+
// `botAma.enabled` is a derived invariant (always true): `gridPrice` is
|
|
1088
|
+
// the single switch that makes a bot AMA-driven, and
|
|
1089
|
+
// usesAmaGridPrice(bot) below is what actually gates AMA work for this
|
|
1090
|
+
// bot. This guard stays only so a future resolver that can fail to
|
|
1091
|
+
// resolve an AMA config cannot silently trade on a missing one.
|
|
934
1092
|
if (!botAma.enabled) {
|
|
935
1093
|
return { ok: false, reason: 'ama disabled' };
|
|
936
1094
|
}
|
|
937
1095
|
const lookbackBars = normalizeAmaSlopeLookbackBars(cfg.amaSlope?.lookbackBars);
|
|
938
1096
|
const filePath = deps.candleFileForBot(bot.botKey, cfg.intervalSeconds);
|
|
939
|
-
|
|
1097
|
+
// mtime-validated read cache: the previous cycle serialized this very
|
|
1098
|
+
// file, so re-parsing ~250 KiB of JSON per bot per hour is pure waste.
|
|
1099
|
+
// The cache decides on the file's stat alone — an unstattable file (or a
|
|
1100
|
+
// storage adapter that reports no mtime) is never served from the cache
|
|
1101
|
+
// and always goes through the loader, so it can never serve stale data.
|
|
1102
|
+
// Injecting deps.loadJson does not change that decision; it only changes
|
|
1103
|
+
// what a cache miss parses.
|
|
1104
|
+
const existing = readCachedJson(filePath, () => deps.loadJson(filePath, null));
|
|
940
1105
|
const existingMeta = existing?.meta && typeof existing.meta === 'object' ? existing.meta : {};
|
|
941
1106
|
let existingCandles = Array.isArray(existing?.candles) ? existing.candles : [];
|
|
942
|
-
const existingMarketSource = normalizeMarketSource(existingMeta.marketSource);
|
|
943
1107
|
const marketSource = resolveMarketSourceForBot(bot) || 'pool';
|
|
944
1108
|
const isBookSource = marketSource === 'book';
|
|
1109
|
+
// Retention targets, derived from the bot's own AMA parameters. Pure and
|
|
1110
|
+
// local, so they are computed before the off-hour gate below (which
|
|
1111
|
+
// needs the warmup target) and reused by the full path unchanged.
|
|
1112
|
+
const amaWarmupBars = getAmaWarmupBars(botAma.erPeriod, botAma.slowPeriod, lookbackBars, botAma.fastPeriod, botAma.erSmoothPeriod ?? 0);
|
|
1113
|
+
const analysisKeepCount = amaWarmupBars + 1;
|
|
1114
|
+
// Retain one extra raw candle so the closed-candle analysis window still keeps a
|
|
1115
|
+
// full warmup/history set when the newest bucket is the current in-progress bar.
|
|
1116
|
+
const rawKeepCount = analysisKeepCount + 1;
|
|
1117
|
+
// Off-hour skip: the newest closed 1h bucket is already consumed, so
|
|
1118
|
+
// this bot cannot produce a new AMA, trigger, or snapshot this cycle.
|
|
1119
|
+
// Skip BEFORE the stale-tail Kibana verification and the native
|
|
1120
|
+
// overlap fetch below — on a mid-hour restart those are pure waste
|
|
1121
|
+
// (a per-bot RPC fetch, a Kibana round trip, and a ~250 KiB candle
|
|
1122
|
+
// re-serialize) for zero new information. Every input is already
|
|
1123
|
+
// local: persisted state, the candle file we just read, and the wall
|
|
1124
|
+
// clock. Note the chain connection itself is NOT saved here — the
|
|
1125
|
+
// daemon already opened it before runOnce; that socket is closed right
|
|
1126
|
+
// after the cycle, and the startup sleep is what avoids opening one.
|
|
1127
|
+
//
|
|
1128
|
+
// The local candle file is part of the verdict on purpose. The full
|
|
1129
|
+
// cycle also repairs history (Kibana backfill, gap fill) even when no
|
|
1130
|
+
// new candle closed, so a bot whose cache does not yet COVER the
|
|
1131
|
+
// newest closed bucket — short history, unresolved gaps, a source
|
|
1132
|
+
// change — must still run. Only a bot that has demonstrably consumed
|
|
1133
|
+
// that bucket and holds the data for it is skipped.
|
|
1134
|
+
const persistedBotState = (state?.bots && typeof state.bots === 'object')
|
|
1135
|
+
? state.bots[bot.botKey]
|
|
1136
|
+
: null;
|
|
1137
|
+
const offHourSkip = this.shouldSkipBotForClosedCandle(bot, persistedBotState, cfg.intervalSeconds, undefined, cfg);
|
|
1138
|
+
const offHourSkipCovered = !!offHourSkip && this.candleFileCoversClosedBucket(existingCandles, existingMeta, marketSource, offHourSkip.latestClosedBucketStartMs, rawKeepCount);
|
|
1139
|
+
if (offHourSkip && offHourSkipCovered) {
|
|
1140
|
+
const skipNowIso = new Date().toISOString();
|
|
1141
|
+
const skipThreshold = typeof deps.calculateBotThreshold === 'function'
|
|
1142
|
+
? deps.calculateBotThreshold(cfg)
|
|
1143
|
+
: null;
|
|
1144
|
+
const skippedState = {
|
|
1145
|
+
...(persistedBotState && typeof persistedBotState === 'object' ? persistedBotState : {}),
|
|
1146
|
+
botName: bot.name,
|
|
1147
|
+
botKey: bot.botKey,
|
|
1148
|
+
lastCycleSource: 'off-hour-skip',
|
|
1149
|
+
lastCycleAt: skipNowIso,
|
|
1150
|
+
pendingClosedCandle: true,
|
|
1151
|
+
lastTriggerSuppressedReason: 'waiting_for_new_closed_candle',
|
|
1152
|
+
};
|
|
1153
|
+
state.bots[bot.botKey] = skippedState;
|
|
1154
|
+
return this.buildDefaultResult(bot, {
|
|
1155
|
+
dryRunMessages,
|
|
1156
|
+
source: 'off-hour-skip',
|
|
1157
|
+
thresholdPercent: skipThreshold,
|
|
1158
|
+
triggerSuppressedReason: 'waiting_for_new_closed_candle',
|
|
1159
|
+
lastCandleTs: persistedBotState?.lastCandleTs ?? null,
|
|
1160
|
+
rawLastCandleTs: persistedBotState?.rawLastCandleTs ?? null,
|
|
1161
|
+
lastClosedCandleTs: offHourSkip.previousClosedCandleTs || null,
|
|
1162
|
+
pendingClosedCandle: true,
|
|
1163
|
+
});
|
|
1164
|
+
}
|
|
945
1165
|
const kibanaRequestTimeoutMs = Number.isFinite(cfg.kibanaRequestTimeoutMs) && cfg.kibanaRequestTimeoutMs > 0
|
|
946
1166
|
? cfg.kibanaRequestTimeoutMs
|
|
947
1167
|
: MARKET_ADAPTER.KIBANA_REQUEST_TIMEOUT_MS;
|
|
@@ -1043,10 +1263,7 @@ class MarketAdapterService {
|
|
|
1043
1263
|
existingCandles = verified.candles;
|
|
1044
1264
|
applyStaleTailVerificationMeta(verified);
|
|
1045
1265
|
}
|
|
1046
|
-
const
|
|
1047
|
-
const sourceMismatch = (existingMarketSource && existingMarketSource !== marketSource)
|
|
1048
|
-
|| (marketSource === 'book' && hasStoredPoolContext)
|
|
1049
|
-
|| (marketSource === 'pool' && existingMarketSource === 'book');
|
|
1266
|
+
const sourceMismatch = this.isCandleSourceMismatch(existingMeta, marketSource);
|
|
1050
1267
|
if (sourceMismatch) {
|
|
1051
1268
|
existingCandles = [];
|
|
1052
1269
|
existingMeta.nativeRecentTradeSequences = [];
|
|
@@ -1055,11 +1272,6 @@ class MarketAdapterService {
|
|
|
1055
1272
|
existingMeta.staleTailVerifiedEndTs = null;
|
|
1056
1273
|
}
|
|
1057
1274
|
const needBootstrap = existingCandles.length === 0;
|
|
1058
|
-
const amaWarmupBars = getAmaWarmupBars(botAma.erPeriod, botAma.slowPeriod, lookbackBars, botAma.fastPeriod, botAma.erSmoothPeriod ?? 0);
|
|
1059
|
-
const analysisKeepCount = amaWarmupBars + 1;
|
|
1060
|
-
// Retain one extra raw candle so the closed-candle analysis window still keeps a
|
|
1061
|
-
// full warmup/history set when the newest bucket is the current in-progress bar.
|
|
1062
|
-
const rawKeepCount = analysisKeepCount + 1;
|
|
1063
1275
|
const nowIso = new Date().toISOString();
|
|
1064
1276
|
const botThreshold = deps.calculateBotThreshold(cfg);
|
|
1065
1277
|
if (!Number.isFinite(botThreshold) || botThreshold <= 0) {
|
|
@@ -1710,6 +1922,9 @@ class MarketAdapterService {
|
|
|
1710
1922
|
candles: nextCandles,
|
|
1711
1923
|
};
|
|
1712
1924
|
deps.saveJson(filePath, candlePayload);
|
|
1925
|
+
// The object just serialized IS the file's content now, so the next
|
|
1926
|
+
// cycle's read can skip the parse.
|
|
1927
|
+
noteJsonWritten(filePath, candlePayload);
|
|
1713
1928
|
if (!hasNewClosedCandle) {
|
|
1714
1929
|
const { staleData, staleAgeHours } = deps.computeCandleStaleness(lastClosedCandleTs, cfg.maxStaleHours);
|
|
1715
1930
|
const pendingClosedCandle = !staleData;
|
|
@@ -1856,7 +2071,11 @@ class MarketAdapterService {
|
|
|
1856
2071
|
const amaSlopeThresholdPercent = amaSlopeResetDetails.thresholdPercent;
|
|
1857
2072
|
// 4. Advisory collateral-ratio hint only; execution is owned by the debt runtime.
|
|
1858
2073
|
const collateralRecommendation = canExposeDynamicWeights ? adjustCollateralRatio(slopeResult, 1.5, 2.0) : null;
|
|
1859
|
-
|
|
2074
|
+
// Reports the single AMA this bot trades on (its own resolved
|
|
2075
|
+
// parameters, value already computed above as `amaPrice`). No extra
|
|
2076
|
+
// calculateAMA pass: the AMA1..AMA4 preset sweep this replaced fed
|
|
2077
|
+
// nothing but a log line.
|
|
2078
|
+
const amaComparison = deps.buildAmaRecord(botAma, amaPrice);
|
|
1860
2079
|
const closedCandleTs = lastCandle[0] || null;
|
|
1861
2080
|
const { staleData, staleAgeHours } = deps.computeCandleStaleness(closedCandleTs, cfg.maxStaleHours);
|
|
1862
2081
|
const referencePrice = amaPrice;
|
|
@@ -2309,5 +2528,5 @@ class MarketAdapterService {
|
|
|
2309
2528
|
};
|
|
2310
2529
|
}
|
|
2311
2530
|
}
|
|
2312
|
-
export { MarketAdapterService, AMA_SLOPE_PERCENT_MODE_PER_BAR, normalizeAmaSlopePercentMode, convertSlopePercentToPerBar };
|
|
2531
|
+
export { MarketAdapterService, AMA_SLOPE_PERCENT_MODE_PER_BAR, normalizeAmaSlopePercentMode, convertSlopePercentToPerBar, evaluateStateRepairVeto };
|
|
2313
2532
|
//# sourceMappingURL=market_adapter_service.js.map
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute R/S (rescaled range) over `returns[from..to)` (to exclusive).
|
|
3
|
+
* Taking a range instead of a slice keeps the caller's buffer reusable.
|
|
4
|
+
*/
|
|
5
|
+
declare function computeRS(returns: ArrayLike<number>, from: number, to: number): number;
|
|
1
6
|
/**
|
|
2
7
|
* Shared Hurst zone classification used by both HurstAnalyzer.getAnalysis()
|
|
3
8
|
* and the regime gate, so the zone boundaries live in exactly one place.
|
|
@@ -10,8 +15,12 @@ declare function classifyHurst(h: number, band?: number): {
|
|
|
10
15
|
declare class HurstAnalyzer {
|
|
11
16
|
private _w;
|
|
12
17
|
window: number;
|
|
18
|
+
/** Bars of history this analyzer's state depends on (see bufferBars use in the regime gate). */
|
|
19
|
+
bufferBars: number;
|
|
13
20
|
scales: number[];
|
|
14
21
|
private _prices;
|
|
22
|
+
private _returns;
|
|
23
|
+
private _priceCount;
|
|
15
24
|
private _updateCount;
|
|
16
25
|
hurst: number;
|
|
17
26
|
isReady: boolean;
|
|
@@ -44,5 +53,5 @@ declare class HurstAnalyzer {
|
|
|
44
53
|
updateCount: number;
|
|
45
54
|
};
|
|
46
55
|
}
|
|
47
|
-
export { HurstAnalyzer, classifyHurst };
|
|
56
|
+
export { HurstAnalyzer, classifyHurst, computeRS };
|
|
48
57
|
//# sourceMappingURL=hurst_analyzer.d.ts.map
|