dexbot 1.4.11 → 1.4.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/analysis/chart_utils.d.ts.map +1 -1
- package/dist/analysis/chart_utils.js +9 -18
- package/dist/analysis/chart_utils.js.map +1 -1
- package/dist/analysis/math_utils.d.ts.map +1 -1
- package/dist/analysis/math_utils.js +6 -16
- package/dist/analysis/math_utils.js.map +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +31 -38
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +1 -1
- package/dist/analysis/trend_detection/hurst_analyzer.js +7 -10
- package/dist/analysis/trend_detection/hurst_analyzer.js.map +1 -1
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js +10 -14
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js.map +1 -1
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js +10 -15
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js.map +1 -1
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js +7 -10
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js.map +1 -1
- package/dist/bot.d.ts.map +1 -1
- package/dist/bot.js +4 -12
- package/dist/bot.js.map +1 -1
- package/dist/credential-daemon.d.ts +0 -1
- package/dist/credential-daemon.d.ts.map +1 -1
- package/dist/credential-daemon.js +3 -123
- package/dist/credential-daemon.js.map +1 -1
- package/dist/dexbot.d.ts +0 -87
- package/dist/dexbot.d.ts.map +1 -1
- package/dist/dexbot.js +11 -14
- package/dist/dexbot.js.map +1 -1
- package/dist/market_adapter/ama_signal_runner.js +8 -9
- package/dist/market_adapter/ama_signal_runner.js.map +1 -1
- package/dist/market_adapter/candle_utils.js +1 -7
- package/dist/market_adapter/candle_utils.js.map +1 -1
- package/dist/market_adapter/core/asymmetric_bounds.js +1 -4
- package/dist/market_adapter/core/asymmetric_bounds.js.map +1 -1
- package/dist/market_adapter/core/config_normalizers.js +5 -9
- package/dist/market_adapter/core/config_normalizers.js.map +1 -1
- package/dist/market_adapter/core/kibana_candles.js +8 -15
- package/dist/market_adapter/core/kibana_candles.js.map +1 -1
- package/dist/market_adapter/core/kibana_client.js +7 -13
- package/dist/market_adapter/core/kibana_client.js.map +1 -1
- package/dist/market_adapter/core/kibana_market_candles.js +6 -12
- package/dist/market_adapter/core/kibana_market_candles.js.map +1 -1
- package/dist/market_adapter/core/market_adapter_service.js +92 -102
- package/dist/market_adapter/core/market_adapter_service.js.map +1 -1
- package/dist/market_adapter/core/strategies/ama.js +5 -10
- package/dist/market_adapter/core/strategies/ama.js.map +1 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.js +21 -24
- package/dist/market_adapter/core/strategies/ama_slope_model.js.map +1 -1
- package/dist/market_adapter/core/strategies/atr/calculator.js +3 -5
- package/dist/market_adapter/core/strategies/atr/calculator.js.map +1 -1
- package/dist/market_adapter/core/strategies/collateral_manager.js +4 -6
- package/dist/market_adapter/core/strategies/collateral_manager.js.map +1 -1
- package/dist/market_adapter/core/strategies/regime_gate.js +15 -22
- package/dist/market_adapter/core/strategies/regime_gate.js.map +1 -1
- package/dist/market_adapter/index.d.ts +23 -23
- package/dist/market_adapter/index.d.ts.map +1 -1
- package/dist/market_adapter/index.js +24 -82
- package/dist/market_adapter/index.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +2 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js +59 -98
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -1
- package/dist/market_adapter/inputs/kibana_source.js +11 -17
- package/dist/market_adapter/inputs/kibana_source.js.map +1 -1
- package/dist/market_adapter/interval_utils.js +1 -2
- package/dist/market_adapter/interval_utils.js.map +1 -1
- package/dist/market_adapter/log_format.js +1 -7
- package/dist/market_adapter/log_format.js.map +1 -1
- package/dist/market_adapter/lp_chart_core.js +20 -22
- package/dist/market_adapter/lp_chart_core.js.map +1 -1
- package/dist/market_adapter/lp_chart_runner.d.ts +1 -1
- package/dist/market_adapter/lp_chart_runner.d.ts.map +1 -1
- package/dist/market_adapter/lp_chart_runner.js +41 -57
- package/dist/market_adapter/lp_chart_runner.js.map +1 -1
- package/dist/market_adapter/lp_chart_strategy_loader.js +30 -34
- package/dist/market_adapter/lp_chart_strategy_loader.js.map +1 -1
- package/dist/market_adapter/market_adapter.d.ts +2 -2
- package/dist/market_adapter/market_adapter.d.ts.map +1 -1
- package/dist/market_adapter/market_adapter.js +157 -221
- package/dist/market_adapter/market_adapter.js.map +1 -1
- package/dist/market_adapter/merge_lp_data.js +17 -18
- package/dist/market_adapter/merge_lp_data.js.map +1 -1
- package/dist/market_adapter/test_helpers.js +3 -14
- package/dist/market_adapter/test_helpers.js.map +1 -1
- package/dist/market_adapter/utils/adapter_client.js +7 -16
- package/dist/market_adapter/utils/adapter_client.js.map +1 -1
- package/dist/market_adapter/utils/atomic_write.js +3 -5
- package/dist/market_adapter/utils/atomic_write.js.map +1 -1
- package/dist/market_adapter/utils/chain.d.ts.map +1 -1
- package/dist/market_adapter/utils/chain.js +9 -17
- package/dist/market_adapter/utils/chain.js.map +1 -1
- package/dist/market_adapter/utils/data_discovery.js +8 -10
- 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 +11 -14
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +1 -1
- package/dist/market_adapter/utils/file_lock.js +14 -19
- package/dist/market_adapter/utils/file_lock.js.map +1 -1
- package/dist/market_adapter/utils/native_history.js +8 -14
- package/dist/market_adapter/utils/native_history.js.map +1 -1
- package/dist/market_adapter/utils/paths.js +3 -6
- package/dist/market_adapter/utils/paths.js.map +1 -1
- package/dist/modules/account_bots.d.ts +1 -1
- package/dist/modules/account_bots.d.ts.map +1 -1
- package/dist/modules/account_bots.js +90 -97
- package/dist/modules/account_bots.js.map +1 -1
- package/dist/modules/account_orders.d.ts +0 -9
- package/dist/modules/account_orders.d.ts.map +1 -1
- package/dist/modules/account_orders.js +26 -121
- package/dist/modules/account_orders.js.map +1 -1
- package/dist/modules/authority_resolver.js +12 -18
- package/dist/modules/authority_resolver.js.map +1 -1
- package/dist/modules/bitshares-native/chain_client.js +16 -21
- package/dist/modules/bitshares-native/chain_client.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.js +12 -72
- package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.js +13 -40
- package/dist/modules/bitshares-native/crypto/ecc.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.js +5 -6
- package/dist/modules/bitshares-native/crypto/ecc_selector.js.map +1 -1
- package/dist/modules/bitshares-native/index.d.ts +8 -8
- package/dist/modules/bitshares-native/index.d.ts.map +1 -1
- package/dist/modules/bitshares-native/index.js +11 -68
- package/dist/modules/bitshares-native/index.js.map +1 -1
- package/dist/modules/bitshares-native/lru_cache.js +3 -6
- package/dist/modules/bitshares-native/lru_cache.js.map +1 -1
- package/dist/modules/bitshares-native/resolvers.js +9 -11
- package/dist/modules/bitshares-native/resolvers.js.map +1 -1
- package/dist/modules/bitshares-native/serial/chain_constants.js +3 -28
- package/dist/modules/bitshares-native/serial/chain_constants.js.map +1 -1
- package/dist/modules/bitshares-native/serial/index.d.ts +4 -4
- package/dist/modules/bitshares-native/serial/index.d.ts.map +1 -1
- package/dist/modules/bitshares-native/serial/index.js +5 -46
- package/dist/modules/bitshares-native/serial/index.js.map +1 -1
- package/dist/modules/bitshares-native/serial/operations.d.ts +98 -98
- package/dist/modules/bitshares-native/serial/operations.d.ts.map +1 -1
- package/dist/modules/bitshares-native/serial/operations.js +372 -473
- package/dist/modules/bitshares-native/serial/operations.js.map +1 -1
- package/dist/modules/bitshares-native/serial/serializer.js +3 -8
- package/dist/modules/bitshares-native/serial/serializer.js.map +1 -1
- package/dist/modules/bitshares-native/serial/types.js +9 -74
- package/dist/modules/bitshares-native/serial/types.js.map +1 -1
- package/dist/modules/bitshares-native/signing_client.d.ts.map +1 -1
- package/dist/modules/bitshares-native/signing_client.js +11 -48
- 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 +24 -27
- package/dist/modules/bitshares-native/subscriptions.js.map +1 -1
- package/dist/modules/bitshares-native/transport.d.ts.map +1 -1
- package/dist/modules/bitshares-native/transport.js +14 -26
- package/dist/modules/bitshares-native/transport.js.map +1 -1
- package/dist/modules/bitshares-native/tx/builder.js +29 -72
- package/dist/modules/bitshares-native/tx/builder.js.map +1 -1
- package/dist/modules/bitshares-native/tx/tx_cache.js +12 -21
- package/dist/modules/bitshares-native/tx/tx_cache.js.map +1 -1
- package/dist/modules/bitshares_client.d.ts +21 -0
- package/dist/modules/bitshares_client.d.ts.map +1 -1
- package/dist/modules/bitshares_client.js +32 -86
- 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 +30 -49
- package/dist/modules/bot_settings.js.map +1 -1
- package/dist/modules/bots_file_lock.d.ts.map +1 -1
- package/dist/modules/bots_file_lock.js +5 -13
- package/dist/modules/bots_file_lock.js.map +1 -1
- package/dist/modules/broadcast_failure.js +1 -3
- package/dist/modules/broadcast_failure.js.map +1 -1
- package/dist/modules/chain_keys.d.ts +4 -9
- package/dist/modules/chain_keys.d.ts.map +1 -1
- package/dist/modules/chain_keys.js +77 -182
- package/dist/modules/chain_keys.js.map +1 -1
- package/dist/modules/chain_orders.d.ts +2 -2
- package/dist/modules/chain_orders.d.ts.map +1 -1
- package/dist/modules/chain_orders.js +81 -144
- package/dist/modules/chain_orders.js.map +1 -1
- package/dist/modules/config.d.ts.map +1 -1
- package/dist/modules/config.js +23 -28
- package/dist/modules/config.js.map +1 -1
- package/dist/modules/constants.d.ts +2 -9
- package/dist/modules/constants.d.ts.map +1 -1
- package/dist/modules/constants.js +38 -73
- package/dist/modules/constants.js.map +1 -1
- package/dist/modules/cr_planner.js +15 -26
- package/dist/modules/cr_planner.js.map +1 -1
- package/dist/modules/credential_policy.d.ts +3 -6
- package/dist/modules/credential_policy.d.ts.map +1 -1
- package/dist/modules/credential_policy.js +62 -153
- package/dist/modules/credential_policy.js.map +1 -1
- package/dist/modules/credential_runtime.d.ts +1 -1
- package/dist/modules/credential_runtime.d.ts.map +1 -1
- package/dist/modules/credential_runtime.js +34 -41
- package/dist/modules/credential_runtime.js.map +1 -1
- package/dist/modules/credential_session_cache.d.ts +1 -1
- package/dist/modules/credential_session_cache.d.ts.map +1 -1
- package/dist/modules/credential_session_cache.js +5 -42
- package/dist/modules/credential_session_cache.js.map +1 -1
- package/dist/modules/credit_runtime.d.ts.map +1 -1
- package/dist/modules/credit_runtime.js +126 -162
- package/dist/modules/credit_runtime.js.map +1 -1
- package/dist/modules/crypto/browser_provider.d.ts +1 -1
- package/dist/modules/crypto/browser_provider.d.ts.map +1 -1
- package/dist/modules/crypto/browser_provider.js +7 -11
- package/dist/modules/crypto/browser_provider.js.map +1 -1
- package/dist/modules/crypto/index.d.ts +6 -6
- package/dist/modules/crypto/index.d.ts.map +1 -1
- package/dist/modules/crypto/index.js +12 -30
- package/dist/modules/crypto/index.js.map +1 -1
- package/dist/modules/crypto/node_provider.d.ts +1 -1
- package/dist/modules/crypto/node_provider.d.ts.map +1 -1
- package/dist/modules/crypto/node_provider.js +3 -5
- package/dist/modules/crypto/node_provider.js.map +1 -1
- package/dist/modules/crypto/provider.js +1 -2
- package/dist/modules/crypto/pure_ripemd160.js +1 -3
- package/dist/modules/crypto/pure_ripemd160.js.map +1 -1
- package/dist/modules/crypto/pure_scrypt.js +1 -4
- package/dist/modules/crypto/pure_scrypt.js.map +1 -1
- package/dist/modules/crypto/pure_secp256k1.d.ts +1 -1
- package/dist/modules/crypto/pure_secp256k1.d.ts.map +1 -1
- package/dist/modules/crypto/pure_secp256k1.js +1 -16
- package/dist/modules/crypto/pure_secp256k1.js.map +1 -1
- package/dist/modules/crypto/sync.d.ts.map +1 -1
- package/dist/modules/crypto/sync.js +16 -17
- package/dist/modules/crypto/sync.js.map +1 -1
- package/dist/modules/daemon_node_health.js +14 -16
- package/dist/modules/daemon_node_health.js.map +1 -1
- package/dist/modules/dexbot_class.d.ts +19 -14
- package/dist/modules/dexbot_class.d.ts.map +1 -1
- package/dist/modules/dexbot_class.js +127 -164
- package/dist/modules/dexbot_class.js.map +1 -1
- package/dist/modules/dexbot_cow_runtime.d.ts +28 -27
- package/dist/modules/dexbot_cow_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_cow_runtime.js +55 -45
- package/dist/modules/dexbot_cow_runtime.js.map +1 -1
- package/dist/modules/dexbot_credential_client.d.ts +6 -2
- package/dist/modules/dexbot_credential_client.d.ts.map +1 -1
- package/dist/modules/dexbot_credential_client.js +21 -31
- package/dist/modules/dexbot_credential_client.js.map +1 -1
- package/dist/modules/dexbot_fill_runtime.d.ts +23 -23
- package/dist/modules/dexbot_fill_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_fill_runtime.js +119 -77
- package/dist/modules/dexbot_fill_runtime.js.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts +46 -38
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.js +81 -81
- package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
- package/dist/modules/dexbot_startup_runtime.d.ts +3 -3
- package/dist/modules/dexbot_startup_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_startup_runtime.js +43 -81
- package/dist/modules/dexbot_startup_runtime.js.map +1 -1
- package/dist/modules/dexbot_state_recovery.d.ts +11 -11
- package/dist/modules/dexbot_state_recovery.js +32 -78
- package/dist/modules/dexbot_state_recovery.js.map +1 -1
- package/dist/modules/env.js +3 -7
- package/dist/modules/env.js.map +1 -1
- package/dist/modules/fund_registry.d.ts.map +1 -1
- package/dist/modules/fund_registry.js +12 -24
- package/dist/modules/fund_registry.js.map +1 -1
- package/dist/modules/general_settings.js +10 -16
- 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 +12 -19
- package/dist/modules/graceful_shutdown.js.map +1 -1
- package/dist/modules/key_store.d.ts.map +1 -1
- package/dist/modules/key_store.js +27 -65
- package/dist/modules/key_store.js.map +1 -1
- package/dist/modules/launcher/bot_supervisor.d.ts +1 -1
- package/dist/modules/launcher/bot_supervisor.d.ts.map +1 -1
- package/dist/modules/launcher/bot_supervisor.js +89 -118
- package/dist/modules/launcher/bot_supervisor.js.map +1 -1
- package/dist/modules/launcher/child_env.js +1 -5
- package/dist/modules/launcher/child_env.js.map +1 -1
- package/dist/modules/launcher/credential_bootstrap.js +22 -31
- package/dist/modules/launcher/credential_bootstrap.js.map +1 -1
- package/dist/modules/launcher/credential_daemon.js +37 -75
- package/dist/modules/launcher/credential_daemon.js.map +1 -1
- package/dist/modules/launcher/credential_secret.js +2 -37
- package/dist/modules/launcher/credential_secret.js.map +1 -1
- package/dist/modules/launcher/foreign_cred_daemon.js +25 -31
- package/dist/modules/launcher/foreign_cred_daemon.js.map +1 -1
- package/dist/modules/launcher/headless_password.js +10 -12
- package/dist/modules/launcher/headless_password.js.map +1 -1
- package/dist/modules/launcher/launch_modes.js +3 -9
- package/dist/modules/launcher/launch_modes.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 +25 -35
- 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 +42 -45
- package/dist/modules/launcher/market_adapter_watchdog.js.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts +1 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.js +67 -138
- package/dist/modules/launcher/monolithic_runtime.js.map +1 -1
- package/dist/modules/launcher/runtime_entry.d.ts +1 -11
- package/dist/modules/launcher/runtime_entry.d.ts.map +1 -1
- package/dist/modules/launcher/runtime_entry.js +12 -15
- package/dist/modules/launcher/runtime_entry.js.map +1 -1
- package/dist/modules/launcher/status_reporting.d.ts +1 -1
- package/dist/modules/launcher/status_reporting.d.ts.map +1 -1
- package/dist/modules/launcher/status_reporting.js +15 -36
- package/dist/modules/launcher/status_reporting.js.map +1 -1
- package/dist/modules/launcher/supervisor_control.js +4 -9
- package/dist/modules/launcher/supervisor_control.js.map +1 -1
- package/dist/modules/logger.d.ts +1 -1
- package/dist/modules/logger.d.ts.map +1 -1
- package/dist/modules/logger.js +3 -38
- package/dist/modules/logger.js.map +1 -1
- package/dist/modules/market_adapter_whitelist.js +9 -18
- package/dist/modules/market_adapter_whitelist.js.map +1 -1
- package/dist/modules/node_failure_ledger.js +1 -3
- package/dist/modules/node_failure_ledger.js.map +1 -1
- package/dist/modules/node_health_cache.d.ts.map +1 -1
- package/dist/modules/node_health_cache.js +15 -25
- package/dist/modules/node_health_cache.js.map +1 -1
- package/dist/modules/node_manager.d.ts +1 -1
- package/dist/modules/node_manager.d.ts.map +1 -1
- package/dist/modules/node_manager.js +44 -43
- package/dist/modules/node_manager.js.map +1 -1
- package/dist/modules/order/accounting.d.ts.map +1 -1
- package/dist/modules/order/accounting.js +102 -118
- package/dist/modules/order/accounting.js.map +1 -1
- package/dist/modules/order/async_lock.d.ts +3 -15
- package/dist/modules/order/async_lock.d.ts.map +1 -1
- package/dist/modules/order/async_lock.js +6 -26
- package/dist/modules/order/async_lock.js.map +1 -1
- package/dist/modules/order/export.js +34 -75
- package/dist/modules/order/export.js.map +1 -1
- package/dist/modules/order/format.d.ts +1 -3
- package/dist/modules/order/format.d.ts.map +1 -1
- package/dist/modules/order/format.js +4 -24
- package/dist/modules/order/format.js.map +1 -1
- package/dist/modules/order/grid.d.ts +3 -3
- package/dist/modules/order/grid.d.ts.map +1 -1
- package/dist/modules/order/grid.js +206 -262
- package/dist/modules/order/grid.js.map +1 -1
- package/dist/modules/order/grid_reconcile.d.ts.map +1 -1
- package/dist/modules/order/grid_reconcile.js +77 -94
- package/dist/modules/order/grid_reconcile.js.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.d.ts.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.js +117 -149
- package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
- package/dist/modules/order/index.d.ts.map +1 -1
- package/dist/modules/order/index.js +11 -45
- package/dist/modules/order/index.js.map +1 -1
- package/dist/modules/order/logger.js +28 -69
- package/dist/modules/order/logger.js.map +1 -1
- package/dist/modules/order/logger_state.d.ts.map +1 -1
- package/dist/modules/order/logger_state.js +3 -4
- package/dist/modules/order/logger_state.js.map +1 -1
- package/dist/modules/order/manager.d.ts +10 -0
- package/dist/modules/order/manager.d.ts.map +1 -1
- package/dist/modules/order/manager.js +131 -151
- package/dist/modules/order/manager.js.map +1 -1
- package/dist/modules/order/processed_fill_store.js +2 -7
- package/dist/modules/order/processed_fill_store.js.map +1 -1
- package/dist/modules/order/strategy.js +23 -25
- package/dist/modules/order/strategy.js.map +1 -1
- package/dist/modules/order/sync_engine.d.ts +27 -0
- package/dist/modules/order/sync_engine.d.ts.map +1 -1
- package/dist/modules/order/sync_engine.js +232 -181
- package/dist/modules/order/sync_engine.js.map +1 -1
- package/dist/modules/order/utils/math.d.ts +1 -25
- package/dist/modules/order/utils/math.d.ts.map +1 -1
- package/dist/modules/order/utils/math.js +49 -172
- package/dist/modules/order/utils/math.js.map +1 -1
- package/dist/modules/order/utils/order.d.ts +46 -2
- package/dist/modules/order/utils/order.d.ts.map +1 -1
- package/dist/modules/order/utils/order.js +165 -143
- package/dist/modules/order/utils/order.js.map +1 -1
- package/dist/modules/order/utils/system.d.ts +3 -1
- package/dist/modules/order/utils/system.d.ts.map +1 -1
- package/dist/modules/order/utils/system.js +152 -211
- package/dist/modules/order/utils/system.js.map +1 -1
- package/dist/modules/order/utils/timeout.js +1 -4
- package/dist/modules/order/utils/timeout.js.map +1 -1
- package/dist/modules/order/utils/validate.js +91 -142
- package/dist/modules/order/utils/validate.js.map +1 -1
- package/dist/modules/order/utils/withPoolRef.js +21 -61
- package/dist/modules/order/utils/withPoolRef.js.map +1 -1
- package/dist/modules/order/working_grid.js +6 -9
- package/dist/modules/order/working_grid.js.map +1 -1
- package/dist/modules/path_api.d.ts.map +1 -1
- package/dist/modules/path_api.js +8 -11
- package/dist/modules/path_api.js.map +1 -1
- package/dist/modules/paths.d.ts.map +1 -1
- package/dist/modules/paths.js +61 -67
- package/dist/modules/paths.js.map +1 -1
- package/dist/modules/process_discovery.js +13 -21
- package/dist/modules/process_discovery.js.map +1 -1
- package/dist/modules/runtime.js +7 -11
- package/dist/modules/runtime.js.map +1 -1
- package/dist/modules/runtime_settings.d.ts.map +1 -1
- package/dist/modules/runtime_settings.js +14 -16
- package/dist/modules/runtime_settings.js.map +1 -1
- package/dist/modules/settings_merge.js +1 -3
- package/dist/modules/settings_merge.js.map +1 -1
- package/dist/modules/socket_json_client.js +3 -5
- package/dist/modules/socket_json_client.js.map +1 -1
- package/dist/modules/storage/browser_adapter.js +1 -4
- package/dist/modules/storage/browser_adapter.js.map +1 -1
- package/dist/modules/storage/index.d.ts +3 -2
- package/dist/modules/storage/index.d.ts.map +1 -1
- package/dist/modules/storage/index.js +5 -8
- package/dist/modules/storage/index.js.map +1 -1
- package/dist/modules/storage/node_adapter.d.ts +3 -4
- package/dist/modules/storage/node_adapter.d.ts.map +1 -1
- package/dist/modules/storage/node_adapter.js +12 -16
- package/dist/modules/storage/node_adapter.js.map +1 -1
- package/dist/modules/storage/types.js +1 -2
- package/dist/modules/types.d.ts +0 -6
- package/dist/modules/types.d.ts.map +1 -1
- package/dist/modules/types.js +1 -2
- package/dist/modules/types.js.map +1 -1
- package/dist/modules/utils/base58check.js +8 -15
- package/dist/modules/utils/base58check.js.map +1 -1
- package/dist/modules/utils/build_dir.js +3 -7
- package/dist/modules/utils/build_dir.js.map +1 -1
- package/dist/modules/utils/errors.js +1 -5
- package/dist/modules/utils/errors.js.map +1 -1
- package/dist/modules/utils/math_utils.d.ts +1 -1
- package/dist/modules/utils/math_utils.d.ts.map +1 -1
- package/dist/modules/utils/math_utils.js +2 -7
- package/dist/modules/utils/math_utils.js.map +1 -1
- package/dist/modules/validate_profiles.d.ts.map +1 -1
- package/dist/modules/validate_profiles.js +18 -25
- package/dist/modules/validate_profiles.js.map +1 -1
- package/dist/pm2.d.ts +4 -70
- package/dist/pm2.d.ts.map +1 -1
- package/dist/pm2.js +106 -132
- package/dist/pm2.js.map +1 -1
- package/dist/scripts/analyze-git.js +13 -17
- package/dist/scripts/analyze-git.js.map +1 -1
- package/dist/scripts/analyze-orders.d.ts.map +1 -1
- package/dist/scripts/analyze-orders.js +48 -63
- package/dist/scripts/analyze-orders.js.map +1 -1
- package/dist/scripts/diagnose-kibana-candles.d.ts.map +1 -1
- package/dist/scripts/diagnose-kibana-candles.js +2 -1
- package/dist/scripts/diagnose-kibana-candles.js.map +1 -1
- package/dist/scripts/diagnose-pool-history.d.ts.map +1 -1
- package/dist/scripts/diagnose-pool-history.js +2 -1
- package/dist/scripts/diagnose-pool-history.js.map +1 -1
- package/dist/scripts/divergence-calc.d.ts.map +1 -1
- package/dist/scripts/divergence-calc.js +2 -2
- package/dist/scripts/divergence-calc.js.map +1 -1
- package/dist/scripts/fix-err-message.js +17 -22
- package/dist/scripts/fix-err-message.js.map +1 -1
- package/dist/scripts/generate_lp_chart.d.ts.map +1 -1
- package/dist/scripts/generate_lp_chart.js +7 -15
- package/dist/scripts/generate_lp_chart.js.map +1 -1
- package/dist/scripts/generate_mainnet_corpus_report.d.ts.map +1 -1
- package/dist/scripts/generate_mainnet_corpus_report.js +3 -2
- package/dist/scripts/generate_mainnet_corpus_report.js.map +1 -1
- package/dist/scripts/generate_market_adapter_whitelist.d.ts.map +1 -1
- package/dist/scripts/generate_market_adapter_whitelist.js +18 -24
- package/dist/scripts/generate_market_adapter_whitelist.js.map +1 -1
- package/dist/scripts/native_release_gates.js +15 -19
- package/dist/scripts/native_release_gates.js.map +1 -1
- package/dist/scripts/print_grid.d.ts.map +1 -1
- package/dist/scripts/print_grid.js +2 -2
- package/dist/scripts/print_grid.js.map +1 -1
- package/dist/scripts/run-tests.js +12 -17
- package/dist/scripts/run-tests.js.map +1 -1
- package/dist/scripts/runner.d.ts.map +1 -1
- package/dist/scripts/runner.js +18 -20
- package/dist/scripts/runner.js.map +1 -1
- package/dist/scripts/sync-version.js +2 -2
- package/dist/scripts/sync-version.js.map +1 -1
- package/dist/scripts/test-credit-renewal.d.ts.map +1 -1
- package/dist/scripts/test-credit-renewal.js +4 -3
- package/dist/scripts/test-credit-renewal.js.map +1 -1
- package/dist/scripts/update.js +77 -89
- package/dist/scripts/update.js.map +1 -1
- package/dist/scripts/validate_bots.d.ts.map +1 -1
- package/dist/scripts/validate_bots.js +2 -2
- package/dist/scripts/validate_bots.js.map +1 -1
- package/dist/scripts/verify-browser-bundle.js +12 -17
- package/dist/scripts/verify-browser-bundle.js.map +1 -1
- package/dist/unlock.d.ts +0 -30
- package/dist/unlock.d.ts.map +1 -1
- package/dist/unlock.js +95 -143
- package/dist/unlock.js.map +1 -1
- package/package.json +5 -8
- package/scripts/README.md +1 -1
- package/scripts/create-bot-symlinks.sh +2 -2
- package/dist/modules/utils/fs_utils.d.ts +0 -18
- package/dist/modules/utils/fs_utils.d.ts.map +0 -1
- package/dist/modules/utils/fs_utils.js +0 -32
- package/dist/modules/utils/fs_utils.js.map +0 -1
- package/dist/scripts/migrate_bot_keys.d.ts +0 -3
- package/dist/scripts/migrate_bot_keys.d.ts.map +0 -1
- package/dist/scripts/migrate_bot_keys.js +0 -225
- package/dist/scripts/migrate_bot_keys.js.map +0 -1
|
@@ -1,31 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const chain_1 = require("../utils/chain");
|
|
12
|
-
const regime_gate_1 = require("./strategies/regime_gate");
|
|
13
|
-
const ama_1 = require("./strategies/ama");
|
|
14
|
-
const kalman_trend_analyzer_1 = require("../../analysis/trend_detection/kalman_trend_analyzer");
|
|
15
|
-
const collateral_manager_1 = require("./strategies/collateral_manager");
|
|
16
|
-
const constants_1 = require("../../modules/constants");
|
|
17
|
-
const order_1 = require("../../modules/order/utils/order");
|
|
18
|
-
const logger_1 = __importDefault(require("../../modules/logger"));
|
|
19
|
-
const math_utils_1 = require("../../modules/utils/math_utils");
|
|
1
|
+
import { calculateATR } from './strategies/atr/calculator.js';
|
|
2
|
+
import { normalizeMarketSource, hasNumericStartPrice, resolveMarketSourceForBot } from '../utils/chain.js';
|
|
3
|
+
import { computeRegimeMultiplier } from './strategies/regime_gate.js';
|
|
4
|
+
import { calculateAMA, getAmaWarmupBars } from './strategies/ama.js';
|
|
5
|
+
import { KalmanTrendAnalyzer } from '../../analysis/trend_detection/kalman_trend_analyzer.js';
|
|
6
|
+
import { adjustCollateralRatio } from './strategies/collateral_manager.js';
|
|
7
|
+
import { DEFAULT_CONFIG, MARKET_ADAPTER } from '../../modules/constants.js';
|
|
8
|
+
import { resolveConfiguredPriceBound } from '../../modules/order/utils/order.js';
|
|
9
|
+
import Logger from '../../modules/logger.js';
|
|
10
|
+
import { roundTo } from '../../modules/utils/math_utils.js';
|
|
20
11
|
'use strict';
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const marketAdapterServiceLogger = new
|
|
12
|
+
import { computeAmaSlopeWeights, computeAverageAmaSlopePct, } from './strategies/ama_slope_model.js';
|
|
13
|
+
import { normalizeAtrPeriod, normalizeMaxVolatilityOffset, normalizeVolatilityThreshold, } from './config_normalizers.js';
|
|
14
|
+
import { buildKalmanVelocitySeries, computeAbsolutePercentileThreshold, } from '../../analysis/trend_detection/kalman_velocity_smoothing.js';
|
|
15
|
+
import { resolveMaxAsymmetryFactor, computeAsymmetricBoundsMetrics, } from './asymmetric_bounds.js';
|
|
16
|
+
import { getErrorMessage } from '../../modules/utils/errors.js';
|
|
17
|
+
const marketAdapterServiceLogger = new Logger('MarketAdapterService');
|
|
27
18
|
const AMA_SLOPE_PERCENT_MODE_PER_BAR = 'perBar';
|
|
28
|
-
exports.AMA_SLOPE_PERCENT_MODE_PER_BAR = AMA_SLOPE_PERCENT_MODE_PER_BAR;
|
|
29
19
|
const AMA_SLOPE_PERCENT_MODE_WINDOW = 'window';
|
|
30
20
|
function normalizeAmaSlopePercentMode(value) {
|
|
31
21
|
const text = String(value || '').trim().toLowerCase();
|
|
@@ -37,7 +27,7 @@ function normalizeAmaSlopePercentMode(value) {
|
|
|
37
27
|
}
|
|
38
28
|
return null;
|
|
39
29
|
}
|
|
40
|
-
function normalizeAmaSlopeLookbackBars(value, fallback =
|
|
30
|
+
function normalizeAmaSlopeLookbackBars(value, fallback = MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_LOOKBACK_BARS) {
|
|
41
31
|
const n = Number(value);
|
|
42
32
|
if (Number.isFinite(n) && n > 0)
|
|
43
33
|
return Math.ceil(n);
|
|
@@ -79,7 +69,7 @@ function computeGridPriceOffsetPlan(bot, amaSlope) {
|
|
|
79
69
|
const targetSpreadPercentRaw = Number(bot?.targetSpreadPercent);
|
|
80
70
|
const targetSpreadPercent = Number.isFinite(targetSpreadPercentRaw) && targetSpreadPercentRaw > 0
|
|
81
71
|
? targetSpreadPercentRaw
|
|
82
|
-
: Number(
|
|
72
|
+
: Number(DEFAULT_CONFIG.targetSpreadPercent);
|
|
83
73
|
const maxGridPriceOffsetPct = targetSpreadPercent / 2;
|
|
84
74
|
const trend = amaSlope?.trend;
|
|
85
75
|
const rawSlopeOffset = Number(amaSlope?.rawSlopeOffset);
|
|
@@ -91,14 +81,14 @@ function computeGridPriceOffsetPlan(bot, amaSlope) {
|
|
|
91
81
|
? Math.min(directionalSlope / maxSlopeOffset, 1)
|
|
92
82
|
: 0;
|
|
93
83
|
const direction = trend === 'UP' ? 1 : trend === 'DOWN' ? -1 : 0;
|
|
94
|
-
const gridPriceOffsetPct =
|
|
84
|
+
const gridPriceOffsetPct = roundTo(direction * slopeRatio * maxGridPriceOffsetPct, 1e6) || 0;
|
|
95
85
|
return {
|
|
96
86
|
trend: trend || 'NEUTRAL',
|
|
97
87
|
rawSlopeOffset: Number.isFinite(rawSlopeOffset) ? rawSlopeOffset : null,
|
|
98
88
|
maxSlopeOffset: Number.isFinite(maxSlopeOffset) ? maxSlopeOffset : null,
|
|
99
|
-
slopeRatio:
|
|
100
|
-
targetSpreadPercent:
|
|
101
|
-
maxGridPriceOffsetPct:
|
|
89
|
+
slopeRatio: roundTo(slopeRatio, 1e6) || 0,
|
|
90
|
+
targetSpreadPercent: roundTo(targetSpreadPercent, 1e6),
|
|
91
|
+
maxGridPriceOffsetPct: roundTo(maxGridPriceOffsetPct, 1e6),
|
|
102
92
|
gridPriceOffsetPct,
|
|
103
93
|
};
|
|
104
94
|
}
|
|
@@ -172,7 +162,7 @@ class MarketAdapterService {
|
|
|
172
162
|
: 1;
|
|
173
163
|
const maxCandles = Number.isFinite(cfg?.maxNativeGapFillCandles)
|
|
174
164
|
? cfg.maxNativeGapFillCandles
|
|
175
|
-
:
|
|
165
|
+
: MARKET_ADAPTER.STALE_TAIL_THRESHOLD_CANDLES;
|
|
176
166
|
// Include the candle before and after the missing run so Kibana repair
|
|
177
167
|
// does not truncate a valid threshold-sized gap while still respecting
|
|
178
168
|
// the configured "trust native no-trade up to N candles" threshold.
|
|
@@ -181,7 +171,7 @@ class MarketAdapterService {
|
|
|
181
171
|
getTrustedNoTradeGapThresholdCandles(cfg) {
|
|
182
172
|
return Number.isFinite(cfg?.maxNativeGapFillCandles)
|
|
183
173
|
? cfg.maxNativeGapFillCandles
|
|
184
|
-
:
|
|
174
|
+
: MARKET_ADAPTER.STALE_TAIL_THRESHOLD_CANDLES;
|
|
185
175
|
}
|
|
186
176
|
fillNativeIncrementalClosedGaps(candles, previousLastTs, intervalSeconds, nowMs = this.getNowMs()) {
|
|
187
177
|
const deps = this.deps;
|
|
@@ -344,29 +334,29 @@ class MarketAdapterService {
|
|
|
344
334
|
return centerPrice;
|
|
345
335
|
try {
|
|
346
336
|
const startPrice = Number.isFinite(ref) && ref > 0 ? ref : base;
|
|
347
|
-
const minP =
|
|
348
|
-
const maxP =
|
|
337
|
+
const minP = resolveConfiguredPriceBound(bot?.minPrice, DEFAULT_CONFIG.minPrice, startPrice, 'min') ?? 0;
|
|
338
|
+
const maxP = resolveConfiguredPriceBound(bot?.maxPrice, DEFAULT_CONFIG.maxPrice, startPrice, 'max') ?? 0;
|
|
349
339
|
if (!Number.isFinite(minP) || !Number.isFinite(maxP))
|
|
350
340
|
return base;
|
|
351
341
|
return Math.min(maxP, Math.max(minP, base));
|
|
352
342
|
}
|
|
353
343
|
catch (err) {
|
|
354
|
-
throw new Error(`clampGridPriceToBounds: failed to resolve bounds: ${
|
|
344
|
+
throw new Error(`clampGridPriceToBounds: failed to resolve bounds: ${getErrorMessage(err)}`);
|
|
355
345
|
}
|
|
356
346
|
}
|
|
357
347
|
computeAppliedAsymmetryMetrics(bot, centerPrice, dynamicWeights) {
|
|
358
|
-
const maxAsymmetryFactor =
|
|
348
|
+
const maxAsymmetryFactor = resolveMaxAsymmetryFactor(bot?.asymmetricBounds?.maxAsymmetryFactor, dynamicWeights?.maxAsymmetryFactor, MARKET_ADAPTER.ASYMMETRIC_BOUNDS_MAX_ASYMMETRY_FACTOR);
|
|
359
349
|
let minP = null;
|
|
360
350
|
let maxP = null;
|
|
361
351
|
try {
|
|
362
|
-
minP =
|
|
363
|
-
maxP =
|
|
352
|
+
minP = resolveConfiguredPriceBound(bot?.minPrice, DEFAULT_CONFIG.minPrice, centerPrice, 'min');
|
|
353
|
+
maxP = resolveConfiguredPriceBound(bot?.maxPrice, DEFAULT_CONFIG.maxPrice, centerPrice, 'max');
|
|
364
354
|
}
|
|
365
355
|
catch (_) {
|
|
366
356
|
// Intentional: if bound resolution fails, minP/maxP stay null.
|
|
367
357
|
// computeAsymmetricBoundsMetrics handles null bounds with safe defaults.
|
|
368
358
|
}
|
|
369
|
-
return
|
|
359
|
+
return computeAsymmetricBoundsMetrics({
|
|
370
360
|
centerPrice,
|
|
371
361
|
minPrice: minP,
|
|
372
362
|
maxPrice: maxP,
|
|
@@ -536,16 +526,16 @@ class MarketAdapterService {
|
|
|
536
526
|
}
|
|
537
527
|
_computeDynamicWeights(params) {
|
|
538
528
|
const { closes, amaValues, lookbackBars, botAma, weightVariance, nowIso, cfg, bot, atrPeriod } = params;
|
|
539
|
-
const clipPercentile = cfg.clipPercentile ??
|
|
540
|
-
const nz = cfg.amaSlope?.neutralZonePct ??
|
|
541
|
-
const amaMaxS = cfg.amaSlope?.maxSlopePct ??
|
|
529
|
+
const clipPercentile = cfg.clipPercentile ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_CLIP_PERCENTILE;
|
|
530
|
+
const nz = cfg.amaSlope?.neutralZonePct ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_NEUTRAL_ZONE_PCT;
|
|
531
|
+
const amaMaxS = cfg.amaSlope?.maxSlopePct ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_MAX_SLOPE_PCT;
|
|
542
532
|
const kalMaxS = cfg.kalmanSlope?.maxSlopePct
|
|
543
|
-
??
|
|
544
|
-
const mo = cfg.maxSlopeOffset ??
|
|
545
|
-
const volatilityClamp =
|
|
546
|
-
const volatilityThreshold =
|
|
547
|
-
const volatilityExponent = cfg.volatilityExponent ??
|
|
548
|
-
const volatilityScaleX = cfg.volatilityScaleX ??
|
|
533
|
+
?? MARKET_ADAPTER.DYNAMIC_WEIGHT_KALMAN_MAX_SLOPE_PCT;
|
|
534
|
+
const mo = cfg.maxSlopeOffset ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_ASYMMETRIC_OFFSET_CLAMP;
|
|
535
|
+
const volatilityClamp = normalizeMaxVolatilityOffset(cfg.maxVolatilityOffset);
|
|
536
|
+
const volatilityThreshold = normalizeVolatilityThreshold(cfg.volatilityThreshold);
|
|
537
|
+
const volatilityExponent = cfg.volatilityExponent ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_VOLATILITY_EXPONENT;
|
|
538
|
+
const volatilityScaleX = cfg.volatilityScaleX ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_VOLATILITY_SCALE_X_DEFAULT;
|
|
549
539
|
// Compute separate clip thresholds for AMA (slopes) and Kalman (velocities)
|
|
550
540
|
let amaClipThreshold = Infinity;
|
|
551
541
|
let kalClipThreshold = Infinity;
|
|
@@ -557,7 +547,7 @@ class MarketAdapterService {
|
|
|
557
547
|
for (let i = amaSlopeReadyBars; i < amaValues.length; i++) {
|
|
558
548
|
const last = amaValues[i];
|
|
559
549
|
const past = amaValues[i - lookbackBars];
|
|
560
|
-
const slopePct =
|
|
550
|
+
const slopePct = computeAverageAmaSlopePct(last, past, lookbackBars);
|
|
561
551
|
if (Number.isFinite(slopePct))
|
|
562
552
|
amaSlopes.push(Math.abs(slopePct));
|
|
563
553
|
}
|
|
@@ -581,12 +571,12 @@ class MarketAdapterService {
|
|
|
581
571
|
clipPercentile,
|
|
582
572
|
clipThreshold: amaClipThreshold,
|
|
583
573
|
};
|
|
584
|
-
const slopeResult =
|
|
574
|
+
const slopeResult = computeAmaSlopeWeights(amaValues, weightVariance, slopeCfg);
|
|
585
575
|
// Kalman filter computation - collect per-bar results in single pass
|
|
586
|
-
const kalman = new
|
|
587
|
-
rNoise: cfg.kalman?.rNoise ??
|
|
588
|
-
qTactical: cfg.kalman?.qTactical ??
|
|
589
|
-
qModal: cfg.kalman?.qModal ??
|
|
576
|
+
const kalman = new KalmanTrendAnalyzer({
|
|
577
|
+
rNoise: cfg.kalman?.rNoise ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_KALMAN_R_NOISE_DEFAULT,
|
|
578
|
+
qTactical: cfg.kalman?.qTactical ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_KALMAN_Q_TACTICAL_DEFAULT,
|
|
579
|
+
qModal: cfg.kalman?.qModal ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_KALMAN_Q_MODAL_DEFAULT,
|
|
590
580
|
warmupBars: cfg.kalman?.warmupBars ?? 20,
|
|
591
581
|
});
|
|
592
582
|
const kalmanHistory = [];
|
|
@@ -597,13 +587,13 @@ class MarketAdapterService {
|
|
|
597
587
|
const kalmanResult = kalmanHistory[kalmanHistory.length - 1];
|
|
598
588
|
const kalmanWarmupBars = kalman.warmupBars ?? 20;
|
|
599
589
|
// Regime gate (Hurst + PE bilinear multiplier)
|
|
600
|
-
const regimeSensitivity = cfg.regimeSensitivity ??
|
|
601
|
-
const absoluteThreshold = cfg.absoluteThreshold ??
|
|
590
|
+
const regimeSensitivity = cfg.regimeSensitivity ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_REGIME_SENSITIVITY;
|
|
591
|
+
const absoluteThreshold = cfg.absoluteThreshold ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_ABSOLUTE_THRESHOLD_DEFAULT;
|
|
602
592
|
let regimeResult = null;
|
|
603
593
|
let regimeMultiplier = 1.0;
|
|
604
594
|
const regimeMultipliers = new Array(closes.length).fill(1.0);
|
|
605
595
|
if (regimeSensitivity > 0) {
|
|
606
|
-
regimeResult =
|
|
596
|
+
regimeResult = computeRegimeMultiplier(closes, {
|
|
607
597
|
regimeSensitivity,
|
|
608
598
|
regimeTable: cfg.regimeTable,
|
|
609
599
|
hurstZoneBand: cfg.hurstZoneBand,
|
|
@@ -619,17 +609,17 @@ class MarketAdapterService {
|
|
|
619
609
|
}
|
|
620
610
|
}
|
|
621
611
|
}
|
|
622
|
-
const alpha = cfg.alpha ??
|
|
623
|
-
const dw = cfg.dw ??
|
|
624
|
-
const gain = cfg.gain ??
|
|
625
|
-
const kalmanSmoothPct = cfg.kalmanSmoothPct ??
|
|
626
|
-
const kalmanDispScaleMult = cfg.kalmanDispScaleMult ??
|
|
627
|
-
const kalmanDispThresholdMult = cfg.kalmanDispThresholdMult ??
|
|
628
|
-
const kalmanSmoothSpanPct = cfg.kalmanSmoothSpanPct ??
|
|
629
|
-
const signalConfirmBars = cfg.signalConfirmBars ??
|
|
612
|
+
const alpha = cfg.alpha ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_ALPHA;
|
|
613
|
+
const dw = cfg.dw ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_DW;
|
|
614
|
+
const gain = cfg.gain ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_GAIN;
|
|
615
|
+
const kalmanSmoothPct = cfg.kalmanSmoothPct ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_KALMAN_SMOOTH_PCT_DEFAULT;
|
|
616
|
+
const kalmanDispScaleMult = cfg.kalmanDispScaleMult ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_KALMAN_DISP_SCALE_MULT_DEFAULT;
|
|
617
|
+
const kalmanDispThresholdMult = cfg.kalmanDispThresholdMult ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_KALMAN_DISP_THRESHOLD_MULT_DEFAULT;
|
|
618
|
+
const kalmanSmoothSpanPct = cfg.kalmanSmoothSpanPct ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_KALMAN_SMOOTH_SPAN_PCT_DEFAULT;
|
|
619
|
+
const signalConfirmBars = cfg.signalConfirmBars ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_SIGNAL_CONFIRM_BARS_DEFAULT;
|
|
630
620
|
const minOutputThreshold = cfg.minOutputThreshold
|
|
631
|
-
??
|
|
632
|
-
const dispScaleMinPct = cfg.dispScaleMinPct ??
|
|
621
|
+
?? MARKET_ADAPTER.DYNAMIC_WEIGHT_ASYMMETRIC_TREND_THRESHOLD;
|
|
622
|
+
const dispScaleMinPct = cfg.dispScaleMinPct ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_DISP_SCALE_MIN_PCT;
|
|
633
623
|
const hasDirectionalOffset = mo > 0;
|
|
634
624
|
const useAmaBlend = hasDirectionalOffset && alpha !== 0;
|
|
635
625
|
const useKalmanBlend = hasDirectionalOffset && alpha !== 1;
|
|
@@ -640,14 +630,14 @@ class MarketAdapterService {
|
|
|
640
630
|
let amaOffsets = new Array(closes.length).fill(0);
|
|
641
631
|
let kalmanOffsets = new Array(closes.length).fill(0);
|
|
642
632
|
if (useKalmanBlend) {
|
|
643
|
-
kalmanSmoothedVelocityPct =
|
|
633
|
+
kalmanSmoothedVelocityPct = buildKalmanVelocitySeries(kalmanHistory, {
|
|
644
634
|
kalmanSmoothPct,
|
|
645
635
|
kalmanDispScaleMult,
|
|
646
636
|
kalmanDispThresholdMult,
|
|
647
637
|
kalmanSmoothSpanPct,
|
|
648
638
|
});
|
|
649
639
|
kalClipThreshold = useClipThreshold
|
|
650
|
-
?
|
|
640
|
+
? computeAbsolutePercentileThreshold(kalmanSmoothedVelocityPct.slice(kalmanWarmupBars), clipPercentile, Infinity)
|
|
651
641
|
: Infinity;
|
|
652
642
|
for (let i = 0; i < kalmanHistory.length; i++) {
|
|
653
643
|
const kr = kalmanHistory[i];
|
|
@@ -673,7 +663,7 @@ class MarketAdapterService {
|
|
|
673
663
|
const past = amaValues[i - lookbackBars];
|
|
674
664
|
if (!Number.isFinite(last) || !Number.isFinite(past) || past === 0)
|
|
675
665
|
continue;
|
|
676
|
-
const sp =
|
|
666
|
+
const sp = computeAverageAmaSlopePct(last, past, lookbackBars);
|
|
677
667
|
if (!Number.isFinite(sp))
|
|
678
668
|
continue;
|
|
679
669
|
const csp = Math.max(-amaClipThreshold, Math.min(amaClipThreshold, sp));
|
|
@@ -682,7 +672,7 @@ class MarketAdapterService {
|
|
|
682
672
|
: 0;
|
|
683
673
|
}
|
|
684
674
|
}
|
|
685
|
-
const offsetClamp = cfg.maxSlopeOffset ??
|
|
675
|
+
const offsetClamp = cfg.maxSlopeOffset ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_ASYMMETRIC_OFFSET_CLAMP;
|
|
686
676
|
const channelNorm = Math.max(Math.abs(offsetClamp), 1e-9);
|
|
687
677
|
const outputThreshold = minOutputThreshold;
|
|
688
678
|
const outputThresholdIsZero = zeroOutputThreshold;
|
|
@@ -708,7 +698,7 @@ class MarketAdapterService {
|
|
|
708
698
|
: (Math.abs(regimeAdjusted) < outputThreshold ? 0 : regimeAdjusted);
|
|
709
699
|
const off = Math.max(-offsetClamp, Math.min(offsetClamp, gatedOff * gain));
|
|
710
700
|
gatedOffSeries[i] = gatedOff;
|
|
711
|
-
combinedOffSeries[i] =
|
|
701
|
+
combinedOffSeries[i] = roundTo(off, 1000);
|
|
712
702
|
}
|
|
713
703
|
const confirmBars = Math.max(0, Math.min(5, Math.round(signalConfirmBars)));
|
|
714
704
|
let echoedOffSeries = new Array(closes.length).fill(0);
|
|
@@ -758,7 +748,7 @@ class MarketAdapterService {
|
|
|
758
748
|
const finalOff = echoedOffSeries[echoedOffSeries.length - 1] ?? rawFinalOff;
|
|
759
749
|
const lastAmaOffset = useAmaBlend ? (amaOffsets[amaOffsets.length - 1] ?? 0) : 0;
|
|
760
750
|
const amaSlopeGated = slopeResult.isReady
|
|
761
|
-
?
|
|
751
|
+
? roundTo(alpha * (lastAmaOffset / channelNorm) * gain * regimeMultiplier, 1000)
|
|
762
752
|
: 0;
|
|
763
753
|
const amaSlope = {
|
|
764
754
|
trend: slopeResult.trend,
|
|
@@ -792,14 +782,14 @@ class MarketAdapterService {
|
|
|
792
782
|
};
|
|
793
783
|
const staticSell = bot.weightDistribution.sell;
|
|
794
784
|
const staticBuy = bot.weightDistribution.buy;
|
|
795
|
-
const MIN_W =
|
|
796
|
-
const MAX_W =
|
|
785
|
+
const MIN_W = MARKET_ADAPTER.DYNAMIC_WEIGHT_MIN_WEIGHT;
|
|
786
|
+
const MAX_W = MARKET_ADAPTER.DYNAMIC_WEIGHT_MAX_WEIGHT;
|
|
797
787
|
const clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, v));
|
|
798
788
|
const belowMinOutputThreshold = Math.abs(finalPreGainOff) < outputThreshold;
|
|
799
789
|
const volPenalty = slopeResult.isReady ? (slopeResult.symmetricDelta ?? 0) : 0;
|
|
800
790
|
const trendOff = belowMinOutputThreshold ? 0 : finalOff;
|
|
801
|
-
const effectiveSell =
|
|
802
|
-
const effectiveBuy =
|
|
791
|
+
const effectiveSell = roundTo(clamp(staticSell - trendOff + volPenalty, MIN_W, MAX_W), 100);
|
|
792
|
+
const effectiveBuy = roundTo(clamp(staticBuy + trendOff + volPenalty, MIN_W, MAX_W), 100);
|
|
803
793
|
const weights = {
|
|
804
794
|
sell: effectiveSell,
|
|
805
795
|
buy: effectiveBuy,
|
|
@@ -928,7 +918,7 @@ class MarketAdapterService {
|
|
|
928
918
|
if ((!bot.assetA && !bot.assetAId) || (!bot.assetB && !bot.assetBId)) {
|
|
929
919
|
return { ok: false, reason: 'missing asset pair' };
|
|
930
920
|
}
|
|
931
|
-
if (
|
|
921
|
+
if (hasNumericStartPrice(bot?.startPrice)) {
|
|
932
922
|
const nowIso = new Date().toISOString();
|
|
933
923
|
const thresholdPercent = typeof deps.calculateBotThreshold === 'function'
|
|
934
924
|
? deps.calculateBotThreshold(cfg)
|
|
@@ -969,12 +959,12 @@ class MarketAdapterService {
|
|
|
969
959
|
const existing = deps.loadJson(filePath, null);
|
|
970
960
|
const existingMeta = existing?.meta && typeof existing.meta === 'object' ? existing.meta : {};
|
|
971
961
|
let existingCandles = Array.isArray(existing?.candles) ? existing.candles : [];
|
|
972
|
-
const existingMarketSource =
|
|
973
|
-
const marketSource =
|
|
962
|
+
const existingMarketSource = normalizeMarketSource(existingMeta.marketSource);
|
|
963
|
+
const marketSource = resolveMarketSourceForBot(bot) || 'pool';
|
|
974
964
|
const isBookSource = marketSource === 'book';
|
|
975
965
|
const kibanaRequestTimeoutMs = Number.isFinite(cfg.kibanaRequestTimeoutMs) && cfg.kibanaRequestTimeoutMs > 0
|
|
976
966
|
? cfg.kibanaRequestTimeoutMs
|
|
977
|
-
:
|
|
967
|
+
: MARKET_ADAPTER.KIBANA_REQUEST_TIMEOUT_MS;
|
|
978
968
|
const fetchKibanaCandles = async (options = {}) => {
|
|
979
969
|
const kibanaOptions = {
|
|
980
970
|
timeout: kibanaRequestTimeoutMs,
|
|
@@ -982,7 +972,7 @@ class MarketAdapterService {
|
|
|
982
972
|
};
|
|
983
973
|
if (isBookSource) {
|
|
984
974
|
if (!deps.kibanaMarketSource || typeof deps.kibanaMarketSource.getMarketCandles !== 'function') {
|
|
985
|
-
throw new Error('
|
|
975
|
+
throw new Error('order book candle source unavailable');
|
|
986
976
|
}
|
|
987
977
|
return deps.kibanaMarketSource.getMarketCandles(ctx.assetA, ctx.assetB, kibanaOptions);
|
|
988
978
|
}
|
|
@@ -1063,7 +1053,7 @@ class MarketAdapterService {
|
|
|
1063
1053
|
if (existingCandles.length > 0) {
|
|
1064
1054
|
const staleThreshold = Number.isFinite(cfg.staleTailThreshold)
|
|
1065
1055
|
? cfg.staleTailThreshold
|
|
1066
|
-
:
|
|
1056
|
+
: MARKET_ADAPTER.STALE_TAIL_THRESHOLD_CANDLES;
|
|
1067
1057
|
const verified = await verifyAndPruneStaleTail(existingCandles, staleThreshold, staleTailVerifiedRangeFromMeta());
|
|
1068
1058
|
existingCandles = verified.candles;
|
|
1069
1059
|
applyStaleTailVerificationMeta(verified);
|
|
@@ -1080,7 +1070,7 @@ class MarketAdapterService {
|
|
|
1080
1070
|
existingMeta.staleTailVerifiedEndTs = null;
|
|
1081
1071
|
}
|
|
1082
1072
|
const needBootstrap = existingCandles.length === 0;
|
|
1083
|
-
const amaWarmupBars =
|
|
1073
|
+
const amaWarmupBars = getAmaWarmupBars(botAma.erPeriod, botAma.slowPeriod, lookbackBars, botAma.fastPeriod, botAma.erSmoothPeriod ?? 0);
|
|
1084
1074
|
const analysisKeepCount = amaWarmupBars + 1;
|
|
1085
1075
|
// Retain one extra raw candle so the closed-candle analysis window still keeps a
|
|
1086
1076
|
// full warmup/history set when the newest bucket is the current in-progress bar.
|
|
@@ -1225,11 +1215,11 @@ class MarketAdapterService {
|
|
|
1225
1215
|
consolidateByTimestamp: true,
|
|
1226
1216
|
fillGapsToRequestedRange: false,
|
|
1227
1217
|
apiKey: null,
|
|
1228
|
-
}), cfg.sourceRetries, cfg.retryDelayMs, 'kibana
|
|
1218
|
+
}), cfg.sourceRetries, cfg.retryDelayMs, 'kibana order book bootstrap failed');
|
|
1229
1219
|
}
|
|
1230
1220
|
catch (_) {
|
|
1231
1221
|
if (typeof deps.logger?.warn === 'function')
|
|
1232
|
-
deps.logger.warn(`[market_adapter] ${ctx.botKey}: kibana
|
|
1222
|
+
deps.logger.warn(`[market_adapter] ${ctx.botKey}: kibana order book bootstrap failed`);
|
|
1233
1223
|
}
|
|
1234
1224
|
if (Array.isArray(kibanaCandles) && kibanaCandles.length > 0) {
|
|
1235
1225
|
nextCandles = kibanaCandles;
|
|
@@ -1254,7 +1244,7 @@ class MarketAdapterService {
|
|
|
1254
1244
|
sourceLabel = 'native-book-bootstrap';
|
|
1255
1245
|
}
|
|
1256
1246
|
else {
|
|
1257
|
-
throw new Error('both kibana and native
|
|
1247
|
+
throw new Error('both kibana and native order book bootstrap failed');
|
|
1258
1248
|
}
|
|
1259
1249
|
}
|
|
1260
1250
|
}
|
|
@@ -1290,7 +1280,7 @@ class MarketAdapterService {
|
|
|
1290
1280
|
: 0;
|
|
1291
1281
|
const maxNativeGapFill = Number.isFinite(cfg.maxNativeGapFillCandles)
|
|
1292
1282
|
? cfg.maxNativeGapFillCandles
|
|
1293
|
-
:
|
|
1283
|
+
: MARKET_ADAPTER.STALE_TAIL_THRESHOLD_CANDLES;
|
|
1294
1284
|
if (gapBuckets > maxNativeGapFill) {
|
|
1295
1285
|
const verifiedSilence = await verifyAndFillLongSilence(nextCandles, lastTs, latestClosedBucketTs, sourceLabel, nativeCandles);
|
|
1296
1286
|
nextCandles = verifiedSilence.candles;
|
|
@@ -1304,7 +1294,7 @@ class MarketAdapterService {
|
|
|
1304
1294
|
if (nextCandles.length > 0) {
|
|
1305
1295
|
const staleThreshold = Number.isFinite(cfg.staleTailThreshold)
|
|
1306
1296
|
? cfg.staleTailThreshold
|
|
1307
|
-
:
|
|
1297
|
+
: MARKET_ADAPTER.STALE_TAIL_THRESHOLD_CANDLES;
|
|
1308
1298
|
const verified = await verifyAndPruneStaleTail(nextCandles, staleThreshold, staleTailVerifiedRangeFromMeta());
|
|
1309
1299
|
nextCandles = verified.candles;
|
|
1310
1300
|
applyStaleTailVerificationMeta(verified);
|
|
@@ -1418,7 +1408,7 @@ class MarketAdapterService {
|
|
|
1418
1408
|
}
|
|
1419
1409
|
catch (overlapErr) {
|
|
1420
1410
|
if (typeof deps.logger?.log === 'function') {
|
|
1421
|
-
deps.logger.log(`[market_adapter] ${bot.botKey}: overlap fetch exhausted (${
|
|
1411
|
+
deps.logger.log(`[market_adapter] ${bot.botKey}: overlap fetch exhausted (${getErrorMessage(overlapErr)}), falling back to time-based`, 'warn');
|
|
1422
1412
|
}
|
|
1423
1413
|
// Fall through to time-based path below
|
|
1424
1414
|
}
|
|
@@ -1471,7 +1461,7 @@ class MarketAdapterService {
|
|
|
1471
1461
|
}
|
|
1472
1462
|
catch (err) {
|
|
1473
1463
|
if (typeof deps.logger?.warn === 'function') {
|
|
1474
|
-
deps.logger.warn(`[market_adapter] Native fetch failed for ${bot.botKey}; continuing with cached candles (${
|
|
1464
|
+
deps.logger.warn(`[market_adapter] Native fetch failed for ${bot.botKey}; continuing with cached candles (${getErrorMessage(err)})`);
|
|
1475
1465
|
}
|
|
1476
1466
|
nativePagesFetched = 0;
|
|
1477
1467
|
nativeOverlapCount = null;
|
|
@@ -1483,7 +1473,7 @@ class MarketAdapterService {
|
|
|
1483
1473
|
// Verifies with Kibana first to avoid removing genuinely flat market periods.
|
|
1484
1474
|
const staleThreshold = Number.isFinite(cfg.staleTailThreshold)
|
|
1485
1475
|
? cfg.staleTailThreshold
|
|
1486
|
-
:
|
|
1476
|
+
: MARKET_ADAPTER.STALE_TAIL_THRESHOLD_CANDLES;
|
|
1487
1477
|
const verified = await verifyAndPruneStaleTail(nextCandles, staleThreshold, staleTailVerifiedRangeFromMeta());
|
|
1488
1478
|
nextCandles = verified.candles;
|
|
1489
1479
|
applyStaleTailVerificationMeta(verified);
|
|
@@ -1555,7 +1545,7 @@ class MarketAdapterService {
|
|
|
1555
1545
|
}
|
|
1556
1546
|
}
|
|
1557
1547
|
catch (err) {
|
|
1558
|
-
logGapRepairEvent(`[market_adapter] ${bot.botKey}: Kibana gap repair failed (${
|
|
1548
|
+
logGapRepairEvent(`[market_adapter] ${bot.botKey}: Kibana gap repair failed (${getErrorMessage(err) || String(err)})`, 'warn');
|
|
1559
1549
|
}
|
|
1560
1550
|
}
|
|
1561
1551
|
gapAnalysis = typeof deps.detectMissingCandleTimestamps === 'function'
|
|
@@ -1813,14 +1803,14 @@ class MarketAdapterService {
|
|
|
1813
1803
|
// 1. AMA series and closes — used for price reference and signal computation
|
|
1814
1804
|
const analysisCandles = closedCandles;
|
|
1815
1805
|
const closes = analysisCandles.map((c) => Number(c[4])).filter((v) => Number.isFinite(v) && v > 0);
|
|
1816
|
-
const amaValues =
|
|
1806
|
+
const amaValues = calculateAMA(closes, botAma);
|
|
1817
1807
|
// amaPrice is the last value of the full AMA series
|
|
1818
1808
|
const amaPrice = amaValues[amaValues.length - 1];
|
|
1819
1809
|
const lastCandle = latestClosedCandle || [0, 0, 0, 0, 0];
|
|
1820
1810
|
// 2. ATR — used only for the symmetric volatility shift. The asymmetrical
|
|
1821
1811
|
// trend/Kalman branch stays ATR-free to match the research HTML.
|
|
1822
|
-
const atrPeriod =
|
|
1823
|
-
const atr =
|
|
1812
|
+
const atrPeriod = normalizeAtrPeriod(cfg.atrPeriod);
|
|
1813
|
+
const atr = calculateATR(analysisCandles, atrPeriod);
|
|
1824
1814
|
const warn = (message) => {
|
|
1825
1815
|
if (typeof deps.logger?.log === 'function') {
|
|
1826
1816
|
deps.logger.log(message, 'warn');
|
|
@@ -1892,7 +1882,7 @@ class MarketAdapterService {
|
|
|
1892
1882
|
const amaSlopeDeltaPercent = amaSlopeResetDetails.deltaPercent;
|
|
1893
1883
|
const amaSlopeThresholdPercent = amaSlopeResetDetails.thresholdPercent;
|
|
1894
1884
|
// 4. Advisory collateral-ratio hint only; execution is owned by the debt runtime.
|
|
1895
|
-
const collateralRecommendation = canExposeDynamicWeights ?
|
|
1885
|
+
const collateralRecommendation = canExposeDynamicWeights ? adjustCollateralRatio(slopeResult, 1.5, 2.0) : null;
|
|
1896
1886
|
const amaComparison = deps.calcAmaComparison(analysisCandles, bot, ctx);
|
|
1897
1887
|
const closedCandleTs = lastCandle[0] || null;
|
|
1898
1888
|
const { staleData, staleAgeHours } = deps.computeCandleStaleness(closedCandleTs, cfg.maxStaleHours);
|
|
@@ -1964,7 +1954,7 @@ class MarketAdapterService {
|
|
|
1964
1954
|
trend: asymTrend,
|
|
1965
1955
|
minScaleSlots: (cfg.asymmetricBounds?.minScaleSlots != null)
|
|
1966
1956
|
? cfg.asymmetricBounds.minScaleSlots
|
|
1967
|
-
:
|
|
1957
|
+
: MARKET_ADAPTER.ASYMMETRIC_BOUNDS_MIN_SCALE_SLOTS,
|
|
1968
1958
|
};
|
|
1969
1959
|
}
|
|
1970
1960
|
}
|
|
@@ -2018,7 +2008,7 @@ class MarketAdapterService {
|
|
|
2018
2008
|
});
|
|
2019
2009
|
}
|
|
2020
2010
|
catch (err) {
|
|
2021
|
-
triggerCallbackError =
|
|
2011
|
+
triggerCallbackError = getErrorMessage(err);
|
|
2022
2012
|
}
|
|
2023
2013
|
}
|
|
2024
2014
|
};
|
|
@@ -2343,5 +2333,5 @@ class MarketAdapterService {
|
|
|
2343
2333
|
};
|
|
2344
2334
|
}
|
|
2345
2335
|
}
|
|
2346
|
-
|
|
2336
|
+
export { MarketAdapterService, AMA_SLOPE_PERCENT_MODE_PER_BAR, normalizeAmaSlopePercentMode, normalizeAmaSlopeLookbackBars, convertSlopePercentToPerBar };
|
|
2347
2337
|
//# sourceMappingURL=market_adapter_service.js.map
|