dexbot 1.4.21 → 1.4.23
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 +52 -0
- package/README.md +8 -5
- package/analysis/ama_fitting/analyze_ama_price_changes.ts +7 -3
- package/analysis/ama_fitting/analyze_lambda_vs_slow.ts +6 -6
- package/analysis/ama_fitting/calibrate_convergence_er.ts +7 -5
- package/analysis/ama_fitting/fetch_lp_candles.ts +8 -3
- package/analysis/ama_fitting/generate_unified_comparison_chart.ts +30 -67
- package/analysis/ama_fitting/optimizer_high_resolution.ts +26 -17
- package/analysis/ama_fitting/package.json +1 -1
- package/analysis/analyze_derivatives.ts +4 -4
- package/analysis/analyze_dynamic_weight.ts +21 -5
- package/analysis/analyze_kalman.ts +54 -25
- package/analysis/analyze_regime.ts +2 -2
- package/analysis/analyze_regime_windows.ts +27 -19
- package/analysis/analyze_risk_profile.ts +3 -3
- package/analysis/analyze_trade_heatmap.ts +3 -3
- package/analysis/analyze_volatility.ts +2 -2
- package/analysis/bot_fitting/README.md +93 -19
- package/analysis/bot_fitting/backtest_ama_sweep.ts +316 -199
- package/analysis/bot_fitting/backtest_bot_fitting.ts +520 -85
- package/analysis/bot_fitting/shared_utils.ts +15 -9
- package/analysis/bot_key_utils.ts +13 -6
- package/analysis/bot_usage/discover_bot_accounts.ts +5 -3
- package/analysis/bot_usage/kibana_bot_queries.ts +1 -1
- package/analysis/chart_css.ts +6 -4
- package/analysis/chart_ui.ts +0 -1
- package/analysis/chart_utils.ts +11 -2
- package/analysis/derivative_chart_generator.ts +2 -2
- package/analysis/price_sources.ts +8 -2
- package/analysis/resolve_source.ts +1 -1
- package/analysis/trade_profitability.ts +61 -28
- package/analysis/tradingview/README.md +24 -4
- package/analysis/tradingview/analyze_tradingview.ts +1 -1
- package/analysis/tradingview/tradingview_uplot_chart_generator.ts +356 -86
- package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +1 -1
- package/analysis/trend_detection/derivative_analyzer.ts +12 -3
- package/analysis/trend_detection/dynamic_weight_chart_generator.ts +25 -27
- package/analysis/trend_detection/hurst_analyzer.ts +1 -1
- package/analysis/trend_detection/kalman_chart_generator.ts +42 -14
- package/analysis/trend_detection/package.json +1 -1
- package/analysis/trend_detection/regime_chart_generator.ts +39 -19
- package/analysis/trend_detection/tests/test_kalman_trend.ts +1 -1
- package/analysis/trend_detection/tests/test_kalman_velocity_smoothing.ts +1 -1
- package/analysis/trend_detection/volatility_chart_generator.ts +1 -1
- package/claw/index.ts +1 -1
- package/claw/modules/claw_bridge.ts +3 -3
- package/claw/modules/claw_catalog.ts +1 -1
- package/claw/modules/claw_launcher.ts +1 -1
- package/claw/modules/claw_skill_md.ts +7 -10
- package/claw/modules/credit_runtime_adapter.ts +1 -1
- package/claw/modules/decision_loop.ts +5 -9
- package/claw/modules/dexbot_bridge.ts +7 -7
- package/claw/modules/feed_price_source.ts +1 -1
- package/claw/modules/kibana_price_source.ts +1 -1
- package/claw/modules/launcher_mode_detector.ts +1 -1
- package/claw/modules/launcher_paths.ts +1 -1
- package/claw/modules/position_discovery.ts +1 -1
- package/claw/modules/position_health.ts +1 -1
- package/claw/package.json +3 -3
- package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
- package/claw/runtimes/openclaw-plugin/package.json +1 -1
- package/claw/skills/launcher-ops/references/launcher-workflow.md +2 -2
- package/claw/tests/package.json +1 -1
- package/claw/tests/test_claw_bridge.ts +45 -21
- package/claw/tests/test_claw_catalog_and_credentials.ts +8 -4
- package/claw/tests/test_claw_chain_layer.ts +39 -19
- package/claw/tests/test_claw_data_flow.ts +28 -20
- package/claw/tests/test_claw_domain_logic.ts +25 -19
- package/claw/tests/test_claw_manifest_and_matrix.ts +23 -3
- package/claw/tests/test_claw_mcp_transport.ts +13 -8
- package/claw/tests/test_claw_regressions.ts +254 -128
- package/claw/tests/test_claw_skill_generation.ts +1 -1
- package/claw/tests/test_nullclaw_tmp_integration.ts +2 -3
- package/claw/tests/test_position_health.ts +1 -77
- package/claw/tests/test_position_manager.ts +20 -18
- package/claw/tests/test_position_manager_watch_health.ts +39 -43
- package/claw/tests/test_short_mpa_strategy.ts +20 -17
- package/claw/tsconfig.json +4 -3
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.js +7 -3
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.js.map +1 -1
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +6 -6
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js.map +1 -1
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js +7 -5
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js.map +1 -1
- package/dist/analysis/ama_fitting/fetch_lp_candles.js +8 -3
- package/dist/analysis/ama_fitting/fetch_lp_candles.js.map +1 -1
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts +2 -2
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts.map +1 -1
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js +31 -75
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js.map +1 -1
- package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts.map +1 -1
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js +25 -17
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js.map +1 -1
- package/dist/analysis/analyze_derivatives.d.ts +0 -18
- package/dist/analysis/analyze_derivatives.d.ts.map +1 -1
- package/dist/analysis/analyze_derivatives.js +4 -4
- package/dist/analysis/analyze_derivatives.js.map +1 -1
- package/dist/analysis/analyze_dynamic_weight.d.ts +0 -11
- package/dist/analysis/analyze_dynamic_weight.d.ts.map +1 -1
- package/dist/analysis/analyze_dynamic_weight.js +19 -5
- package/dist/analysis/analyze_dynamic_weight.js.map +1 -1
- package/dist/analysis/analyze_kalman.d.ts +0 -10
- package/dist/analysis/analyze_kalman.d.ts.map +1 -1
- package/dist/analysis/analyze_kalman.js +51 -26
- package/dist/analysis/analyze_kalman.js.map +1 -1
- package/dist/analysis/analyze_regime.d.ts +0 -17
- package/dist/analysis/analyze_regime.d.ts.map +1 -1
- package/dist/analysis/analyze_regime.js +2 -2
- package/dist/analysis/analyze_regime.js.map +1 -1
- package/dist/analysis/analyze_regime_windows.d.ts +0 -16
- package/dist/analysis/analyze_regime_windows.d.ts.map +1 -1
- package/dist/analysis/analyze_regime_windows.js +28 -21
- package/dist/analysis/analyze_regime_windows.js.map +1 -1
- package/dist/analysis/analyze_risk_profile.js +3 -3
- package/dist/analysis/analyze_risk_profile.js.map +1 -1
- package/dist/analysis/analyze_trade_heatmap.js +3 -3
- package/dist/analysis/analyze_trade_heatmap.js.map +1 -1
- package/dist/analysis/analyze_volatility.d.ts +0 -19
- package/dist/analysis/analyze_volatility.d.ts.map +1 -1
- package/dist/analysis/analyze_volatility.js +2 -2
- package/dist/analysis/analyze_volatility.js.map +1 -1
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts +30 -14
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts.map +1 -1
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js +330 -193
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js.map +1 -1
- package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts +136 -1
- package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts.map +1 -1
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js +527 -83
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js.map +1 -1
- package/dist/analysis/bot_fitting/shared_utils.d.ts +1 -1
- package/dist/analysis/bot_fitting/shared_utils.d.ts.map +1 -1
- package/dist/analysis/bot_fitting/shared_utils.js +14 -8
- package/dist/analysis/bot_fitting/shared_utils.js.map +1 -1
- package/dist/analysis/bot_key_utils.d.ts.map +1 -1
- package/dist/analysis/bot_key_utils.js +13 -6
- package/dist/analysis/bot_key_utils.js.map +1 -1
- package/dist/analysis/bot_usage/discover_bot_accounts.js +5 -3
- package/dist/analysis/bot_usage/discover_bot_accounts.js.map +1 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +1 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.js +1 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.js.map +1 -1
- package/dist/analysis/chart_css.d.ts +3 -1
- package/dist/analysis/chart_css.d.ts.map +1 -1
- package/dist/analysis/chart_css.js +6 -3
- package/dist/analysis/chart_css.js.map +1 -1
- package/dist/analysis/chart_ui.d.ts.map +1 -1
- package/dist/analysis/chart_ui.js.map +1 -1
- package/dist/analysis/chart_utils.d.ts.map +1 -1
- package/dist/analysis/chart_utils.js +15 -2
- package/dist/analysis/chart_utils.js.map +1 -1
- package/dist/analysis/derivative_chart_generator.js +2 -2
- package/dist/analysis/derivative_chart_generator.js.map +1 -1
- package/dist/analysis/price_sources.d.ts +1 -0
- package/dist/analysis/price_sources.d.ts.map +1 -1
- package/dist/analysis/price_sources.js +8 -2
- package/dist/analysis/price_sources.js.map +1 -1
- package/dist/analysis/resolve_source.d.ts.map +1 -1
- package/dist/analysis/resolve_source.js +1 -1
- package/dist/analysis/resolve_source.js.map +1 -1
- package/dist/analysis/trade_profitability.d.ts.map +1 -1
- package/dist/analysis/trade_profitability.js +58 -29
- package/dist/analysis/trade_profitability.js.map +1 -1
- package/dist/analysis/tradingview/analyze_tradingview.js +1 -1
- package/dist/analysis/tradingview/analyze_tradingview.js.map +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +356 -86
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +1 -1
- package/dist/analysis/trend_detection/derivative_analyzer.d.ts +1 -0
- package/dist/analysis/trend_detection/derivative_analyzer.d.ts.map +1 -1
- package/dist/analysis/trend_detection/derivative_analyzer.js +12 -3
- package/dist/analysis/trend_detection/derivative_analyzer.js.map +1 -1
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +1 -1
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +26 -27
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +1 -1
- package/dist/analysis/trend_detection/hurst_analyzer.d.ts +1 -1
- package/dist/analysis/trend_detection/hurst_analyzer.d.ts.map +1 -1
- package/dist/analysis/trend_detection/hurst_analyzer.js +1 -1
- package/dist/analysis/trend_detection/hurst_analyzer.js.map +1 -1
- package/dist/analysis/trend_detection/kalman_chart_generator.d.ts.map +1 -1
- package/dist/analysis/trend_detection/kalman_chart_generator.js +41 -13
- package/dist/analysis/trend_detection/kalman_chart_generator.js.map +1 -1
- package/dist/analysis/trend_detection/regime_chart_generator.d.ts.map +1 -1
- package/dist/analysis/trend_detection/regime_chart_generator.js +38 -19
- package/dist/analysis/trend_detection/regime_chart_generator.js.map +1 -1
- package/dist/analysis/trend_detection/tests/test_kalman_trend.js +1 -1
- package/dist/analysis/trend_detection/tests/test_kalman_trend.js.map +1 -1
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js +1 -1
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js.map +1 -1
- package/dist/analysis/trend_detection/volatility_chart_generator.js +1 -1
- package/dist/analysis/trend_detection/volatility_chart_generator.js.map +1 -1
- package/dist/bot.js +1 -1
- package/dist/bot.js.map +1 -1
- package/dist/credential-daemon.d.ts +1 -1
- package/dist/credential-daemon.js +1 -1
- package/dist/dexbot.d.ts.map +1 -1
- package/dist/dexbot.js +7 -8
- package/dist/dexbot.js.map +1 -1
- package/dist/market_adapter/ama_signal_runner.js +3 -1
- package/dist/market_adapter/ama_signal_runner.js.map +1 -1
- package/dist/market_adapter/candle_utils.d.ts +1 -3
- package/dist/market_adapter/candle_utils.d.ts.map +1 -1
- package/dist/market_adapter/candle_utils.js +1 -11
- package/dist/market_adapter/candle_utils.js.map +1 -1
- package/dist/market_adapter/core/asymmetric_bounds.d.ts.map +1 -1
- package/dist/market_adapter/core/asymmetric_bounds.js +33 -30
- package/dist/market_adapter/core/asymmetric_bounds.js.map +1 -1
- package/dist/market_adapter/core/config_normalizers.d.ts.map +1 -1
- package/dist/market_adapter/core/config_normalizers.js +10 -1
- package/dist/market_adapter/core/config_normalizers.js.map +1 -1
- package/dist/market_adapter/core/kibana_candles.d.ts +18 -42
- package/dist/market_adapter/core/kibana_candles.d.ts.map +1 -1
- package/dist/market_adapter/core/kibana_candles.js +101 -7
- package/dist/market_adapter/core/kibana_candles.js.map +1 -1
- package/dist/market_adapter/core/kibana_client.d.ts +0 -14
- package/dist/market_adapter/core/kibana_client.d.ts.map +1 -1
- package/dist/market_adapter/core/kibana_client.js +39 -6
- package/dist/market_adapter/core/kibana_client.js.map +1 -1
- package/dist/market_adapter/core/kibana_market_candles.d.ts +0 -27
- package/dist/market_adapter/core/kibana_market_candles.d.ts.map +1 -1
- package/dist/market_adapter/core/kibana_market_candles.js +1 -1
- package/dist/market_adapter/core/kibana_market_candles.js.map +1 -1
- package/dist/market_adapter/core/market_adapter_service.d.ts +21 -11
- package/dist/market_adapter/core/market_adapter_service.d.ts.map +1 -1
- package/dist/market_adapter/core/market_adapter_service.js +95 -37
- package/dist/market_adapter/core/market_adapter_service.js.map +1 -1
- package/dist/market_adapter/core/signals/hurst_analyzer.d.ts +10 -1
- package/dist/market_adapter/core/signals/hurst_analyzer.d.ts.map +1 -1
- package/dist/market_adapter/core/signals/hurst_analyzer.js +28 -17
- package/dist/market_adapter/core/signals/hurst_analyzer.js.map +1 -1
- package/dist/market_adapter/core/signals/kalman_trend_analyzer.d.ts +5 -0
- package/dist/market_adapter/core/signals/kalman_trend_analyzer.d.ts.map +1 -1
- package/dist/market_adapter/core/signals/kalman_trend_analyzer.js +24 -24
- package/dist/market_adapter/core/signals/kalman_trend_analyzer.js.map +1 -1
- package/dist/market_adapter/core/signals/kalman_velocity_smoothing.d.ts.map +1 -1
- package/dist/market_adapter/core/signals/kalman_velocity_smoothing.js +5 -1
- package/dist/market_adapter/core/signals/kalman_velocity_smoothing.js.map +1 -1
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts.map +1 -1
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js +20 -3
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js.map +1 -1
- package/dist/market_adapter/core/strategies/ama.js +1 -1
- package/dist/market_adapter/core/strategies/ama.js.map +1 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.d.ts +2 -2
- package/dist/market_adapter/core/strategies/ama_slope_model.d.ts.map +1 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.js +16 -4
- package/dist/market_adapter/core/strategies/ama_slope_model.js.map +1 -1
- package/dist/market_adapter/core/strategies/atr/calculator.d.ts +4 -3
- package/dist/market_adapter/core/strategies/atr/calculator.d.ts.map +1 -1
- package/dist/market_adapter/core/strategies/atr/calculator.js +16 -8
- package/dist/market_adapter/core/strategies/atr/calculator.js.map +1 -1
- package/dist/market_adapter/core/strategies/collateral_manager.d.ts.map +1 -1
- package/dist/market_adapter/core/strategies/collateral_manager.js +8 -3
- package/dist/market_adapter/core/strategies/collateral_manager.js.map +1 -1
- package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts +40 -1
- package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts.map +1 -1
- package/dist/market_adapter/core/strategies/dynamic_weight_series.js +116 -2
- package/dist/market_adapter/core/strategies/dynamic_weight_series.js.map +1 -1
- package/dist/market_adapter/core/strategies/regime_gate.d.ts.map +1 -1
- package/dist/market_adapter/core/strategies/regime_gate.js +26 -20
- package/dist/market_adapter/core/strategies/regime_gate.js.map +1 -1
- package/dist/market_adapter/core/strategies/volatility_shift.d.ts.map +1 -1
- package/dist/market_adapter/core/strategies/volatility_shift.js +3 -0
- package/dist/market_adapter/core/strategies/volatility_shift.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +69 -55
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +0 -26
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js +67 -14
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -1
- package/dist/market_adapter/inputs/kibana_source.d.ts +4 -28
- package/dist/market_adapter/inputs/kibana_source.d.ts.map +1 -1
- package/dist/market_adapter/inputs/kibana_source.js +5 -2
- package/dist/market_adapter/inputs/kibana_source.js.map +1 -1
- package/dist/market_adapter/lp_chart_core.js +1 -1
- package/dist/market_adapter/lp_chart_core.js.map +1 -1
- package/dist/market_adapter/lp_chart_runner.d.ts +10 -1
- package/dist/market_adapter/lp_chart_runner.d.ts.map +1 -1
- package/dist/market_adapter/lp_chart_runner.js +2 -2
- package/dist/market_adapter/lp_chart_runner.js.map +1 -1
- package/dist/market_adapter/lp_chart_strategy_loader.js +1 -1
- package/dist/market_adapter/lp_chart_strategy_loader.js.map +1 -1
- package/dist/market_adapter/market_adapter.d.ts +1 -2
- package/dist/market_adapter/market_adapter.d.ts.map +1 -1
- package/dist/market_adapter/market_adapter.js +9 -8
- package/dist/market_adapter/market_adapter.js.map +1 -1
- package/dist/market_adapter/test_helpers.d.ts +3 -3
- package/dist/market_adapter/test_helpers.d.ts.map +1 -1
- package/dist/market_adapter/test_helpers.js +3 -3
- package/dist/market_adapter/test_helpers.js.map +1 -1
- package/dist/market_adapter/utils/adapter_client.js +1 -1
- package/dist/market_adapter/utils/adapter_client.js.map +1 -1
- package/dist/market_adapter/utils/atomic_write.js +1 -1
- package/dist/market_adapter/utils/atomic_write.js.map +1 -1
- package/dist/market_adapter/utils/chain.d.ts +0 -2
- package/dist/market_adapter/utils/chain.d.ts.map +1 -1
- package/dist/market_adapter/utils/chain.js +2 -3
- package/dist/market_adapter/utils/chain.js.map +1 -1
- package/dist/market_adapter/utils/data_discovery.d.ts.map +1 -1
- package/dist/market_adapter/utils/data_discovery.js +24 -8
- package/dist/market_adapter/utils/data_discovery.js.map +1 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +1 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js +2 -5
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +1 -1
- package/dist/market_adapter/utils/file_lock.d.ts +4 -1
- package/dist/market_adapter/utils/file_lock.d.ts.map +1 -1
- package/dist/market_adapter/utils/file_lock.js +89 -25
- package/dist/market_adapter/utils/file_lock.js.map +1 -1
- package/dist/market_adapter/utils/native_history.d.ts.map +1 -1
- package/dist/market_adapter/utils/native_history.js +5 -1
- package/dist/market_adapter/utils/native_history.js.map +1 -1
- package/dist/modules/account_bots.d.ts.map +1 -1
- package/dist/modules/account_bots.js +47 -12
- package/dist/modules/account_bots.js.map +1 -1
- package/dist/modules/authority_resolver.js +1 -1
- package/dist/modules/authority_resolver.js.map +1 -1
- package/dist/modules/bitshares-native/chain_client.js +1 -1
- package/dist/modules/bitshares-native/chain_client.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts +0 -12
- package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.js +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.js +1 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.js.map +1 -1
- package/dist/modules/bitshares-native/index.d.ts.map +1 -1
- package/dist/modules/bitshares-native/index.js +1 -1
- package/dist/modules/bitshares-native/index.js.map +1 -1
- package/dist/modules/bitshares-native/lru_cache.js +1 -1
- package/dist/modules/bitshares-native/lru_cache.js.map +1 -1
- package/dist/modules/bitshares-native/resolvers.d.ts +0 -2
- package/dist/modules/bitshares-native/resolvers.d.ts.map +1 -1
- package/dist/modules/bitshares-native/resolvers.js +18 -4
- package/dist/modules/bitshares-native/resolvers.js.map +1 -1
- package/dist/modules/bitshares-native/serial/chain_constants.js +1 -1
- package/dist/modules/bitshares-native/serial/chain_constants.js.map +1 -1
- package/dist/modules/bitshares-native/serial/index.d.ts.map +1 -1
- package/dist/modules/bitshares-native/serial/index.js +1 -1
- package/dist/modules/bitshares-native/serial/index.js.map +1 -1
- package/dist/modules/bitshares-native/serial/operations.js +1 -1
- package/dist/modules/bitshares-native/serial/operations.js.map +1 -1
- package/dist/modules/bitshares-native/serial/serializer.js +1 -1
- package/dist/modules/bitshares-native/serial/serializer.js.map +1 -1
- package/dist/modules/bitshares-native/serial/types.js +1 -1
- package/dist/modules/bitshares-native/serial/types.js.map +1 -1
- package/dist/modules/bitshares-native/signing_client.js +2 -2
- package/dist/modules/bitshares-native/signing_client.js.map +1 -1
- package/dist/modules/bitshares-native/subscriptions.d.ts.map +1 -1
- package/dist/modules/bitshares-native/subscriptions.js +5 -14
- package/dist/modules/bitshares-native/subscriptions.js.map +1 -1
- package/dist/modules/bitshares-native/transport.js +1 -1
- package/dist/modules/bitshares-native/transport.js.map +1 -1
- package/dist/modules/bitshares-native/tx/builder.js +1 -1
- package/dist/modules/bitshares-native/tx/builder.js.map +1 -1
- package/dist/modules/bitshares-native/tx/tx_cache.d.ts +3 -2
- package/dist/modules/bitshares-native/tx/tx_cache.d.ts.map +1 -1
- package/dist/modules/bitshares-native/tx/tx_cache.js +7 -4
- package/dist/modules/bitshares-native/tx/tx_cache.js.map +1 -1
- package/dist/modules/bitshares_client.js +10 -10
- package/dist/modules/bitshares_client.js.map +1 -1
- package/dist/modules/bot_settings.d.ts.map +1 -1
- package/dist/modules/bot_settings.js +11 -18
- package/dist/modules/bot_settings.js.map +1 -1
- package/dist/modules/bots_file_lock.d.ts +1 -1
- package/dist/modules/bots_file_lock.js +1 -1
- package/dist/modules/broadcast_failure.d.ts +13 -0
- package/dist/modules/broadcast_failure.d.ts.map +1 -1
- package/dist/modules/broadcast_failure.js +0 -13
- package/dist/modules/broadcast_failure.js.map +1 -1
- package/dist/modules/chain_orders.d.ts.map +1 -1
- package/dist/modules/chain_orders.js +15 -17
- package/dist/modules/chain_orders.js.map +1 -1
- package/dist/modules/config.js +1 -1
- package/dist/modules/config.js.map +1 -1
- package/dist/modules/constants.d.ts +21 -20
- package/dist/modules/constants.d.ts.map +1 -1
- package/dist/modules/constants.js +60 -63
- package/dist/modules/constants.js.map +1 -1
- package/dist/modules/cr_planner.d.ts +1 -7
- package/dist/modules/cr_planner.d.ts.map +1 -1
- package/dist/modules/cr_planner.js +3 -77
- package/dist/modules/cr_planner.js.map +1 -1
- package/dist/modules/credential_policy.d.ts +0 -4
- package/dist/modules/credential_policy.d.ts.map +1 -1
- package/dist/modules/credential_policy.js +17 -2
- package/dist/modules/credential_policy.js.map +1 -1
- package/dist/modules/credit_runtime.d.ts +0 -7
- package/dist/modules/credit_runtime.d.ts.map +1 -1
- package/dist/modules/credit_runtime.js +21 -60
- package/dist/modules/credit_runtime.js.map +1 -1
- package/dist/modules/crypto/index.d.ts +0 -2
- package/dist/modules/crypto/index.d.ts.map +1 -1
- package/dist/modules/crypto/index.js +0 -2
- package/dist/modules/crypto/index.js.map +1 -1
- package/dist/modules/crypto/sync.js.map +1 -1
- package/dist/modules/daemon_node_health.js +1 -1
- package/dist/modules/daemon_node_health.js.map +1 -1
- package/dist/modules/dexbot_class.d.ts +8 -134
- package/dist/modules/dexbot_class.d.ts.map +1 -1
- package/dist/modules/dexbot_class.js +36 -197
- package/dist/modules/dexbot_class.js.map +1 -1
- package/dist/modules/dexbot_credential_client.js +1 -1
- package/dist/modules/dexbot_credential_client.js.map +1 -1
- package/dist/modules/dexbot_fill_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_fill_runtime.js +3 -6
- package/dist/modules/dexbot_fill_runtime.js.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts +6 -34
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.js +27 -19
- package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
- package/dist/modules/dexbot_startup_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_startup_runtime.js +31 -15
- package/dist/modules/dexbot_startup_runtime.js.map +1 -1
- package/dist/modules/dexbot_state_recovery.d.ts +2 -2
- package/dist/modules/dexbot_state_recovery.d.ts.map +1 -1
- package/dist/modules/dexbot_state_recovery.js +9 -6
- package/dist/modules/dexbot_state_recovery.js.map +1 -1
- package/dist/modules/fund_registry.d.ts.map +1 -1
- package/dist/modules/fund_registry.js +19 -4
- package/dist/modules/fund_registry.js.map +1 -1
- package/dist/modules/general_settings.d.ts +1 -2
- package/dist/modules/general_settings.d.ts.map +1 -1
- package/dist/modules/general_settings.js +1 -2
- package/dist/modules/general_settings.js.map +1 -1
- package/dist/modules/graceful_shutdown.d.ts.map +1 -1
- package/dist/modules/graceful_shutdown.js +10 -1
- package/dist/modules/graceful_shutdown.js.map +1 -1
- package/dist/modules/grid_price_source.d.ts +19 -0
- package/dist/modules/grid_price_source.d.ts.map +1 -0
- package/dist/modules/grid_price_source.js +23 -0
- package/dist/modules/grid_price_source.js.map +1 -0
- package/dist/modules/key_store.d.ts +0 -5
- package/dist/modules/key_store.d.ts.map +1 -1
- package/dist/modules/key_store.js +1 -14
- package/dist/modules/key_store.js.map +1 -1
- package/dist/modules/launcher/bot_supervisor.d.ts.map +1 -1
- package/dist/modules/launcher/bot_supervisor.js +9 -19
- package/dist/modules/launcher/bot_supervisor.js.map +1 -1
- package/dist/modules/launcher/child_env.d.ts +1 -2
- package/dist/modules/launcher/child_env.d.ts.map +1 -1
- package/dist/modules/launcher/child_env.js +1 -1
- package/dist/modules/launcher/child_env.js.map +1 -1
- package/dist/modules/launcher/foreign_cred_daemon.d.ts.map +1 -1
- package/dist/modules/launcher/foreign_cred_daemon.js +2 -14
- package/dist/modules/launcher/foreign_cred_daemon.js.map +1 -1
- package/dist/modules/launcher/market_adapter_runtime.d.ts +1 -1
- package/dist/modules/launcher/market_adapter_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/market_adapter_runtime.js +3 -14
- package/dist/modules/launcher/market_adapter_runtime.js.map +1 -1
- package/dist/modules/launcher/market_adapter_watchdog.d.ts.map +1 -1
- package/dist/modules/launcher/market_adapter_watchdog.js +3 -2
- package/dist/modules/launcher/market_adapter_watchdog.js.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts +0 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.js +3 -18
- package/dist/modules/launcher/monolithic_runtime.js.map +1 -1
- package/dist/modules/launcher/runtime_entry.d.ts.map +1 -1
- package/dist/modules/launcher/runtime_entry.js +4 -5
- package/dist/modules/launcher/runtime_entry.js.map +1 -1
- package/dist/modules/launcher/status_reporting.js +1 -1
- package/dist/modules/launcher/status_reporting.js.map +1 -1
- package/dist/modules/launcher/supervisor_control.js +1 -1
- package/dist/modules/launcher/supervisor_control.js.map +1 -1
- package/dist/modules/market_adapter_whitelist.d.ts +2 -2
- package/dist/modules/market_adapter_whitelist.d.ts.map +1 -1
- package/dist/modules/market_adapter_whitelist.js +12 -6
- package/dist/modules/market_adapter_whitelist.js.map +1 -1
- package/dist/modules/node_failure_ledger.d.ts +23 -0
- package/dist/modules/node_failure_ledger.d.ts.map +1 -1
- package/dist/modules/node_failure_ledger.js +0 -23
- package/dist/modules/node_failure_ledger.js.map +1 -1
- package/dist/modules/node_manager.d.ts.map +1 -1
- package/dist/modules/node_manager.js +3 -3
- package/dist/modules/node_manager.js.map +1 -1
- package/dist/modules/order/accounting.js +1 -1
- package/dist/modules/order/accounting.js.map +1 -1
- package/dist/modules/order/async_lock.d.ts +6 -0
- package/dist/modules/order/async_lock.d.ts.map +1 -1
- package/dist/modules/order/async_lock.js +11 -0
- package/dist/modules/order/async_lock.js.map +1 -1
- package/dist/modules/order/export.d.ts +1 -1
- package/dist/modules/order/export.js +10 -10
- package/dist/modules/order/export.js.map +1 -1
- package/dist/modules/order/format.d.ts +1 -0
- package/dist/modules/order/format.d.ts.map +1 -1
- package/dist/modules/order/format.js +0 -6
- package/dist/modules/order/format.js.map +1 -1
- package/dist/modules/order/grid.d.ts +2 -12
- package/dist/modules/order/grid.d.ts.map +1 -1
- package/dist/modules/order/grid.js +40 -27
- package/dist/modules/order/grid.js.map +1 -1
- package/dist/modules/order/grid_reconcile.d.ts +1 -1
- package/dist/modules/order/grid_reconcile.js +1 -1
- package/dist/modules/order/grid_reconcile_internal.js +1 -1
- package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
- package/dist/modules/order/logger.d.ts +3 -0
- package/dist/modules/order/logger.d.ts.map +1 -1
- package/dist/modules/order/logger.js +22 -13
- package/dist/modules/order/logger.js.map +1 -1
- package/dist/modules/order/logger_state.d.ts +4 -9
- package/dist/modules/order/logger_state.d.ts.map +1 -1
- package/dist/modules/order/logger_state.js +5 -14
- package/dist/modules/order/logger_state.js.map +1 -1
- package/dist/modules/order/manager.d.ts +1 -4
- package/dist/modules/order/manager.d.ts.map +1 -1
- package/dist/modules/order/manager.js +34 -33
- package/dist/modules/order/manager.js.map +1 -1
- package/dist/modules/order/processed_fill_store.d.ts.map +1 -1
- package/dist/modules/order/processed_fill_store.js +9 -3
- package/dist/modules/order/processed_fill_store.js.map +1 -1
- package/dist/modules/order/strategy.d.ts +6 -4
- package/dist/modules/order/strategy.d.ts.map +1 -1
- package/dist/modules/order/strategy.js +6 -4
- package/dist/modules/order/strategy.js.map +1 -1
- package/dist/modules/order/sync_engine.js +7 -7
- package/dist/modules/order/sync_engine.js.map +1 -1
- package/dist/modules/order/utils/math.d.ts +29 -3
- package/dist/modules/order/utils/math.d.ts.map +1 -1
- package/dist/modules/order/utils/math.js +54 -10
- package/dist/modules/order/utils/math.js.map +1 -1
- package/dist/modules/order/utils/order.d.ts.map +1 -1
- package/dist/modules/order/utils/order.js +14 -2
- package/dist/modules/order/utils/order.js.map +1 -1
- package/dist/modules/order/utils/system.d.ts +3 -8
- package/dist/modules/order/utils/system.d.ts.map +1 -1
- package/dist/modules/order/utils/system.js +14 -4
- package/dist/modules/order/utils/system.js.map +1 -1
- package/dist/modules/order/utils/validate.js +1 -1
- package/dist/modules/order/utils/validate.js.map +1 -1
- package/dist/modules/path_api.js +1 -1
- package/dist/modules/path_api.js.map +1 -1
- package/dist/modules/paths.d.ts +1 -7
- package/dist/modules/paths.d.ts.map +1 -1
- package/dist/modules/paths.js +1 -1
- package/dist/modules/paths.js.map +1 -1
- package/dist/modules/process_discovery.d.ts +3 -0
- package/dist/modules/process_discovery.d.ts.map +1 -1
- package/dist/modules/process_discovery.js +15 -1
- package/dist/modules/process_discovery.js.map +1 -1
- package/dist/modules/runtime_settings.js +1 -1
- package/dist/modules/runtime_settings.js.map +1 -1
- package/dist/modules/settings_merge.d.ts +5 -1
- package/dist/modules/settings_merge.d.ts.map +1 -1
- package/dist/modules/settings_merge.js +14 -3
- package/dist/modules/settings_merge.js.map +1 -1
- package/dist/modules/socket_json_client.d.ts.map +1 -1
- package/dist/modules/socket_json_client.js +12 -2
- package/dist/modules/socket_json_client.js.map +1 -1
- package/dist/modules/storage/browser_adapter.d.ts.map +1 -1
- package/dist/modules/storage/browser_adapter.js +5 -3
- package/dist/modules/storage/browser_adapter.js.map +1 -1
- package/dist/modules/storage/index.d.ts +1 -1
- package/dist/modules/storage/index.js +1 -1
- package/dist/modules/types.d.ts +1 -1
- package/dist/modules/types.d.ts.map +1 -1
- package/dist/modules/validate_profiles.d.ts.map +1 -1
- package/dist/modules/validate_profiles.js +6 -8
- package/dist/modules/validate_profiles.js.map +1 -1
- package/dist/pm2.d.ts.map +1 -1
- package/dist/pm2.js +2 -3
- package/dist/pm2.js.map +1 -1
- package/dist/scripts/analyze-git.d.ts +1 -1
- package/dist/scripts/analyze-git.js +1 -1
- package/dist/scripts/analyze-orders.d.ts.map +1 -1
- package/dist/scripts/analyze-orders.js +61 -18
- package/dist/scripts/analyze-orders.js.map +1 -1
- package/dist/scripts/diagnose-pool-history.js +1 -1
- package/dist/scripts/divergence-calc.d.ts +1 -1
- package/dist/scripts/divergence-calc.js +3 -3
- package/dist/scripts/native_release_gates.js +4 -2
- package/dist/scripts/native_release_gates.js.map +1 -1
- package/dist/scripts/print_grid.d.ts +1 -1
- package/dist/scripts/print_grid.js +1 -1
- package/dist/scripts/run-tests.js +38 -19
- package/dist/scripts/run-tests.js.map +1 -1
- package/dist/scripts/runner.d.ts +3 -5
- package/dist/scripts/runner.d.ts.map +1 -1
- package/dist/scripts/runner.js +3 -5
- package/dist/scripts/runner.js.map +1 -1
- package/dist/scripts/sync-version.d.ts +2 -2
- package/dist/scripts/sync-version.js +7 -4
- package/dist/scripts/sync-version.js.map +1 -1
- package/dist/scripts/update.d.ts +1 -1
- package/dist/scripts/update.js +1 -1
- package/dist/scripts/validate_bots.d.ts +1 -1
- package/dist/scripts/validate_bots.js +1 -1
- package/dist/scripts/verify-browser-bundle.d.ts +1 -1
- package/dist/scripts/verify-browser-bundle.js +1 -1
- package/dist/unlock.js +4 -4
- package/dist/unlock.js.map +1 -1
- package/docs/BITSHARES_ONBOARDING.md +15 -10
- package/docs/COPY_ON_WRITE_MASTER_PLAN.md +9 -9
- package/docs/DEXBOT_COMPARISON.md +19 -19
- package/docs/EVOLUTION.md +18 -44
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
- package/docs/GRID_RECALCULATION.md +1 -1
- package/docs/README.md +3 -3
- package/docs/architecture.md +5 -5
- package/docs/developer_guide.md +6 -6
- package/market_adapter/README.md +13 -8
- package/package.json +22 -14
- package/scripts/README.md +33 -7
- package/scripts/clean-dist.js +10 -2
- package/tests/README.md +4 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
'use strict';
|
|
1
2
|
|
|
2
3
|
import { roundTo } from '../../modules/order/utils/math.js';
|
|
3
|
-
'use strict';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Derivative Analyzer
|
|
@@ -235,6 +235,10 @@ class DerivativeAnalyzer {
|
|
|
235
235
|
rsiBullThreshold: number;
|
|
236
236
|
rsiBearThreshold: number;
|
|
237
237
|
macdMinHist: number;
|
|
238
|
+
// Resolved threshold for the MACD-line gates: falls back to the historical
|
|
239
|
+
// 0.02 default only when unset/NaN, so an explicit 0 (strict sign test)
|
|
240
|
+
// stays expressible via the API.
|
|
241
|
+
macdLineGateThreshold: number;
|
|
238
242
|
fastSmaCommitmentBars: number;
|
|
239
243
|
trendFilterEnabled: boolean;
|
|
240
244
|
trendFilterMinBars: number;
|
|
@@ -311,6 +315,11 @@ class DerivativeAnalyzer {
|
|
|
311
315
|
this.rsiBullThreshold = config.rsiBullThreshold ?? 55;
|
|
312
316
|
this.rsiBearThreshold = config.rsiBearThreshold ?? 45;
|
|
313
317
|
this.macdMinHist = config.macdMinHist ?? 0;
|
|
318
|
+
// Unset/NaN → historical 0.02 gate default; explicit 0 → strict sign test.
|
|
319
|
+
// (`this.macdMinHist || 0.02` at the gates made explicit 0 unreachable.)
|
|
320
|
+
this.macdLineGateThreshold = config.macdMinHist != null && Number.isFinite(config.macdMinHist)
|
|
321
|
+
? config.macdMinHist
|
|
322
|
+
: 0.02;
|
|
314
323
|
this.fastSmaCommitmentBars = config.fastSmaCommitmentBars ?? 2;
|
|
315
324
|
this.trendFilterEnabled = config.trendFilterEnabled ?? false;
|
|
316
325
|
this.trendFilterMinBars = config.trendFilterMinBars ?? 3;
|
|
@@ -421,7 +430,7 @@ class DerivativeAnalyzer {
|
|
|
421
430
|
// This ignores marginal crossings at ~0 and ensures signals only start when
|
|
422
431
|
// momentum is clearly confirmed.
|
|
423
432
|
if (this.macd && this.currMacd !== null) {
|
|
424
|
-
const threshold = this.
|
|
433
|
+
const threshold = this.macdLineGateThreshold;
|
|
425
434
|
if ((rawInterp === 'BEAR' || rawInterp === 'BEAR_WEAK') && this.currMacd.macd > -threshold)
|
|
426
435
|
rawInterp = 'NEUTRAL';
|
|
427
436
|
if ((rawInterp === 'BULL' || rawInterp === 'BULL_WEAK') && this.currMacd.macd < threshold)
|
|
@@ -744,7 +753,7 @@ class DerivativeAnalyzer {
|
|
|
744
753
|
if (interp !== 'BULL' && interp !== 'BEAR') return false;
|
|
745
754
|
|
|
746
755
|
if (this.macd && this.currMacd !== null) {
|
|
747
|
-
const threshold = this.
|
|
756
|
+
const threshold = this.macdLineGateThreshold;
|
|
748
757
|
if (interp === 'BULL' && this.currMacd.macd < threshold) return true;
|
|
749
758
|
if (interp === 'BEAR' && this.currMacd.macd > -threshold) return true;
|
|
750
759
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
1
2
|
|
|
2
3
|
import { DEFAULT_CONFIG, MARKET_ADAPTER } from '../../modules/constants.js';
|
|
3
4
|
import { getAmaWarmupBars } from '../../market_adapter/core/strategies/ama.js';
|
|
4
5
|
import { bilinearInterpolate } from '../../market_adapter/core/strategies/regime_interp.js';
|
|
5
|
-
import { computeDynamicWeightSeries, computeAverageAmaSlopePct, echoLatchSeries, roundToN } from '../../market_adapter/core/strategies/dynamic_weight_series.js';
|
|
6
|
+
import { computeDynamicWeightSeries, computeAverageAmaSlopePct, computeAmaSlopeClipThreshold, echoLatchSeries, roundToN } from '../../market_adapter/core/strategies/dynamic_weight_series.js';
|
|
6
7
|
import {
|
|
7
8
|
buildKalmanVelocitySeries,
|
|
8
9
|
computeAbsolutePercentileThreshold,
|
|
@@ -12,12 +13,12 @@ import {
|
|
|
12
13
|
import { embedFunctionSources, escapeHtml, serializeJsonForScript, toEpochSeconds, UPLOT_SHARED_SCRIPT } from '../chart_utils.js';
|
|
13
14
|
import { sharedChartCSS } from '../chart_css.js';
|
|
14
15
|
import { Y_AXIS_SIZE, makeCursorConfig, bindHoverStateFn, wireChartEvents, zoomResetScript, sizeChartsFn } from '../chart_ui.js';
|
|
15
|
-
'use strict';
|
|
16
16
|
|
|
17
17
|
// Browser-embedded shared functions — the interactive chart runs the exact same
|
|
18
18
|
// pure logic as the live market adapter service instead of a hand-copied copy.
|
|
19
19
|
const EMBEDDED_SHARED_FUNCS = embedFunctionSources([
|
|
20
20
|
computeAverageAmaSlopePct,
|
|
21
|
+
computeAmaSlopeClipThreshold,
|
|
21
22
|
bilinearInterpolate,
|
|
22
23
|
echoLatchSeries,
|
|
23
24
|
buildKalmanVelocitySeries,
|
|
@@ -36,7 +37,7 @@ function generateHTML(data: any, title = 'Dynamic Weight Research') {
|
|
|
36
37
|
// payload transport, and client paste-clamp bounds.
|
|
37
38
|
const LB_MIN = 1, LB_MAX = 32;
|
|
38
39
|
const GAIN_MIN = 0.5, GAIN_MAX = 2.0;
|
|
39
|
-
const AMA_MS_MIN = 0.
|
|
40
|
+
const AMA_MS_MIN = 0.06, AMA_MS_MAX = 0.12;
|
|
40
41
|
const KAL_MS_MIN = 0.5, KAL_MS_MAX = 1.5;
|
|
41
42
|
const CLIP_PCT_MAX = 20;
|
|
42
43
|
const TH_MIN = 0, TH_MAX = 0.5;
|
|
@@ -204,10 +205,14 @@ function generateHTML(data: any, title = 'Dynamic Weight Research') {
|
|
|
204
205
|
const sorted: number[] = [];
|
|
205
206
|
for (let i = safeStartIndex; i < realBarCount; i++) { if (arr[i] != null) sorted.push(Math.abs(arr[i])); }
|
|
206
207
|
sorted.sort((a, b) => a - b);
|
|
208
|
+
// Empty pool → Infinity: the live percentile lookup treats an empty
|
|
209
|
+
// history as "no clipping" (percentileFromSorted returns Infinity);
|
|
210
|
+
// collapsing to 0 here would clip every slope to ±0 instead.
|
|
211
|
+
if (sorted.length === 0) return new Array(101).fill(Infinity);
|
|
207
212
|
const pcts: number[] = [];
|
|
208
213
|
for (let p = 0; p <= 100; p++) {
|
|
209
214
|
const idx = Math.min(Math.floor(sorted.length * p / 100), sorted.length - 1);
|
|
210
|
-
pcts.push(sorted[idx]
|
|
215
|
+
pcts.push(sorted[idx]);
|
|
211
216
|
}
|
|
212
217
|
return pcts;
|
|
213
218
|
}
|
|
@@ -437,8 +442,11 @@ function generateHTML(data: any, title = 'Dynamic Weight Research') {
|
|
|
437
442
|
const gainValToSlider = (val) => Math.round((Math.log(Math.max(Math.exp(GAIN_LOG_MIN), val)) - GAIN_LOG_MIN) / (GAIN_LOG_MAX - GAIN_LOG_MIN) * 1000);
|
|
438
443
|
|
|
439
444
|
let currentClipPct = data.clipPct ?? ${JSON.stringify(defaultClipPct)};
|
|
445
|
+
// Only the clipPct===0 branch value is ever read (recalcWeights reads
|
|
446
|
+
// currentAmaClipThreshold solely when clipping is disabled; otherwise
|
|
447
|
+
// it uses the canonical dynamicClipThreshold from computeAmaSlopeClipThreshold).
|
|
440
448
|
const maxAmaSlope = data.amaPercentiles[data.amaPercentiles.length - 1];
|
|
441
|
-
let currentAmaClipThreshold = currentClipPct === 0 ? maxAmaSlope :
|
|
449
|
+
let currentAmaClipThreshold = currentClipPct === 0 ? maxAmaSlope : Infinity;
|
|
442
450
|
let currentKalClipThreshold = currentClipPct === 0 ? Infinity : data.kalPercentiles[100 - currentClipPct];
|
|
443
451
|
|
|
444
452
|
// Regime table and axis nodes from payload — sourced from MARKET_ADAPTER in constants.ts
|
|
@@ -589,22 +597,11 @@ function generateHTML(data: any, title = 'Dynamic Weight Research') {
|
|
|
589
597
|
const amaErWarmup = Math.max(0, Number.isFinite(data.amaErPeriod) ? Math.ceil(data.amaErPeriod) : ${JSON.stringify(MARKET_ADAPTER.AMAS[MARKET_ADAPTER.DEFAULT_AMA_KEY as keyof typeof MARKET_ADAPTER.AMAS].erPeriod)});
|
|
590
598
|
const amaReadyBar = Math.max(lb, amaErWarmup + lb);
|
|
591
599
|
|
|
592
|
-
// Recompute clip threshold based on current lookback
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
// Keep every finite slope (zeros included) — matches the live
|
|
598
|
-
// market adapter service clip pool exactly.
|
|
599
|
-
const s = computeAverageAmaSlopePct(data.ama3Prices[i], data.ama3Prices[i - lb], lb);
|
|
600
|
-
if (Number.isFinite(s)) slopes.push(Math.abs(s));
|
|
601
|
-
}
|
|
602
|
-
if (slopes.length > 0) {
|
|
603
|
-
slopes.sort((a, b) => a - b);
|
|
604
|
-
const idx = Math.min(Math.floor((100 - currentClipPct) / 100 * slopes.length), slopes.length - 1);
|
|
605
|
-
dynamicClipThreshold = slopes[idx];
|
|
606
|
-
}
|
|
607
|
-
}
|
|
600
|
+
// Recompute clip threshold based on current lookback — canonical
|
|
601
|
+
// implementation (computeAmaSlopeClipThreshold injected above),
|
|
602
|
+
// shared with the live market adapter service. Trailing padded
|
|
603
|
+
// nulls beyond realBarCount are skipped by its finiteness guards.
|
|
604
|
+
dynamicClipThreshold = computeAmaSlopeClipThreshold(data.ama3Prices, amaErWarmup, lb, currentClipPct);
|
|
608
605
|
|
|
609
606
|
for (let i = 0; i < data.realBarCount; i++) {
|
|
610
607
|
// AMA raw slope % for the display panel (offsets computed in recalcWeights)
|
|
@@ -790,7 +787,7 @@ function generateHTML(data: any, title = 'Dynamic Weight Research') {
|
|
|
790
787
|
const cRaw = combinedOff[idx];
|
|
791
788
|
const cRawEl = document.getElementById('l-combined-raw');
|
|
792
789
|
if (cRaw == null) { cRawEl.textContent = '-'; cRawEl.style.color = '#8b949e'; }
|
|
793
|
-
else { cRawEl.textContent = (cRaw >= 0 ? '+' : '') + cRaw.toFixed(3); cRawEl.style.color =
|
|
790
|
+
else { cRawEl.textContent = (cRaw >= 0 ? '+' : '') + cRaw.toFixed(3); cRawEl.style.color = '#8b949e'; }
|
|
794
791
|
|
|
795
792
|
const cEcho = echoCombinedOff[idx];
|
|
796
793
|
const cEchoEl = document.getElementById('l-combined-echo');
|
|
@@ -1018,7 +1015,7 @@ function generateHTML(data: any, title = 'Dynamic Weight Research') {
|
|
|
1018
1015
|
],
|
|
1019
1016
|
axes: [
|
|
1020
1017
|
makeTimeAxis(false),
|
|
1021
|
-
{ scale: 'p', stroke: '#ffffff', grid: { stroke: '#1c2128', dash: [4, 4] }, ticks: { stroke: '#
|
|
1018
|
+
{ scale: 'p', stroke: '#ffffff', grid: { stroke: '#1c2128', dash: [4, 4] }, ticks: { stroke: '#30363d', width: 1 }, size: Y_AXIS_SIZE, font: '11px Segoe UI, sans-serif',
|
|
1022
1019
|
values: (u, v) => v.map(x => x != null ? (x >= 0 ? '+' : '') + (x * 10).toFixed(2) + '‰' : '') }
|
|
1023
1020
|
],
|
|
1024
1021
|
cursor: cursorCfg,
|
|
@@ -1036,7 +1033,7 @@ function generateHTML(data: any, title = 'Dynamic Weight Research') {
|
|
|
1036
1033
|
],
|
|
1037
1034
|
axes: [
|
|
1038
1035
|
makeTimeAxis(false),
|
|
1039
|
-
{ scale: 'v', stroke: '#ffffff', grid: { stroke: '#1c2128', dash: [4, 4] }, ticks: { stroke: '#
|
|
1036
|
+
{ scale: 'v', stroke: '#ffffff', grid: { stroke: '#1c2128', dash: [4, 4] }, ticks: { stroke: '#30363d', width: 1 }, size: Y_AXIS_SIZE, font: '11px Segoe UI, sans-serif',
|
|
1040
1037
|
values: (u, v) => v.map(x => x != null ? (x >= 0 ? '+' : '') + x.toFixed(1) + '%' : '') }
|
|
1041
1038
|
],
|
|
1042
1039
|
cursor: cursorCfg,
|
|
@@ -1061,7 +1058,7 @@ function generateHTML(data: any, title = 'Dynamic Weight Research') {
|
|
|
1061
1058
|
],
|
|
1062
1059
|
axes: [
|
|
1063
1060
|
makeTimeAxis(true),
|
|
1064
|
-
{ scale: 'ow', stroke: '#ffffff', grid: { stroke: '#1c2128', dash: [4, 4] }, ticks: { stroke: '#
|
|
1061
|
+
{ scale: 'ow', stroke: '#ffffff', grid: { stroke: '#1c2128', dash: [4, 4] }, ticks: { stroke: '#30363d', width: 1 }, size: Y_AXIS_SIZE, font: '11px Segoe UI, sans-serif',
|
|
1065
1062
|
values: (u, v) => v.map(x => x != null ? (x >= 0 ? '+' : '') + x.toFixed(2) : ''),
|
|
1066
1063
|
splits: () => { const m = Math.max(0.5, currentOutputAxisMax || 0.5); return [-m, -m/2, 0, m/2, m]; } }
|
|
1067
1064
|
],
|
|
@@ -1163,7 +1160,9 @@ function generateHTML(data: any, title = 'Dynamic Weight Research') {
|
|
|
1163
1160
|
currentAmaClipThreshold = data.amaPercentiles[data.amaPercentiles.length - 1];
|
|
1164
1161
|
currentKalClipThreshold = Infinity;
|
|
1165
1162
|
} else {
|
|
1166
|
-
|
|
1163
|
+
// AMA clip threshold for clipPct>0 comes from the canonical
|
|
1164
|
+
// computeAmaSlopeClipThreshold inside recalcInputs() —
|
|
1165
|
+
// no percentile-table store needed here.
|
|
1167
1166
|
recalcKalmanClipThreshold();
|
|
1168
1167
|
}
|
|
1169
1168
|
document.getElementById('clip-value').textContent = currentClipPct + '%';
|
|
@@ -1260,7 +1259,6 @@ function applyParams(p, btn) {
|
|
|
1260
1259
|
currentAmaClipThreshold = data.amaPercentiles[data.amaPercentiles.length - 1];
|
|
1261
1260
|
currentKalClipThreshold = Infinity;
|
|
1262
1261
|
} else {
|
|
1263
|
-
currentAmaClipThreshold = data.amaPercentiles[100 - currentClipPct];
|
|
1264
1262
|
recalcKalmanClipThreshold();
|
|
1265
1263
|
}
|
|
1266
1264
|
}
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* Re-export shim — canonical implementation lives in
|
|
5
5
|
* market_adapter/core/signals/hurst_analyzer.ts.
|
|
6
6
|
*/
|
|
7
|
-
export { HurstAnalyzer } from '../../market_adapter/core/signals/hurst_analyzer.js';
|
|
7
|
+
export { HurstAnalyzer, classifyHurst } from '../../market_adapter/core/signals/hurst_analyzer.js';
|
|
@@ -1,21 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
1
2
|
|
|
3
|
+
import { MARKET_ADAPTER } from '../../modules/constants.js';
|
|
4
|
+
import { computeDynamicWeightSeries } from '../../market_adapter/core/strategies/dynamic_weight_series.js';
|
|
5
|
+
import { computeAbsolutePercentileThreshold } from '../../market_adapter/core/signals/kalman_velocity_smoothing.js';
|
|
2
6
|
import { escapeHtml, serializeJsonForScript, toEpochSeconds, UPLOT_SHARED_SCRIPT } from '../chart_utils.js';
|
|
3
7
|
import { sharedChartCSS } from '../chart_css.js';
|
|
4
8
|
import { Y_AXIS_SIZE, makeCursorConfig, bindHoverStateFn, wireChartEvents, zoomResetScript, sizeChartsFn } from '../chart_ui.js';
|
|
5
|
-
'use strict';
|
|
6
9
|
|
|
7
10
|
|
|
8
|
-
const NEUTRAL_ZONE_PCT = 0.15;
|
|
9
|
-
const MAX_SLOPE_PCT = 3.0;
|
|
10
|
-
const MAX_SLOPE_OFFSET = 0.5;
|
|
11
|
-
|
|
12
|
-
function computeKalmanWeightOffset(velocityPct: any, isReady: any) {
|
|
13
|
-
if (!isReady || velocityPct == null) return 0;
|
|
14
|
-
if (Math.abs(velocityPct) < NEUTRAL_ZONE_PCT) return 0;
|
|
15
|
-
return Math.max(-MAX_SLOPE_OFFSET, Math.min(MAX_SLOPE_OFFSET,
|
|
16
|
-
(velocityPct / MAX_SLOPE_PCT) * MAX_SLOPE_OFFSET));
|
|
17
|
-
}
|
|
18
|
-
|
|
19
11
|
function generateHTML(data: any, title = 'Kalman Trajectory Analysis') {
|
|
20
12
|
const results = data.allResults || [];
|
|
21
13
|
if (results.length === 0) throw new Error('No analysis results in input');
|
|
@@ -31,7 +23,43 @@ function generateHTML(data: any, title = 'Kalman Trajectory Analysis') {
|
|
|
31
23
|
const trendUp = results.map((r: any) =>
|
|
32
24
|
r.kalmanPrice != null && r.modalPrice != null ? r.kalmanPrice > r.modalPrice : null
|
|
33
25
|
);
|
|
34
|
-
|
|
26
|
+
|
|
27
|
+
// Kalman weight channel — canonical implementation shared with the live
|
|
28
|
+
// market adapter (computeDynamicWeightSeries), including the percentile
|
|
29
|
+
// clip threshold and the displacement-confidence/momentum-alignment
|
|
30
|
+
// composite the previous hand-rolled copy omitted.
|
|
31
|
+
const amaLb = MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_LOOKBACK_BARS;
|
|
32
|
+
const defaultAmaKey = MARKET_ADAPTER.DEFAULT_AMA_KEY as keyof typeof MARKET_ADAPTER.AMAS;
|
|
33
|
+
const amaErPeriod = data.amaConfig?.erPeriod ?? MARKET_ADAPTER.AMAS[defaultAmaKey].erPeriod;
|
|
34
|
+
const clipPct = data.clipPct ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_CLIP_PERCENTILE;
|
|
35
|
+
const velocityPct = results.map((r: any) => r.velocityFilteredPct ?? r.velocityPct ?? null);
|
|
36
|
+
const displacementPct = results.map((r: any) => r.displacementRawPct ?? r.displacementPct ?? null);
|
|
37
|
+
const isReady = results.map((r: any) => !!r.isReady);
|
|
38
|
+
const kalClipThreshold = clipPct > 0
|
|
39
|
+
? computeAbsolutePercentileThreshold(velocityPct, clipPct, Infinity)
|
|
40
|
+
: Infinity;
|
|
41
|
+
const dwSeries = computeDynamicWeightSeries({
|
|
42
|
+
amaValues: prices, // AMA channel unused here; length driver only
|
|
43
|
+
kalmanVelocityPct: velocityPct,
|
|
44
|
+
kalmanDisplacementPct: displacementPct,
|
|
45
|
+
kalmanIsReady: isReady,
|
|
46
|
+
regimeMultipliers: undefined,
|
|
47
|
+
lookbackBars: amaLb,
|
|
48
|
+
amaErPeriod,
|
|
49
|
+
amaClipThreshold: Infinity,
|
|
50
|
+
kalClipThreshold,
|
|
51
|
+
neutralZonePct: MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_NEUTRAL_ZONE_PCT,
|
|
52
|
+
amaMaxSlopePct: MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_MAX_SLOPE_PCT,
|
|
53
|
+
kalmanMaxSlopePct: MARKET_ADAPTER.DYNAMIC_WEIGHT_KALMAN_MAX_SLOPE_PCT,
|
|
54
|
+
offsetClamp: MARKET_ADAPTER.DYNAMIC_WEIGHT_ASYMMETRIC_OFFSET_CLAMP,
|
|
55
|
+
dispScaleMinPct: MARKET_ADAPTER.DYNAMIC_WEIGHT_DISP_SCALE_MIN_PCT,
|
|
56
|
+
alpha: MARKET_ADAPTER.DYNAMIC_WEIGHT_ALPHA,
|
|
57
|
+
dw: MARKET_ADAPTER.DYNAMIC_WEIGHT_DW,
|
|
58
|
+
gain: MARKET_ADAPTER.DYNAMIC_WEIGHT_GAIN,
|
|
59
|
+
minOutputThreshold: MARKET_ADAPTER.DYNAMIC_WEIGHT_ASYMMETRIC_TREND_THRESHOLD,
|
|
60
|
+
signalConfirmBars: MARKET_ADAPTER.DYNAMIC_WEIGHT_SIGNAL_CONFIRM_BARS_DEFAULT,
|
|
61
|
+
});
|
|
62
|
+
const kalmanWeights = dwSeries.kalmanOffsets;
|
|
35
63
|
const amaWeights = results.map((r: any) => r.amaWeightOffset ?? null);
|
|
36
64
|
|
|
37
65
|
// Future Projection (150 bars)
|
|
@@ -101,7 +129,7 @@ function generateHTML(data: any, title = 'Kalman Trajectory Analysis') {
|
|
|
101
129
|
<div id="ama-panel">
|
|
102
130
|
<div class="legend">
|
|
103
131
|
<div class="legend-item"><div class="dot" style="background:linear-gradient(to bottom,#f0a000,#4a90d9);"></div>AMA Weight: <span id="l-ama-w" style="font-weight:bold;">-</span></div>
|
|
104
|
-
<span style="color:#8b949e;font-size:10px;">lookback
|
|
132
|
+
<span style="color:#8b949e;font-size:10px;">lookback ${amaLb} bars · er${escapeHtml(String(data.amaConfig?.erPeriod ?? amaErPeriod))}/${escapeHtml(String(data.amaConfig?.fastPeriod ?? MARKET_ADAPTER.AMAS[defaultAmaKey].fastPeriod))}/${escapeHtml(String(data.amaConfig?.slowPeriod ?? MARKET_ADAPTER.AMAS[defaultAmaKey].slowPeriod))}</span>
|
|
105
133
|
</div>
|
|
106
134
|
<div id="ama-chart"></div>
|
|
107
135
|
</div>
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
1
2
|
|
|
3
|
+
import { MARKET_ADAPTER } from '../../modules/constants.js';
|
|
2
4
|
import { escapeHtml, serializeJsonForScript, toEpochSeconds, UPLOT_SHARED_SCRIPT } from '../chart_utils.js';
|
|
3
5
|
import { sharedChartCSS } from '../chart_css.js';
|
|
4
6
|
import { Y_AXIS_SIZE, makeCursorConfig, bindHoverStateFn, wireChartEvents, zoomResetScript, sizeChartsFn, fmtDateFn } from '../chart_ui.js';
|
|
5
|
-
|
|
7
|
+
|
|
8
|
+
// Zone boundaries sourced from MARKET_ADAPTER (single source of truth shared
|
|
9
|
+
// with the live adapter) instead of hardcoded copies. Hurst classification
|
|
10
|
+
// uses inclusive >=/<= bounds matching market_adapter/core/signals/hurst_analyzer.ts.
|
|
11
|
+
const HURST_WINDOW_DEFAULT = MARKET_ADAPTER.HURST_CONFIG.window;
|
|
12
|
+
const HURST_SCALES_DEFAULT = MARKET_ADAPTER.HURST_CONFIG.scales;
|
|
13
|
+
const PE_M_DEFAULT = MARKET_ADAPTER.PE_CONFIG.m;
|
|
14
|
+
const PE_WINDOW_DEFAULT = MARKET_ADAPTER.PE_CONFIG.window;
|
|
15
|
+
const H_UPPER = 0.5 + MARKET_ADAPTER.HURST_ZONE_BAND;
|
|
16
|
+
const H_LOWER = 0.5 - MARKET_ADAPTER.HURST_ZONE_BAND;
|
|
17
|
+
const PE_STRUCTURED = MARKET_ADAPTER.PE_NODES[0];
|
|
18
|
+
const PE_NOISE = MARKET_ADAPTER.PE_NODES[MARKET_ADAPTER.PE_NODES.length - 1];
|
|
6
19
|
|
|
7
20
|
|
|
8
21
|
/**
|
|
@@ -61,16 +74,16 @@ function generateRegimeHTML(data: any, title = 'Regime Analysis') {
|
|
|
61
74
|
}
|
|
62
75
|
|
|
63
76
|
// Background shading segments (server-side, passed to browser via JSON payload)
|
|
64
|
-
const hurstSegments = buildSegments(hurstArr.slice(0, realBarCount), (v: any) => v
|
|
65
|
-
const peSegments = buildSegments(peArr.slice(0, realBarCount), (v: any) => v <
|
|
77
|
+
const hurstSegments = buildSegments(hurstArr.slice(0, realBarCount), (v: any) => v >= H_UPPER, (v: any) => v <= H_LOWER);
|
|
78
|
+
const peSegments = buildSegments(peArr.slice(0, realBarCount), (v: any) => v < PE_STRUCTURED, (v: any) => v > PE_NOISE);
|
|
66
79
|
|
|
67
80
|
const payload = {
|
|
68
81
|
dates, prices, ama3Prices, hurstArr, peArr,
|
|
69
82
|
hurstSegments, peSegments,
|
|
70
83
|
realBarCount,
|
|
71
|
-
hurstWindow: hurstConfig.window ??
|
|
72
|
-
peM: peConfig.m ??
|
|
73
|
-
peWindow: peConfig.window ??
|
|
84
|
+
hurstWindow: hurstConfig.window ?? HURST_WINDOW_DEFAULT,
|
|
85
|
+
peM: peConfig.m ?? PE_M_DEFAULT,
|
|
86
|
+
peWindow: peConfig.window ?? PE_WINDOW_DEFAULT,
|
|
74
87
|
};
|
|
75
88
|
|
|
76
89
|
return `<!DOCTYPE html>
|
|
@@ -96,12 +109,12 @@ function generateRegimeHTML(data: any, title = 'Regime Analysis') {
|
|
|
96
109
|
<div style="font-weight:bold;color:#fff;">${escapeHtml(title)}</div>
|
|
97
110
|
<div style="display:flex;align-items:center;gap:16px;">
|
|
98
111
|
<span style="font-size:10px;color:#8b949e;font-family:monospace;">
|
|
99
|
-
Hurst: window=${escapeHtml(String(hurstConfig.window ??
|
|
112
|
+
Hurst: window=${escapeHtml(String(hurstConfig.window ?? HURST_WINDOW_DEFAULT))} bars · scales=[${escapeHtml((hurstConfig.scales ?? HURST_SCALES_DEFAULT).join(','))}]
|
|
100
113
|
|
|
|
101
|
-
PE: m=${escapeHtml(String(peConfig.m ??
|
|
114
|
+
PE: m=${escapeHtml(String(peConfig.m ?? PE_M_DEFAULT))} · window=${escapeHtml(String(peConfig.window ?? PE_WINDOW_DEFAULT))} bars
|
|
102
115
|
</span>
|
|
103
116
|
<span style="font-size:11px;color:#adbac7;text-transform:uppercase;">
|
|
104
|
-
H&
|
|
117
|
+
H≥${H_UPPER.toFixed(2)}=trend · H≤${H_LOWER.toFixed(2)}=revert · PE<${PE_STRUCTURED.toFixed(2)}=structured · PE>${PE_NOISE.toFixed(2)}=noise
|
|
105
118
|
| Scroll · Drag · Ctrl+0
|
|
106
119
|
</span>
|
|
107
120
|
</div>
|
|
@@ -122,7 +135,7 @@ function generateRegimeHTML(data: any, title = 'Regime Analysis') {
|
|
|
122
135
|
<div class="legend">
|
|
123
136
|
<div class="legend-item"><div class="dot" style="background:#4dc3ff;"></div>H: <span id="l-hurst" style="font-weight:bold;color:#4dc3ff;">-</span></div>
|
|
124
137
|
<div class="legend-item">Regime: <span id="l-hurst-regime" style="font-weight:bold;">-</span></div>
|
|
125
|
-
<div class="legend-item" style="color:#555;font-size:10px;">window=${escapeHtml(String(hurstConfig.window ??
|
|
138
|
+
<div class="legend-item" style="color:#555;font-size:10px;">window=${escapeHtml(String(hurstConfig.window ?? HURST_WINDOW_DEFAULT))} bars</div>
|
|
126
139
|
</div>
|
|
127
140
|
<div id="hurst-chart"></div>
|
|
128
141
|
</div>
|
|
@@ -131,7 +144,7 @@ function generateRegimeHTML(data: any, title = 'Regime Analysis') {
|
|
|
131
144
|
<div class="legend">
|
|
132
145
|
<div class="legend-item"><div class="dot" style="background:#d2a8ff;"></div>PE: <span id="l-pe" style="font-weight:bold;color:#d2a8ff;">-</span></div>
|
|
133
146
|
<div class="legend-item">Regime: <span id="l-pe-regime" style="font-weight:bold;">-</span></div>
|
|
134
|
-
<div class="legend-item" style="color:#555;font-size:10px;">m=${escapeHtml(String(peConfig.m ??
|
|
147
|
+
<div class="legend-item" style="color:#555;font-size:10px;">m=${escapeHtml(String(peConfig.m ?? PE_M_DEFAULT))}, window=${escapeHtml(String(peConfig.window ?? PE_WINDOW_DEFAULT))} bars</div>
|
|
135
148
|
</div>
|
|
136
149
|
<div id="pe-chart"></div>
|
|
137
150
|
</div>
|
|
@@ -156,16 +169,23 @@ function generateRegimeHTML(data: any, title = 'Regime Analysis') {
|
|
|
156
169
|
${fmtDateFn()}
|
|
157
170
|
${bindHoverStateFn()}
|
|
158
171
|
|
|
172
|
+
// Inclusive zone boundaries — same semantics as the live classifier
|
|
173
|
+
// (market_adapter/core/signals/hurst_analyzer.ts classifyHurst).
|
|
174
|
+
const H_UPPER = ${JSON.stringify(H_UPPER)};
|
|
175
|
+
const H_LOWER = ${JSON.stringify(H_LOWER)};
|
|
176
|
+
const PE_STRUCTURED = ${JSON.stringify(PE_STRUCTURED)};
|
|
177
|
+
const PE_NOISE = ${JSON.stringify(PE_NOISE)};
|
|
178
|
+
|
|
159
179
|
function hurstRegimeLabel(v) {
|
|
160
180
|
if (v == null) return '<span class="badge badge-grey">-</span>';
|
|
161
|
-
if (v
|
|
162
|
-
if (v
|
|
181
|
+
if (v >= H_UPPER) return '<span class="badge badge-green">TRENDING</span>';
|
|
182
|
+
if (v <= H_LOWER) return '<span class="badge badge-red">MEAN REV</span>';
|
|
163
183
|
return '<span class="badge badge-grey">RANDOM</span>';
|
|
164
184
|
}
|
|
165
185
|
function peRegimeLabel(v) {
|
|
166
186
|
if (v == null) return '<span class="badge badge-grey">-</span>';
|
|
167
|
-
if (v <
|
|
168
|
-
if (v >
|
|
187
|
+
if (v < PE_STRUCTURED) return '<span class="badge badge-green">STRUCTURED</span>';
|
|
188
|
+
if (v > PE_NOISE) return '<span class="badge badge-red">NOISE</span>';
|
|
169
189
|
return '<span class="badge badge-grey">MIXED</span>';
|
|
170
190
|
}
|
|
171
191
|
|
|
@@ -218,13 +238,13 @@ function generateRegimeHTML(data: any, title = 'Regime Analysis') {
|
|
|
218
238
|
// ── chart instances ──────────────────────────────────────────────────
|
|
219
239
|
|
|
220
240
|
const hurstRefLines = [
|
|
221
|
-
{ y:
|
|
241
|
+
{ y: H_UPPER, color: 'rgba(46,160,67,0.5)' },
|
|
222
242
|
{ y: 0.50, color: 'rgba(110,118,129,0.3)' },
|
|
223
|
-
{ y:
|
|
243
|
+
{ y: H_LOWER, color: 'rgba(248,81,73,0.5)' },
|
|
224
244
|
];
|
|
225
245
|
const peRefLines = [
|
|
226
|
-
{ y:
|
|
227
|
-
{ y:
|
|
246
|
+
{ y: PE_NOISE, color: 'rgba(248,81,73,0.5)' },
|
|
247
|
+
{ y: PE_STRUCTURED, color: 'rgba(46,160,67,0.5)' },
|
|
228
248
|
];
|
|
229
249
|
|
|
230
250
|
const hurstBgFn = makeBgHook(data.hurstSegments, hurstRefLines, 'h');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
'use strict';
|
|
1
2
|
|
|
2
3
|
import { MARKET_ADAPTER } from '../../modules/constants.js';
|
|
3
4
|
import { computeATRSeries } from '../../market_adapter/core/strategies/atr/calculator.js';
|
|
@@ -5,7 +6,6 @@ import { computeVolatilityShift } from '../../market_adapter/core/strategies/vol
|
|
|
5
6
|
import { embedFunctionSources, escapeHtml, serializeJsonForScript, toEpochSeconds, UPLOT_SHARED_SCRIPT } from '../chart_utils.js';
|
|
6
7
|
import { sharedChartCSS } from '../chart_css.js';
|
|
7
8
|
import { Y_AXIS_SIZE, makeCursorConfig, bindHoverStateFn, wireChartEvents, zoomResetScript, sizeChartsFn } from '../chart_ui.js';
|
|
8
|
-
'use strict';
|
|
9
9
|
|
|
10
10
|
const EMBEDDED_SHARED_FUNCS = embedFunctionSources([computeATRSeries, computeVolatilityShift]);
|
|
11
11
|
|
package/claw/index.ts
CHANGED
|
@@ -4,7 +4,7 @@ const require = createRequire(import.meta.url);
|
|
|
4
4
|
|
|
5
5
|
import { createClawInfrastructure } from './claw_infra.js';
|
|
6
6
|
import { describeClawBridge } from './claw_manifest.js';
|
|
7
|
-
import { runMemuCommand } from './memu_bridge.js';
|
|
7
|
+
import { describeMemuBridge, runMemuCommand } from './memu_bridge.js';
|
|
8
8
|
import { clone } from './utils.js';
|
|
9
9
|
import { adjustMpaCollateral, borrowMpa, cancelLimitOrder, createLimitOrder, executeBatch, getMpaPosition, getOpenOrders, repayMpaDebt, buildUpdateLimitOrderOperation, updateLimitOrder, settleMpa } from './chain_actions.js';
|
|
10
10
|
import { buildCloseShortPlan, buildOpenShortPlan, buildTakeProfitPlan, closeShortOnBts, openShortOnBts, placeTakeProfitBuyOrderOnBts } from './short_mpa_strategy.js';
|
|
@@ -126,7 +126,7 @@ function describeRuntimeManifest(options: ClawBridgeOptions = {}): any {
|
|
|
126
126
|
function describeCommandManifest(options: ClawBridgeOptions = {}): any {
|
|
127
127
|
const runtimeName = options.runtimeName || options.runtime?.name || null;
|
|
128
128
|
if (runtimeName && String(runtimeName).trim().toLowerCase() === 'memu') {
|
|
129
|
-
return
|
|
129
|
+
return describeMemuBridge(options);
|
|
130
130
|
}
|
|
131
131
|
return describeClawBridge(options);
|
|
132
132
|
}
|
|
@@ -373,7 +373,7 @@ async function runClawCommand(command: string, options: ClawBridgeOptions = {}):
|
|
|
373
373
|
return launcherPm2Restart(safeOptions.botName || 'all', safeOptions);
|
|
374
374
|
|
|
375
375
|
case 'memu-manifest':
|
|
376
|
-
return
|
|
376
|
+
return describeMemuBridge(safeOptions);
|
|
377
377
|
|
|
378
378
|
case 'memu-memorize':
|
|
379
379
|
case 'memu-retrieve':
|
|
@@ -809,7 +809,7 @@ function getClawToolCatalog() {
|
|
|
809
809
|
return CLAW_TOOL_CATALOG.map(cloneTool);
|
|
810
810
|
}
|
|
811
811
|
|
|
812
|
-
function buildClawCommandExamples(scriptPath = '
|
|
812
|
+
function buildClawCommandExamples(scriptPath = 'node dist/claw/scripts/claw_bridge.js') {
|
|
813
813
|
return CLAW_TOOL_CATALOG
|
|
814
814
|
.filter((tool) => Array.isArray(tool.exampleArgs))
|
|
815
815
|
.map((tool) => [
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
'use strict';
|
|
1
2
|
|
|
2
3
|
import { createRequire } from 'node:module';
|
|
3
4
|
const require = createRequire(import.meta.url);
|
|
@@ -8,7 +9,6 @@ import { loadSettingsFile, resolveRawBotEntries, saveSettingsFile, normalizeBotE
|
|
|
8
9
|
import { normalizeMode, detectMode, setPreferredMode, describeModeChoice } from './launcher_mode_detector.js';
|
|
9
10
|
import { normalizeRoot, resolveRuntimeScript, normalizeProfileDir } from './launcher_paths.js';
|
|
10
11
|
import { getErrorMessage } from '../../modules/utils/errors.js';
|
|
11
|
-
'use strict';
|
|
12
12
|
|
|
13
13
|
const storage = getStorage();
|
|
14
14
|
|
|
@@ -12,14 +12,11 @@ function normalizeClawRepoRoot(repoRoot: string) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
// Generated docs must reference scripts that actually exist. Claw tooling
|
|
15
|
-
//
|
|
16
|
-
//
|
|
15
|
+
// ships compiled to dist/claw/scripts/ (npm run build); generated skill
|
|
16
|
+
// files always reference the node + .js form so they work without any
|
|
17
|
+
// TypeScript loader installed.
|
|
17
18
|
function resolveScriptInvocation(repoRoot: string, name: string) {
|
|
18
|
-
|
|
19
|
-
if (storage.exists(jsPath)) {
|
|
20
|
-
return { command: 'node', script: jsPath };
|
|
21
|
-
}
|
|
22
|
-
return { command: 'npx tsx', script: path.join(repoRoot, 'claw', 'scripts', `${name}.ts`) };
|
|
19
|
+
return { command: 'node', script: path.join(repoRoot, 'dist', 'claw', 'scripts', `${name}.js`) };
|
|
23
20
|
}
|
|
24
21
|
|
|
25
22
|
function buildBridgeInvocation(repoRoot: string, profileRoot: string, command: string, extraArgs: any[] = []) {
|
|
@@ -49,8 +46,8 @@ function buildToolSummary(runtimeName: string) {
|
|
|
49
46
|
|
|
50
47
|
function buildRuntimeSetup(runtime: any, repoRoot: string, profileRoot: string) {
|
|
51
48
|
const { command, script: mcpScriptPath } = resolveScriptInvocation(repoRoot, 'claw_mcp_server');
|
|
52
|
-
// command is 'node'
|
|
53
|
-
// executable and args correctly for
|
|
49
|
+
// command is 'node'; split so the config blocks can set the
|
|
50
|
+
// executable and args correctly for the built layout.
|
|
54
51
|
const runnerParts = command.split(' ');
|
|
55
52
|
const mcpExec = runnerParts[0];
|
|
56
53
|
const mcpArgs = `[${[...runnerParts.slice(1), mcpScriptPath, '--profile-root', profileRoot].map((part: any) => JSON.stringify(part)).join(', ')}]`;
|
|
@@ -209,7 +206,7 @@ function buildRuntimeSetup(runtime: any, repoRoot: string, profileRoot: string)
|
|
|
209
206
|
'Start the memU MCP server:',
|
|
210
207
|
'',
|
|
211
208
|
'```bash',
|
|
212
|
-
`
|
|
209
|
+
`node ${path.join(repoRoot, 'dist', 'claw', 'scripts', 'memu_mcp_server.js').replace(/\\/g, '/')} --memu-dir ${PATHS.CLAW.MEMU_DIR.replace(/\\/g, '/')}`,
|
|
213
210
|
'```',
|
|
214
211
|
'',
|
|
215
212
|
'Or use the npm script:',
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
'use strict';
|
|
1
2
|
|
|
2
3
|
import { PATHS } from '../../modules/paths.js';
|
|
3
4
|
import CreditRuntime from '../../modules/credit_runtime.js';
|
|
4
5
|
import { getErrorMessage } from '../../modules/utils/errors.js';
|
|
5
|
-
'use strict';
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
function createCreditRuntimeAdapter(infra: any, options: Record<string, any> = {}) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
'use strict';
|
|
1
2
|
/**
|
|
2
3
|
* Decision Loop
|
|
3
4
|
*
|
|
@@ -16,22 +17,17 @@
|
|
|
16
17
|
*/
|
|
17
18
|
|
|
18
19
|
|
|
19
|
-
import { createRequire } from 'node:module';
|
|
20
|
-
const require = createRequire(import.meta.url);
|
|
21
|
-
|
|
22
20
|
import { discoverPositions } from './position_discovery.js';
|
|
23
21
|
import { assessPosition } from './position_health.js';
|
|
24
22
|
import { fetchTrendInput } from './feed_price_source.js';
|
|
25
23
|
import { getErrorMessage } from '../../modules/utils/errors.js';
|
|
26
|
-
|
|
24
|
+
// Static import (previously a lazy createRequire fallback): lazy require()
|
|
25
|
+
// bypasses the ESM loader hooks that compiled tests use for module mocking,
|
|
26
|
+
// and the analyzer module carries no circular-import risk.
|
|
27
|
+
import { KalmanTrendAnalyzer } from '../../market_adapter/core/signals/kalman_trend_analyzer.js';
|
|
27
28
|
|
|
28
29
|
|
|
29
|
-
// Lazy-load KalmanTrendAnalyzer to avoid circular dependency issues at startup
|
|
30
|
-
let KalmanTrendAnalyzer: any = null;
|
|
31
30
|
function getTrendAnalyzer() {
|
|
32
|
-
if (!KalmanTrendAnalyzer) {
|
|
33
|
-
KalmanTrendAnalyzer = require('../../market_adapter/core/signals/kalman_trend_analyzer').KalmanTrendAnalyzer;
|
|
34
|
-
}
|
|
35
31
|
return KalmanTrendAnalyzer;
|
|
36
32
|
}
|
|
37
33
|
|
|
@@ -41,13 +41,13 @@ function getDexbot2Root() {
|
|
|
41
41
|
function resolveDexbot2Path(relativePath: string) {
|
|
42
42
|
const root = getDexbot2Root();
|
|
43
43
|
const normalizedPath = String(relativePath || '');
|
|
44
|
-
const candidates = [path.join(root, normalizedPath)];
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
// Compiled build first: under plain node there is no tsx-style .js→.ts
|
|
46
|
+
// interception, so resolving to the source tree would break require().
|
|
47
|
+
const candidates = [
|
|
48
|
+
path.join(root, BUILD_DIR, normalizedPath),
|
|
49
|
+
path.join(root, normalizedPath),
|
|
50
|
+
];
|
|
51
51
|
|
|
52
52
|
for (const candidate of candidates) {
|
|
53
53
|
if (candidateExists(candidate)) {
|
|
@@ -55,7 +55,7 @@ function resolveDexbot2Path(relativePath: string) {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
return candidates[
|
|
58
|
+
return candidates[0];
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
function requireDexbot2Module(relativePath: string) {
|