dexbot 1.4.21 → 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 +30 -0
- package/README.md +1 -1
- 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 +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 +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 +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/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/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 +3 -3
- 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 +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 +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 +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 +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 +3 -6
- 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.js +1 -1
- 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 +53 -56
- 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 +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 +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/order.d.ts.map +1 -1
- package/dist/modules/order/utils/order.js +1 -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 +35 -16
- 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 +2 -2
- 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/COPY_ON_WRITE_MASTER_PLAN.md +9 -9
- package/docs/DEXBOT_COMPARISON.md +4 -4
- package/docs/EVOLUTION.md +16 -43
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
- package/docs/README.md +1 -1
- package/docs/architecture.md +5 -5
- package/docs/developer_guide.md +6 -6
- 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,3 +1,4 @@
|
|
|
1
|
+
'use strict';
|
|
1
2
|
/**
|
|
2
3
|
* KIBANA ELASTICSEARCH CLIENT
|
|
3
4
|
*
|
|
@@ -15,7 +16,6 @@
|
|
|
15
16
|
import { createRequire } from 'node:module';
|
|
16
17
|
import { MARKET_ADAPTER } from '../../modules/constants.js';
|
|
17
18
|
import { getErrorMessage } from '../../modules/utils/errors.js';
|
|
18
|
-
'use strict';
|
|
19
19
|
const _require = createRequire(import.meta.url);
|
|
20
20
|
let _https;
|
|
21
21
|
const https = new Proxy({}, {
|
|
@@ -69,26 +69,48 @@ function doKibanaRequest(cfg, esQuery, resolve, reject, redirectCount = 0) {
|
|
|
69
69
|
}, (res) => {
|
|
70
70
|
// Follow a single redirect (common with auth or load-balancer rewrites)
|
|
71
71
|
if (redirectCount === 0 && res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
72
|
+
// Consume/destroy the 3xx body so the socket is released instead of
|
|
73
|
+
// being held open until timeout.
|
|
74
|
+
res.resume();
|
|
72
75
|
const redirectUrl = new URL(res.headers.location, cfg.kibanaUrl);
|
|
73
76
|
return doKibanaRequest({ ...cfg, kibanaUrl: redirectUrl.href }, esQuery, resolve, reject, redirectCount + 1);
|
|
74
77
|
}
|
|
75
78
|
let raw = '';
|
|
79
|
+
let resSettled = false;
|
|
80
|
+
const fail = (err) => {
|
|
81
|
+
if (resSettled)
|
|
82
|
+
return;
|
|
83
|
+
resSettled = true;
|
|
84
|
+
reject(err);
|
|
85
|
+
};
|
|
76
86
|
res.on('data', (c) => { raw += c; });
|
|
87
|
+
// A response stream that dies mid-transfer (server/proxy connection reset
|
|
88
|
+
// on large payloads) never emits 'end' — without these handlers the
|
|
89
|
+
// surrounding promise stays pending forever and callers hang.
|
|
90
|
+
res.on('aborted', () => {
|
|
91
|
+
fail(new Error('Kibana response aborted (connection reset mid-transfer — reduce kibanaPageSize / restrict _source fields)'));
|
|
92
|
+
});
|
|
93
|
+
res.on('error', (e) => {
|
|
94
|
+
fail(new Error(`Kibana response stream error: ${getErrorMessage(e)}`));
|
|
95
|
+
});
|
|
77
96
|
res.on('end', () => {
|
|
97
|
+
if (resSettled)
|
|
98
|
+
return;
|
|
78
99
|
if (res.statusCode === 401 || res.statusCode === 403) {
|
|
79
|
-
|
|
100
|
+
fail(new Error(`Kibana auth required (HTTP ${res.statusCode}). ` +
|
|
80
101
|
`Set config.apiKey — generate in Kibana → Stack Management → API Keys.`));
|
|
81
102
|
return;
|
|
82
103
|
}
|
|
83
104
|
if (res.statusCode >= 400) {
|
|
84
|
-
|
|
105
|
+
fail(new Error(`HTTP ${res.statusCode}: ${raw.slice(0, 300)}`));
|
|
85
106
|
return;
|
|
86
107
|
}
|
|
87
108
|
try {
|
|
109
|
+
resSettled = true;
|
|
88
110
|
resolve(JSON.parse(raw));
|
|
89
111
|
}
|
|
90
112
|
catch (e) {
|
|
91
|
-
|
|
113
|
+
fail(new Error(`JSON parse failed: ${getErrorMessage(e)}\n${raw.slice(0, 200)}`));
|
|
92
114
|
}
|
|
93
115
|
});
|
|
94
116
|
});
|
|
@@ -101,8 +123,19 @@ function doKibanaRequest(cfg, esQuery, resolve, reject, redirectCount = 0) {
|
|
|
101
123
|
signal.addEventListener('abort', onAbort, { once: true });
|
|
102
124
|
req.on('close', () => signal.removeEventListener('abort', onAbort));
|
|
103
125
|
}
|
|
104
|
-
|
|
105
|
-
|
|
126
|
+
// A destroyed request can emit both 'timeout' and 'error' — settle once.
|
|
127
|
+
let settled = false;
|
|
128
|
+
const settleReject = (err) => {
|
|
129
|
+
if (settled)
|
|
130
|
+
return;
|
|
131
|
+
settled = true;
|
|
132
|
+
reject(err);
|
|
133
|
+
};
|
|
134
|
+
req.on('error', settleReject);
|
|
135
|
+
req.on('timeout', () => {
|
|
136
|
+
req.destroy();
|
|
137
|
+
settleReject(new Error('Kibana request timed out'));
|
|
138
|
+
});
|
|
106
139
|
req.write(body);
|
|
107
140
|
req.end();
|
|
108
141
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kibana_client.js","sourceRoot":"","sources":["../../../market_adapter/core/kibana_client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"kibana_client.js","sourceRoot":"","sources":["../../../market_adapter/core/kibana_client.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb;;;;;;;;;;;;;GAaG;AAGH,OAAO,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AEF,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC9B,GAAG,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;QACrB,GAAG,CAAC,OAAO,EAAE,CAAC;QACd,YAAY,CAAC,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAChB,GAAG,CAAC,GAAG,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,YAAY,CAAC,MAAW,EAAE,OAAY;IAC7C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,GAAG,GAAG,EAAE,GAAG,cAAc,EAAE,GAAG,MAAM,EAAE,CAAC;QAC7C,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC;AAED,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -1,30 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* KIBANA MARKET CANDLES
|
|
3
|
-
*
|
|
4
|
-
* Fetches OHLCV candles from order book fill operations (op_type 4)
|
|
5
|
-
* for any asset pair on BitShares. Unlike kibana_source.ts which handles
|
|
6
|
-
* LP pool swaps (op_type 63), this module handles regular limit order fills.
|
|
7
|
-
*
|
|
8
|
-
* Use case: historical price candles for MPA/BTS markets where the margin
|
|
9
|
-
* trading system needs trend detection input beyond just the current
|
|
10
|
-
* on-chain feed price.
|
|
11
|
-
*
|
|
12
|
-
* Data source:
|
|
13
|
-
* Kibana: https://kibana.bitshares.dev
|
|
14
|
-
* Index: bitshares-*
|
|
15
|
-
* Operation type: 4 (fill_order)
|
|
16
|
-
*
|
|
17
|
-
* ES field paths for fill_order:
|
|
18
|
-
* op_object.pays.amount – integer amount paid
|
|
19
|
-
* op_object.pays.asset_id – asset ID paid
|
|
20
|
-
* op_object.receives.amount – integer amount received
|
|
21
|
-
* op_object.receives.asset_id – asset ID received
|
|
22
|
-
* op_object.account_id – whose order was filled
|
|
23
|
-
* op_object.order_id – the limit order that filled
|
|
24
|
-
*
|
|
25
|
-
* Output: [[timestamp_ms, open, high, low, close, volume_base], ...]
|
|
26
|
-
* Same OHLCV format as kibana_source.ts for compatibility with candle_utils.
|
|
27
|
-
*/
|
|
28
1
|
/**
|
|
29
2
|
* Fetch bidirectional fill candles for an asset pair.
|
|
30
3
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kibana_market_candles.d.ts","sourceRoot":"","sources":["../../../market_adapter/core/kibana_market_candles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"kibana_market_candles.d.ts","sourceRoot":"","sources":["../../../market_adapter/core/kibana_market_candles.ts"],"names":[],"mappings":"AA4CA;;;;;;;;;;GAUG;AACH,iBAAe,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAE,GAAQ,kBAQzE;AAED;;;;;;;GAOG;AACH,iBAAe,oBAAoB,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAE,GAAQ,kBAQ7E;AAED,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
'use strict';
|
|
1
2
|
/**
|
|
2
3
|
* KIBANA MARKET CANDLES
|
|
3
4
|
*
|
|
@@ -26,7 +27,6 @@
|
|
|
26
27
|
* Same OHLCV format as kibana_source.ts for compatibility with candle_utils.
|
|
27
28
|
*/
|
|
28
29
|
import { fetchKibanaCandles, fetchKibanaClosePrices } from './kibana_candles.js';
|
|
29
|
-
'use strict';
|
|
30
30
|
const OP_FILL_ORDER = 4;
|
|
31
31
|
const FILL_FIELD_MAP = {
|
|
32
32
|
soldAssetField: 'operation_history.op_object.pays.asset_id.keyword',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kibana_market_candles.js","sourceRoot":"","sources":["../../../market_adapter/core/kibana_market_candles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"kibana_market_candles.js","sourceRoot":"","sources":["../../../market_adapter/core/kibana_market_candles.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAGjF,MAAM,aAAa,GAAG,CAAC,CAAC;AAExB,MAAM,cAAc,GAAG;IACrB,cAAc,EAAE,mDAAmD;IACnE,kBAAkB,EAAE,uDAAuD;IAC3E,eAAe,EAAE,yCAAyC;IAC1D,mBAAmB,EAAE,6CAA6C;CACnE,CAAC;AAEF,gFAAgF;AAEhF;;;;;;;;;;GAUG;AACH,KAAK,UAAU,gBAAgB,CAAC,MAAW,EAAE,MAAW,EAAE,SAAc,EAAE;IACxE,OAAO,kBAAkB,CAAC;QACxB,MAAM,EAAE,aAAa;QACrB,QAAQ,EAAE,cAAc;QACxB,MAAM;QACN,MAAM;QACN,MAAM;KACP,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,KAAK,UAAU,oBAAoB,CAAC,MAAW,EAAE,MAAW,EAAE,SAAc,EAAE;IAC5E,OAAO,sBAAsB,CAAC;QAC5B,MAAM,EAAE,aAAa;QACrB,QAAQ,EAAE,cAAc;QACxB,MAAM;QACN,MAAM;QACN,MAAM;KACP,CAAC,CAAC;AACL,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,CAAA"}
|
|
@@ -6,6 +6,16 @@ declare class MarketAdapterService {
|
|
|
6
6
|
constructor(deps?: any);
|
|
7
7
|
static isRetryableClosedCandleFailure(reason: any): boolean;
|
|
8
8
|
getNowMs(): any;
|
|
9
|
+
/**
|
|
10
|
+
* Kibana bootstrap lookback in hours — exact conversion of the required
|
|
11
|
+
* candle count at the bot's interval, mirroring getGapRepairMaxHours().
|
|
12
|
+
* The caller passes rawKeepCount (getAmaWarmupBars() + 1 closed bar + 1
|
|
13
|
+
* in-progress raw bar); if Kibana returns fewer bars than amaWarmupBars
|
|
14
|
+
* (thin/gappy data), the existing native-backfill fallback handles it.
|
|
15
|
+
* cfg.bootstrapLookbackHours stays as a floor so operators can seed
|
|
16
|
+
* deeper history than the analytical minimum.
|
|
17
|
+
*/
|
|
18
|
+
bootstrapKibanaLookbackHours(cfg: any, keepCount: any): number;
|
|
9
19
|
selectClosedCandles(candles: any, intervalSeconds: any, nowMs?: any): {
|
|
10
20
|
closedCandles: any[];
|
|
11
21
|
currentBucketStartMs: null;
|
|
@@ -78,7 +88,7 @@ declare class MarketAdapterService {
|
|
|
78
88
|
slopePct: number | null;
|
|
79
89
|
slopeOffset: number;
|
|
80
90
|
rawSlopeOffset: any;
|
|
81
|
-
amaSlopeGated:
|
|
91
|
+
amaSlopeGated: any;
|
|
82
92
|
regimeMultiplier: number;
|
|
83
93
|
regimeSensitivity: any;
|
|
84
94
|
absoluteThreshold: any;
|
|
@@ -90,11 +100,11 @@ declare class MarketAdapterService {
|
|
|
90
100
|
maxSlopeOffset: any;
|
|
91
101
|
maxAsymmetryFactor: any;
|
|
92
102
|
minScaleSlots: any;
|
|
93
|
-
clipPercentile:
|
|
103
|
+
clipPercentile: number;
|
|
94
104
|
neutralZonePct: any;
|
|
95
105
|
volatilityThreshold: number;
|
|
96
|
-
volatilityExponent:
|
|
97
|
-
volatilityScaleX:
|
|
106
|
+
volatilityExponent: number;
|
|
107
|
+
volatilityScaleX: number;
|
|
98
108
|
amaSlope: {
|
|
99
109
|
maxSlopePct: any;
|
|
100
110
|
};
|
|
@@ -107,7 +117,7 @@ declare class MarketAdapterService {
|
|
|
107
117
|
kalmanDispThresholdMult: any;
|
|
108
118
|
kalmanSmoothSpanPct: any;
|
|
109
119
|
signalConfirmBars: any;
|
|
110
|
-
amaChannelContribution:
|
|
120
|
+
amaChannelContribution: any;
|
|
111
121
|
rawFinalOffset: any;
|
|
112
122
|
trendOffset: any;
|
|
113
123
|
finalOffset: any;
|
|
@@ -136,7 +146,7 @@ declare class MarketAdapterService {
|
|
|
136
146
|
};
|
|
137
147
|
slopeOffset: number;
|
|
138
148
|
rawSlopeOffset: any;
|
|
139
|
-
amaSlopeGated:
|
|
149
|
+
amaSlopeGated: any;
|
|
140
150
|
volatilityPenalty: number;
|
|
141
151
|
finalOffset: any;
|
|
142
152
|
alpha: any;
|
|
@@ -150,11 +160,11 @@ declare class MarketAdapterService {
|
|
|
150
160
|
kalmanSlope: {
|
|
151
161
|
maxSlopePct: any;
|
|
152
162
|
};
|
|
153
|
-
clipPercentile:
|
|
163
|
+
clipPercentile: number;
|
|
154
164
|
neutralZonePct: any;
|
|
155
165
|
volatilityThreshold: number;
|
|
156
|
-
volatilityExponent:
|
|
157
|
-
volatilityScaleX:
|
|
166
|
+
volatilityExponent: number;
|
|
167
|
+
volatilityScaleX: number;
|
|
158
168
|
maxVolatilityOffset: number;
|
|
159
169
|
kalmanSmoothPct: any;
|
|
160
170
|
kalmanDispScaleMult: any;
|
|
@@ -164,7 +174,7 @@ declare class MarketAdapterService {
|
|
|
164
174
|
rawFinalOffset: any;
|
|
165
175
|
maxAsymmetryFactor: any;
|
|
166
176
|
minScaleSlots: any;
|
|
167
|
-
amaChannelContribution:
|
|
177
|
+
amaChannelContribution: any;
|
|
168
178
|
trend: string;
|
|
169
179
|
confidence: number;
|
|
170
180
|
slopePct: number | null;
|
|
@@ -194,7 +204,7 @@ declare class MarketAdapterService {
|
|
|
194
204
|
slopePct: number | null;
|
|
195
205
|
slopeOffset: number;
|
|
196
206
|
rawSlopeOffset: any;
|
|
197
|
-
amaSlopeGated:
|
|
207
|
+
amaSlopeGated: any;
|
|
198
208
|
regimeMultiplier: number;
|
|
199
209
|
symmetricDelta: number;
|
|
200
210
|
weightVariance: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"market_adapter_service.d.ts","sourceRoot":"","sources":["../../../market_adapter/core/market_adapter_service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"market_adapter_service.d.ts","sourceRoot":"","sources":["../../../market_adapter/core/market_adapter_service.ts"],"names":[],"mappings":"AAmCA,QAAA,MAAM,8BAA8B,WAAW,CAAC;AAGhD,iBAAS,4BAA4B,CAAC,KAAK,EAAE,GAAG,8BAS/C;AAQD,iBAAS,2BAA2B,CAAC,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,iBAM5E;AA4DD,cAAM,oBAAoB;IACtB,IAAI,EAAE,GAAG,CAAC;gBACE,IAAI,GAAE,GAAQ;IAU1B,MAAM,CAAC,8BAA8B,CAAC,MAAM,EAAE,GAAG;IAOjD,QAAQ;IAIR;;;;;;;;OAQG;IACH,4BAA4B,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG;IAQrD,mBAAmB,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,KAAK,GAAE,GAAqB;;;;;;;IAgBpF,wBAAwB,CAAC,GAAG,EAAE,GAAG;IAajC,uBAAuB,CAAC,iBAAiB,EAAE,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,WAAW,GAAE,GAAQ;;;;IAgB3F,mCAAmC,CAAC,iBAAiB,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG;IAQ1E,oBAAoB,CAAC,GAAG,EAAE,GAAG;IAe7B,oCAAoC,CAAC,GAAG,EAAE,GAAG;IAM7C,+BAA+B,CAAC,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,KAAK,GAAE,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5B,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,KAAK,GAAE,GAAQ;CAiiDtF;AAED,OAAO,EAAE,oBAAoB,EAAE,8BAA8B,EAAE,4BAA4B,EAAE,2BAA2B,EAAE,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
'use strict';
|
|
1
2
|
import { calculateATR } from './strategies/atr/calculator.js';
|
|
2
3
|
import { normalizeMarketSource, hasNumericStartPrice, resolveMarketSourceForBot } from '../utils/chain.js';
|
|
3
4
|
import { computeRegimeMultiplier } from './strategies/regime_gate.js';
|
|
@@ -7,10 +8,10 @@ import { KalmanTrendAnalyzer } from './signals/kalman_trend_analyzer.js';
|
|
|
7
8
|
import { adjustCollateralRatio } from './strategies/collateral_manager.js';
|
|
8
9
|
import { DEFAULT_CONFIG, MARKET_ADAPTER } from '../../modules/constants.js';
|
|
9
10
|
import { resolveConfiguredPriceBound } from '../../modules/order/utils/order.js';
|
|
11
|
+
import { usesAmaGridPrice } from '../../modules/grid_price_source.js';
|
|
10
12
|
import Logger from '../../modules/order/logger.js';
|
|
11
13
|
import { roundTo } from '../../modules/order/utils/math.js';
|
|
12
|
-
|
|
13
|
-
import { computeAmaSlopeWeights, computeAverageAmaSlopePct, } from './strategies/ama_slope_model.js';
|
|
14
|
+
import { computeAmaSlopeWeights, computeAmaSlopeClipThreshold, } from './strategies/ama_slope_model.js';
|
|
14
15
|
import { normalizeAtrPeriod, normalizeMaxVolatilityOffset, normalizeVolatilityThreshold, } from './config_normalizers.js';
|
|
15
16
|
import { buildKalmanVelocitySeries, computeAbsolutePercentileThreshold, } from './signals/kalman_velocity_smoothing.js';
|
|
16
17
|
import { resolveMaxAsymmetryFactor, computeAsymmetricBoundsMetrics, } from './asymmetric_bounds.js';
|
|
@@ -113,6 +114,22 @@ class MarketAdapterService {
|
|
|
113
114
|
getNowMs() {
|
|
114
115
|
return typeof this.deps.getNowMs === 'function' ? this.deps.getNowMs() : Date.now();
|
|
115
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Kibana bootstrap lookback in hours — exact conversion of the required
|
|
119
|
+
* candle count at the bot's interval, mirroring getGapRepairMaxHours().
|
|
120
|
+
* The caller passes rawKeepCount (getAmaWarmupBars() + 1 closed bar + 1
|
|
121
|
+
* in-progress raw bar); if Kibana returns fewer bars than amaWarmupBars
|
|
122
|
+
* (thin/gappy data), the existing native-backfill fallback handles it.
|
|
123
|
+
* cfg.bootstrapLookbackHours stays as a floor so operators can seed
|
|
124
|
+
* deeper history than the analytical minimum.
|
|
125
|
+
*/
|
|
126
|
+
bootstrapKibanaLookbackHours(cfg, keepCount) {
|
|
127
|
+
const intervalSeconds = Number(cfg?.intervalSeconds);
|
|
128
|
+
const intervalHours = Number.isFinite(intervalSeconds) && intervalSeconds > 0
|
|
129
|
+
? intervalSeconds / 3600
|
|
130
|
+
: 1;
|
|
131
|
+
return Math.max(Number(cfg?.bootstrapLookbackHours) || 0, Number(keepCount) * intervalHours);
|
|
132
|
+
}
|
|
116
133
|
selectClosedCandles(candles, intervalSeconds, nowMs = this.getNowMs()) {
|
|
117
134
|
const bucketMs = Number(intervalSeconds) * 1000;
|
|
118
135
|
if (!Number.isFinite(bucketMs) || bucketMs <= 0) {
|
|
@@ -533,7 +550,13 @@ class MarketAdapterService {
|
|
|
533
550
|
}
|
|
534
551
|
_computeDynamicWeights(params) {
|
|
535
552
|
const { closes, amaValues, lookbackBars, botAma, weightVariance, nowIso, cfg, bot, atrPeriod } = params;
|
|
536
|
-
|
|
553
|
+
// clipPercentile must stay inside (0, 100] — values above 100 would
|
|
554
|
+
// otherwise produce negative percentile indices (NaN thresholds)
|
|
555
|
+
// downstream, and <= 0 disables clipping.
|
|
556
|
+
const rawClipPercentile = cfg.clipPercentile ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_CLIP_PERCENTILE;
|
|
557
|
+
const clipPercentile = Number.isFinite(rawClipPercentile)
|
|
558
|
+
? Math.max(0, Math.min(100, Number(rawClipPercentile)))
|
|
559
|
+
: MARKET_ADAPTER.DYNAMIC_WEIGHT_CLIP_PERCENTILE;
|
|
537
560
|
const nz = cfg.amaSlope?.neutralZonePct ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_NEUTRAL_ZONE_PCT;
|
|
538
561
|
const amaMaxS = cfg.amaSlope?.maxSlopePct ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_MAX_SLOPE_PCT;
|
|
539
562
|
const kalMaxS = cfg.kalmanSlope?.maxSlopePct
|
|
@@ -541,29 +564,20 @@ class MarketAdapterService {
|
|
|
541
564
|
const mo = cfg.maxSlopeOffset ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_ASYMMETRIC_OFFSET_CLAMP;
|
|
542
565
|
const volatilityClamp = normalizeMaxVolatilityOffset(cfg.maxVolatilityOffset);
|
|
543
566
|
const volatilityThreshold = normalizeVolatilityThreshold(cfg.volatilityThreshold);
|
|
544
|
-
|
|
545
|
-
|
|
567
|
+
// Normalize volatility knobs into their effective ranges at the single
|
|
568
|
+
// read point so config, applied value and reported payload always
|
|
569
|
+
// agree (computeVolatilityShift hard-clamps to the same bounds).
|
|
570
|
+
const rawVolatilityExponent = cfg.volatilityExponent ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_VOLATILITY_EXPONENT;
|
|
571
|
+
const volatilityExponent = Number.isFinite(rawVolatilityExponent)
|
|
572
|
+
? Math.max(MARKET_ADAPTER.DYNAMIC_WEIGHT_VOLATILITY_EXPONENT_MIN, Math.min(MARKET_ADAPTER.DYNAMIC_WEIGHT_VOLATILITY_EXPONENT_MAX, Number(rawVolatilityExponent)))
|
|
573
|
+
: MARKET_ADAPTER.DYNAMIC_WEIGHT_VOLATILITY_EXPONENT;
|
|
574
|
+
const rawVolatilityScaleX = cfg.volatilityScaleX ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_VOLATILITY_SCALE_X_DEFAULT;
|
|
575
|
+
const volatilityScaleX = Number.isFinite(rawVolatilityScaleX)
|
|
576
|
+
? Math.max(MARKET_ADAPTER.DYNAMIC_WEIGHT_VOLATILITY_SCALE_X_MIN, Math.min(MARKET_ADAPTER.DYNAMIC_WEIGHT_VOLATILITY_SCALE_X_MAX, Number(rawVolatilityScaleX)))
|
|
577
|
+
: MARKET_ADAPTER.DYNAMIC_WEIGHT_VOLATILITY_SCALE_X_DEFAULT;
|
|
546
578
|
// Compute separate clip thresholds for AMA (slopes) and Kalman (velocities)
|
|
547
|
-
let amaClipThreshold =
|
|
579
|
+
let amaClipThreshold = computeAmaSlopeClipThreshold(amaValues, botAma.erPeriod, lookbackBars, clipPercentile);
|
|
548
580
|
let kalClipThreshold = Infinity;
|
|
549
|
-
const amaSlopeReadyBars = Math.ceil(botAma.erPeriod) + lookbackBars;
|
|
550
|
-
if (clipPercentile > 0 && amaValues.length > amaSlopeReadyBars) {
|
|
551
|
-
// AMA clip threshold from slope distribution — skip the ER window,
|
|
552
|
-
// but do not require the full convergence-retention window.
|
|
553
|
-
const amaSlopes = [];
|
|
554
|
-
for (let i = amaSlopeReadyBars; i < amaValues.length; i++) {
|
|
555
|
-
const last = amaValues[i];
|
|
556
|
-
const past = amaValues[i - lookbackBars];
|
|
557
|
-
const slopePct = computeAverageAmaSlopePct(last, past, lookbackBars);
|
|
558
|
-
if (Number.isFinite(slopePct))
|
|
559
|
-
amaSlopes.push(Math.abs(slopePct));
|
|
560
|
-
}
|
|
561
|
-
if (amaSlopes.length > 0) {
|
|
562
|
-
const sorted = amaSlopes.sort((a, b) => a - b);
|
|
563
|
-
const idx = Math.min(Math.floor((100 - clipPercentile) / 100 * sorted.length), sorted.length - 1);
|
|
564
|
-
amaClipThreshold = sorted[idx];
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
581
|
const slopeCfg = {
|
|
568
582
|
...(cfg.amaSlope || {}),
|
|
569
583
|
erPeriod: botAma.erPeriod,
|
|
@@ -581,7 +595,7 @@ class MarketAdapterService {
|
|
|
581
595
|
rNoise: cfg.kalman?.rNoise ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_KALMAN_R_NOISE_DEFAULT,
|
|
582
596
|
qTactical: cfg.kalman?.qTactical ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_KALMAN_Q_TACTICAL_DEFAULT,
|
|
583
597
|
qModal: cfg.kalman?.qModal ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_KALMAN_Q_MODAL_DEFAULT,
|
|
584
|
-
warmupBars: cfg.kalman?.warmupBars ??
|
|
598
|
+
warmupBars: cfg.kalman?.warmupBars ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_KALMAN_WARMUP_BARS_DEFAULT,
|
|
585
599
|
});
|
|
586
600
|
const kalmanHistory = [];
|
|
587
601
|
for (const price of closes) {
|
|
@@ -646,7 +660,6 @@ class MarketAdapterService {
|
|
|
646
660
|
: Infinity;
|
|
647
661
|
}
|
|
648
662
|
const offsetClamp = cfg.maxSlopeOffset ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_ASYMMETRIC_OFFSET_CLAMP;
|
|
649
|
-
const channelNorm = Math.max(Math.abs(offsetClamp), 1e-9);
|
|
650
663
|
const outputThreshold = minOutputThreshold;
|
|
651
664
|
// Per-bar directional offset series — canonical implementation shared
|
|
652
665
|
// with the research chart and test harness (see dynamic_weight_series.ts).
|
|
@@ -672,14 +685,43 @@ class MarketAdapterService {
|
|
|
672
685
|
signalConfirmBars,
|
|
673
686
|
clampFinalOutput: true,
|
|
674
687
|
});
|
|
675
|
-
const {
|
|
688
|
+
const { combinedOffSeries, gatedOffSeries, echoedOffSeries, echoedGatedOffSeries, } = seriesResult;
|
|
676
689
|
const rawFinalOff = combinedOffSeries[combinedOffSeries.length - 1] ?? 0;
|
|
677
690
|
const rawFinalPreGainOff = gatedOffSeries[gatedOffSeries.length - 1] ?? 0;
|
|
678
691
|
const finalPreGainOff = echoedGatedOffSeries[echoedGatedOffSeries.length - 1] ?? rawFinalPreGainOff;
|
|
679
692
|
const finalOff = echoedOffSeries[echoedOffSeries.length - 1] ?? rawFinalOff;
|
|
680
|
-
|
|
693
|
+
// Diagnostic: AMA channel contribution derived from the canonical
|
|
694
|
+
// pipeline with the Kalman channel disabled, so the dead-band gate,
|
|
695
|
+
// per-bar regime multipliers, gain/clamp and echo latch all match the
|
|
696
|
+
// path that produces finalOffset. (The previous closed-form
|
|
697
|
+
// alpha*(offset/norm)*gain*regime recomputation diverged from
|
|
698
|
+
// finalOffset whenever gating or signal confirmation was active.)
|
|
699
|
+
const amaOnlySeriesResult = computeDynamicWeightSeries({
|
|
700
|
+
amaValues,
|
|
701
|
+
kalmanVelocityPct: kalmanSmoothedVelocityPct.map(() => null),
|
|
702
|
+
kalmanDisplacementPct: kalmanHistory.map(() => null),
|
|
703
|
+
kalmanIsReady: kalmanHistory.map(() => false),
|
|
704
|
+
regimeMultipliers,
|
|
705
|
+
lookbackBars,
|
|
706
|
+
amaErPeriod: botAma.erPeriod,
|
|
707
|
+
amaClipThreshold,
|
|
708
|
+
kalClipThreshold: Infinity,
|
|
709
|
+
neutralZonePct: nz,
|
|
710
|
+
amaMaxSlopePct: amaMaxS,
|
|
711
|
+
kalmanMaxSlopePct: kalMaxS,
|
|
712
|
+
offsetClamp,
|
|
713
|
+
dispScaleMinPct,
|
|
714
|
+
alpha,
|
|
715
|
+
dw,
|
|
716
|
+
gain,
|
|
717
|
+
minOutputThreshold,
|
|
718
|
+
signalConfirmBars,
|
|
719
|
+
clampFinalOutput: true,
|
|
720
|
+
});
|
|
681
721
|
const amaSlopeGated = slopeResult.isReady
|
|
682
|
-
?
|
|
722
|
+
? (useAmaBlend
|
|
723
|
+
? (amaOnlySeriesResult.echoedOffSeries[amaOnlySeriesResult.echoedOffSeries.length - 1] ?? 0)
|
|
724
|
+
: 0)
|
|
683
725
|
: 0;
|
|
684
726
|
const amaSlope = {
|
|
685
727
|
trend: slopeResult.trend,
|
|
@@ -849,12 +891,19 @@ class MarketAdapterService {
|
|
|
849
891
|
if ((!bot.assetA && !bot.assetAId) || (!bot.assetB && !bot.assetBId)) {
|
|
850
892
|
return { ok: false, reason: 'missing asset pair' };
|
|
851
893
|
}
|
|
894
|
+
// Persisted state files may predate the `bots` map (or hold a partial
|
|
895
|
+
// JSON) — normalize once here so every later state.bots access is safe.
|
|
896
|
+
if (!state || typeof state !== 'object') {
|
|
897
|
+
return { ok: false, reason: 'invalid adapter state' };
|
|
898
|
+
}
|
|
899
|
+
if (!state.bots || typeof state.bots !== 'object') {
|
|
900
|
+
state.bots = {};
|
|
901
|
+
}
|
|
852
902
|
if (hasNumericStartPrice(bot?.startPrice)) {
|
|
853
903
|
const nowIso = new Date().toISOString();
|
|
854
904
|
const thresholdPercent = typeof deps.calculateBotThreshold === 'function'
|
|
855
905
|
? deps.calculateBotThreshold(cfg)
|
|
856
906
|
: null;
|
|
857
|
-
state.bots = state.bots || {};
|
|
858
907
|
state.bots[bot.botKey] = this.buildDefaultBotState(bot, {
|
|
859
908
|
startPrice: bot.startPrice,
|
|
860
909
|
priceMode: 'fixed',
|
|
@@ -913,6 +962,12 @@ class MarketAdapterService {
|
|
|
913
962
|
return deps.kibanaSource.getLpCandlesForPool(ctx.poolId, ctx.assetA, ctx.assetB, kibanaOptions);
|
|
914
963
|
};
|
|
915
964
|
const staleTailVerifiedRangeFromMeta = () => {
|
|
965
|
+
// Meta fields are persisted as explicit null when absent — guard
|
|
966
|
+
// before Number() since Number(null) === 0 would masquerade as a
|
|
967
|
+
// valid epoch timestamp.
|
|
968
|
+
if (existingMeta.staleTailVerifiedStartTs == null || existingMeta.staleTailVerifiedEndTs == null) {
|
|
969
|
+
return {};
|
|
970
|
+
}
|
|
916
971
|
const startTs = Number(existingMeta.staleTailVerifiedStartTs);
|
|
917
972
|
const endTs = Number(existingMeta.staleTailVerifiedEndTs);
|
|
918
973
|
if (Number.isFinite(startTs) && Number.isFinite(endTs)) {
|
|
@@ -938,7 +993,7 @@ class MarketAdapterService {
|
|
|
938
993
|
// Skip Kibana verification if this tail range was already confirmed flat
|
|
939
994
|
// on a previous cycle (the current tail is contained within a verified range).
|
|
940
995
|
const { startTs: vStart, endTs: vEnd } = verifiedRange;
|
|
941
|
-
if (Number.isFinite(vStart) &&
|
|
996
|
+
if (Number.isFinite(vStart) && Number.isFinite(vEnd)
|
|
942
997
|
&& tailStartTs >= vStart && tailEndTs <= vEnd) {
|
|
943
998
|
return { candles, keptStaleTailStartTs: tailStartTs, keptStaleTailEndTs: tailEndTs };
|
|
944
999
|
}
|
|
@@ -1137,7 +1192,7 @@ class MarketAdapterService {
|
|
|
1137
1192
|
const nowMs = this.getNowMs();
|
|
1138
1193
|
if (needBootstrap) {
|
|
1139
1194
|
// Bootstrap: Kibana first (deep history), native as fallback
|
|
1140
|
-
const kibanaLookbackHours =
|
|
1195
|
+
const kibanaLookbackHours = this.bootstrapKibanaLookbackHours(cfg, rawKeepCount);
|
|
1141
1196
|
let kibanaCandles = null;
|
|
1142
1197
|
try {
|
|
1143
1198
|
kibanaCandles = await deps.withRetries(() => fetchKibanaCandles({
|
|
@@ -1232,7 +1287,7 @@ class MarketAdapterService {
|
|
|
1232
1287
|
}
|
|
1233
1288
|
}
|
|
1234
1289
|
else if (needBootstrap) {
|
|
1235
|
-
const lookbackHours =
|
|
1290
|
+
const lookbackHours = this.bootstrapKibanaLookbackHours(cfg, rawKeepCount);
|
|
1236
1291
|
// ── Step 1: Kibana first (deep history, handles large candle requirements) ──
|
|
1237
1292
|
let kibanaCandles = null;
|
|
1238
1293
|
try {
|
|
@@ -1773,7 +1828,7 @@ class MarketAdapterService {
|
|
|
1773
1828
|
const isAsymmetricBoundsWhitelisted = isGridRangeScalingWhitelisted;
|
|
1774
1829
|
const hasExplicitBaseWeights = Number.isFinite(bot.weightDistribution?.sell)
|
|
1775
1830
|
&& Number.isFinite(bot.weightDistribution?.buy);
|
|
1776
|
-
const isAmaGridBot =
|
|
1831
|
+
const isAmaGridBot = usesAmaGridPrice(bot);
|
|
1777
1832
|
const shouldComputeDynamicWeightSignal = isAmaGridBot && hasExplicitBaseWeights
|
|
1778
1833
|
&& (isDynamicWeightWhitelisted || isGridRangeScalingWhitelisted);
|
|
1779
1834
|
const canExposeDynamicWeights = isDynamicWeightWhitelisted && shouldComputeDynamicWeightSignal;
|
|
@@ -1848,6 +1903,11 @@ class MarketAdapterService {
|
|
|
1848
1903
|
if (hasUnresolvedCandleGaps) {
|
|
1849
1904
|
triggerSuppressedReason = 'unresolved_candle_gaps';
|
|
1850
1905
|
}
|
|
1906
|
+
else if (staleData) {
|
|
1907
|
+
// Mirror the !hasNewClosedCandle path so state records why no
|
|
1908
|
+
// trigger/snapshot write happened on a stale-but-new cycle.
|
|
1909
|
+
triggerSuppressedReason = 'stale_candle_data';
|
|
1910
|
+
}
|
|
1851
1911
|
const buildDynamicGridOptions = (options = {}) => {
|
|
1852
1912
|
const payload = {
|
|
1853
1913
|
gridCenterPrice: options.gridCenterPrice ?? null, // explicit baseline if provided
|
|
@@ -2118,9 +2178,7 @@ class MarketAdapterService {
|
|
|
2118
2178
|
const stateAmaSlopeThresholdPercent = preserveRetryBaseline
|
|
2119
2179
|
? (botState.amaSlopeThresholdPercent ?? amaSlopeThresholdPercent ?? null)
|
|
2120
2180
|
: (amaSlopeThresholdPercent ?? botState.amaSlopeThresholdPercent ?? null);
|
|
2121
|
-
const stateGridRangeScalingAmaSlope =
|
|
2122
|
-
? (botState.gridRangeScalingAmaSlope || previousGridResetAmaSlope || null)
|
|
2123
|
-
: (botState.gridRangeScalingAmaSlope || previousGridResetAmaSlope || null);
|
|
2181
|
+
const stateGridRangeScalingAmaSlope = botState.gridRangeScalingAmaSlope || previousGridResetAmaSlope || null;
|
|
2124
2182
|
state.bots[bot.botKey] = {
|
|
2125
2183
|
...botState,
|
|
2126
2184
|
botName: bot.name,
|