dexbot 1.6.7 → 1.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -1
- package/README.md +3 -3
- package/analysis/README.md +2 -3
- package/analysis/tradingview/README.md +78 -1
- package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +1 -1
- package/claw/package.json +1 -1
- package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
- package/claw/runtimes/openclaw-plugin/package.json +1 -1
- package/dist/analysis/tradingview/analyze_tradingview.d.ts +4 -0
- package/dist/analysis/tradingview/analyze_tradingview.js +55 -0
- package/dist/analysis/tradingview/grid_reset_config.d.ts +61 -0
- package/dist/analysis/tradingview/grid_reset_config.js +235 -0
- package/dist/analysis/tradingview/grid_reset_sim.d.ts +67 -0
- package/dist/analysis/tradingview/grid_reset_sim.js +307 -0
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +419 -3
- package/dist/dexbot.js +22 -6
- package/dist/market_adapter/core/market_adapter_service.js +14 -2
- package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts +8 -1
- package/dist/market_adapter/core/strategies/dynamic_weight_series.js +5 -1
- package/dist/market_adapter/inputs/window_cache.d.ts +97 -19
- package/dist/market_adapter/inputs/window_cache.js +302 -48
- package/dist/market_adapter/market_adapter.d.ts +8 -1
- package/dist/market_adapter/market_adapter.js +22 -4
- package/dist/modules/account_bots.js +10 -0
- package/dist/modules/account_orders.d.ts +24 -2
- package/dist/modules/account_orders.js +41 -4
- package/dist/modules/bot_settings.js +10 -1
- package/dist/modules/config.d.ts +1 -0
- package/dist/modules/config.js +1 -0
- package/dist/modules/constants.d.ts +11 -3
- package/dist/modules/constants.js +116 -37
- package/dist/modules/dexbot_class.d.ts +6 -76
- package/dist/modules/dexbot_class.js +0 -32
- package/dist/modules/dexbot_cow_runtime.d.ts +3 -58
- package/dist/modules/dexbot_cow_runtime.js +4 -87
- package/dist/modules/dexbot_maintenance_runtime.d.ts +15 -1
- package/dist/modules/dexbot_maintenance_runtime.js +59 -11
- package/dist/modules/dexbot_startup_runtime.js +73 -20
- package/dist/modules/dexbot_state_recovery.d.ts +6 -0
- package/dist/modules/dexbot_state_recovery.js +21 -0
- package/dist/modules/order/async_lock.d.ts +8 -0
- package/dist/modules/order/async_lock.js +15 -0
- package/dist/modules/order/genesis_policy.d.ts +162 -0
- package/dist/modules/order/genesis_policy.js +267 -0
- package/dist/modules/order/grid.js +76 -134
- package/dist/modules/order/grid_reconcile.d.ts +9 -0
- package/dist/modules/order/grid_reconcile.js +13 -4
- package/dist/modules/order/grid_reconcile_internal.js +2 -2
- package/dist/modules/order/manager.d.ts +4 -0
- package/dist/modules/order/manager.js +14 -1
- package/dist/modules/order/sync_engine.d.ts +19 -0
- package/dist/modules/order/sync_engine.js +284 -344
- package/dist/modules/order/utils/math.d.ts +22 -1
- package/dist/modules/order/utils/math.js +64 -1
- package/dist/modules/order/utils/order.d.ts +43 -58
- package/dist/modules/order/utils/order.js +220 -197
- package/dist/modules/order/utils/system.js +8 -1
- package/dist/modules/paths.d.ts +1 -0
- package/dist/modules/paths.js +1 -0
- package/dist/modules/version_notice.d.ts +165 -0
- package/dist/modules/version_notice.js +364 -0
- package/dist/pm2.js +9 -0
- package/dist/unlock.js +28 -0
- package/docs/BITSHARES_ONBOARDING.md +8 -1
- package/docs/COW_INVARIANTS.md +3 -2
- package/docs/DEXBOT_COMPARISON.md +4 -4
- package/docs/EVOLUTION.md +20 -19
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
- package/docs/GRID_PRICE_INVARIANT.md +149 -31
- package/docs/GRID_RECALCULATION.md +12 -0
- package/docs/README.md +3 -1
- package/docs/WORKFLOW.md +16 -5
- package/market_adapter/README.md +1 -1
- package/modules/README.md +18 -1
- package/package.json +13 -5
- package/scripts/README.md +28 -2
- package/scripts/clear-all.sh +13 -4
- package/scripts/clear-logs.sh +13 -4
- package/scripts/clear-market-adapter.sh +6 -0
- package/scripts/clear-orders.sh +5 -0
- package/scripts/lib/dexbot-paths.sh +108 -0
- package/tests/README.md +11 -3
- package/analysis/account_resolver.ts +0 -161
- package/analysis/ama_fitting/analyze_ama_price_changes.ts +0 -155
- package/analysis/ama_fitting/analyze_lambda_vs_slow.ts +0 -404
- package/analysis/ama_fitting/calibrate_convergence_er.ts +0 -201
- package/analysis/ama_fitting/fetch_lp_candles.ts +0 -184
- package/analysis/ama_fitting/generate_unified_comparison_chart.ts +0 -232
- package/analysis/ama_fitting/optimizer_high_resolution.ts +0 -802
- package/analysis/analyze_dynamic_weight.ts +0 -243
- package/analysis/analyze_kalman.ts +0 -157
- package/analysis/analyze_regime.ts +0 -158
- package/analysis/analyze_regime_windows.ts +0 -470
- package/analysis/analyze_risk_profile.ts +0 -199
- package/analysis/analyze_trade_heatmap.ts +0 -362
- package/analysis/analyze_volatility.ts +0 -182
- package/analysis/bot_fitting/backtest_ama_sweep.ts +0 -934
- package/analysis/bot_fitting/backtest_bot_fitting.ts +0 -861
- package/analysis/bot_fitting/shared_utils.ts +0 -52
- package/analysis/bot_key_utils.ts +0 -426
- package/analysis/bot_usage/discover_bot_accounts.ts +0 -635
- package/analysis/bot_usage/kibana_bot_queries.ts +0 -211
- package/analysis/chain_pool.ts +0 -47
- package/analysis/chart_css.ts +0 -62
- package/analysis/chart_ui.ts +0 -105
- package/analysis/chart_utils.ts +0 -210
- package/analysis/fills_source.ts +0 -228
- package/analysis/grid_correction_check.ts +0 -786
- package/analysis/math_utils.ts +0 -53
- package/analysis/price_sources.ts +0 -136
- package/analysis/resolve_bot_accounts.ts +0 -199
- package/analysis/resolve_source.ts +0 -99
- package/analysis/results/ama_sweep_results_lp_pool_133_1h.json +0 -2455
- package/analysis/results/bot_fitting_results_lp_pool_133_1h.json +0 -218
- package/analysis/trade_profitability.ts +0 -1335
- package/analysis/tradingview/analyze_tradingview.ts +0 -280
- package/analysis/tradingview/h-bts_tradingview.html +0 -1570
- package/analysis/tradingview/t-bts_tradingview.html +0 -1570
- package/analysis/tradingview/tradingview_uplot_chart_generator.ts +0 -3268
- package/analysis/trend_detection/dynamic_weight_chart_generator.ts +0 -1481
- package/analysis/trend_detection/hurst_analyzer.ts +0 -7
- package/analysis/trend_detection/kalman_chart_generator.ts +0 -398
- package/analysis/trend_detection/kalman_trend_analyzer.ts +0 -9
- package/analysis/trend_detection/kalman_velocity_smoothing.ts +0 -7
- package/analysis/trend_detection/package.json +0 -23
- package/analysis/trend_detection/permutation_entropy_analyzer.ts +0 -7
- package/analysis/trend_detection/regime_chart_generator.ts +0 -338
- package/analysis/trend_detection/tests/test_kalman_trend.ts +0 -153
- package/analysis/trend_detection/tests/test_kalman_velocity_smoothing.ts +0 -64
- package/analysis/trend_detection/volatility_chart_generator.ts +0 -654
- package/analysis/tsconfig.json +0 -29
- package/claw/tests/package.json +0 -3
- package/claw/tests/test_claw_bridge.ts +0 -570
- package/claw/tests/test_claw_catalog_and_credentials.ts +0 -156
- package/claw/tests/test_claw_chain_layer.ts +0 -739
- package/claw/tests/test_claw_data_flow.ts +0 -525
- package/claw/tests/test_claw_domain_logic.ts +0 -471
- package/claw/tests/test_claw_manifest_and_matrix.ts +0 -222
- package/claw/tests/test_claw_mcp_transport.ts +0 -243
- package/claw/tests/test_claw_regressions.ts +0 -711
- package/claw/tests/test_claw_skill_generation.ts +0 -103
- package/claw/tests/test_claw_state_store.ts +0 -44
- package/claw/tests/test_dexbot_profiles.ts +0 -654
- package/claw/tests/test_memu_bridge.ts +0 -189
- package/claw/tests/test_nullclaw_tmp_integration.ts +0 -57
- package/claw/tests/test_position_health.ts +0 -343
- package/claw/tests/test_position_manager.ts +0 -429
- package/claw/tests/test_position_manager_watch_health.ts +0 -100
- package/claw/tests/test_short_mpa_strategy.ts +0 -232
- package/dist/analysis/account_resolver.d.ts.map +0 -1
- package/dist/analysis/account_resolver.js.map +0 -1
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.js.map +0 -1
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js.map +0 -1
- package/dist/analysis/ama_fitting/calibrate_convergence_er.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js.map +0 -1
- package/dist/analysis/ama_fitting/fetch_lp_candles.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/fetch_lp_candles.js.map +0 -1
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js.map +0 -1
- package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js.map +0 -1
- package/dist/analysis/analyze_dynamic_weight.d.ts.map +0 -1
- package/dist/analysis/analyze_dynamic_weight.js.map +0 -1
- package/dist/analysis/analyze_kalman.d.ts.map +0 -1
- package/dist/analysis/analyze_kalman.js.map +0 -1
- package/dist/analysis/analyze_regime.d.ts.map +0 -1
- package/dist/analysis/analyze_regime.js.map +0 -1
- package/dist/analysis/analyze_regime_windows.d.ts.map +0 -1
- package/dist/analysis/analyze_regime_windows.js.map +0 -1
- package/dist/analysis/analyze_risk_profile.d.ts.map +0 -1
- package/dist/analysis/analyze_risk_profile.js.map +0 -1
- package/dist/analysis/analyze_trade_heatmap.d.ts.map +0 -1
- package/dist/analysis/analyze_trade_heatmap.js.map +0 -1
- package/dist/analysis/analyze_volatility.d.ts.map +0 -1
- package/dist/analysis/analyze_volatility.js.map +0 -1
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts.map +0 -1
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js.map +0 -1
- package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts.map +0 -1
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js.map +0 -1
- package/dist/analysis/bot_fitting/shared_utils.d.ts.map +0 -1
- package/dist/analysis/bot_fitting/shared_utils.js.map +0 -1
- package/dist/analysis/bot_key_utils.d.ts.map +0 -1
- package/dist/analysis/bot_key_utils.js.map +0 -1
- package/dist/analysis/bot_usage/discover_bot_accounts.d.ts.map +0 -1
- package/dist/analysis/bot_usage/discover_bot_accounts.js.map +0 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +0 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.js.map +0 -1
- package/dist/analysis/chain_pool.d.ts.map +0 -1
- package/dist/analysis/chain_pool.js.map +0 -1
- package/dist/analysis/chart_css.d.ts.map +0 -1
- package/dist/analysis/chart_css.js.map +0 -1
- package/dist/analysis/chart_ui.d.ts.map +0 -1
- package/dist/analysis/chart_ui.js.map +0 -1
- package/dist/analysis/chart_utils.d.ts.map +0 -1
- package/dist/analysis/chart_utils.js.map +0 -1
- package/dist/analysis/fills_source.d.ts.map +0 -1
- package/dist/analysis/fills_source.js.map +0 -1
- package/dist/analysis/grid_correction_check.d.ts.map +0 -1
- package/dist/analysis/grid_correction_check.js.map +0 -1
- package/dist/analysis/math_utils.d.ts.map +0 -1
- package/dist/analysis/math_utils.js.map +0 -1
- package/dist/analysis/price_sources.d.ts.map +0 -1
- package/dist/analysis/price_sources.js.map +0 -1
- package/dist/analysis/resolve_bot_accounts.d.ts.map +0 -1
- package/dist/analysis/resolve_bot_accounts.js.map +0 -1
- package/dist/analysis/resolve_source.d.ts.map +0 -1
- package/dist/analysis/resolve_source.js.map +0 -1
- package/dist/analysis/trade_profitability.d.ts.map +0 -1
- package/dist/analysis/trade_profitability.js.map +0 -1
- package/dist/analysis/tradingview/analyze_tradingview.d.ts.map +0 -1
- package/dist/analysis/tradingview/analyze_tradingview.js.map +0 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +0 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/hurst_analyzer.d.ts.map +0 -1
- package/dist/analysis/trend_detection/hurst_analyzer.js.map +0 -1
- package/dist/analysis/trend_detection/kalman_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/kalman_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/kalman_trend_analyzer.d.ts.map +0 -1
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js.map +0 -1
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.d.ts.map +0 -1
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js.map +0 -1
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.d.ts.map +0 -1
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js.map +0 -1
- package/dist/analysis/trend_detection/regime_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/regime_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts +0 -2
- package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts.map +0 -1
- package/dist/analysis/trend_detection/tests/test_kalman_trend.js +0 -128
- package/dist/analysis/trend_detection/tests/test_kalman_trend.js.map +0 -1
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts +0 -2
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts.map +0 -1
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js +0 -37
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js.map +0 -1
- package/dist/analysis/trend_detection/volatility_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/volatility_chart_generator.js.map +0 -1
- package/dist/bot.d.ts.map +0 -1
- package/dist/bot.js.map +0 -1
- package/dist/credential-daemon.d.ts.map +0 -1
- package/dist/credential-daemon.js.map +0 -1
- package/dist/dexbot.d.ts.map +0 -1
- package/dist/dexbot.js.map +0 -1
- package/dist/market_adapter/ama_signal_runner.d.ts.map +0 -1
- package/dist/market_adapter/ama_signal_runner.js.map +0 -1
- package/dist/market_adapter/candle_utils.d.ts.map +0 -1
- package/dist/market_adapter/candle_utils.js.map +0 -1
- package/dist/market_adapter/core/asymmetric_bounds.d.ts.map +0 -1
- package/dist/market_adapter/core/asymmetric_bounds.js.map +0 -1
- package/dist/market_adapter/core/config_normalizers.d.ts.map +0 -1
- package/dist/market_adapter/core/config_normalizers.js.map +0 -1
- package/dist/market_adapter/core/kibana_candles.d.ts.map +0 -1
- package/dist/market_adapter/core/kibana_candles.js.map +0 -1
- package/dist/market_adapter/core/kibana_client.d.ts.map +0 -1
- package/dist/market_adapter/core/kibana_client.js.map +0 -1
- package/dist/market_adapter/core/kibana_market_candles.d.ts.map +0 -1
- package/dist/market_adapter/core/kibana_market_candles.js.map +0 -1
- package/dist/market_adapter/core/market_adapter_service.d.ts.map +0 -1
- package/dist/market_adapter/core/market_adapter_service.js.map +0 -1
- package/dist/market_adapter/core/signals/hurst_analyzer.d.ts.map +0 -1
- package/dist/market_adapter/core/signals/hurst_analyzer.js.map +0 -1
- package/dist/market_adapter/core/signals/kalman_trend_analyzer.d.ts.map +0 -1
- package/dist/market_adapter/core/signals/kalman_trend_analyzer.js.map +0 -1
- package/dist/market_adapter/core/signals/kalman_velocity_smoothing.d.ts.map +0 -1
- package/dist/market_adapter/core/signals/kalman_velocity_smoothing.js.map +0 -1
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts.map +0 -1
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js.map +0 -1
- package/dist/market_adapter/core/strategies/ama.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/ama.js.map +0 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.js.map +0 -1
- package/dist/market_adapter/core/strategies/atr/calculator.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/atr/calculator.js.map +0 -1
- package/dist/market_adapter/core/strategies/collateral_manager.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/collateral_manager.js.map +0 -1
- package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/dynamic_weight_series.js.map +0 -1
- package/dist/market_adapter/core/strategies/regime_gate.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/regime_gate.js.map +0 -1
- package/dist/market_adapter/core/strategies/regime_interp.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/regime_interp.js.map +0 -1
- package/dist/market_adapter/core/strategies/volatility_shift.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/volatility_shift.js.map +0 -1
- package/dist/market_adapter/inputs/fetch_book_data.d.ts.map +0 -1
- package/dist/market_adapter/inputs/fetch_book_data.js.map +0 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.d.ts.map +0 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +0 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +0 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +0 -1
- package/dist/market_adapter/inputs/kibana_feed_source.d.ts.map +0 -1
- package/dist/market_adapter/inputs/kibana_feed_source.js.map +0 -1
- package/dist/market_adapter/inputs/kibana_source.d.ts.map +0 -1
- package/dist/market_adapter/inputs/kibana_source.js.map +0 -1
- package/dist/market_adapter/inputs/window_cache.d.ts.map +0 -1
- package/dist/market_adapter/inputs/window_cache.js.map +0 -1
- package/dist/market_adapter/interval_utils.d.ts.map +0 -1
- package/dist/market_adapter/interval_utils.js.map +0 -1
- package/dist/market_adapter/log_format.d.ts.map +0 -1
- package/dist/market_adapter/log_format.js.map +0 -1
- package/dist/market_adapter/lp_chart_core.d.ts.map +0 -1
- package/dist/market_adapter/lp_chart_core.js.map +0 -1
- package/dist/market_adapter/lp_chart_runner.d.ts.map +0 -1
- package/dist/market_adapter/lp_chart_runner.js.map +0 -1
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts.map +0 -1
- package/dist/market_adapter/lp_chart_strategy_loader.js.map +0 -1
- package/dist/market_adapter/market_adapter.d.ts.map +0 -1
- package/dist/market_adapter/market_adapter.js.map +0 -1
- package/dist/market_adapter/test_helpers.d.ts.map +0 -1
- package/dist/market_adapter/test_helpers.js.map +0 -1
- package/dist/market_adapter/utils/adapter_client.d.ts.map +0 -1
- package/dist/market_adapter/utils/adapter_client.js.map +0 -1
- package/dist/market_adapter/utils/atomic_write.d.ts.map +0 -1
- package/dist/market_adapter/utils/atomic_write.js.map +0 -1
- package/dist/market_adapter/utils/chain.d.ts.map +0 -1
- package/dist/market_adapter/utils/chain.js.map +0 -1
- package/dist/market_adapter/utils/data_discovery.d.ts.map +0 -1
- package/dist/market_adapter/utils/data_discovery.js.map +0 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +0 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +0 -1
- package/dist/market_adapter/utils/file_lock.d.ts.map +0 -1
- package/dist/market_adapter/utils/file_lock.js.map +0 -1
- package/dist/market_adapter/utils/native_history.d.ts.map +0 -1
- package/dist/market_adapter/utils/native_history.js.map +0 -1
- package/dist/modules/account_bots.d.ts.map +0 -1
- package/dist/modules/account_bots.js.map +0 -1
- package/dist/modules/account_orders.d.ts.map +0 -1
- package/dist/modules/account_orders.js.map +0 -1
- package/dist/modules/authority_resolver.d.ts.map +0 -1
- package/dist/modules/authority_resolver.js.map +0 -1
- package/dist/modules/bitshares-native/chain_client.d.ts.map +0 -1
- package/dist/modules/bitshares-native/chain_client.js.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc.d.ts.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc.js.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.js.map +0 -1
- package/dist/modules/bitshares-native/index.d.ts.map +0 -1
- package/dist/modules/bitshares-native/index.js.map +0 -1
- package/dist/modules/bitshares-native/lru_cache.d.ts.map +0 -1
- package/dist/modules/bitshares-native/lru_cache.js.map +0 -1
- package/dist/modules/bitshares-native/resolvers.d.ts.map +0 -1
- package/dist/modules/bitshares-native/resolvers.js.map +0 -1
- package/dist/modules/bitshares-native/serial/chain_constants.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/chain_constants.js.map +0 -1
- package/dist/modules/bitshares-native/serial/index.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/index.js.map +0 -1
- package/dist/modules/bitshares-native/serial/operations.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/operations.js.map +0 -1
- package/dist/modules/bitshares-native/serial/serializer.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/serializer.js.map +0 -1
- package/dist/modules/bitshares-native/serial/types.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/types.js.map +0 -1
- package/dist/modules/bitshares-native/signing_client.d.ts.map +0 -1
- package/dist/modules/bitshares-native/signing_client.js.map +0 -1
- package/dist/modules/bitshares-native/subscriptions.d.ts.map +0 -1
- package/dist/modules/bitshares-native/subscriptions.js.map +0 -1
- package/dist/modules/bitshares-native/transport.d.ts.map +0 -1
- package/dist/modules/bitshares-native/transport.js.map +0 -1
- package/dist/modules/bitshares-native/tx/builder.d.ts.map +0 -1
- package/dist/modules/bitshares-native/tx/builder.js.map +0 -1
- package/dist/modules/bitshares-native/tx/tx_cache.d.ts.map +0 -1
- package/dist/modules/bitshares-native/tx/tx_cache.js.map +0 -1
- package/dist/modules/bitshares_client.d.ts.map +0 -1
- package/dist/modules/bitshares_client.js.map +0 -1
- package/dist/modules/bot_defaults.d.ts.map +0 -1
- package/dist/modules/bot_defaults.js.map +0 -1
- package/dist/modules/bot_settings.d.ts.map +0 -1
- package/dist/modules/bot_settings.js.map +0 -1
- package/dist/modules/bots_file_lock.d.ts.map +0 -1
- package/dist/modules/bots_file_lock.js.map +0 -1
- package/dist/modules/broadcast_failure.d.ts.map +0 -1
- package/dist/modules/broadcast_failure.js.map +0 -1
- package/dist/modules/chain_keys.d.ts.map +0 -1
- package/dist/modules/chain_keys.js.map +0 -1
- package/dist/modules/chain_orders.d.ts.map +0 -1
- package/dist/modules/chain_orders.js.map +0 -1
- package/dist/modules/cli_colors.d.ts.map +0 -1
- package/dist/modules/cli_colors.js.map +0 -1
- package/dist/modules/cli_start_onboarding.d.ts.map +0 -1
- package/dist/modules/cli_start_onboarding.js.map +0 -1
- package/dist/modules/cli_start_output.d.ts.map +0 -1
- package/dist/modules/cli_start_output.js.map +0 -1
- package/dist/modules/config.d.ts.map +0 -1
- package/dist/modules/config.js.map +0 -1
- package/dist/modules/constants.d.ts.map +0 -1
- package/dist/modules/constants.js.map +0 -1
- package/dist/modules/cr_planner.d.ts.map +0 -1
- package/dist/modules/cr_planner.js.map +0 -1
- package/dist/modules/credential_policy.d.ts.map +0 -1
- package/dist/modules/credential_policy.js.map +0 -1
- package/dist/modules/credential_runtime.d.ts.map +0 -1
- package/dist/modules/credential_runtime.js.map +0 -1
- package/dist/modules/credential_session_cache.d.ts.map +0 -1
- package/dist/modules/credential_session_cache.js.map +0 -1
- package/dist/modules/credit_pricing.d.ts.map +0 -1
- package/dist/modules/credit_pricing.js.map +0 -1
- package/dist/modules/credit_runtime.d.ts.map +0 -1
- package/dist/modules/credit_runtime.js.map +0 -1
- package/dist/modules/crypto/browser_provider.d.ts.map +0 -1
- package/dist/modules/crypto/browser_provider.js.map +0 -1
- package/dist/modules/crypto/index.d.ts.map +0 -1
- package/dist/modules/crypto/index.js.map +0 -1
- package/dist/modules/crypto/node_provider.d.ts.map +0 -1
- package/dist/modules/crypto/node_provider.js.map +0 -1
- package/dist/modules/crypto/provider.d.ts.map +0 -1
- package/dist/modules/crypto/provider.js.map +0 -1
- package/dist/modules/crypto/pure_ripemd160.d.ts.map +0 -1
- package/dist/modules/crypto/pure_ripemd160.js.map +0 -1
- package/dist/modules/crypto/pure_scrypt.d.ts.map +0 -1
- package/dist/modules/crypto/pure_scrypt.js.map +0 -1
- package/dist/modules/crypto/pure_secp256k1.d.ts.map +0 -1
- package/dist/modules/crypto/pure_secp256k1.js.map +0 -1
- package/dist/modules/crypto/sync.d.ts.map +0 -1
- package/dist/modules/crypto/sync.js.map +0 -1
- package/dist/modules/daemon_node_health.d.ts.map +0 -1
- package/dist/modules/daemon_node_health.js.map +0 -1
- package/dist/modules/dexbot_class.d.ts.map +0 -1
- package/dist/modules/dexbot_class.js.map +0 -1
- package/dist/modules/dexbot_cow_runtime.d.ts.map +0 -1
- package/dist/modules/dexbot_cow_runtime.js.map +0 -1
- package/dist/modules/dexbot_credential_client.d.ts.map +0 -1
- package/dist/modules/dexbot_credential_client.js.map +0 -1
- package/dist/modules/dexbot_fill_runtime.d.ts.map +0 -1
- package/dist/modules/dexbot_fill_runtime.js.map +0 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +0 -1
- package/dist/modules/dexbot_maintenance_runtime.js.map +0 -1
- package/dist/modules/dexbot_startup_runtime.d.ts.map +0 -1
- package/dist/modules/dexbot_startup_runtime.js.map +0 -1
- package/dist/modules/dexbot_state_recovery.d.ts.map +0 -1
- package/dist/modules/dexbot_state_recovery.js.map +0 -1
- package/dist/modules/env.d.ts.map +0 -1
- package/dist/modules/env.js.map +0 -1
- package/dist/modules/fund_registry.d.ts.map +0 -1
- package/dist/modules/fund_registry.js.map +0 -1
- package/dist/modules/general_settings.d.ts.map +0 -1
- package/dist/modules/general_settings.js.map +0 -1
- package/dist/modules/graceful_shutdown.d.ts.map +0 -1
- package/dist/modules/graceful_shutdown.js.map +0 -1
- package/dist/modules/grid_price_source.d.ts.map +0 -1
- package/dist/modules/grid_price_source.js.map +0 -1
- package/dist/modules/key_store.d.ts.map +0 -1
- package/dist/modules/key_store.js.map +0 -1
- package/dist/modules/launcher/adapter_requirement.d.ts.map +0 -1
- package/dist/modules/launcher/adapter_requirement.js.map +0 -1
- package/dist/modules/launcher/bot_supervisor.d.ts.map +0 -1
- package/dist/modules/launcher/bot_supervisor.js.map +0 -1
- package/dist/modules/launcher/child_env.d.ts.map +0 -1
- package/dist/modules/launcher/child_env.js.map +0 -1
- package/dist/modules/launcher/credential_bootstrap.d.ts.map +0 -1
- package/dist/modules/launcher/credential_bootstrap.js.map +0 -1
- package/dist/modules/launcher/credential_daemon.d.ts.map +0 -1
- package/dist/modules/launcher/credential_daemon.js.map +0 -1
- package/dist/modules/launcher/credential_secret.d.ts.map +0 -1
- package/dist/modules/launcher/credential_secret.js.map +0 -1
- package/dist/modules/launcher/foreign_cred_daemon.d.ts.map +0 -1
- package/dist/modules/launcher/foreign_cred_daemon.js.map +0 -1
- package/dist/modules/launcher/headless_password.d.ts.map +0 -1
- package/dist/modules/launcher/headless_password.js.map +0 -1
- package/dist/modules/launcher/launch_modes.d.ts.map +0 -1
- package/dist/modules/launcher/launch_modes.js.map +0 -1
- package/dist/modules/launcher/market_adapter_runtime.d.ts.map +0 -1
- package/dist/modules/launcher/market_adapter_runtime.js.map +0 -1
- package/dist/modules/launcher/market_adapter_watchdog.d.ts.map +0 -1
- package/dist/modules/launcher/market_adapter_watchdog.js.map +0 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts.map +0 -1
- package/dist/modules/launcher/monolithic_runtime.js.map +0 -1
- package/dist/modules/launcher/runtime_entry.d.ts.map +0 -1
- package/dist/modules/launcher/runtime_entry.js.map +0 -1
- package/dist/modules/launcher/status_reporting.d.ts.map +0 -1
- package/dist/modules/launcher/status_reporting.js.map +0 -1
- package/dist/modules/launcher/supervisor_control.d.ts.map +0 -1
- package/dist/modules/launcher/supervisor_control.js.map +0 -1
- package/dist/modules/market_adapter_whitelist.d.ts.map +0 -1
- package/dist/modules/market_adapter_whitelist.js.map +0 -1
- package/dist/modules/node_connect_policy.d.ts.map +0 -1
- package/dist/modules/node_connect_policy.js.map +0 -1
- package/dist/modules/node_failure_ledger.d.ts.map +0 -1
- package/dist/modules/node_failure_ledger.js.map +0 -1
- package/dist/modules/node_health_cache.d.ts.map +0 -1
- package/dist/modules/node_health_cache.js.map +0 -1
- package/dist/modules/node_manager.d.ts.map +0 -1
- package/dist/modules/node_manager.js.map +0 -1
- package/dist/modules/order/accounting.d.ts.map +0 -1
- package/dist/modules/order/accounting.js.map +0 -1
- package/dist/modules/order/async_lock.d.ts.map +0 -1
- package/dist/modules/order/async_lock.js.map +0 -1
- package/dist/modules/order/export.d.ts.map +0 -1
- package/dist/modules/order/export.js.map +0 -1
- package/dist/modules/order/format.d.ts.map +0 -1
- package/dist/modules/order/format.js.map +0 -1
- package/dist/modules/order/grid.d.ts.map +0 -1
- package/dist/modules/order/grid.js.map +0 -1
- package/dist/modules/order/grid_reconcile.d.ts.map +0 -1
- package/dist/modules/order/grid_reconcile.js.map +0 -1
- package/dist/modules/order/grid_reconcile_internal.d.ts.map +0 -1
- package/dist/modules/order/grid_reconcile_internal.js.map +0 -1
- package/dist/modules/order/index.d.ts.map +0 -1
- package/dist/modules/order/index.js.map +0 -1
- package/dist/modules/order/logger.d.ts.map +0 -1
- package/dist/modules/order/logger.js.map +0 -1
- package/dist/modules/order/logger_state.d.ts.map +0 -1
- package/dist/modules/order/logger_state.js.map +0 -1
- package/dist/modules/order/manager.d.ts.map +0 -1
- package/dist/modules/order/manager.js.map +0 -1
- package/dist/modules/order/processed_fill_store.d.ts.map +0 -1
- package/dist/modules/order/processed_fill_store.js.map +0 -1
- package/dist/modules/order/strategy.d.ts.map +0 -1
- package/dist/modules/order/strategy.js.map +0 -1
- package/dist/modules/order/sync_engine.d.ts.map +0 -1
- package/dist/modules/order/sync_engine.js.map +0 -1
- package/dist/modules/order/utils/math.d.ts.map +0 -1
- package/dist/modules/order/utils/math.js.map +0 -1
- package/dist/modules/order/utils/order.d.ts.map +0 -1
- package/dist/modules/order/utils/order.js.map +0 -1
- package/dist/modules/order/utils/slot.d.ts.map +0 -1
- package/dist/modules/order/utils/slot.js.map +0 -1
- package/dist/modules/order/utils/system.d.ts.map +0 -1
- package/dist/modules/order/utils/system.js.map +0 -1
- package/dist/modules/order/utils/timeout.d.ts.map +0 -1
- package/dist/modules/order/utils/timeout.js.map +0 -1
- package/dist/modules/order/utils/validate.d.ts.map +0 -1
- package/dist/modules/order/utils/validate.js.map +0 -1
- package/dist/modules/order/utils/withPoolRef.d.ts.map +0 -1
- package/dist/modules/order/utils/withPoolRef.js.map +0 -1
- package/dist/modules/order/working_grid.d.ts.map +0 -1
- package/dist/modules/order/working_grid.js.map +0 -1
- package/dist/modules/path_api.d.ts.map +0 -1
- package/dist/modules/path_api.js.map +0 -1
- package/dist/modules/paths.d.ts.map +0 -1
- package/dist/modules/paths.js.map +0 -1
- package/dist/modules/process_discovery.d.ts.map +0 -1
- package/dist/modules/process_discovery.js.map +0 -1
- package/dist/modules/runtime.d.ts.map +0 -1
- package/dist/modules/runtime.js.map +0 -1
- package/dist/modules/runtime_settings.d.ts.map +0 -1
- package/dist/modules/runtime_settings.js.map +0 -1
- package/dist/modules/settings_merge.d.ts.map +0 -1
- package/dist/modules/settings_merge.js.map +0 -1
- package/dist/modules/socket_json_client.d.ts.map +0 -1
- package/dist/modules/socket_json_client.js.map +0 -1
- package/dist/modules/storage/browser_adapter.d.ts.map +0 -1
- package/dist/modules/storage/browser_adapter.js.map +0 -1
- package/dist/modules/storage/index.d.ts.map +0 -1
- package/dist/modules/storage/index.js.map +0 -1
- package/dist/modules/storage/node_adapter.d.ts.map +0 -1
- package/dist/modules/storage/node_adapter.js.map +0 -1
- package/dist/modules/storage/types.d.ts.map +0 -1
- package/dist/modules/storage/types.js.map +0 -1
- package/dist/modules/types.d.ts.map +0 -1
- package/dist/modules/types.js.map +0 -1
- package/dist/modules/utils/base58check.d.ts.map +0 -1
- package/dist/modules/utils/base58check.js.map +0 -1
- package/dist/modules/utils/build_dir.d.ts.map +0 -1
- package/dist/modules/utils/build_dir.js.map +0 -1
- package/dist/modules/utils/chain_logs.d.ts.map +0 -1
- package/dist/modules/utils/chain_logs.js.map +0 -1
- package/dist/modules/utils/errors.d.ts.map +0 -1
- package/dist/modules/utils/errors.js.map +0 -1
- package/dist/modules/utils/sanitize_key.d.ts.map +0 -1
- package/dist/modules/utils/sanitize_key.js.map +0 -1
- package/dist/modules/utils/text_width.d.ts.map +0 -1
- package/dist/modules/utils/text_width.js.map +0 -1
- package/dist/modules/validate_profiles.d.ts.map +0 -1
- package/dist/modules/validate_profiles.js.map +0 -1
- package/dist/pm2.d.ts.map +0 -1
- package/dist/pm2.js.map +0 -1
- package/dist/scripts/analyze-credit.d.ts.map +0 -1
- package/dist/scripts/analyze-credit.js.map +0 -1
- package/dist/scripts/analyze-git.d.ts.map +0 -1
- package/dist/scripts/analyze-git.js.map +0 -1
- package/dist/scripts/analyze-orders.d.ts.map +0 -1
- package/dist/scripts/analyze-orders.js.map +0 -1
- package/dist/scripts/chart_command.d.ts.map +0 -1
- package/dist/scripts/chart_command.js.map +0 -1
- package/dist/scripts/diagnose-kibana-candles.d.ts.map +0 -1
- package/dist/scripts/diagnose-kibana-candles.js.map +0 -1
- package/dist/scripts/diagnose-pool-history.d.ts.map +0 -1
- package/dist/scripts/diagnose-pool-history.js.map +0 -1
- package/dist/scripts/divergence-calc.d.ts.map +0 -1
- package/dist/scripts/divergence-calc.js.map +0 -1
- package/dist/scripts/dw.d.ts.map +0 -1
- package/dist/scripts/dw.js.map +0 -1
- package/dist/scripts/generate_lp_chart.d.ts.map +0 -1
- package/dist/scripts/generate_lp_chart.js.map +0 -1
- package/dist/scripts/generate_mainnet_corpus_report.d.ts.map +0 -1
- package/dist/scripts/generate_mainnet_corpus_report.js.map +0 -1
- package/dist/scripts/native_release_gates.d.ts.map +0 -1
- package/dist/scripts/native_release_gates.js.map +0 -1
- package/dist/scripts/print_grid.d.ts.map +0 -1
- package/dist/scripts/print_grid.js.map +0 -1
- package/dist/scripts/run-tests.d.ts.map +0 -1
- package/dist/scripts/run-tests.js.map +0 -1
- package/dist/scripts/runner.d.ts.map +0 -1
- package/dist/scripts/runner.js.map +0 -1
- package/dist/scripts/sync-version.d.ts.map +0 -1
- package/dist/scripts/sync-version.js.map +0 -1
- package/dist/scripts/test-credit-renewal.d.ts.map +0 -1
- package/dist/scripts/test-credit-renewal.js.map +0 -1
- package/dist/scripts/tv.d.ts.map +0 -1
- package/dist/scripts/tv.js.map +0 -1
- package/dist/scripts/update.d.ts.map +0 -1
- package/dist/scripts/update.js.map +0 -1
- package/dist/scripts/update_dist_freshness.d.ts.map +0 -1
- package/dist/scripts/update_dist_freshness.js.map +0 -1
- package/dist/scripts/validate_bots.d.ts.map +0 -1
- package/dist/scripts/validate_bots.js.map +0 -1
- package/dist/scripts/verify-browser-bundle.d.ts.map +0 -1
- package/dist/scripts/verify-browser-bundle.js.map +0 -1
- package/dist/unlock.d.ts.map +0 -1
- package/dist/unlock.js.map +0 -1
package/analysis/math_utils.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
import fs from 'node:fs';
|
|
4
|
-
import { getStorage } from '../modules/storage/index.js';
|
|
5
|
-
const { readJSON } = getStorage();
|
|
6
|
-
import {
|
|
7
|
-
getCandleClose,
|
|
8
|
-
getCandleTimestamp,
|
|
9
|
-
normalizeCandle,
|
|
10
|
-
} from '../market_adapter/candle_utils.js';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Math utilities for analysis scripts.
|
|
15
|
-
*
|
|
16
|
-
* Candle accessors are centralized in market_adapter (candle_utils.ts) and
|
|
17
|
-
* re-exported here so analysis tooling shares one logic path with the
|
|
18
|
-
* live adapter and the browser-embedded chart scripts.
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
function range(min: number, max: number, step: number, decimals: any = 4) {
|
|
22
|
-
const out: number[] = [];
|
|
23
|
-
for (let v = min; v <= max + 1e-9; v += step) out.push(Number(v.toFixed(decimals)));
|
|
24
|
-
return [...new Set(out)];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function calcStdDev(arr: any) {
|
|
28
|
-
const mean = arr.reduce((a: any, b: any) => a + b, 0) / arr.length;
|
|
29
|
-
const sqDiffs = arr.reduce((sum: any, v: any) => sum + (v - mean) ** 2, 0);
|
|
30
|
-
return Math.sqrt(sqDiffs / arr.length);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Parse a candle JSON file with format detection:
|
|
35
|
-
* flat array → {candles: [...]} → {data: [...]}
|
|
36
|
-
*/
|
|
37
|
-
function loadCandleFile(filePath: any) {
|
|
38
|
-
if (!filePath || !fs.existsSync(filePath)) return { candles: [], meta: null };
|
|
39
|
-
const raw = readJSON(filePath);
|
|
40
|
-
if (Array.isArray(raw)) return { candles: raw, meta: null };
|
|
41
|
-
if (raw && Array.isArray(raw.candles)) return { candles: raw.candles, meta: raw.meta || raw };
|
|
42
|
-
if (raw && Array.isArray(raw.data)) return { candles: raw.data, meta: raw };
|
|
43
|
-
return { candles: [], meta: null };
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export {
|
|
47
|
-
range,
|
|
48
|
-
calcStdDev,
|
|
49
|
-
getCandleClose,
|
|
50
|
-
getCandleTimestamp,
|
|
51
|
-
normalizeCandle,
|
|
52
|
-
loadCandleFile,
|
|
53
|
-
}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
import fs from 'node:fs';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import { fillCandleGaps } from '../market_adapter/candle_utils.js';
|
|
6
|
-
import { getCandleClose, getCandleTimestamp, loadCandleFile } from './math_utils.js';
|
|
7
|
-
import { PATHS } from '../modules/paths.js';
|
|
8
|
-
import { getStorage } from '../modules/storage/index.js';
|
|
9
|
-
const { readJSON } = getStorage();
|
|
10
|
-
import { getErrorMessage } from '../modules/utils/errors.js';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Price Source Abstraction
|
|
14
|
-
*
|
|
15
|
-
* Unified interface for fetching market prices from multiple sources:
|
|
16
|
-
* - JSON candle files
|
|
17
|
-
* - Market adapter state
|
|
18
|
-
*
|
|
19
|
-
* Each source returns: { marketPrice, timestamp }
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
interface JsonFileConfig {
|
|
24
|
-
filePath: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
class JsonFileSource {
|
|
28
|
-
filePath: string;
|
|
29
|
-
name: string;
|
|
30
|
-
|
|
31
|
-
constructor(config: JsonFileConfig) {
|
|
32
|
-
this.filePath = config.filePath;
|
|
33
|
-
this.name = `json:${path.basename(this.filePath)}`;
|
|
34
|
-
if (!fs.existsSync(this.filePath)) {
|
|
35
|
-
throw new Error(`[JsonFileSource] File not found: ${this.filePath}`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async fetchCandles(): Promise<any[]> {
|
|
40
|
-
try {
|
|
41
|
-
const { candles, meta } = loadCandleFile(this.filePath);
|
|
42
|
-
if (!Array.isArray(candles) || candles.length === 0) {
|
|
43
|
-
throw new Error('Expected JSON array or object with .candles or .data property');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const intervalSeconds = meta?.intervalSeconds || 3600;
|
|
47
|
-
const lookbackHours = meta?.lookbackHours;
|
|
48
|
-
|
|
49
|
-
if (lookbackHours && candles.length > 0) {
|
|
50
|
-
const nowMs = new Date(meta.fetchedAt || Date.now()).getTime();
|
|
51
|
-
const startTs = nowMs - (lookbackHours * 3600 * 1000);
|
|
52
|
-
return fillCandleGaps(candles, intervalSeconds, startTs, nowMs);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return candles;
|
|
56
|
-
} catch (err: any) {
|
|
57
|
-
throw new Error(`[JsonFileSource] Failed to read ${this.filePath}: ${getErrorMessage(err)}`);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
extractMarketPrice(candle: any): { marketPrice: any; timestamp: any } {
|
|
62
|
-
return { marketPrice: getCandleClose(candle), timestamp: getCandleTimestamp(candle) };
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
interface MarketAdapterConfig {
|
|
67
|
-
stateDir?: string;
|
|
68
|
-
botKey: string;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
class MarketAdapterSource {
|
|
72
|
-
stateDir: string;
|
|
73
|
-
centersFile: string;
|
|
74
|
-
botKey: string;
|
|
75
|
-
name: string;
|
|
76
|
-
|
|
77
|
-
constructor(config: MarketAdapterConfig) {
|
|
78
|
-
this.stateDir = config.stateDir || PATHS.MARKET_ADAPTER.STATE_DIR;
|
|
79
|
-
// Canonical filename from modules/paths.ts when using the default
|
|
80
|
-
// state dir; custom state dirs keep the sibling-file layout.
|
|
81
|
-
this.centersFile = config.stateDir
|
|
82
|
-
? path.join(this.stateDir, 'market_adapter_centers.json')
|
|
83
|
-
: PATHS.MARKET_ADAPTER.CENTERS_FILE;
|
|
84
|
-
this.botKey = config.botKey;
|
|
85
|
-
this.name = `market_adapter:${this.botKey}`;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
async fetchCandles(): Promise<any[]> {
|
|
89
|
-
const centersFile = this.centersFile;
|
|
90
|
-
if (!fs.existsSync(centersFile)) {
|
|
91
|
-
throw new Error(`[MarketAdapterSource] Centers file not found: ${centersFile}`);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
try {
|
|
95
|
-
const data = readJSON(centersFile);
|
|
96
|
-
|
|
97
|
-
let botData = data[this.botKey];
|
|
98
|
-
if (!botData && data.bots && data.bots[this.botKey]) {
|
|
99
|
-
botData = data.bots[this.botKey];
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (!botData) {
|
|
103
|
-
throw new Error(`Bot '${this.botKey}' not found in centers file`);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return botData.history?.map((entry: any) => ({
|
|
107
|
-
timestamp: entry.timestamp,
|
|
108
|
-
open: entry.center,
|
|
109
|
-
high: entry.center,
|
|
110
|
-
low: entry.center,
|
|
111
|
-
close: entry.center,
|
|
112
|
-
volume: 0,
|
|
113
|
-
})) || [];
|
|
114
|
-
} catch (err: any) {
|
|
115
|
-
throw new Error(`[MarketAdapterSource] Failed to read: ${getErrorMessage(err)}`);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
extractMarketPrice(candle: any): { marketPrice: any; timestamp: any } {
|
|
120
|
-
return { marketPrice: candle.close, timestamp: candle.timestamp };
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function createSource(type: string, config: JsonFileConfig | MarketAdapterConfig): JsonFileSource | MarketAdapterSource {
|
|
125
|
-
switch (type.toLowerCase()) {
|
|
126
|
-
case 'json':
|
|
127
|
-
return new JsonFileSource(config as JsonFileConfig);
|
|
128
|
-
case 'market_adapter':
|
|
129
|
-
return new MarketAdapterSource(config as MarketAdapterConfig);
|
|
130
|
-
default:
|
|
131
|
-
throw new Error(`[PriceSource] Unknown type: ${type}`);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export { createSource }
|
|
136
|
-
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* BOT ACCOUNT-ID BACKFILL
|
|
6
|
-
*
|
|
7
|
-
* Resolves every bot's preferredAccount name to its chain account ID and
|
|
8
|
-
* stamps `accountId` next to `preferredAccount` in profiles/bots.json, so
|
|
9
|
-
* analysis tools and scripts can skip the chain lookup on later runs.
|
|
10
|
-
* Nothing is ever written by hand — all IDs in the file come from this
|
|
11
|
-
* script, the bot editor, or the analysis tools themselves.
|
|
12
|
-
*
|
|
13
|
-
* Usage:
|
|
14
|
-
* node dist/analysis/resolve_bot_accounts.js [--bot-key <key>] [--refresh]
|
|
15
|
-
* [--timeout-ms <n>] [--dry-run] [--json]
|
|
16
|
-
*
|
|
17
|
-
* Exit code 0 = all bot accounts resolved (or nothing to do),
|
|
18
|
-
* 1 = one or more resolutions failed.
|
|
19
|
-
*
|
|
20
|
-
* Short-lived batch tool: suppresses chain INFO logging and disconnects the
|
|
21
|
-
* shared client on exit. Run standalone only — never import/call from a
|
|
22
|
-
* long-running process holding a live connection.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import { loadBotSettings, computeBotKey, persistBotAccountId } from './bot_key_utils.js';
|
|
26
|
-
import { setGlobalConsoleLevel, getGlobalConsoleLevel } from '../modules/order/logger.js';
|
|
27
|
-
import { sleep } from '../modules/order/utils/system.js';
|
|
28
|
-
import { getErrorMessage } from '../modules/utils/errors.js';
|
|
29
|
-
|
|
30
|
-
const DEFAULT_TIMEOUT_MS = 20000;
|
|
31
|
-
|
|
32
|
-
function printHelp() {
|
|
33
|
-
console.log(`\
|
|
34
|
-
Usage: node dist/analysis/resolve_bot_accounts.js [options]
|
|
35
|
-
|
|
36
|
-
Resolve bot preferredAccount names to chain IDs and store them as accountId
|
|
37
|
-
in profiles/bots.json (byte-preserving; comments and formatting survive).
|
|
38
|
-
|
|
39
|
-
Options:
|
|
40
|
-
--bot-key <key> Only process this bot key or bot name (default: all bots)
|
|
41
|
-
--refresh Re-resolve even when a stored accountId exists
|
|
42
|
-
--timeout-ms <n> Per-account chain lookup timeout (default: ${DEFAULT_TIMEOUT_MS})
|
|
43
|
-
--dry-run Report what would change without writing anything
|
|
44
|
-
--json Append a machine-readable summary
|
|
45
|
-
--help, -h Show this help
|
|
46
|
-
`);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function parseArgs() {
|
|
50
|
-
const args = process.argv.slice(2);
|
|
51
|
-
if (args.includes('--help') || args.includes('-h')) { printHelp(); process.exit(0); }
|
|
52
|
-
const opts: any = {
|
|
53
|
-
botKey: null,
|
|
54
|
-
refresh: false,
|
|
55
|
-
timeoutMs: DEFAULT_TIMEOUT_MS,
|
|
56
|
-
dryRun: false,
|
|
57
|
-
json: false,
|
|
58
|
-
};
|
|
59
|
-
for (let i = 0; i < args.length; i++) {
|
|
60
|
-
switch (args[i]) {
|
|
61
|
-
case '--bot-key': opts.botKey = args[++i]; break;
|
|
62
|
-
case '--refresh': opts.refresh = true; break;
|
|
63
|
-
case '--timeout-ms': opts.timeoutMs = parseInt(args[++i], 10); break;
|
|
64
|
-
case '--dry-run': opts.dryRun = true; break;
|
|
65
|
-
case '--json': opts.json = true; break;
|
|
66
|
-
default:
|
|
67
|
-
console.error(`Unknown option: ${args[i]}`);
|
|
68
|
-
process.exit(1);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if (!Number.isFinite(opts.timeoutMs) || opts.timeoutMs <= 0) {
|
|
72
|
-
console.error('Error: --timeout-ms must be a positive number.');
|
|
73
|
-
process.exit(1);
|
|
74
|
-
}
|
|
75
|
-
return opts;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
async function resolveWithTimeout(chainOrders: any, ref: string, timeoutMs: number): Promise<{ id: string | null; reason: string }> {
|
|
79
|
-
const timeoutErr: any = new Error(`lookup timed out after ${timeoutMs}ms`);
|
|
80
|
-
timeoutErr.code = 'ACCOUNT_LOOKUP_TIMEOUT';
|
|
81
|
-
try {
|
|
82
|
-
const id = await Promise.race([
|
|
83
|
-
chainOrders.resolveAccountId(ref),
|
|
84
|
-
sleep(timeoutMs).then(() => { throw timeoutErr; }),
|
|
85
|
-
]);
|
|
86
|
-
if (id && /^1\.2\.\d+$/.test(String(id))) return { id: String(id), reason: 'resolved' };
|
|
87
|
-
return { id: null, reason: 'not-found' };
|
|
88
|
-
} catch (err: any) {
|
|
89
|
-
return { id: null, reason: err && err.code === 'ACCOUNT_LOOKUP_TIMEOUT' ? 'timeout' : 'error' };
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
async function main() {
|
|
94
|
-
const opts = parseArgs();
|
|
95
|
-
const settings = loadBotSettings();
|
|
96
|
-
const entries = Array.isArray(settings?.bots) ? settings.bots : [];
|
|
97
|
-
if (!entries.length) {
|
|
98
|
-
console.log('No bots in profiles/bots.json — nothing to do.');
|
|
99
|
-
process.exit(0);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
let targets = entries.map((bot: any, index: number) => ({ bot, index, key: computeBotKey(bot, index) }));
|
|
103
|
-
if (opts.botKey) {
|
|
104
|
-
const want = String(opts.botKey).toLowerCase();
|
|
105
|
-
targets = targets.filter((t: any) => t.key === want || String(t.bot?.name ?? '').toLowerCase() === want);
|
|
106
|
-
if (!targets.length) {
|
|
107
|
-
console.error(`Error: bot '${opts.botKey}' not found in profiles/bots.json.`);
|
|
108
|
-
process.exit(1);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// Suppress chain INFO spam for the whole batch; restored in finally.
|
|
113
|
-
// (setSuppressConnectionLog is read lazily so this file never drags the
|
|
114
|
-
// chain stack in when it cannot be loaded.)
|
|
115
|
-
let chainClient: any = null;
|
|
116
|
-
let prevSuppress = false;
|
|
117
|
-
let prevGlobalLevel: string | null = null;
|
|
118
|
-
let suppressionArmed = false;
|
|
119
|
-
let chainOrders: any = null;
|
|
120
|
-
try {
|
|
121
|
-
chainClient = await import('../modules/bitshares_client.js');
|
|
122
|
-
prevSuppress = chainClient.isSuppressConnectionLog();
|
|
123
|
-
prevGlobalLevel = getGlobalConsoleLevel();
|
|
124
|
-
suppressionArmed = true;
|
|
125
|
-
chainClient.setSuppressConnectionLog(true);
|
|
126
|
-
setGlobalConsoleLevel('warn');
|
|
127
|
-
chainOrders = await import('../modules/chain_orders.js');
|
|
128
|
-
} catch (err: any) {
|
|
129
|
-
console.error(`Error: could not load the chain stack (${getErrorMessage(err)}).`);
|
|
130
|
-
process.exit(1);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const results: any[] = [];
|
|
134
|
-
try {
|
|
135
|
-
for (const t of targets) {
|
|
136
|
-
const name = t.bot?.name ?? t.key;
|
|
137
|
-
const prefRaw = t.bot?.preferredAccount != null ? String(t.bot.preferredAccount) : '';
|
|
138
|
-
const stored = /^1\.2\.\d+$/.test(String(t.bot?.accountId ?? '')) ? String(t.bot.accountId) : null;
|
|
139
|
-
if (!prefRaw) {
|
|
140
|
-
results.push({ key: t.key, name, status: 'skipped', detail: 'no preferredAccount' });
|
|
141
|
-
console.log(`- ${t.key}: skipped (no preferredAccount)`);
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
if (/^1\.2\.\d+$/.test(prefRaw)) {
|
|
145
|
-
if (stored !== prefRaw) {
|
|
146
|
-
const wrote = opts.dryRun ? true : persistBotAccountId(t.key, prefRaw);
|
|
147
|
-
const status = !wrote ? 'failed' : (opts.dryRun ? 'would-update' : 'updated');
|
|
148
|
-
results.push({ key: t.key, name, status, detail: wrote ? `preferredAccount is authoritative (${prefRaw})` : 'could not write profiles/bots.json' });
|
|
149
|
-
console.log(`- ${t.key}: ${!wrote ? 'FAILED to write' : (opts.dryRun ? 'would update' : 'updated')} stored accountId → ${prefRaw} (preferredAccount is authoritative)`);
|
|
150
|
-
} else {
|
|
151
|
-
results.push({ key: t.key, name, status: 'cached', detail: prefRaw });
|
|
152
|
-
console.log(`- ${t.key}: cached (${prefRaw})`);
|
|
153
|
-
}
|
|
154
|
-
continue;
|
|
155
|
-
}
|
|
156
|
-
if (stored && !opts.refresh) {
|
|
157
|
-
results.push({ key: t.key, name, status: 'cached', detail: stored });
|
|
158
|
-
console.log(`- ${t.key}: cached (${stored})`);
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
161
|
-
const r = await resolveWithTimeout(chainOrders, prefRaw, opts.timeoutMs);
|
|
162
|
-
if (r.id) {
|
|
163
|
-
const changed = stored !== r.id;
|
|
164
|
-
const wrote = !changed || opts.dryRun ? true : persistBotAccountId(t.key, r.id);
|
|
165
|
-
const status = !wrote ? 'failed' : (opts.dryRun ? (changed ? 'would-update' : 'unchanged') : (changed ? (stored ? 'updated' : 'stored') : 'unchanged'));
|
|
166
|
-
results.push({ key: t.key, name, status, detail: wrote ? r.id : 'could not write profiles/bots.json' });
|
|
167
|
-
console.log(`- ${t.key}: '${prefRaw}' → ${r.id}${!wrote ? ' (FAILED to store)' : (changed ? (opts.dryRun ? ' (would store)' : (stored ? ' (updated)' : ' (stored)')) : ' (unchanged)')}`);
|
|
168
|
-
} else {
|
|
169
|
-
const why = r.reason === 'timeout' ? `nodes unreachable (timed out after ${opts.timeoutMs}ms)` : 'not found on the blockchain';
|
|
170
|
-
results.push({ key: t.key, name, status: 'failed', detail: why });
|
|
171
|
-
console.log(`- ${t.key}: FAILED to resolve '${prefRaw}' (${why})`);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
} finally {
|
|
175
|
-
if (chainClient) {
|
|
176
|
-
try { await chainClient.disconnectClient(); } catch (_) { /* best-effort cleanup */ }
|
|
177
|
-
if (suppressionArmed) {
|
|
178
|
-
try { chainClient.setSuppressConnectionLog(prevSuppress); } catch (_) { /* restore-only */ }
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
if (suppressionArmed) {
|
|
182
|
-
try { setGlobalConsoleLevel(prevGlobalLevel); } catch (_) { /* restore-only */ }
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const failed = results.filter((r: any) => r.status === 'failed');
|
|
187
|
-
const skipped = results.filter((r: any) => r.status === 'skipped').length;
|
|
188
|
-
const ok = results.length - failed.length - skipped;
|
|
189
|
-
console.log(`\nDone: ${ok} resolved, ${skipped} skipped, ${failed.length} failed${opts.dryRun ? ' (dry run, nothing written)' : ''}.`);
|
|
190
|
-
if (opts.json) {
|
|
191
|
-
console.log(JSON.stringify({ dryRun: opts.dryRun, results }, null, 2));
|
|
192
|
-
}
|
|
193
|
-
process.exit(failed.length ? 1 : 0);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
main().catch((err: any) => {
|
|
197
|
-
console.error('Fatal:', getErrorMessage(err));
|
|
198
|
-
process.exit(1);
|
|
199
|
-
});
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { PATHS } from '../modules/paths.js';
|
|
5
|
-
import { MARKET_ADAPTER } from '../modules/constants.js';
|
|
6
|
-
import { createSource } from './price_sources.js';
|
|
7
|
-
import { resolveCandleFile, resolveAmaConfig, resolveAmaKey, loadBotSettings, computeBotKey } from './bot_key_utils.js';
|
|
8
|
-
import { findLatestLpData } from '../market_adapter/utils/data_discovery.js';
|
|
9
|
-
import { loadCandleFile } from './math_utils.js';
|
|
10
|
-
|
|
11
|
-
const INTERVAL_LABEL = MARKET_ADAPTER.RUNTIME_DEFAULTS.intervalLabel;
|
|
12
|
-
|
|
13
|
-
interface SourceConfig {
|
|
14
|
-
type?: string;
|
|
15
|
-
botKey?: string;
|
|
16
|
-
filePath?: string;
|
|
17
|
-
stateDir?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface SourceResolution {
|
|
21
|
-
source: ReturnType<typeof createSource>;
|
|
22
|
-
botKey?: string;
|
|
23
|
-
amaConfig: { erPeriod: number; fastPeriod: number; slowPeriod: number; erSmoothPeriod: number };
|
|
24
|
-
amaKey: string;
|
|
25
|
-
// Candle-file meta when the source is backed by a JSON file (pool id,
|
|
26
|
-
// asset ids/symbols, intervalSeconds); null for the centers-file fallback.
|
|
27
|
-
meta: any;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function listAvailableBots(): void {
|
|
31
|
-
const settings = loadBotSettings();
|
|
32
|
-
if (!settings?.bots?.length) {
|
|
33
|
-
console.log('No bots found in profiles/bots.json');
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
console.log('Available bot keys:');
|
|
37
|
-
settings.bots.forEach((bot: any, i: number) => {
|
|
38
|
-
const key = computeBotKey(bot, i);
|
|
39
|
-
console.log(` ${key} (name: ${bot.name})`);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function resolveSource(config: SourceConfig, options: { quiet?: boolean } = {}): SourceResolution {
|
|
44
|
-
const { quiet = false } = options;
|
|
45
|
-
|
|
46
|
-
if (config.type === 'market_adapter') {
|
|
47
|
-
if (!config.botKey) {
|
|
48
|
-
throw new Error("No --bot-key provided. Use --list-bots to see available keys, or --file to specify a data file directly.");
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const candleFile = resolveCandleFile(config.botKey, INTERVAL_LABEL);
|
|
52
|
-
if (candleFile) {
|
|
53
|
-
if (!quiet) console.log(`[Source] Resolved bot '${config.botKey}' → ${path.basename(candleFile)}`);
|
|
54
|
-
const source = createSource('json', { filePath: candleFile });
|
|
55
|
-
return {
|
|
56
|
-
source,
|
|
57
|
-
botKey: config.botKey,
|
|
58
|
-
amaConfig: resolveAmaConfig(config.botKey),
|
|
59
|
-
amaKey: resolveAmaKey(config.botKey),
|
|
60
|
-
meta: loadCandleFile(candleFile).meta,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (!quiet) console.log(`[Source] No candle cache for '${config.botKey}', using centers file`);
|
|
65
|
-
const stateDir = config.stateDir || PATHS.MARKET_ADAPTER.STATE_DIR;
|
|
66
|
-
const source = createSource('market_adapter', { botKey: config.botKey, stateDir });
|
|
67
|
-
return {
|
|
68
|
-
source,
|
|
69
|
-
botKey: config.botKey,
|
|
70
|
-
amaConfig: resolveAmaConfig(config.botKey),
|
|
71
|
-
amaKey: resolveAmaKey(config.botKey),
|
|
72
|
-
meta: null,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (config.type === 'json') {
|
|
77
|
-
let filePath = config.filePath;
|
|
78
|
-
if (!filePath) {
|
|
79
|
-
const autoFile = findLatestLpData();
|
|
80
|
-
if (autoFile) {
|
|
81
|
-
filePath = autoFile;
|
|
82
|
-
if (!quiet) console.log(`[Source] Auto-discovered LP data: ${autoFile}`);
|
|
83
|
-
} else {
|
|
84
|
-
throw new Error('No --file provided and no LP data auto-discovered in market_adapter/data/lp');
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
const source = createSource('json', { filePath: filePath! });
|
|
88
|
-
const meta = loadCandleFile(filePath).meta;
|
|
89
|
-
if (config.botKey) {
|
|
90
|
-
return { source, botKey: config.botKey, amaConfig: resolveAmaConfig(config.botKey), amaKey: resolveAmaKey(config.botKey), meta };
|
|
91
|
-
}
|
|
92
|
-
return { source, amaConfig: resolveAmaConfig(''), amaKey: 'AMA3', meta };
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
throw new Error(`[Source] Unknown source type: ${config.type}. Use 'market_adapter' or 'json'.`);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export { resolveSource, listAvailableBots }
|
|
99
|
-
export type { SourceConfig }
|