dexbot 1.4.10 → 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 +6 -5
- 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 +54 -23
- 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.d.ts +2 -0
- package/dist/market_adapter/core/market_adapter_service.d.ts.map +1 -1
- package/dist/market_adapter/core/market_adapter_service.js +100 -101
- 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 +163 -222
- 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 +4 -14
- package/dist/modules/constants.d.ts.map +1 -1
- package/dist/modules/constants.js +46 -78
- 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 +3 -2
- package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.js +97 -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 +8 -8
- package/dist/modules/order/grid.d.ts.map +1 -1
- package/dist/modules/order/grid.js +254 -266
- 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.d.ts +0 -8
- package/dist/modules/order/logger.d.ts.map +1 -1
- package/dist/modules/order/logger.js +28 -141
- 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 -79
- package/dist/modules/order/manager.d.ts.map +1 -1
- package/dist/modules/order/manager.js +131 -247
- 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.d.ts.map +1 -1
- package/dist/modules/process_discovery.js +14 -23
- 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 +93 -95
- 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 +258 -222
- 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,94 +1,30 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return function (mod) {
|
|
29
|
-
if (mod && mod.__esModule) return mod;
|
|
30
|
-
var result = {};
|
|
31
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
-
__setModuleDefault(result, mod);
|
|
33
|
-
return result;
|
|
34
|
-
};
|
|
35
|
-
})();
|
|
36
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
-
};
|
|
39
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports._setBitsharesClientForTests = exports.normalizeNativeMarketHistoryCandles = exports.isBotGridRangeScalingWhitelisted = exports.isBotAsymmetricBoundsWhitelisted = exports.isBotDynamicWeightWhitelisted = exports.isBotWhitelisted = exports.normalizeMarketSource = exports.DEFAULTS = exports.DEFAULT_AMA = void 0;
|
|
41
|
-
exports.main = main;
|
|
42
|
-
exports.runOnceForAma = runOnceForAma;
|
|
43
|
-
exports.calculateBotThreshold = calculateBotThreshold;
|
|
44
|
-
exports.calcAmaComparison = calcAmaComparison;
|
|
45
|
-
exports.computeCandleStaleness = computeCandleStaleness;
|
|
46
|
-
exports.sleepUntilAlignedBoundary = sleepUntilAlignedBoundary;
|
|
47
|
-
exports.resolveAmaForBot = resolveAmaForBot;
|
|
48
|
-
exports.resolveDeltaThresholdPercentFromGeneralSettings = resolveDeltaThresholdPercentFromGeneralSettings;
|
|
49
|
-
exports.applyRuntimeDefaultsFromGeneralSettings = applyRuntimeDefaultsFromGeneralSettings;
|
|
50
|
-
exports.resolveBotCfg = resolveBotCfg;
|
|
51
|
-
exports.usesAmaGridPrice = usesAmaGridPrice;
|
|
52
|
-
exports.usesOrderbookMarketSource = usesOrderbookMarketSource;
|
|
53
|
-
exports._resetCycleCache = _resetCycleCache;
|
|
54
|
-
exports.writeCenterSnapshot = writeCenterSnapshot;
|
|
55
|
-
exports.writeBotDynamicGrid = writeBotDynamicGrid;
|
|
56
|
-
exports.writeGridResetTrigger = writeGridResetTrigger;
|
|
57
|
-
exports.mergeGridResetMetadataFromDynamicGrid = mergeGridResetMetadataFromDynamicGrid;
|
|
58
|
-
exports.fetchNativeMarketHistorySince = fetchNativeMarketHistorySince;
|
|
59
|
-
exports.loadMarketAdapterSettings = loadMarketAdapterSettings;
|
|
60
|
-
exports.findPairForBot = findPairForBot;
|
|
61
|
-
const path_api_1 = require("../modules/path_api");
|
|
62
|
-
const storage_1 = require("../modules/storage");
|
|
63
|
-
const system_1 = require("../modules/order/utils/system");
|
|
64
|
-
const general_settings_1 = require("../modules/general_settings");
|
|
65
|
-
const constants_1 = require("../modules/constants");
|
|
66
|
-
const bot_settings_1 = require("../modules/bot_settings");
|
|
67
|
-
const ama_1 = require("./core/strategies/ama");
|
|
68
|
-
const kibanaSource = __importStar(require("./inputs/kibana_source"));
|
|
69
|
-
const kibanaMarketSource = __importStar(require("./core/kibana_market_candles"));
|
|
70
|
-
const candle_utils_1 = require("./candle_utils");
|
|
71
|
-
const interval_utils_1 = require("./interval_utils");
|
|
72
|
-
const tradingview_uplot_chart_generator_1 = require("../analysis/tradingview/tradingview_uplot_chart_generator");
|
|
73
|
-
const atomic_write_1 = require("./utils/atomic_write");
|
|
74
|
-
const file_lock_1 = require("./utils/file_lock");
|
|
75
|
-
const dynamic_grid_snapshot_1 = require("./utils/dynamic_grid_snapshot");
|
|
76
|
-
const paths_1 = require("../modules/paths");
|
|
77
|
-
const logger_1 = __importDefault(require("../modules/logger"));
|
|
78
|
-
const fs_utils_1 = require("../modules/utils/fs_utils");
|
|
79
|
-
const math_utils_1 = require("../modules/utils/math_utils");
|
|
80
|
-
const config_normalizers_js_1 = require("./core/config_normalizers.js");
|
|
81
|
-
const market_adapter_whitelist_js_1 = require("../modules/market_adapter_whitelist.js");
|
|
82
|
-
Object.defineProperty(exports, "isBotWhitelisted", { enumerable: true, get: function () { return market_adapter_whitelist_js_1.isBotWhitelisted; } });
|
|
83
|
-
Object.defineProperty(exports, "isBotDynamicWeightWhitelisted", { enumerable: true, get: function () { return market_adapter_whitelist_js_1.isBotDynamicWeightWhitelisted; } });
|
|
84
|
-
Object.defineProperty(exports, "isBotAsymmetricBoundsWhitelisted", { enumerable: true, get: function () { return market_adapter_whitelist_js_1.isBotAsymmetricBoundsWhitelisted; } });
|
|
85
|
-
Object.defineProperty(exports, "isBotGridRangeScalingWhitelisted", { enumerable: true, get: function () { return market_adapter_whitelist_js_1.isBotGridRangeScalingWhitelisted; } });
|
|
86
|
-
const chain_js_1 = require("./utils/chain.js");
|
|
87
|
-
Object.defineProperty(exports, "normalizeMarketSource", { enumerable: true, get: function () { return chain_js_1.normalizeMarketSource; } });
|
|
88
|
-
Object.defineProperty(exports, "_setBitsharesClientForTests", { enumerable: true, get: function () { return chain_js_1.setBitsharesClientForTests; } });
|
|
89
|
-
const native_history_js_1 = require("./utils/native_history.js");
|
|
90
|
-
Object.defineProperty(exports, "normalizeNativeMarketHistoryCandles", { enumerable: true, get: function () { return native_history_js_1.normalizeNativeMarketHistoryCandles; } });
|
|
91
|
-
const log_format_js_1 = require("./log_format.js");
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
4
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
5
|
+
import { path } from '../modules/path_api.js';
|
|
6
|
+
import { getStorage } from '../modules/storage/index.js';
|
|
7
|
+
import { parseJsonWithComments, sleep, ensureDir } from '../modules/order/utils/system.js';
|
|
8
|
+
import { readGeneralSettings } from '../modules/general_settings.js';
|
|
9
|
+
import { DEFAULT_CONFIG, MARKET_ADAPTER, NATIVE_CLIENT, API_LIMITS, TIMING } from '../modules/constants.js';
|
|
10
|
+
import { normalizeBotEntry } from '../modules/bot_settings.js';
|
|
11
|
+
import { calculateAMA } from './core/strategies/ama.js';
|
|
12
|
+
import * as kibanaSource from './inputs/kibana_source.js';
|
|
13
|
+
import * as kibanaMarketSource from './core/kibana_market_candles.js';
|
|
14
|
+
import { tradesToCandles, detectMissingCandleTimestamps, fillCandleGaps, detectStaleTail, pruneStaleTail, mergeCandles } from './candle_utils.js';
|
|
15
|
+
import { toIntervalLabel } from './interval_utils.js';
|
|
16
|
+
import { loadMarketProfiles } from '../analysis/tradingview/tradingview_uplot_chart_generator.js';
|
|
17
|
+
import { writeJsonAtomic } from './utils/atomic_write.js';
|
|
18
|
+
import { acquireFileLockSync, releaseFileLockSync } from './utils/file_lock.js';
|
|
19
|
+
import { updateDynamicGridSnapshotSync } from './utils/dynamic_grid_snapshot.js';
|
|
20
|
+
import { PATHS, getRecalculateTriggerFile } from '../modules/paths.js';
|
|
21
|
+
import Logger from '../modules/logger.js';
|
|
22
|
+
import { fixedTo, roundTo } from '../modules/utils/math_utils.js';
|
|
23
|
+
import { normalizeAtrPeriod, normalizeMaxVolatilityOffset, normalizeVolatilityThreshold, } from './core/config_normalizers.js';
|
|
24
|
+
import { resetMarketAdapterWhitelistCache, isBotWhitelisted, isBotDynamicWeightWhitelisted, isBotAsymmetricBoundsWhitelisted, isBotGridRangeScalingWhitelisted, } from '../modules/market_adapter_whitelist.js';
|
|
25
|
+
import { normalizeAssetSymbol, normalizeMarketSource, resolveMarketSourceForBot, resolveBotContext, isExactPair, isSamePair, isExactPairIds, isSamePairIds, getBitsharesClient, setBitsharesClientForTests, } from './utils/chain.js';
|
|
26
|
+
import { normalizeNativeMarketHistoryCandles, } from './utils/native_history.js';
|
|
27
|
+
import { formatLogPercent, buildWeightSummary, buildDynamicWeightInputsLog, buildDynamicWeightTuningLog, buildAsymmetricBoundsLog, buildStartupDefaultsLog, } from './log_format.js';
|
|
92
28
|
'use strict';
|
|
93
29
|
/**
|
|
94
30
|
* PRICE ADAPTER — standalone or auto-launched by dexbot runtime.
|
|
@@ -101,31 +37,32 @@ const log_format_js_1 = require("./log_format.js");
|
|
|
101
37
|
*
|
|
102
38
|
* No wallet keys/password/auth required (read-only chain + Kibana bootstrap).
|
|
103
39
|
*/
|
|
104
|
-
const storage =
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
const
|
|
109
|
-
const
|
|
110
|
-
const
|
|
111
|
-
const
|
|
112
|
-
const
|
|
113
|
-
const
|
|
114
|
-
const
|
|
115
|
-
const
|
|
116
|
-
const
|
|
40
|
+
const storage = getStorage();
|
|
41
|
+
const { readJSON } = storage;
|
|
42
|
+
const ROOT = PATHS.PROJECT_ROOT;
|
|
43
|
+
const BOTS_FILE = PATHS.PROFILES.BOTS_JSON;
|
|
44
|
+
const DATA_DIR = PATHS.MARKET_ADAPTER.DATA_DIR;
|
|
45
|
+
const STATE_DIR = PATHS.MARKET_ADAPTER.STATE_DIR;
|
|
46
|
+
const STATE_FILE = PATHS.MARKET_ADAPTER.STATE_FILE;
|
|
47
|
+
const CENTER_FILE = PATHS.MARKET_ADAPTER.CENTERS_FILE;
|
|
48
|
+
const LOCK_FILE = PATHS.MARKET_ADAPTER.LOCK_FILE;
|
|
49
|
+
const MARKET_ADAPTER_SOURCE = path.relative(PATHS.PROJECT_ROOT, __filename).replace(/^dist[\\\/]/, '');
|
|
50
|
+
const MARKET_ADAPTER_SETTINGS_FILE = PATHS.PROFILES.MARKET_ADAPTER_SETTINGS_JSON;
|
|
51
|
+
const LP_OP_TYPE = NATIVE_CLIENT.OPERATIONS.LIQUIDITY_POOL_EXCHANGE;
|
|
52
|
+
const API_MAX_PAGE = API_LIMITS.LP_API_MAX_PAGE;
|
|
53
|
+
const RUNTIME_DEFAULTS = MARKET_ADAPTER.RUNTIME_DEFAULTS;
|
|
117
54
|
const DEFAULTS = {
|
|
118
55
|
pollSeconds: RUNTIME_DEFAULTS.pollSeconds,
|
|
119
|
-
deltaThresholdPercent:
|
|
56
|
+
deltaThresholdPercent: MARKET_ADAPTER.AMA_DELTA_THRESHOLD_PERCENT,
|
|
120
57
|
amaSlopeDeltaThresholdPercent: undefined,
|
|
121
|
-
absoluteThreshold:
|
|
58
|
+
absoluteThreshold: MARKET_ADAPTER.DYNAMIC_WEIGHT_ABSOLUTE_THRESHOLD_DEFAULT,
|
|
122
59
|
intervalSeconds: RUNTIME_DEFAULTS.intervalSeconds,
|
|
123
60
|
bootstrapLookbackHours: RUNTIME_DEFAULTS.bootstrapLookbackHours,
|
|
124
61
|
nativeBackfillHours: RUNTIME_DEFAULTS.nativeBackfillHours,
|
|
125
62
|
maxStaleHours: RUNTIME_DEFAULTS.maxStaleHours,
|
|
126
63
|
sourceRetries: RUNTIME_DEFAULTS.sourceRetries,
|
|
127
64
|
retryDelayMs: RUNTIME_DEFAULTS.retryDelayMs,
|
|
128
|
-
kibanaRequestTimeoutMs:
|
|
65
|
+
kibanaRequestTimeoutMs: MARKET_ADAPTER.KIBANA_REQUEST_TIMEOUT_MS,
|
|
129
66
|
metricsJson: false,
|
|
130
67
|
quiet: false,
|
|
131
68
|
dryRun: false,
|
|
@@ -133,26 +70,25 @@ const DEFAULTS = {
|
|
|
133
70
|
maxPages: RUNTIME_DEFAULTS.maxPages,
|
|
134
71
|
pageLimit: RUNTIME_DEFAULTS.pageLimit,
|
|
135
72
|
once: false,
|
|
136
|
-
maxNativeGapFillCandles:
|
|
137
|
-
staleTailThreshold:
|
|
73
|
+
maxNativeGapFillCandles: MARKET_ADAPTER.STALE_TAIL_THRESHOLD_CANDLES,
|
|
74
|
+
staleTailThreshold: MARKET_ADAPTER.STALE_TAIL_THRESHOLD_CANDLES,
|
|
138
75
|
amaSlope: {
|
|
139
|
-
lookbackBars:
|
|
140
|
-
maxSlopePct:
|
|
141
|
-
neutralZonePct:
|
|
142
|
-
deltaThresholdPct:
|
|
76
|
+
lookbackBars: MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_LOOKBACK_BARS,
|
|
77
|
+
maxSlopePct: MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_MAX_SLOPE_PCT,
|
|
78
|
+
neutralZonePct: MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_NEUTRAL_ZONE_PCT,
|
|
79
|
+
deltaThresholdPct: MARKET_ADAPTER.AMA_SLOPE_DELTA_THRESHOLD_PERCENT,
|
|
143
80
|
},
|
|
144
81
|
kalmanSlope: {
|
|
145
|
-
maxSlopePct:
|
|
82
|
+
maxSlopePct: MARKET_ADAPTER.DYNAMIC_WEIGHT_KALMAN_MAX_SLOPE_PCT,
|
|
146
83
|
},
|
|
147
|
-
atrPeriod:
|
|
84
|
+
atrPeriod: MARKET_ADAPTER.DYNAMIC_WEIGHT_ATR_PERIOD_DEFAULT,
|
|
148
85
|
};
|
|
149
|
-
exports.DEFAULTS = DEFAULTS;
|
|
150
86
|
// Cycle-scoped caches — reset once per runOnce() so each cycle reads files fresh
|
|
151
87
|
// but all bots within that cycle share the same loaded data (N bots → 1 file read).
|
|
152
88
|
let _marketAdapterSettingsCache = null;
|
|
153
89
|
function _resetCycleCache() {
|
|
154
90
|
_marketAdapterSettingsCache = null;
|
|
155
|
-
|
|
91
|
+
resetMarketAdapterWhitelistCache();
|
|
156
92
|
}
|
|
157
93
|
function loadMarketAdapterSettings() {
|
|
158
94
|
if (_marketAdapterSettingsCache !== null)
|
|
@@ -160,11 +96,11 @@ function loadMarketAdapterSettings() {
|
|
|
160
96
|
if (!storage.exists(MARKET_ADAPTER_SETTINGS_FILE))
|
|
161
97
|
return null;
|
|
162
98
|
try {
|
|
163
|
-
_marketAdapterSettingsCache =
|
|
99
|
+
_marketAdapterSettingsCache = readJSON(MARKET_ADAPTER_SETTINGS_FILE);
|
|
164
100
|
return _marketAdapterSettingsCache;
|
|
165
101
|
}
|
|
166
102
|
catch (_) {
|
|
167
|
-
console.warn(`[WARN] Failed to parse ${MARKET_ADAPTER_SETTINGS_FILE}: ${
|
|
103
|
+
console.warn(`[WARN] Failed to parse ${MARKET_ADAPTER_SETTINGS_FILE}: ${getErrorMessage(_)}. Using defaults.`);
|
|
168
104
|
_marketAdapterSettingsCache = false;
|
|
169
105
|
return null;
|
|
170
106
|
}
|
|
@@ -174,27 +110,27 @@ function findPairForBot(bot, pairs) {
|
|
|
174
110
|
return null;
|
|
175
111
|
const botAId = String(bot.assetAId || '');
|
|
176
112
|
const botBId = String(bot.assetBId || '');
|
|
177
|
-
const botA =
|
|
178
|
-
const botB =
|
|
113
|
+
const botA = normalizeAssetSymbol(bot.assetA);
|
|
114
|
+
const botB = normalizeAssetSymbol(bot.assetB);
|
|
179
115
|
let fallbackMatch = null;
|
|
180
116
|
for (const p of pairs) {
|
|
181
117
|
const parts = String(p.key || '').split('|');
|
|
182
118
|
const pAId = parts[0];
|
|
183
119
|
const pBId = parts[1];
|
|
184
|
-
const pA =
|
|
185
|
-
const pB =
|
|
120
|
+
const pA = normalizeAssetSymbol(p.assetASymbol);
|
|
121
|
+
const pB = normalizeAssetSymbol(p.assetBSymbol);
|
|
186
122
|
if (botAId && botBId && pAId && pBId) {
|
|
187
|
-
if (
|
|
123
|
+
if (isExactPairIds(botAId, botBId, pAId, pBId))
|
|
188
124
|
return p;
|
|
189
|
-
if (!fallbackMatch &&
|
|
125
|
+
if (!fallbackMatch && isSamePairIds(botAId, botBId, pAId, pBId)) {
|
|
190
126
|
fallbackMatch = p;
|
|
191
127
|
continue;
|
|
192
128
|
}
|
|
193
129
|
}
|
|
194
130
|
if (botA && botB && pA && pB) {
|
|
195
|
-
if (
|
|
131
|
+
if (isExactPair(botA, botB, pA, pB))
|
|
196
132
|
return p;
|
|
197
|
-
if (!fallbackMatch &&
|
|
133
|
+
if (!fallbackMatch && isSamePair(botA, botB, pA, pB)) {
|
|
198
134
|
fallbackMatch = p;
|
|
199
135
|
}
|
|
200
136
|
}
|
|
@@ -213,25 +149,25 @@ function applyAmaSlopeOverrides(target, overrides) {
|
|
|
213
149
|
return target;
|
|
214
150
|
target.amaSlope = { ...(target.amaSlope || {}) };
|
|
215
151
|
const previousLookbackBars = target.amaSlope.lookbackBars;
|
|
216
|
-
const explicitMode =
|
|
152
|
+
const explicitMode = normalizeAmaSlopePercentMode(overrides.amaSlopePercentMode
|
|
217
153
|
?? overrides.amaSlopeUnits
|
|
218
154
|
?? overrides.amaSlope?.percentMode
|
|
219
155
|
?? overrides.amaSlope?.units);
|
|
220
156
|
if (explicitMode)
|
|
221
157
|
target.amaSlopePercentMode = explicitMode;
|
|
222
|
-
const mode = explicitMode || target.amaSlopePercentMode ||
|
|
158
|
+
const mode = explicitMode || target.amaSlopePercentMode || AMA_SLOPE_PERCENT_MODE_PER_BAR;
|
|
223
159
|
if (overrides.amaSlopeDeltaThresholdPercent != null) {
|
|
224
|
-
target.amaSlopeDeltaThresholdPercent =
|
|
160
|
+
target.amaSlopeDeltaThresholdPercent = convertSlopePercentToPerBar(overrides.amaSlopeDeltaThresholdPercent, overrides.amaSlope?.lookbackBars ?? previousLookbackBars, mode);
|
|
225
161
|
}
|
|
226
162
|
if (overrides.amaSlope && typeof overrides.amaSlope === 'object') {
|
|
227
163
|
const { percentMode: _percentMode, units: _units, maxSlopePct, neutralZonePct, ...amaSlopeRest } = overrides.amaSlope;
|
|
228
164
|
target.amaSlope = { ...target.amaSlope, ...amaSlopeRest };
|
|
229
165
|
const lookbackBars = target.amaSlope.lookbackBars ?? previousLookbackBars;
|
|
230
166
|
if (maxSlopePct != null) {
|
|
231
|
-
target.amaSlope.maxSlopePct =
|
|
167
|
+
target.amaSlope.maxSlopePct = convertSlopePercentToPerBar(maxSlopePct, lookbackBars, mode);
|
|
232
168
|
}
|
|
233
169
|
if (neutralZonePct != null) {
|
|
234
|
-
target.amaSlope.neutralZonePct =
|
|
170
|
+
target.amaSlope.neutralZonePct = convertSlopePercentToPerBar(neutralZonePct, lookbackBars, mode);
|
|
235
171
|
}
|
|
236
172
|
}
|
|
237
173
|
return target;
|
|
@@ -277,15 +213,20 @@ function applyMarketAdapterOverrides(target, overrides, opts = {}) {
|
|
|
277
213
|
'kalmanSmoothSpanPct',
|
|
278
214
|
'signalConfirmBars',
|
|
279
215
|
'dispScaleMinPct',
|
|
280
|
-
'asymmetricBounds',
|
|
281
216
|
]);
|
|
282
217
|
if (overrides.maxVolatilityOffset != null) {
|
|
283
|
-
target.maxVolatilityOffset =
|
|
218
|
+
target.maxVolatilityOffset = normalizeMaxVolatilityOffset(overrides.maxVolatilityOffset);
|
|
219
|
+
}
|
|
220
|
+
// Per-field merge for asymmetricBounds so a bot-level override (e.g. only
|
|
221
|
+
// minScaleSlots) does not wipe a market-level maxAsymmetryFactor. Mirrors how
|
|
222
|
+
// amaSlope/kalmanSlope are merged across the globals/pair/bot layers.
|
|
223
|
+
if (overrides.asymmetricBounds && typeof overrides.asymmetricBounds === 'object') {
|
|
224
|
+
target.asymmetricBounds = { ...(target.asymmetricBounds || {}), ...overrides.asymmetricBounds };
|
|
284
225
|
}
|
|
285
226
|
if (overrides.atrPeriod != null)
|
|
286
|
-
target.atrPeriod =
|
|
227
|
+
target.atrPeriod = normalizeAtrPeriod(overrides.atrPeriod);
|
|
287
228
|
if (overrides.volatilityThreshold != null) {
|
|
288
|
-
target.volatilityThreshold =
|
|
229
|
+
target.volatilityThreshold = normalizeVolatilityThreshold(overrides.volatilityThreshold);
|
|
289
230
|
}
|
|
290
231
|
if (overrides.peNodes)
|
|
291
232
|
target.peNodes = overrides.peNodes;
|
|
@@ -322,10 +263,9 @@ function resolveBotCfg(bot, globalCfg) {
|
|
|
322
263
|
}
|
|
323
264
|
return merged;
|
|
324
265
|
}
|
|
325
|
-
const DEFAULT_AMA_KEY = String(
|
|
326
|
-
const BUILTIN_AMAS =
|
|
327
|
-
const DEFAULT_AMA =
|
|
328
|
-
exports.DEFAULT_AMA = DEFAULT_AMA;
|
|
266
|
+
const DEFAULT_AMA_KEY = String(MARKET_ADAPTER.DEFAULT_AMA_KEY).toUpperCase();
|
|
267
|
+
const BUILTIN_AMAS = MARKET_ADAPTER.AMAS;
|
|
268
|
+
const DEFAULT_AMA = MARKET_ADAPTER.AMAS.AMA3;
|
|
329
269
|
const AMA_KEYWORDS = new Set(['ama', 'ama1', 'ama2', 'ama3', 'ama4']);
|
|
330
270
|
const AMA_PRESET_KEYS = ['AMA1', 'AMA2', 'AMA3', 'AMA4'];
|
|
331
271
|
function normalizeAmaPreset(raw) {
|
|
@@ -351,17 +291,17 @@ function isAmaKeyword(raw) {
|
|
|
351
291
|
function usesAmaGridPrice(bot) {
|
|
352
292
|
return isAmaKeyword(bot?.gridPrice);
|
|
353
293
|
}
|
|
354
|
-
function
|
|
355
|
-
return
|
|
294
|
+
function usesBookMarketSource(bot) {
|
|
295
|
+
return resolveMarketSourceForBot(bot) === 'book';
|
|
356
296
|
}
|
|
357
297
|
function findAmaProfileForBot(bot, ctx) {
|
|
358
|
-
const profiles =
|
|
298
|
+
const profiles = loadMarketProfiles()?.profiles || [];
|
|
359
299
|
if (profiles.length === 0)
|
|
360
300
|
return null;
|
|
361
|
-
const botAssetA =
|
|
362
|
-
const botAssetB =
|
|
363
|
-
const ctxAssetAId =
|
|
364
|
-
const ctxAssetBId =
|
|
301
|
+
const botAssetA = normalizeAssetSymbol(bot?.assetA);
|
|
302
|
+
const botAssetB = normalizeAssetSymbol(bot?.assetB);
|
|
303
|
+
const ctxAssetAId = normalizeAssetSymbol(ctx?.assetA?.id);
|
|
304
|
+
const ctxAssetBId = normalizeAssetSymbol(ctx?.assetB?.id);
|
|
365
305
|
if (!botAssetA && !ctxAssetAId)
|
|
366
306
|
return null;
|
|
367
307
|
if (!botAssetB && !ctxAssetBId)
|
|
@@ -371,12 +311,12 @@ function findAmaProfileForBot(bot, ctx) {
|
|
|
371
311
|
const pB = p?.assetB;
|
|
372
312
|
const pAId = p?.assetAId;
|
|
373
313
|
const pBId = p?.assetBId;
|
|
374
|
-
const exactBySymbol = botAssetA && botAssetB && pA && pB &&
|
|
314
|
+
const exactBySymbol = botAssetA && botAssetB && pA && pB && isExactPair(botAssetA, botAssetB, pA, pB);
|
|
375
315
|
const exactById = ctxAssetAId && ctxAssetBId && pAId && pBId
|
|
376
|
-
&&
|
|
377
|
-
const symmetricBySymbol = botAssetA && botAssetB && pA && pB &&
|
|
316
|
+
&& isExactPairIds(ctxAssetAId, ctxAssetBId, pAId, pBId);
|
|
317
|
+
const symmetricBySymbol = botAssetA && botAssetB && pA && pB && isSamePair(botAssetA, botAssetB, pA, pB);
|
|
378
318
|
const symmetricById = ctxAssetAId && ctxAssetBId && pAId && pBId
|
|
379
|
-
&&
|
|
319
|
+
&& isSamePairIds(ctxAssetAId, ctxAssetBId, pAId, pBId);
|
|
380
320
|
const matchRank = (exactById || exactBySymbol)
|
|
381
321
|
? 2
|
|
382
322
|
: ((symmetricById || symmetricBySymbol) ? 1 : 0);
|
|
@@ -409,7 +349,7 @@ function normalizeErSmoothPeriod(raw, fallback = 0) {
|
|
|
409
349
|
}
|
|
410
350
|
function resolveErSmoothPeriodForBot(bot) {
|
|
411
351
|
const raw = (bot && typeof bot.ama === 'object' && bot.ama !== null) ? bot.ama : {};
|
|
412
|
-
const globalErSmoothPeriod = normalizeErSmoothPeriod(
|
|
352
|
+
const globalErSmoothPeriod = normalizeErSmoothPeriod(MARKET_ADAPTER.AMA_ER_SMOOTH_FAST_PERIOD, 0);
|
|
413
353
|
if (Object.prototype.hasOwnProperty.call(raw, 'erSmoothPeriod')) {
|
|
414
354
|
return normalizeErSmoothPeriod(raw.erSmoothPeriod, globalErSmoothPeriod);
|
|
415
355
|
}
|
|
@@ -477,7 +417,7 @@ function withRetries(fn, attempts, baseDelayMs, label) {
|
|
|
477
417
|
break;
|
|
478
418
|
const waitMs = Math.max(0, baseDelayMs) * (i + 1);
|
|
479
419
|
if (waitMs > 0)
|
|
480
|
-
await
|
|
420
|
+
await sleep(waitMs);
|
|
481
421
|
}
|
|
482
422
|
}
|
|
483
423
|
const msg = label ? `${label}: ${lastErr?.message || 'unknown error'}` : (lastErr?.message || 'unknown error');
|
|
@@ -600,7 +540,7 @@ function applyRuntimeDefaultsFromGeneralSettings(cfg, provided = {}, settingsOve
|
|
|
600
540
|
const out = { ...cfg };
|
|
601
541
|
if (!provided?.deltaThresholdPercent) {
|
|
602
542
|
const settings = settingsOverride === undefined
|
|
603
|
-
?
|
|
543
|
+
? readGeneralSettings({ fallback: null })
|
|
604
544
|
: settingsOverride;
|
|
605
545
|
const fromSettings = resolveDeltaThresholdPercentFromGeneralSettings(settings);
|
|
606
546
|
if (fromSettings != null) {
|
|
@@ -609,8 +549,8 @@ function applyRuntimeDefaultsFromGeneralSettings(cfg, provided = {}, settingsOve
|
|
|
609
549
|
}
|
|
610
550
|
return out;
|
|
611
551
|
}
|
|
612
|
-
const marketAdapterLogFile =
|
|
613
|
-
const logger = new
|
|
552
|
+
const marketAdapterLogFile = path.join(PATHS.LOGS_DIR, 'market_adapter.log');
|
|
553
|
+
const logger = new Logger('MarketAdapter', { quiet: DEFAULTS.quiet, logFile: marketAdapterLogFile });
|
|
614
554
|
function log(cfg, ...args) {
|
|
615
555
|
logger.quiet = !!cfg?.quiet;
|
|
616
556
|
logger.info(...args);
|
|
@@ -645,24 +585,24 @@ function loadActiveBots() {
|
|
|
645
585
|
if (!storage.exists(BOTS_FILE)) {
|
|
646
586
|
throw new Error(`Bots file not found at ${BOTS_FILE}`);
|
|
647
587
|
}
|
|
648
|
-
const raw =
|
|
588
|
+
const raw = parseJsonWithComments(storage.readFile(BOTS_FILE));
|
|
649
589
|
const bots = Array.isArray(raw?.bots) ? raw.bots : (Array.isArray(raw) ? raw : []);
|
|
650
590
|
return bots
|
|
651
|
-
.map((b, i) =>
|
|
591
|
+
.map((b, i) => normalizeBotEntry(b, i))
|
|
652
592
|
.filter((b) => b.active);
|
|
653
593
|
}
|
|
654
594
|
function loadJson(filePath, defaultValue) {
|
|
655
595
|
try {
|
|
656
596
|
if (!storage.exists(filePath))
|
|
657
597
|
return defaultValue;
|
|
658
|
-
return
|
|
598
|
+
return readJSON(filePath);
|
|
659
599
|
}
|
|
660
600
|
catch (_) {
|
|
661
601
|
return defaultValue;
|
|
662
602
|
}
|
|
663
603
|
}
|
|
664
604
|
function saveJson(filePath, data) {
|
|
665
|
-
|
|
605
|
+
writeJsonAtomic(filePath, data);
|
|
666
606
|
}
|
|
667
607
|
function parseChainTimeToMs(timeStr) {
|
|
668
608
|
if (!timeStr)
|
|
@@ -673,8 +613,8 @@ function parseChainTimeToMs(timeStr) {
|
|
|
673
613
|
function candleFileForBot(botKey, intervalSeconds = RUNTIME_DEFAULTS.intervalSeconds) {
|
|
674
614
|
const label = intervalSeconds === RUNTIME_DEFAULTS.intervalSeconds
|
|
675
615
|
? RUNTIME_DEFAULTS.intervalLabel
|
|
676
|
-
:
|
|
677
|
-
return
|
|
616
|
+
: toIntervalLabel(intervalSeconds);
|
|
617
|
+
return path.join(DATA_DIR, `market_adapter_${botKey}_${label}.json`);
|
|
678
618
|
}
|
|
679
619
|
function calculateBotThreshold(cfg) {
|
|
680
620
|
const value = Number(cfg?.deltaThresholdPercent);
|
|
@@ -742,7 +682,7 @@ function calcAmaComparison(candles, bot = null, ctx = null) {
|
|
|
742
682
|
out.push({ ...p, value: null, ok: false });
|
|
743
683
|
continue;
|
|
744
684
|
}
|
|
745
|
-
const values =
|
|
685
|
+
const values = calculateAMA(closes, {
|
|
746
686
|
erPeriod: p.erPeriod,
|
|
747
687
|
fastPeriod: p.fastPeriod,
|
|
748
688
|
slowPeriod: p.slowPeriod,
|
|
@@ -754,7 +694,7 @@ function calcAmaComparison(candles, bot = null, ctx = null) {
|
|
|
754
694
|
return out;
|
|
755
695
|
}
|
|
756
696
|
async function fetchNativeTradesSince(poolId, sinceMs, pageLimit, maxPages) {
|
|
757
|
-
const { BitShares } =
|
|
697
|
+
const { BitShares } = getBitsharesClient();
|
|
758
698
|
const trades = [];
|
|
759
699
|
const seenSequences = new Set();
|
|
760
700
|
let pages = 0;
|
|
@@ -824,7 +764,7 @@ function nativeHistoryRowToTrade(row) {
|
|
|
824
764
|
};
|
|
825
765
|
}
|
|
826
766
|
async function fetchNativeTradesUntilOverlap(poolId, overlapSequences, minOverlap, pageLimit, maxPages) {
|
|
827
|
-
const { BitShares } =
|
|
767
|
+
const { BitShares } = getBitsharesClient();
|
|
828
768
|
const overlapSet = new Set((Array.isArray(overlapSequences) ? overlapSequences : [])
|
|
829
769
|
.map((v) => String(v))
|
|
830
770
|
.filter((v) => v !== ''));
|
|
@@ -881,7 +821,7 @@ async function fetchNativeTradesUntilOverlap(poolId, overlapSequences, minOverla
|
|
|
881
821
|
};
|
|
882
822
|
}
|
|
883
823
|
async function fetchNativeMarketHistorySince(assetA, assetB, sinceMs, untilMs, intervalSeconds, options = {}) {
|
|
884
|
-
const { BitShares } =
|
|
824
|
+
const { BitShares } = getBitsharesClient();
|
|
885
825
|
if (!BitShares) {
|
|
886
826
|
throw new Error('BitShares client unavailable');
|
|
887
827
|
}
|
|
@@ -897,14 +837,14 @@ async function fetchNativeMarketHistorySince(assetA, assetB, sinceMs, untilMs, i
|
|
|
897
837
|
else {
|
|
898
838
|
throw new Error('native market history source unavailable');
|
|
899
839
|
}
|
|
900
|
-
let candles =
|
|
840
|
+
let candles = normalizeNativeMarketHistoryCandles(history, assetA, assetB, intervalSeconds);
|
|
901
841
|
if (candles.length > 0 && typeof options.fillCandleGaps === 'function') {
|
|
902
842
|
candles = options.fillCandleGaps(candles, intervalSeconds);
|
|
903
843
|
}
|
|
904
844
|
return candles;
|
|
905
845
|
}
|
|
906
846
|
function writeGridResetTrigger(bot, payload) {
|
|
907
|
-
const triggerPath =
|
|
847
|
+
const triggerPath = getRecalculateTriggerFile(bot.botKey);
|
|
908
848
|
const content = {
|
|
909
849
|
createdAt: new Date().toISOString(),
|
|
910
850
|
source: MARKET_ADAPTER_SOURCE,
|
|
@@ -912,10 +852,10 @@ function writeGridResetTrigger(bot, payload) {
|
|
|
912
852
|
botKey: bot.botKey,
|
|
913
853
|
...payload,
|
|
914
854
|
};
|
|
915
|
-
|
|
855
|
+
writeJsonAtomic(triggerPath, content);
|
|
916
856
|
return triggerPath;
|
|
917
857
|
}
|
|
918
|
-
const ORDERS_DIR =
|
|
858
|
+
const ORDERS_DIR = PATHS.ORDERS_DIR;
|
|
919
859
|
/**
|
|
920
860
|
* Atomically write the dynamic grid snapshot for a bot to profiles/orders/<botKey>.dynamicgrid.json.
|
|
921
861
|
* Contains AMA-derived center price and any computed effective weight offsets.
|
|
@@ -924,7 +864,7 @@ const ORDERS_DIR = paths_1.PATHS.ORDERS_DIR;
|
|
|
924
864
|
*/
|
|
925
865
|
function writeBotDynamicGrid(botKey, gridCenterPrice, options = {}) {
|
|
926
866
|
try {
|
|
927
|
-
const filePath =
|
|
867
|
+
const filePath = path.join(ORDERS_DIR, `${botKey}.dynamicgrid.json`);
|
|
928
868
|
const preserveGridResetMetadata = (target, snapshot) => {
|
|
929
869
|
if (!snapshot?.lastGridResetAt)
|
|
930
870
|
return target;
|
|
@@ -951,16 +891,16 @@ function writeBotDynamicGrid(botKey, gridCenterPrice, options = {}) {
|
|
|
951
891
|
}
|
|
952
892
|
return target;
|
|
953
893
|
};
|
|
954
|
-
const result =
|
|
894
|
+
const result = updateDynamicGridSnapshotSync(filePath, (previousSnapshot) => {
|
|
955
895
|
const amaCenterPrice = Number(options.amaCenterPrice);
|
|
956
896
|
const resolvedGridCenterPrice = Number.isFinite(Number(gridCenterPrice))
|
|
957
|
-
?
|
|
897
|
+
? roundTo(Number(gridCenterPrice), 1e8)
|
|
958
898
|
: null;
|
|
959
899
|
const payload = {
|
|
960
900
|
gridCenterPrice: resolvedGridCenterPrice,
|
|
961
901
|
centerPrice: resolvedGridCenterPrice,
|
|
962
902
|
amaCenterPrice: Number.isFinite(amaCenterPrice) && amaCenterPrice > 0 ? amaCenterPrice : resolvedGridCenterPrice,
|
|
963
|
-
amaSlopePercentMode:
|
|
903
|
+
amaSlopePercentMode: AMA_SLOPE_PERCENT_MODE_PER_BAR,
|
|
964
904
|
updatedAt: new Date().toISOString(),
|
|
965
905
|
source: MARKET_ADAPTER_SOURCE,
|
|
966
906
|
};
|
|
@@ -994,14 +934,14 @@ function writeBotDynamicGrid(botKey, gridCenterPrice, options = {}) {
|
|
|
994
934
|
return result.ok && result.written;
|
|
995
935
|
}
|
|
996
936
|
catch (err) {
|
|
997
|
-
logger.warn(`[writeBotDynamicGrid] Failed to write dynamic grid for ${botKey}: ${
|
|
937
|
+
logger.warn(`[writeBotDynamicGrid] Failed to write dynamic grid for ${botKey}: ${getErrorMessage(err)}`);
|
|
998
938
|
return false;
|
|
999
939
|
}
|
|
1000
940
|
}
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
const adapterService = new
|
|
1004
|
-
resolveBotContext
|
|
941
|
+
import { MarketAdapterService, AMA_SLOPE_PERCENT_MODE_PER_BAR, normalizeAmaSlopePercentMode, convertSlopePercentToPerBar, } from './core/market_adapter_service.js';
|
|
942
|
+
import { getErrorMessage } from '../modules/utils/errors.js';
|
|
943
|
+
const adapterService = new MarketAdapterService({
|
|
944
|
+
resolveBotContext,
|
|
1005
945
|
resolveAmaForBot,
|
|
1006
946
|
candleFileForBot,
|
|
1007
947
|
loadJson,
|
|
@@ -1014,22 +954,22 @@ const adapterService = new market_adapter_service_js_1.MarketAdapterService({
|
|
|
1014
954
|
fetchNativeMarketHistorySince,
|
|
1015
955
|
fetchNativeTradesSince,
|
|
1016
956
|
fetchNativeTradesUntilOverlap,
|
|
1017
|
-
tradesToCandles
|
|
1018
|
-
detectMissingCandleTimestamps
|
|
1019
|
-
fillCandleGaps
|
|
1020
|
-
detectStaleTail
|
|
1021
|
-
pruneStaleTail
|
|
1022
|
-
mergeCandles
|
|
957
|
+
tradesToCandles,
|
|
958
|
+
detectMissingCandleTimestamps,
|
|
959
|
+
fillCandleGaps,
|
|
960
|
+
detectStaleTail,
|
|
961
|
+
pruneStaleTail,
|
|
962
|
+
mergeCandles,
|
|
1023
963
|
pruneCandles,
|
|
1024
964
|
calcAmaComparison,
|
|
1025
965
|
writeGridResetTrigger,
|
|
1026
966
|
writeBotDynamicGrid,
|
|
1027
|
-
isBotWhitelisted
|
|
1028
|
-
isBotDynamicWeightWhitelisted
|
|
1029
|
-
isBotGridRangeScalingWhitelisted
|
|
967
|
+
isBotWhitelisted,
|
|
968
|
+
isBotDynamicWeightWhitelisted,
|
|
969
|
+
isBotGridRangeScalingWhitelisted,
|
|
1030
970
|
logger,
|
|
1031
971
|
root: ROOT,
|
|
1032
|
-
path
|
|
972
|
+
path,
|
|
1033
973
|
});
|
|
1034
974
|
async function processBot(bot, state, cfg, contextCache, hooks = {}) {
|
|
1035
975
|
return adapterService.processBot(bot, state, cfg, contextCache, hooks);
|
|
@@ -1053,7 +993,7 @@ function writeCenterSnapshot(state) {
|
|
|
1053
993
|
lastDeltaPercent: v.lastDeltaPercent,
|
|
1054
994
|
amaSlopeDeltaPercent: v.amaSlopeDeltaPercent,
|
|
1055
995
|
amaSlopeThresholdPercent: v.amaSlopeThresholdPercent,
|
|
1056
|
-
amaSlopePercentMode: v.amaSlopePercentMode ||
|
|
996
|
+
amaSlopePercentMode: v.amaSlopePercentMode || AMA_SLOPE_PERCENT_MODE_PER_BAR,
|
|
1057
997
|
gridRangeScalingAmaSlope: v.gridRangeScalingAmaSlope,
|
|
1058
998
|
weights: v.weights,
|
|
1059
999
|
effectiveWeights: v.effectiveWeights,
|
|
@@ -1072,10 +1012,10 @@ function mergeGridResetMetadataFromDynamicGrid(state) {
|
|
|
1072
1012
|
for (const [botKey, botState] of Object.entries(bots)) {
|
|
1073
1013
|
if (!botState || typeof botState !== 'object')
|
|
1074
1014
|
continue;
|
|
1075
|
-
const snapshotPath =
|
|
1015
|
+
const snapshotPath = path.join(ORDERS_DIR, `${botKey}.dynamicgrid.json`);
|
|
1076
1016
|
let snapshot;
|
|
1077
1017
|
try {
|
|
1078
|
-
snapshot =
|
|
1018
|
+
snapshot = readJSON(snapshotPath);
|
|
1079
1019
|
}
|
|
1080
1020
|
catch (_) {
|
|
1081
1021
|
continue;
|
|
@@ -1107,7 +1047,7 @@ async function runOnce(cfg, state, contextCache) {
|
|
|
1107
1047
|
log(cfg, `Active bots: ${allBots.length} | AMA-grid bots: ${bots.length}`);
|
|
1108
1048
|
const results = [];
|
|
1109
1049
|
for (const bot of bots) {
|
|
1110
|
-
const isDryRun = cfg.dryRun || (!cfg.whitelistAll && !
|
|
1050
|
+
const isDryRun = cfg.dryRun || (!cfg.whitelistAll && !isBotWhitelisted(bot.botKey));
|
|
1111
1051
|
write(cfg, `- ${bot.name} (${bot.botKey})${isDryRun ? ' [DRY RUN]' : ''}: `);
|
|
1112
1052
|
try {
|
|
1113
1053
|
const botCfg = resolveBotCfg(bot, cfg);
|
|
@@ -1137,9 +1077,9 @@ async function runOnce(cfg, state, contextCache) {
|
|
|
1137
1077
|
const patchText = Number.isFinite(r.kibanaGapRepairCount) && r.kibanaGapRepairCount > 0 ? ` KIBANA_PATCH(${r.kibanaGapRepairCount})` : '';
|
|
1138
1078
|
const backfillText = Number.isFinite(r.kibanaBackfillCount) && r.kibanaBackfillCount > 0 ? ` BACKFILL(${r.kibanaBackfillCount})` : '';
|
|
1139
1079
|
const gapText = Number.isFinite(r.unresolvedGapCount) && r.unresolvedGapCount > 0 ? ` GAPS(${r.unresolvedGapCount})` : '';
|
|
1140
|
-
const trigText = r.triggered ? ` TRIGGERED -> ${r.triggerPath ?
|
|
1080
|
+
const trigText = r.triggered ? ` TRIGGERED -> ${r.triggerPath ? path.relative(ROOT, r.triggerPath) : '[suppressed, dry-run]'}` : '';
|
|
1141
1081
|
const pendingText = r.pendingClosedCandle ? ' WAITING_FOR_CLOSED_CANDLE' : '';
|
|
1142
|
-
const weightText =
|
|
1082
|
+
const weightText = buildWeightSummary(r.weights);
|
|
1143
1083
|
const trendText = r.amaSlope?.trend ? ` trend=${r.amaSlope.trend}` : '';
|
|
1144
1084
|
const warmupText = r.triggerSuppressedReason === 'ama_warmup_insufficient'
|
|
1145
1085
|
? ` WARMUP_INSUFFICIENT(used=${r.analysisCandleCount}${Number.isFinite(r.analysisKeepCount) ? `/${r.analysisKeepCount}` : ''})`
|
|
@@ -1174,19 +1114,19 @@ async function runOnce(cfg, state, contextCache) {
|
|
|
1174
1114
|
}
|
|
1175
1115
|
if (isOneHourResult && r.weights?.meta) {
|
|
1176
1116
|
const m = r.weights.meta;
|
|
1177
|
-
log(cfg, ` Inputs: ${
|
|
1178
|
-
log(cfg, ` Tuning: ${
|
|
1117
|
+
log(cfg, ` Inputs: ${buildDynamicWeightInputsLog(m, r.amaConfig)}`);
|
|
1118
|
+
log(cfg, ` Tuning: ${buildDynamicWeightTuningLog(m)}`);
|
|
1179
1119
|
}
|
|
1180
1120
|
if (isOneHourResult && r.gridRangeScalingWhitelisted) {
|
|
1181
1121
|
const asymSource = r.weights?.meta && Number.isFinite(r.weights.meta.rawAsymmetryFactor)
|
|
1182
1122
|
? r.weights.meta
|
|
1183
1123
|
: r;
|
|
1184
|
-
log(cfg, ` Asymmetric bounds: ${
|
|
1124
|
+
log(cfg, ` Asymmetric bounds: ${buildAsymmetricBoundsLog(asymSource)}`);
|
|
1185
1125
|
}
|
|
1186
1126
|
if (Array.isArray(r.amaComparison) && r.amaComparison.length > 0) {
|
|
1187
1127
|
const parts = r.amaComparison.map((a) => {
|
|
1188
1128
|
const val = Number.isFinite(a.value) ? a.value.toFixed(8) : 'n/a';
|
|
1189
|
-
const erSmoothText = Number.isFinite(Number(a.erSmoothPeriod)) ? `/es${
|
|
1129
|
+
const erSmoothText = Number.isFinite(Number(a.erSmoothPeriod)) ? `/es${fixedTo(a.erSmoothPeriod, 0)}` : '';
|
|
1190
1130
|
return `${a.name}[${a.erPeriod}/${a.fastPeriod}/${a.slowPeriod}${erSmoothText}]=${val}`;
|
|
1191
1131
|
});
|
|
1192
1132
|
log(cfg, ` AMA compare: ${parts.join(' | ')}`);
|
|
@@ -1198,12 +1138,12 @@ async function runOnce(cfg, state, contextCache) {
|
|
|
1198
1138
|
});
|
|
1199
1139
|
}
|
|
1200
1140
|
catch (err) {
|
|
1201
|
-
log(cfg, `error (${
|
|
1141
|
+
log(cfg, `error (${getErrorMessage(err)})`);
|
|
1202
1142
|
results.push({
|
|
1203
1143
|
botName: bot.name,
|
|
1204
1144
|
botKey: bot.botKey,
|
|
1205
1145
|
ok: false,
|
|
1206
|
-
reason:
|
|
1146
|
+
reason: getErrorMessage(err),
|
|
1207
1147
|
});
|
|
1208
1148
|
}
|
|
1209
1149
|
}
|
|
@@ -1255,13 +1195,13 @@ async function runOnceForAma(overrides = {}) {
|
|
|
1255
1195
|
...overrides,
|
|
1256
1196
|
once: true,
|
|
1257
1197
|
});
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
const lock =
|
|
1198
|
+
ensureDir(DATA_DIR);
|
|
1199
|
+
ensureDir(STATE_DIR);
|
|
1200
|
+
const lock = acquireFileLockSync(LOCK_FILE, {
|
|
1261
1201
|
staleMs: Math.max(2, cfg.pollSeconds) * 1000 * 2,
|
|
1262
1202
|
});
|
|
1263
1203
|
try {
|
|
1264
|
-
const { connectClient } =
|
|
1204
|
+
const { connectClient } = getBitsharesClient();
|
|
1265
1205
|
await connectClient();
|
|
1266
1206
|
const state = loadJson(STATE_FILE, { meta: {}, bots: {} });
|
|
1267
1207
|
const contextCache = new Map();
|
|
@@ -1273,25 +1213,25 @@ async function runOnceForAma(overrides = {}) {
|
|
|
1273
1213
|
};
|
|
1274
1214
|
}
|
|
1275
1215
|
finally {
|
|
1276
|
-
const { disconnectClient } =
|
|
1216
|
+
const { disconnectClient } = getBitsharesClient();
|
|
1277
1217
|
disconnectClient();
|
|
1278
|
-
|
|
1218
|
+
releaseFileLockSync(lock);
|
|
1279
1219
|
}
|
|
1280
1220
|
}
|
|
1281
1221
|
async function main() {
|
|
1282
1222
|
const cfg = parseArgs();
|
|
1283
1223
|
logger.quiet = cfg.quiet;
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
const lock =
|
|
1224
|
+
ensureDir(DATA_DIR);
|
|
1225
|
+
ensureDir(STATE_DIR);
|
|
1226
|
+
const lock = acquireFileLockSync(LOCK_FILE, {
|
|
1287
1227
|
staleMs: Math.max(2, cfg.pollSeconds) * 1000 * 2,
|
|
1288
1228
|
});
|
|
1289
1229
|
try {
|
|
1290
1230
|
log(cfg, '═══════════════════════════════════════');
|
|
1291
1231
|
log(cfg, ' Market Adapter Hub Settings:');
|
|
1292
1232
|
log(cfg, ` runtime : poll=${cfg.pollSeconds}s | bootstrap=${cfg.bootstrapLookbackHours}h | native=${cfg.nativeBackfillHours}h | stale=${cfg.maxStaleHours}h`);
|
|
1293
|
-
log(cfg, ` fetch : retries=${cfg.sourceRetries}x${cfg.retryDelayMs}ms | pages=${cfg.maxPages}x${cfg.pageLimit} | delta=${
|
|
1294
|
-
log(cfg,
|
|
1233
|
+
log(cfg, ` fetch : retries=${cfg.sourceRetries}x${cfg.retryDelayMs}ms | pages=${cfg.maxPages}x${cfg.pageLimit} | delta=${formatLogPercent(cfg.deltaThresholdPercent, 3)} | dryRun=${cfg.dryRun ? 'yes' : 'no'} | quiet=${cfg.quiet ? 'yes' : 'no'} | metrics=${cfg.metricsJson ? 'yes' : 'no'}`);
|
|
1234
|
+
log(cfg, buildStartupDefaultsLog(DEFAULT_AMA, DEFAULT_CONFIG, MARKET_ADAPTER));
|
|
1295
1235
|
log(cfg, '═══════════════════════════════════════');
|
|
1296
1236
|
if (cfg.once && cfg.dryRun) {
|
|
1297
1237
|
log(cfg, 'Dry run: config validation + lock acquisition OK (no network, no writes).');
|
|
@@ -1302,7 +1242,7 @@ async function main() {
|
|
|
1302
1242
|
let lastErr = null;
|
|
1303
1243
|
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
1304
1244
|
try {
|
|
1305
|
-
const { connectClient } =
|
|
1245
|
+
const { connectClient } = getBitsharesClient();
|
|
1306
1246
|
await connectClient();
|
|
1307
1247
|
lastErr = null;
|
|
1308
1248
|
break;
|
|
@@ -1310,9 +1250,9 @@ async function main() {
|
|
|
1310
1250
|
catch (err) {
|
|
1311
1251
|
lastErr = err;
|
|
1312
1252
|
if (attempt < maxRetries) {
|
|
1313
|
-
const delay = Math.min(1000 * Math.pow(2, attempt - 1),
|
|
1314
|
-
logger.warn(`Connection attempt ${attempt}/${maxRetries} failed: ${
|
|
1315
|
-
await
|
|
1253
|
+
const delay = Math.min(1000 * Math.pow(2, attempt - 1), TIMING.RETRY_BACKOFF_CAP_MS);
|
|
1254
|
+
logger.warn(`Connection attempt ${attempt}/${maxRetries} failed: ${getErrorMessage(err)}; retrying in ${delay}ms`);
|
|
1255
|
+
await sleep(delay);
|
|
1316
1256
|
}
|
|
1317
1257
|
}
|
|
1318
1258
|
}
|
|
@@ -1335,33 +1275,34 @@ async function main() {
|
|
|
1335
1275
|
// Connect for this cycle using the lightweight native read-only client.
|
|
1336
1276
|
// Tear down after runOnce so the connection never sits idle.
|
|
1337
1277
|
try {
|
|
1338
|
-
const { connectClient } =
|
|
1278
|
+
const { connectClient } = getBitsharesClient();
|
|
1339
1279
|
await connectClient();
|
|
1340
1280
|
}
|
|
1341
1281
|
catch (err) {
|
|
1342
|
-
logger.error(`Connection failed before cycle: ${
|
|
1282
|
+
logger.error(`Connection failed before cycle: ${getErrorMessage(err)}`);
|
|
1343
1283
|
// Fall through and let runOnce attempt to handle its own retries/failures
|
|
1344
1284
|
}
|
|
1345
1285
|
await runOnce(cfg, state, contextCache);
|
|
1346
1286
|
try {
|
|
1347
|
-
const { disconnectClient } =
|
|
1287
|
+
const { disconnectClient } = getBitsharesClient();
|
|
1348
1288
|
disconnectClient();
|
|
1349
1289
|
}
|
|
1350
1290
|
catch (_) { }
|
|
1351
1291
|
const sleepMs = sleepUntilAlignedBoundary(cfg.pollSeconds, started, Date.now());
|
|
1352
|
-
await
|
|
1292
|
+
await sleep(sleepMs);
|
|
1353
1293
|
}
|
|
1354
1294
|
}
|
|
1355
1295
|
finally {
|
|
1356
|
-
|
|
1296
|
+
releaseFileLockSync(lock);
|
|
1357
1297
|
}
|
|
1358
1298
|
}
|
|
1359
|
-
if (
|
|
1299
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
1360
1300
|
main()
|
|
1361
1301
|
.then((exitCode) => process.exit(Number.isInteger(exitCode) ? exitCode : 0))
|
|
1362
1302
|
.catch((err) => {
|
|
1363
|
-
logger.error(`Fatal: ${
|
|
1303
|
+
logger.error(`Fatal: ${getErrorMessage(err)}`);
|
|
1364
1304
|
process.exit(1);
|
|
1365
1305
|
});
|
|
1366
1306
|
}
|
|
1307
|
+
export { main, runOnceForAma, DEFAULT_AMA, DEFAULTS, calculateBotThreshold, calcAmaComparison, computeCandleStaleness, normalizeMarketSource, sleepUntilAlignedBoundary, resolveAmaForBot, resolveDeltaThresholdPercentFromGeneralSettings, applyRuntimeDefaultsFromGeneralSettings, resolveBotCfg, usesAmaGridPrice, usesBookMarketSource, isBotWhitelisted, isBotDynamicWeightWhitelisted, isBotAsymmetricBoundsWhitelisted, isBotGridRangeScalingWhitelisted, _resetCycleCache, writeCenterSnapshot, writeBotDynamicGrid, writeGridResetTrigger, mergeGridResetMetadataFromDynamicGrid, normalizeNativeMarketHistoryCandles, fetchNativeMarketHistorySince, setBitsharesClientForTests as _setBitsharesClientForTests, loadMarketAdapterSettings, findPairForBot };
|
|
1367
1308
|
//# sourceMappingURL=market_adapter.js.map
|