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,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;
|
|
@@ -279,7 +215,7 @@ function applyMarketAdapterOverrides(target, overrides, opts = {}) {
|
|
|
279
215
|
'dispScaleMinPct',
|
|
280
216
|
]);
|
|
281
217
|
if (overrides.maxVolatilityOffset != null) {
|
|
282
|
-
target.maxVolatilityOffset =
|
|
218
|
+
target.maxVolatilityOffset = normalizeMaxVolatilityOffset(overrides.maxVolatilityOffset);
|
|
283
219
|
}
|
|
284
220
|
// Per-field merge for asymmetricBounds so a bot-level override (e.g. only
|
|
285
221
|
// minScaleSlots) does not wipe a market-level maxAsymmetryFactor. Mirrors how
|
|
@@ -288,9 +224,9 @@ function applyMarketAdapterOverrides(target, overrides, opts = {}) {
|
|
|
288
224
|
target.asymmetricBounds = { ...(target.asymmetricBounds || {}), ...overrides.asymmetricBounds };
|
|
289
225
|
}
|
|
290
226
|
if (overrides.atrPeriod != null)
|
|
291
|
-
target.atrPeriod =
|
|
227
|
+
target.atrPeriod = normalizeAtrPeriod(overrides.atrPeriod);
|
|
292
228
|
if (overrides.volatilityThreshold != null) {
|
|
293
|
-
target.volatilityThreshold =
|
|
229
|
+
target.volatilityThreshold = normalizeVolatilityThreshold(overrides.volatilityThreshold);
|
|
294
230
|
}
|
|
295
231
|
if (overrides.peNodes)
|
|
296
232
|
target.peNodes = overrides.peNodes;
|
|
@@ -327,10 +263,9 @@ function resolveBotCfg(bot, globalCfg) {
|
|
|
327
263
|
}
|
|
328
264
|
return merged;
|
|
329
265
|
}
|
|
330
|
-
const DEFAULT_AMA_KEY = String(
|
|
331
|
-
const BUILTIN_AMAS =
|
|
332
|
-
const DEFAULT_AMA =
|
|
333
|
-
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;
|
|
334
269
|
const AMA_KEYWORDS = new Set(['ama', 'ama1', 'ama2', 'ama3', 'ama4']);
|
|
335
270
|
const AMA_PRESET_KEYS = ['AMA1', 'AMA2', 'AMA3', 'AMA4'];
|
|
336
271
|
function normalizeAmaPreset(raw) {
|
|
@@ -356,17 +291,17 @@ function isAmaKeyword(raw) {
|
|
|
356
291
|
function usesAmaGridPrice(bot) {
|
|
357
292
|
return isAmaKeyword(bot?.gridPrice);
|
|
358
293
|
}
|
|
359
|
-
function
|
|
360
|
-
return
|
|
294
|
+
function usesBookMarketSource(bot) {
|
|
295
|
+
return resolveMarketSourceForBot(bot) === 'book';
|
|
361
296
|
}
|
|
362
297
|
function findAmaProfileForBot(bot, ctx) {
|
|
363
|
-
const profiles =
|
|
298
|
+
const profiles = loadMarketProfiles()?.profiles || [];
|
|
364
299
|
if (profiles.length === 0)
|
|
365
300
|
return null;
|
|
366
|
-
const botAssetA =
|
|
367
|
-
const botAssetB =
|
|
368
|
-
const ctxAssetAId =
|
|
369
|
-
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);
|
|
370
305
|
if (!botAssetA && !ctxAssetAId)
|
|
371
306
|
return null;
|
|
372
307
|
if (!botAssetB && !ctxAssetBId)
|
|
@@ -376,12 +311,12 @@ function findAmaProfileForBot(bot, ctx) {
|
|
|
376
311
|
const pB = p?.assetB;
|
|
377
312
|
const pAId = p?.assetAId;
|
|
378
313
|
const pBId = p?.assetBId;
|
|
379
|
-
const exactBySymbol = botAssetA && botAssetB && pA && pB &&
|
|
314
|
+
const exactBySymbol = botAssetA && botAssetB && pA && pB && isExactPair(botAssetA, botAssetB, pA, pB);
|
|
380
315
|
const exactById = ctxAssetAId && ctxAssetBId && pAId && pBId
|
|
381
|
-
&&
|
|
382
|
-
const symmetricBySymbol = botAssetA && botAssetB && pA && pB &&
|
|
316
|
+
&& isExactPairIds(ctxAssetAId, ctxAssetBId, pAId, pBId);
|
|
317
|
+
const symmetricBySymbol = botAssetA && botAssetB && pA && pB && isSamePair(botAssetA, botAssetB, pA, pB);
|
|
383
318
|
const symmetricById = ctxAssetAId && ctxAssetBId && pAId && pBId
|
|
384
|
-
&&
|
|
319
|
+
&& isSamePairIds(ctxAssetAId, ctxAssetBId, pAId, pBId);
|
|
385
320
|
const matchRank = (exactById || exactBySymbol)
|
|
386
321
|
? 2
|
|
387
322
|
: ((symmetricById || symmetricBySymbol) ? 1 : 0);
|
|
@@ -414,7 +349,7 @@ function normalizeErSmoothPeriod(raw, fallback = 0) {
|
|
|
414
349
|
}
|
|
415
350
|
function resolveErSmoothPeriodForBot(bot) {
|
|
416
351
|
const raw = (bot && typeof bot.ama === 'object' && bot.ama !== null) ? bot.ama : {};
|
|
417
|
-
const globalErSmoothPeriod = normalizeErSmoothPeriod(
|
|
352
|
+
const globalErSmoothPeriod = normalizeErSmoothPeriod(MARKET_ADAPTER.AMA_ER_SMOOTH_FAST_PERIOD, 0);
|
|
418
353
|
if (Object.prototype.hasOwnProperty.call(raw, 'erSmoothPeriod')) {
|
|
419
354
|
return normalizeErSmoothPeriod(raw.erSmoothPeriod, globalErSmoothPeriod);
|
|
420
355
|
}
|
|
@@ -482,7 +417,7 @@ function withRetries(fn, attempts, baseDelayMs, label) {
|
|
|
482
417
|
break;
|
|
483
418
|
const waitMs = Math.max(0, baseDelayMs) * (i + 1);
|
|
484
419
|
if (waitMs > 0)
|
|
485
|
-
await
|
|
420
|
+
await sleep(waitMs);
|
|
486
421
|
}
|
|
487
422
|
}
|
|
488
423
|
const msg = label ? `${label}: ${lastErr?.message || 'unknown error'}` : (lastErr?.message || 'unknown error');
|
|
@@ -605,7 +540,7 @@ function applyRuntimeDefaultsFromGeneralSettings(cfg, provided = {}, settingsOve
|
|
|
605
540
|
const out = { ...cfg };
|
|
606
541
|
if (!provided?.deltaThresholdPercent) {
|
|
607
542
|
const settings = settingsOverride === undefined
|
|
608
|
-
?
|
|
543
|
+
? readGeneralSettings({ fallback: null })
|
|
609
544
|
: settingsOverride;
|
|
610
545
|
const fromSettings = resolveDeltaThresholdPercentFromGeneralSettings(settings);
|
|
611
546
|
if (fromSettings != null) {
|
|
@@ -614,8 +549,8 @@ function applyRuntimeDefaultsFromGeneralSettings(cfg, provided = {}, settingsOve
|
|
|
614
549
|
}
|
|
615
550
|
return out;
|
|
616
551
|
}
|
|
617
|
-
const marketAdapterLogFile =
|
|
618
|
-
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 });
|
|
619
554
|
function log(cfg, ...args) {
|
|
620
555
|
logger.quiet = !!cfg?.quiet;
|
|
621
556
|
logger.info(...args);
|
|
@@ -650,24 +585,24 @@ function loadActiveBots() {
|
|
|
650
585
|
if (!storage.exists(BOTS_FILE)) {
|
|
651
586
|
throw new Error(`Bots file not found at ${BOTS_FILE}`);
|
|
652
587
|
}
|
|
653
|
-
const raw =
|
|
588
|
+
const raw = parseJsonWithComments(storage.readFile(BOTS_FILE));
|
|
654
589
|
const bots = Array.isArray(raw?.bots) ? raw.bots : (Array.isArray(raw) ? raw : []);
|
|
655
590
|
return bots
|
|
656
|
-
.map((b, i) =>
|
|
591
|
+
.map((b, i) => normalizeBotEntry(b, i))
|
|
657
592
|
.filter((b) => b.active);
|
|
658
593
|
}
|
|
659
594
|
function loadJson(filePath, defaultValue) {
|
|
660
595
|
try {
|
|
661
596
|
if (!storage.exists(filePath))
|
|
662
597
|
return defaultValue;
|
|
663
|
-
return
|
|
598
|
+
return readJSON(filePath);
|
|
664
599
|
}
|
|
665
600
|
catch (_) {
|
|
666
601
|
return defaultValue;
|
|
667
602
|
}
|
|
668
603
|
}
|
|
669
604
|
function saveJson(filePath, data) {
|
|
670
|
-
|
|
605
|
+
writeJsonAtomic(filePath, data);
|
|
671
606
|
}
|
|
672
607
|
function parseChainTimeToMs(timeStr) {
|
|
673
608
|
if (!timeStr)
|
|
@@ -678,8 +613,8 @@ function parseChainTimeToMs(timeStr) {
|
|
|
678
613
|
function candleFileForBot(botKey, intervalSeconds = RUNTIME_DEFAULTS.intervalSeconds) {
|
|
679
614
|
const label = intervalSeconds === RUNTIME_DEFAULTS.intervalSeconds
|
|
680
615
|
? RUNTIME_DEFAULTS.intervalLabel
|
|
681
|
-
:
|
|
682
|
-
return
|
|
616
|
+
: toIntervalLabel(intervalSeconds);
|
|
617
|
+
return path.join(DATA_DIR, `market_adapter_${botKey}_${label}.json`);
|
|
683
618
|
}
|
|
684
619
|
function calculateBotThreshold(cfg) {
|
|
685
620
|
const value = Number(cfg?.deltaThresholdPercent);
|
|
@@ -747,7 +682,7 @@ function calcAmaComparison(candles, bot = null, ctx = null) {
|
|
|
747
682
|
out.push({ ...p, value: null, ok: false });
|
|
748
683
|
continue;
|
|
749
684
|
}
|
|
750
|
-
const values =
|
|
685
|
+
const values = calculateAMA(closes, {
|
|
751
686
|
erPeriod: p.erPeriod,
|
|
752
687
|
fastPeriod: p.fastPeriod,
|
|
753
688
|
slowPeriod: p.slowPeriod,
|
|
@@ -759,7 +694,7 @@ function calcAmaComparison(candles, bot = null, ctx = null) {
|
|
|
759
694
|
return out;
|
|
760
695
|
}
|
|
761
696
|
async function fetchNativeTradesSince(poolId, sinceMs, pageLimit, maxPages) {
|
|
762
|
-
const { BitShares } =
|
|
697
|
+
const { BitShares } = getBitsharesClient();
|
|
763
698
|
const trades = [];
|
|
764
699
|
const seenSequences = new Set();
|
|
765
700
|
let pages = 0;
|
|
@@ -829,7 +764,7 @@ function nativeHistoryRowToTrade(row) {
|
|
|
829
764
|
};
|
|
830
765
|
}
|
|
831
766
|
async function fetchNativeTradesUntilOverlap(poolId, overlapSequences, minOverlap, pageLimit, maxPages) {
|
|
832
|
-
const { BitShares } =
|
|
767
|
+
const { BitShares } = getBitsharesClient();
|
|
833
768
|
const overlapSet = new Set((Array.isArray(overlapSequences) ? overlapSequences : [])
|
|
834
769
|
.map((v) => String(v))
|
|
835
770
|
.filter((v) => v !== ''));
|
|
@@ -886,7 +821,7 @@ async function fetchNativeTradesUntilOverlap(poolId, overlapSequences, minOverla
|
|
|
886
821
|
};
|
|
887
822
|
}
|
|
888
823
|
async function fetchNativeMarketHistorySince(assetA, assetB, sinceMs, untilMs, intervalSeconds, options = {}) {
|
|
889
|
-
const { BitShares } =
|
|
824
|
+
const { BitShares } = getBitsharesClient();
|
|
890
825
|
if (!BitShares) {
|
|
891
826
|
throw new Error('BitShares client unavailable');
|
|
892
827
|
}
|
|
@@ -902,14 +837,14 @@ async function fetchNativeMarketHistorySince(assetA, assetB, sinceMs, untilMs, i
|
|
|
902
837
|
else {
|
|
903
838
|
throw new Error('native market history source unavailable');
|
|
904
839
|
}
|
|
905
|
-
let candles =
|
|
840
|
+
let candles = normalizeNativeMarketHistoryCandles(history, assetA, assetB, intervalSeconds);
|
|
906
841
|
if (candles.length > 0 && typeof options.fillCandleGaps === 'function') {
|
|
907
842
|
candles = options.fillCandleGaps(candles, intervalSeconds);
|
|
908
843
|
}
|
|
909
844
|
return candles;
|
|
910
845
|
}
|
|
911
846
|
function writeGridResetTrigger(bot, payload) {
|
|
912
|
-
const triggerPath =
|
|
847
|
+
const triggerPath = getRecalculateTriggerFile(bot.botKey);
|
|
913
848
|
const content = {
|
|
914
849
|
createdAt: new Date().toISOString(),
|
|
915
850
|
source: MARKET_ADAPTER_SOURCE,
|
|
@@ -917,10 +852,10 @@ function writeGridResetTrigger(bot, payload) {
|
|
|
917
852
|
botKey: bot.botKey,
|
|
918
853
|
...payload,
|
|
919
854
|
};
|
|
920
|
-
|
|
855
|
+
writeJsonAtomic(triggerPath, content);
|
|
921
856
|
return triggerPath;
|
|
922
857
|
}
|
|
923
|
-
const ORDERS_DIR =
|
|
858
|
+
const ORDERS_DIR = PATHS.ORDERS_DIR;
|
|
924
859
|
/**
|
|
925
860
|
* Atomically write the dynamic grid snapshot for a bot to profiles/orders/<botKey>.dynamicgrid.json.
|
|
926
861
|
* Contains AMA-derived center price and any computed effective weight offsets.
|
|
@@ -929,7 +864,7 @@ const ORDERS_DIR = paths_1.PATHS.ORDERS_DIR;
|
|
|
929
864
|
*/
|
|
930
865
|
function writeBotDynamicGrid(botKey, gridCenterPrice, options = {}) {
|
|
931
866
|
try {
|
|
932
|
-
const filePath =
|
|
867
|
+
const filePath = path.join(ORDERS_DIR, `${botKey}.dynamicgrid.json`);
|
|
933
868
|
const preserveGridResetMetadata = (target, snapshot) => {
|
|
934
869
|
if (!snapshot?.lastGridResetAt)
|
|
935
870
|
return target;
|
|
@@ -956,16 +891,16 @@ function writeBotDynamicGrid(botKey, gridCenterPrice, options = {}) {
|
|
|
956
891
|
}
|
|
957
892
|
return target;
|
|
958
893
|
};
|
|
959
|
-
const result =
|
|
894
|
+
const result = updateDynamicGridSnapshotSync(filePath, (previousSnapshot) => {
|
|
960
895
|
const amaCenterPrice = Number(options.amaCenterPrice);
|
|
961
896
|
const resolvedGridCenterPrice = Number.isFinite(Number(gridCenterPrice))
|
|
962
|
-
?
|
|
897
|
+
? roundTo(Number(gridCenterPrice), 1e8)
|
|
963
898
|
: null;
|
|
964
899
|
const payload = {
|
|
965
900
|
gridCenterPrice: resolvedGridCenterPrice,
|
|
966
901
|
centerPrice: resolvedGridCenterPrice,
|
|
967
902
|
amaCenterPrice: Number.isFinite(amaCenterPrice) && amaCenterPrice > 0 ? amaCenterPrice : resolvedGridCenterPrice,
|
|
968
|
-
amaSlopePercentMode:
|
|
903
|
+
amaSlopePercentMode: AMA_SLOPE_PERCENT_MODE_PER_BAR,
|
|
969
904
|
updatedAt: new Date().toISOString(),
|
|
970
905
|
source: MARKET_ADAPTER_SOURCE,
|
|
971
906
|
};
|
|
@@ -999,14 +934,14 @@ function writeBotDynamicGrid(botKey, gridCenterPrice, options = {}) {
|
|
|
999
934
|
return result.ok && result.written;
|
|
1000
935
|
}
|
|
1001
936
|
catch (err) {
|
|
1002
|
-
logger.warn(`[writeBotDynamicGrid] Failed to write dynamic grid for ${botKey}: ${
|
|
937
|
+
logger.warn(`[writeBotDynamicGrid] Failed to write dynamic grid for ${botKey}: ${getErrorMessage(err)}`);
|
|
1003
938
|
return false;
|
|
1004
939
|
}
|
|
1005
940
|
}
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
const adapterService = new
|
|
1009
|
-
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,
|
|
1010
945
|
resolveAmaForBot,
|
|
1011
946
|
candleFileForBot,
|
|
1012
947
|
loadJson,
|
|
@@ -1019,22 +954,22 @@ const adapterService = new market_adapter_service_js_1.MarketAdapterService({
|
|
|
1019
954
|
fetchNativeMarketHistorySince,
|
|
1020
955
|
fetchNativeTradesSince,
|
|
1021
956
|
fetchNativeTradesUntilOverlap,
|
|
1022
|
-
tradesToCandles
|
|
1023
|
-
detectMissingCandleTimestamps
|
|
1024
|
-
fillCandleGaps
|
|
1025
|
-
detectStaleTail
|
|
1026
|
-
pruneStaleTail
|
|
1027
|
-
mergeCandles
|
|
957
|
+
tradesToCandles,
|
|
958
|
+
detectMissingCandleTimestamps,
|
|
959
|
+
fillCandleGaps,
|
|
960
|
+
detectStaleTail,
|
|
961
|
+
pruneStaleTail,
|
|
962
|
+
mergeCandles,
|
|
1028
963
|
pruneCandles,
|
|
1029
964
|
calcAmaComparison,
|
|
1030
965
|
writeGridResetTrigger,
|
|
1031
966
|
writeBotDynamicGrid,
|
|
1032
|
-
isBotWhitelisted
|
|
1033
|
-
isBotDynamicWeightWhitelisted
|
|
1034
|
-
isBotGridRangeScalingWhitelisted
|
|
967
|
+
isBotWhitelisted,
|
|
968
|
+
isBotDynamicWeightWhitelisted,
|
|
969
|
+
isBotGridRangeScalingWhitelisted,
|
|
1035
970
|
logger,
|
|
1036
971
|
root: ROOT,
|
|
1037
|
-
path
|
|
972
|
+
path,
|
|
1038
973
|
});
|
|
1039
974
|
async function processBot(bot, state, cfg, contextCache, hooks = {}) {
|
|
1040
975
|
return adapterService.processBot(bot, state, cfg, contextCache, hooks);
|
|
@@ -1058,7 +993,7 @@ function writeCenterSnapshot(state) {
|
|
|
1058
993
|
lastDeltaPercent: v.lastDeltaPercent,
|
|
1059
994
|
amaSlopeDeltaPercent: v.amaSlopeDeltaPercent,
|
|
1060
995
|
amaSlopeThresholdPercent: v.amaSlopeThresholdPercent,
|
|
1061
|
-
amaSlopePercentMode: v.amaSlopePercentMode ||
|
|
996
|
+
amaSlopePercentMode: v.amaSlopePercentMode || AMA_SLOPE_PERCENT_MODE_PER_BAR,
|
|
1062
997
|
gridRangeScalingAmaSlope: v.gridRangeScalingAmaSlope,
|
|
1063
998
|
weights: v.weights,
|
|
1064
999
|
effectiveWeights: v.effectiveWeights,
|
|
@@ -1077,10 +1012,10 @@ function mergeGridResetMetadataFromDynamicGrid(state) {
|
|
|
1077
1012
|
for (const [botKey, botState] of Object.entries(bots)) {
|
|
1078
1013
|
if (!botState || typeof botState !== 'object')
|
|
1079
1014
|
continue;
|
|
1080
|
-
const snapshotPath =
|
|
1015
|
+
const snapshotPath = path.join(ORDERS_DIR, `${botKey}.dynamicgrid.json`);
|
|
1081
1016
|
let snapshot;
|
|
1082
1017
|
try {
|
|
1083
|
-
snapshot =
|
|
1018
|
+
snapshot = readJSON(snapshotPath);
|
|
1084
1019
|
}
|
|
1085
1020
|
catch (_) {
|
|
1086
1021
|
continue;
|
|
@@ -1112,7 +1047,7 @@ async function runOnce(cfg, state, contextCache) {
|
|
|
1112
1047
|
log(cfg, `Active bots: ${allBots.length} | AMA-grid bots: ${bots.length}`);
|
|
1113
1048
|
const results = [];
|
|
1114
1049
|
for (const bot of bots) {
|
|
1115
|
-
const isDryRun = cfg.dryRun || (!cfg.whitelistAll && !
|
|
1050
|
+
const isDryRun = cfg.dryRun || (!cfg.whitelistAll && !isBotWhitelisted(bot.botKey));
|
|
1116
1051
|
write(cfg, `- ${bot.name} (${bot.botKey})${isDryRun ? ' [DRY RUN]' : ''}: `);
|
|
1117
1052
|
try {
|
|
1118
1053
|
const botCfg = resolveBotCfg(bot, cfg);
|
|
@@ -1142,9 +1077,9 @@ async function runOnce(cfg, state, contextCache) {
|
|
|
1142
1077
|
const patchText = Number.isFinite(r.kibanaGapRepairCount) && r.kibanaGapRepairCount > 0 ? ` KIBANA_PATCH(${r.kibanaGapRepairCount})` : '';
|
|
1143
1078
|
const backfillText = Number.isFinite(r.kibanaBackfillCount) && r.kibanaBackfillCount > 0 ? ` BACKFILL(${r.kibanaBackfillCount})` : '';
|
|
1144
1079
|
const gapText = Number.isFinite(r.unresolvedGapCount) && r.unresolvedGapCount > 0 ? ` GAPS(${r.unresolvedGapCount})` : '';
|
|
1145
|
-
const trigText = r.triggered ? ` TRIGGERED -> ${r.triggerPath ?
|
|
1080
|
+
const trigText = r.triggered ? ` TRIGGERED -> ${r.triggerPath ? path.relative(ROOT, r.triggerPath) : '[suppressed, dry-run]'}` : '';
|
|
1146
1081
|
const pendingText = r.pendingClosedCandle ? ' WAITING_FOR_CLOSED_CANDLE' : '';
|
|
1147
|
-
const weightText =
|
|
1082
|
+
const weightText = buildWeightSummary(r.weights);
|
|
1148
1083
|
const trendText = r.amaSlope?.trend ? ` trend=${r.amaSlope.trend}` : '';
|
|
1149
1084
|
const warmupText = r.triggerSuppressedReason === 'ama_warmup_insufficient'
|
|
1150
1085
|
? ` WARMUP_INSUFFICIENT(used=${r.analysisCandleCount}${Number.isFinite(r.analysisKeepCount) ? `/${r.analysisKeepCount}` : ''})`
|
|
@@ -1179,19 +1114,19 @@ async function runOnce(cfg, state, contextCache) {
|
|
|
1179
1114
|
}
|
|
1180
1115
|
if (isOneHourResult && r.weights?.meta) {
|
|
1181
1116
|
const m = r.weights.meta;
|
|
1182
|
-
log(cfg, ` Inputs: ${
|
|
1183
|
-
log(cfg, ` Tuning: ${
|
|
1117
|
+
log(cfg, ` Inputs: ${buildDynamicWeightInputsLog(m, r.amaConfig)}`);
|
|
1118
|
+
log(cfg, ` Tuning: ${buildDynamicWeightTuningLog(m)}`);
|
|
1184
1119
|
}
|
|
1185
1120
|
if (isOneHourResult && r.gridRangeScalingWhitelisted) {
|
|
1186
1121
|
const asymSource = r.weights?.meta && Number.isFinite(r.weights.meta.rawAsymmetryFactor)
|
|
1187
1122
|
? r.weights.meta
|
|
1188
1123
|
: r;
|
|
1189
|
-
log(cfg, ` Asymmetric bounds: ${
|
|
1124
|
+
log(cfg, ` Asymmetric bounds: ${buildAsymmetricBoundsLog(asymSource)}`);
|
|
1190
1125
|
}
|
|
1191
1126
|
if (Array.isArray(r.amaComparison) && r.amaComparison.length > 0) {
|
|
1192
1127
|
const parts = r.amaComparison.map((a) => {
|
|
1193
1128
|
const val = Number.isFinite(a.value) ? a.value.toFixed(8) : 'n/a';
|
|
1194
|
-
const erSmoothText = Number.isFinite(Number(a.erSmoothPeriod)) ? `/es${
|
|
1129
|
+
const erSmoothText = Number.isFinite(Number(a.erSmoothPeriod)) ? `/es${fixedTo(a.erSmoothPeriod, 0)}` : '';
|
|
1195
1130
|
return `${a.name}[${a.erPeriod}/${a.fastPeriod}/${a.slowPeriod}${erSmoothText}]=${val}`;
|
|
1196
1131
|
});
|
|
1197
1132
|
log(cfg, ` AMA compare: ${parts.join(' | ')}`);
|
|
@@ -1203,12 +1138,12 @@ async function runOnce(cfg, state, contextCache) {
|
|
|
1203
1138
|
});
|
|
1204
1139
|
}
|
|
1205
1140
|
catch (err) {
|
|
1206
|
-
log(cfg, `error (${
|
|
1141
|
+
log(cfg, `error (${getErrorMessage(err)})`);
|
|
1207
1142
|
results.push({
|
|
1208
1143
|
botName: bot.name,
|
|
1209
1144
|
botKey: bot.botKey,
|
|
1210
1145
|
ok: false,
|
|
1211
|
-
reason:
|
|
1146
|
+
reason: getErrorMessage(err),
|
|
1212
1147
|
});
|
|
1213
1148
|
}
|
|
1214
1149
|
}
|
|
@@ -1260,13 +1195,13 @@ async function runOnceForAma(overrides = {}) {
|
|
|
1260
1195
|
...overrides,
|
|
1261
1196
|
once: true,
|
|
1262
1197
|
});
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
const lock =
|
|
1198
|
+
ensureDir(DATA_DIR);
|
|
1199
|
+
ensureDir(STATE_DIR);
|
|
1200
|
+
const lock = acquireFileLockSync(LOCK_FILE, {
|
|
1266
1201
|
staleMs: Math.max(2, cfg.pollSeconds) * 1000 * 2,
|
|
1267
1202
|
});
|
|
1268
1203
|
try {
|
|
1269
|
-
const { connectClient } =
|
|
1204
|
+
const { connectClient } = getBitsharesClient();
|
|
1270
1205
|
await connectClient();
|
|
1271
1206
|
const state = loadJson(STATE_FILE, { meta: {}, bots: {} });
|
|
1272
1207
|
const contextCache = new Map();
|
|
@@ -1278,25 +1213,25 @@ async function runOnceForAma(overrides = {}) {
|
|
|
1278
1213
|
};
|
|
1279
1214
|
}
|
|
1280
1215
|
finally {
|
|
1281
|
-
const { disconnectClient } =
|
|
1216
|
+
const { disconnectClient } = getBitsharesClient();
|
|
1282
1217
|
disconnectClient();
|
|
1283
|
-
|
|
1218
|
+
releaseFileLockSync(lock);
|
|
1284
1219
|
}
|
|
1285
1220
|
}
|
|
1286
1221
|
async function main() {
|
|
1287
1222
|
const cfg = parseArgs();
|
|
1288
1223
|
logger.quiet = cfg.quiet;
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
const lock =
|
|
1224
|
+
ensureDir(DATA_DIR);
|
|
1225
|
+
ensureDir(STATE_DIR);
|
|
1226
|
+
const lock = acquireFileLockSync(LOCK_FILE, {
|
|
1292
1227
|
staleMs: Math.max(2, cfg.pollSeconds) * 1000 * 2,
|
|
1293
1228
|
});
|
|
1294
1229
|
try {
|
|
1295
1230
|
log(cfg, '═══════════════════════════════════════');
|
|
1296
1231
|
log(cfg, ' Market Adapter Hub Settings:');
|
|
1297
1232
|
log(cfg, ` runtime : poll=${cfg.pollSeconds}s | bootstrap=${cfg.bootstrapLookbackHours}h | native=${cfg.nativeBackfillHours}h | stale=${cfg.maxStaleHours}h`);
|
|
1298
|
-
log(cfg, ` fetch : retries=${cfg.sourceRetries}x${cfg.retryDelayMs}ms | pages=${cfg.maxPages}x${cfg.pageLimit} | delta=${
|
|
1299
|
-
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));
|
|
1300
1235
|
log(cfg, '═══════════════════════════════════════');
|
|
1301
1236
|
if (cfg.once && cfg.dryRun) {
|
|
1302
1237
|
log(cfg, 'Dry run: config validation + lock acquisition OK (no network, no writes).');
|
|
@@ -1307,7 +1242,7 @@ async function main() {
|
|
|
1307
1242
|
let lastErr = null;
|
|
1308
1243
|
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
1309
1244
|
try {
|
|
1310
|
-
const { connectClient } =
|
|
1245
|
+
const { connectClient } = getBitsharesClient();
|
|
1311
1246
|
await connectClient();
|
|
1312
1247
|
lastErr = null;
|
|
1313
1248
|
break;
|
|
@@ -1315,9 +1250,9 @@ async function main() {
|
|
|
1315
1250
|
catch (err) {
|
|
1316
1251
|
lastErr = err;
|
|
1317
1252
|
if (attempt < maxRetries) {
|
|
1318
|
-
const delay = Math.min(1000 * Math.pow(2, attempt - 1),
|
|
1319
|
-
logger.warn(`Connection attempt ${attempt}/${maxRetries} failed: ${
|
|
1320
|
-
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);
|
|
1321
1256
|
}
|
|
1322
1257
|
}
|
|
1323
1258
|
}
|
|
@@ -1340,33 +1275,34 @@ async function main() {
|
|
|
1340
1275
|
// Connect for this cycle using the lightweight native read-only client.
|
|
1341
1276
|
// Tear down after runOnce so the connection never sits idle.
|
|
1342
1277
|
try {
|
|
1343
|
-
const { connectClient } =
|
|
1278
|
+
const { connectClient } = getBitsharesClient();
|
|
1344
1279
|
await connectClient();
|
|
1345
1280
|
}
|
|
1346
1281
|
catch (err) {
|
|
1347
|
-
logger.error(`Connection failed before cycle: ${
|
|
1282
|
+
logger.error(`Connection failed before cycle: ${getErrorMessage(err)}`);
|
|
1348
1283
|
// Fall through and let runOnce attempt to handle its own retries/failures
|
|
1349
1284
|
}
|
|
1350
1285
|
await runOnce(cfg, state, contextCache);
|
|
1351
1286
|
try {
|
|
1352
|
-
const { disconnectClient } =
|
|
1287
|
+
const { disconnectClient } = getBitsharesClient();
|
|
1353
1288
|
disconnectClient();
|
|
1354
1289
|
}
|
|
1355
1290
|
catch (_) { }
|
|
1356
1291
|
const sleepMs = sleepUntilAlignedBoundary(cfg.pollSeconds, started, Date.now());
|
|
1357
|
-
await
|
|
1292
|
+
await sleep(sleepMs);
|
|
1358
1293
|
}
|
|
1359
1294
|
}
|
|
1360
1295
|
finally {
|
|
1361
|
-
|
|
1296
|
+
releaseFileLockSync(lock);
|
|
1362
1297
|
}
|
|
1363
1298
|
}
|
|
1364
|
-
if (
|
|
1299
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
1365
1300
|
main()
|
|
1366
1301
|
.then((exitCode) => process.exit(Number.isInteger(exitCode) ? exitCode : 0))
|
|
1367
1302
|
.catch((err) => {
|
|
1368
|
-
logger.error(`Fatal: ${
|
|
1303
|
+
logger.error(`Fatal: ${getErrorMessage(err)}`);
|
|
1369
1304
|
process.exit(1);
|
|
1370
1305
|
});
|
|
1371
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 };
|
|
1372
1308
|
//# sourceMappingURL=market_adapter.js.map
|