dexbot 1.4.20 → 1.4.22
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 +53 -0
- package/README.md +23 -13
- package/analysis/ama_fitting/analyze_ama_price_changes.ts +7 -3
- package/analysis/ama_fitting/analyze_lambda_vs_slow.ts +3 -3
- package/analysis/ama_fitting/calibrate_convergence_er.ts +8 -6
- 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 +22 -13
- 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 +16 -10
- package/analysis/bot_key_utils.ts +14 -11
- package/analysis/bot_usage/discover_bot_accounts.ts +5 -3
- package/analysis/bot_usage/kibana_bot_queries.ts +2 -257
- 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/math_utils.ts +1 -8
- package/analysis/price_sources.ts +8 -2
- package/analysis/resolve_source.ts +1 -1
- package/analysis/results/ama_sweep_results_lp_pool_133_1h.json +2455 -0
- package/analysis/results/bot_fitting_results_lp_pool_133_1h.json +218 -0
- package/analysis/trade_profitability.ts +61 -28
- package/analysis/tradingview/analyze_tradingview.ts +1 -1
- package/analysis/tradingview/h-bts_tradingview.html +1570 -0
- package/analysis/tradingview/t-bts_tradingview.html +1570 -0
- package/analysis/tradingview/tradingview_uplot_chart_generator.ts +302 -74
- 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/ecosystem.config.cjs +2 -3
- package/claw/examples/memu_integration_example.ts +17 -17
- package/claw/index.ts +1 -1
- package/claw/modules/chain_actions.ts +51 -54
- package/claw/modules/chain_broadcast.ts +66 -104
- package/claw/modules/claw_bridge.ts +63 -83
- package/claw/modules/claw_catalog.ts +48 -17
- package/claw/modules/claw_infra.ts +1 -5
- package/claw/modules/claw_launcher.ts +48 -50
- package/claw/modules/claw_skill_md.ts +15 -21
- package/claw/modules/credit_runtime_adapter.ts +3 -19
- package/claw/modules/decision_loop.ts +9 -9
- package/claw/modules/dexbot_bridge.ts +8 -8
- package/claw/modules/dexbot_profiles.ts +5 -21
- package/claw/modules/feed_price_source.ts +1 -1
- package/claw/modules/honest_ecosystem.ts +24 -8
- 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/liquidity_pools.ts +10 -3
- package/claw/modules/mcp_utils.ts +109 -0
- package/claw/modules/memu_bridge.ts +76 -54
- package/claw/modules/mpa_utils.ts +26 -3
- package/claw/modules/position_discovery.ts +17 -28
- package/claw/modules/position_health.ts +1 -1
- package/claw/modules/position_manager.ts +32 -41
- package/claw/modules/position_manager_watch.ts +3 -2
- package/claw/modules/short_mpa_strategy.ts +1 -9
- package/claw/modules/skill_utils.ts +5 -3
- package/claw/modules/utils.ts +9 -1
- package/claw/package.json +3 -3
- package/claw/runtimes/openclaw-plugin/index.ts +27 -10
- package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
- package/claw/runtimes/openclaw-plugin/package.json +1 -1
- package/claw/scripts/claw_bridge.ts +1 -1
- package/claw/scripts/claw_mcp_server.ts +19 -78
- package/claw/scripts/honest_assets_report.ts +19 -84
- package/claw/scripts/memu_mcp_server.ts +57 -155
- package/claw/skills/launcher-ops/references/launcher-workflow.md +2 -2
- package/claw/tests/package.json +1 -1
- package/claw/tests/test_claw_bridge.ts +47 -19
- 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 +3 -3
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js.map +1 -1
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js +8 -6
- 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 +21 -13
- 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 +2 -13
- package/dist/analysis/bot_fitting/shared_utils.d.ts.map +1 -1
- package/dist/analysis/bot_fitting/shared_utils.js +15 -9
- package/dist/analysis/bot_fitting/shared_utils.js.map +1 -1
- package/dist/analysis/bot_key_utils.d.ts +1 -1
- package/dist/analysis/bot_key_utils.d.ts.map +1 -1
- package/dist/analysis/bot_key_utils.js +14 -11
- 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 +1 -337
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +1 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.js +2 -242
- package/dist/analysis/bot_usage/kibana_bot_queries.js.map +1 -1
- package/dist/analysis/chart_css.d.ts +2 -14
- 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/math_utils.d.ts +3 -5
- package/dist/analysis/math_utils.d.ts.map +1 -1
- package/dist/analysis/math_utils.js +3 -5
- package/dist/analysis/math_utils.js.map +1 -1
- package/dist/analysis/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 +302 -74
- 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 +3 -3
- package/dist/bot.js.map +1 -1
- package/dist/credential-daemon.d.ts +1 -1
- package/dist/credential-daemon.js +2 -2
- package/dist/credential-daemon.js.map +1 -1
- package/dist/dexbot.d.ts.map +1 -1
- package/dist/dexbot.js +25 -22
- package/dist/dexbot.js.map +1 -1
- package/dist/market_adapter/ama_signal_runner.js +6 -4
- 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 +1 -17
- package/dist/market_adapter/core/kibana_client.d.ts.map +1 -1
- package/dist/market_adapter/core/kibana_client.js +40 -7
- 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 +22 -13
- package/dist/market_adapter/core/market_adapter_service.d.ts.map +1 -1
- package/dist/market_adapter/core/market_adapter_service.js +96 -38
- 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 +1 -2
- package/dist/market_adapter/core/strategies/regime_gate.d.ts.map +1 -1
- package/dist/market_adapter/core/strategies/regime_gate.js +27 -21
- 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 +71 -57
- 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 +72 -19
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -1
- package/dist/market_adapter/inputs/kibana_source.d.ts +5 -30
- package/dist/market_adapter/inputs/kibana_source.d.ts.map +1 -1
- package/dist/market_adapter/inputs/kibana_source.js +6 -3
- 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.d.ts +1 -2
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts.map +1 -1
- package/dist/market_adapter/lp_chart_strategy_loader.js +5 -5
- 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 +5 -7
- 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 +3 -0
- package/dist/modules/account_bots.d.ts.map +1 -1
- package/dist/modules/account_bots.js +157 -47
- package/dist/modules/account_bots.js.map +1 -1
- package/dist/modules/account_orders.d.ts +1 -7
- package/dist/modules/account_orders.d.ts.map +1 -1
- package/dist/modules/account_orders.js +9 -17
- package/dist/modules/account_orders.js.map +1 -1
- package/dist/modules/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.d.ts +2 -14
- package/dist/modules/bitshares_client.d.ts.map +1 -1
- package/dist/modules/bitshares_client.js +32 -41
- 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 +12 -19
- 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_keys.js +2 -2
- package/dist/modules/chain_keys.js.map +1 -1
- package/dist/modules/chain_orders.d.ts +2 -3
- package/dist/modules/chain_orders.d.ts.map +1 -1
- package/dist/modules/chain_orders.js +23 -42
- package/dist/modules/chain_orders.js.map +1 -1
- package/dist/modules/config.d.ts.map +1 -1
- package/dist/modules/config.js +5 -2
- package/dist/modules/config.js.map +1 -1
- package/dist/modules/constants.d.ts +21 -21
- package/dist/modules/constants.d.ts.map +1 -1
- package/dist/modules/constants.js +53 -60
- 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 +18 -3
- 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 +39 -199
- 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 +11 -7
- 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 +24 -6
- 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 +15 -26
- 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 +7 -13
- package/dist/modules/launcher/foreign_cred_daemon.js.map +1 -1
- package/dist/modules/launcher/market_adapter_runtime.d.ts +3 -4
- package/dist/modules/launcher/market_adapter_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/market_adapter_runtime.js +10 -29
- 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 +4 -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.d.ts +1 -2
- package/dist/modules/launcher/status_reporting.d.ts.map +1 -1
- package/dist/modules/launcher/status_reporting.js +2 -5
- 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 +3 -3
- 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 -8
- package/dist/modules/order/format.d.ts.map +1 -1
- package/dist/modules/order/format.js +0 -14
- 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 +23 -24
- 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 +23 -14
- package/dist/modules/order/logger.js.map +1 -1
- package/dist/modules/order/logger_state.d.ts +5 -22
- package/dist/modules/order/logger_state.d.ts.map +1 -1
- package/dist/modules/order/logger_state.js +6 -25
- 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 +0 -5
- package/dist/modules/order/processed_fill_store.d.ts.map +1 -1
- package/dist/modules/order/processed_fill_store.js +10 -15
- 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.d.ts.map +1 -1
- package/dist/modules/order/sync_engine.js +17 -10
- package/dist/modules/order/sync_engine.js.map +1 -1
- package/dist/modules/order/utils/math.d.ts +7 -1
- package/dist/modules/order/utils/math.d.ts.map +1 -1
- package/dist/modules/order/utils/math.js +19 -1
- 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 +11 -4
- 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 +4 -2
- 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 +17 -4
- 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 +8 -3
- package/dist/modules/storage/browser_adapter.d.ts.map +1 -1
- package/dist/modules/storage/browser_adapter.js +58 -7
- 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/utils/sanitize_key.d.ts +7 -0
- package/dist/modules/utils/sanitize_key.d.ts.map +1 -0
- package/dist/modules/utils/sanitize_key.js +15 -0
- package/dist/modules/utils/sanitize_key.js.map +1 -0
- package/dist/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 +8 -9
- 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 +2 -2
- package/dist/scripts/analyze-orders.d.ts.map +1 -1
- package/dist/scripts/analyze-orders.js +39 -28
- 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 +4 -6
- package/dist/scripts/runner.js.map +1 -1
- package/dist/scripts/sync-version.d.ts +2 -2
- package/dist/scripts/sync-version.js +2 -2
- package/dist/scripts/update.d.ts +1 -1
- package/dist/scripts/update.js +2 -2
- package/dist/scripts/update.js.map +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 +63 -18
- package/docs/COPY_ON_WRITE_MASTER_PLAN.md +14 -23
- package/docs/COW_INVARIANTS.md +4 -4
- package/docs/CREDENTIAL_SECURITY.md +0 -11
- package/docs/DEXBOT_COMPARISON.md +12 -12
- package/docs/EVOLUTION.md +17 -43
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +27 -83
- package/docs/GRID_RECALCULATION.md +1 -13
- package/docs/GRID_RECONCILE.md +24 -24
- package/docs/LIFECYCLE.md +4 -4
- package/docs/LOGGING.md +1 -1
- package/docs/MPA_CREDIT_USAGE.md +3 -3
- package/docs/README.md +2 -2
- package/docs/WORKFLOW.md +2 -2
- package/docs/architecture.md +48 -43
- package/docs/developer_guide.md +22 -24
- package/market_adapter/README.md +0 -2
- package/modules/README.md +2 -1
- package/package.json +22 -14
- package/scripts/README.md +34 -8
- package/scripts/clean-dist.js +10 -2
- package/tests/README.md +4 -3
- package/claw/openclaw.plugin.json +0 -13
- package/dist/market_adapter/merge_lp_data.d.ts +0 -3
- package/dist/market_adapter/merge_lp_data.d.ts.map +0 -1
- package/dist/market_adapter/merge_lp_data.js +0 -125
- package/dist/market_adapter/merge_lp_data.js.map +0 -1
- package/dist/market_adapter/utils/paths.d.ts +0 -3
- package/dist/market_adapter/utils/paths.d.ts.map +0 -1
- package/dist/market_adapter/utils/paths.js +0 -5
- package/dist/market_adapter/utils/paths.js.map +0 -1
|
@@ -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
|
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
const path = require('node:path');
|
|
4
4
|
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
// layout so `pm2 start ecosystem.config.cjs` works from the claw/ package root.
|
|
5
|
+
// This ecosystem config anchors all paths to the dist/claw build output so
|
|
6
|
+
// `pm2 start ecosystem.config.cjs` works from the claw/ package root.
|
|
8
7
|
const DIST_CLAW = path.join(__dirname, '..', 'dist', 'claw');
|
|
9
8
|
|
|
10
9
|
module.exports = {
|
|
@@ -6,26 +6,26 @@ const { createMemuBridge } = require('../modules/memu_bridge');
|
|
|
6
6
|
async function main() {
|
|
7
7
|
console.log('=== memU + DEXBot2 Integration Example ===\n');
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
try {
|
|
10
|
+
const memu = createMemuBridge({
|
|
11
|
+
memuDir: process.env.MEMU_DIR || undefined,
|
|
12
|
+
llmProfiles: process.env.OPENAI_API_KEY
|
|
13
|
+
? {
|
|
14
|
+
default: {
|
|
15
|
+
base_url: process.env.OPENAI_BASE_URL || 'https://api.openai.com/v1',
|
|
16
|
+
api_key: process.env.OPENAI_API_KEY,
|
|
17
|
+
chat_model: process.env.OPENAI_CHAT_MODEL || 'gpt-4o',
|
|
18
|
+
embed_model: process.env.OPENAI_EMBED_MODEL || 'text-embedding-3-small',
|
|
19
|
+
client_backend: 'sdk'
|
|
20
|
+
}
|
|
19
21
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
});
|
|
22
|
+
: undefined
|
|
23
|
+
});
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
console.log('memU bridge created');
|
|
26
|
+
console.log(` memuDir: ${memu.memuDir}`);
|
|
27
|
+
console.log(` stateDir: ${memu.stateDir}\n`);
|
|
27
28
|
|
|
28
|
-
try {
|
|
29
29
|
console.log('--- Step 1: Check memU status ---');
|
|
30
30
|
const status = await memu.getStatus();
|
|
31
31
|
console.log('Status:', JSON.stringify(status, null, 2));
|
package/claw/index.ts
CHANGED
|
@@ -3,11 +3,12 @@ import * as client from './bitshares_client.js';
|
|
|
3
3
|
const { BitShares } = client;
|
|
4
4
|
import { executeOperations } from './chain_broadcast.js';
|
|
5
5
|
import { loadDexbotOrderUtils, requireDexbot2Module, loadDexbotOrderConstants } from './dexbot_bridge.js';
|
|
6
|
-
import { requireBtsBackedMpa
|
|
7
|
-
import { getAsset,
|
|
6
|
+
import { requireBtsBackedMpa } from './mpa_utils.js';
|
|
7
|
+
import { getAsset, getFullAccount, readOpenOrders, resolveAccountId, resolveAccountName } from './chain_queries.js';
|
|
8
8
|
import { getErrorMessage } from '../../modules/utils/errors.js';
|
|
9
9
|
|
|
10
|
-
// Graphene protocol constant: operation type 4 =
|
|
10
|
+
// Graphene protocol constant: operation type 4 = fill_order (limit_order_create
|
|
11
|
+
// is type 1). Account history subscriptions emit op[0] = 4 for matched fills.
|
|
11
12
|
const FILL_ORDER_OPERATION_TYPE = 4;
|
|
12
13
|
const accountSubscriptions = new Map();
|
|
13
14
|
|
|
@@ -134,18 +135,7 @@ async function buildBorrowMpaOperation({
|
|
|
134
135
|
throw new Error(`Account not found: ${accountName}`);
|
|
135
136
|
}
|
|
136
137
|
|
|
137
|
-
const mpaMeta = await
|
|
138
|
-
if (!mpaMeta.bitasset_data_id) {
|
|
139
|
-
throw new Error(`${mpaAsset} is not a market-issued asset`);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const backingAsset = await getBackingAsset(mpaAsset);
|
|
143
|
-
if (!backingAsset) {
|
|
144
|
-
throw new Error(`Could not resolve backing asset for ${mpaAsset}`);
|
|
145
|
-
}
|
|
146
|
-
if (backingAsset.symbol !== CORE_SYMBOL) {
|
|
147
|
-
throw new Error(`${mpaAsset} is backed by ${backingAsset.symbol}, not ${CORE_SYMBOL}; use short_mpa_strategy for non-BTS MPAs`);
|
|
148
|
-
}
|
|
138
|
+
const { backingAsset, mpaAsset: mpaMeta } = await requireBtsBackedMpa(mpaAsset, 'use short_mpa_strategy for non-BTS MPAs');
|
|
149
139
|
|
|
150
140
|
const floatToBlockchainInt = getFloatToBlockchainInt();
|
|
151
141
|
const debtInt = floatToBlockchainInt(debtDelta, mpaMeta.precision);
|
|
@@ -179,18 +169,7 @@ async function buildSettleMpaOperation({ accountName, mpaAsset, amount }: any) {
|
|
|
179
169
|
throw new Error(`Account not found: ${accountName}`);
|
|
180
170
|
}
|
|
181
171
|
|
|
182
|
-
const mpaMeta = await
|
|
183
|
-
if (!mpaMeta.bitasset_data_id) {
|
|
184
|
-
throw new Error(`${mpaAsset} is not a market-issued asset`);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
const backingAsset = await getBackingAsset(mpaAsset);
|
|
188
|
-
if (!backingAsset) {
|
|
189
|
-
throw new Error(`Could not resolve backing asset for ${mpaAsset}`);
|
|
190
|
-
}
|
|
191
|
-
if (backingAsset.symbol !== CORE_SYMBOL) {
|
|
192
|
-
throw new Error(`${mpaAsset} is backed by ${backingAsset.symbol}, not ${CORE_SYMBOL}`);
|
|
193
|
-
}
|
|
172
|
+
const { mpaAsset: mpaMeta } = await requireBtsBackedMpa(mpaAsset);
|
|
194
173
|
|
|
195
174
|
const floatToBlockchainInt = getFloatToBlockchainInt();
|
|
196
175
|
const settleAmountInt = floatToBlockchainInt(amount, mpaMeta.precision);
|
|
@@ -304,36 +283,19 @@ async function listenForFills(accountNameOrId: any, callback: any) {
|
|
|
304
283
|
|
|
305
284
|
if (!accountSubscriptions.has(accountName)) {
|
|
306
285
|
const callbacks: Set<Function> = new Set();
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
// caught here, and attach a catch for async rejections so a rejected
|
|
316
|
-
// handler cannot become an unhandled promise rejection (crash on
|
|
317
|
-
// Node >= 15).
|
|
318
|
-
try {
|
|
319
|
-
const result = fn(fills);
|
|
320
|
-
if (result && typeof result.then === 'function') {
|
|
321
|
-
result.catch((err: any) => {
|
|
322
|
-
console.error('listenForFills callback error:', getErrorMessage(err));
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
|
-
} catch (err: any) {
|
|
326
|
-
console.error('listenForFills callback error:', getErrorMessage(err));
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
BitShares.subscribe('account', bsCallback, accountName);
|
|
286
|
+
let bsCallback: Function | null = null;
|
|
287
|
+
try {
|
|
288
|
+
bsCallback = await subscribeAccountFills(accountName, callbacks);
|
|
289
|
+
} catch (err: any) {
|
|
290
|
+
throw new Error(`Failed to subscribe to account updates for ${accountName}: ${getErrorMessage(err)}`);
|
|
291
|
+
}
|
|
292
|
+
// Register only after the remote subscription succeeded so callers never
|
|
293
|
+
// believe they are subscribed when setup actually failed.
|
|
332
294
|
accountSubscriptions.set(accountName, { callbacks, bsCallback });
|
|
333
295
|
}
|
|
334
296
|
|
|
335
297
|
const entry = accountSubscriptions.get(accountName);
|
|
336
|
-
if (!entry) {
|
|
298
|
+
if (!entry || !entry.bsCallback) {
|
|
337
299
|
throw new Error(`Subscription entry not found for ${accountName}`);
|
|
338
300
|
}
|
|
339
301
|
entry.callbacks.add(callback);
|
|
@@ -357,5 +319,40 @@ async function listenForFills(accountNameOrId: any, callback: any) {
|
|
|
357
319
|
};
|
|
358
320
|
}
|
|
359
321
|
|
|
360
|
-
|
|
322
|
+
/**
|
|
323
|
+
* Subscribe to account history fills and fan them out to every registered
|
|
324
|
+
* callback. The underlying subscription call is async and can reject (network
|
|
325
|
+
* error, unknown account); the promise is awaited by listenForFills so a
|
|
326
|
+
* failure surfaces instead of becoming an unhandled rejection.
|
|
327
|
+
*/
|
|
328
|
+
async function subscribeAccountFills(accountName: string, callbacks: Set<Function>) {
|
|
329
|
+
const bsCallback = (updates: any[] = []) => {
|
|
330
|
+
const fills = updates.filter((update) => update?.op && update.op[0] === FILL_ORDER_OPERATION_TYPE);
|
|
331
|
+
if (fills.length === 0) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
for (const fn of Array.from(callbacks)) {
|
|
336
|
+
// The callback may be async. Run it synchronously so sync throws are
|
|
337
|
+
// caught here, and attach a catch for async rejections so a rejected
|
|
338
|
+
// handler cannot become an unhandled promise rejection (crash on
|
|
339
|
+
// Node >= 15).
|
|
340
|
+
try {
|
|
341
|
+
const result = fn(fills);
|
|
342
|
+
if (result && typeof result.then === 'function') {
|
|
343
|
+
result.catch((err: any) => {
|
|
344
|
+
console.error('listenForFills callback error:', getErrorMessage(err));
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
} catch (err: any) {
|
|
348
|
+
console.error('listenForFills callback error:', getErrorMessage(err));
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
await BitShares.subscribe('account', bsCallback, accountName);
|
|
354
|
+
return bsCallback;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export { adjustMpaCollateral, borrowMpa, buildBorrowMpaOperation, buildCreateLimitOrderOperation, buildUpdateLimitOrderOperation, buildSettleMpaOperation, cancelLimitOrder, createLimitOrder, executeBatch, getMpaPosition, getOpenOrders, listenForFills, repayMpaDebt, updateLimitOrder, settleMpa }
|
|
361
358
|
|