dexbot 1.4.20 → 1.4.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -0
- package/README.md +23 -13
- package/analysis/ama_fitting/analyze_ama_price_changes.ts +7 -3
- package/analysis/ama_fitting/analyze_lambda_vs_slow.ts +3 -3
- package/analysis/ama_fitting/calibrate_convergence_er.ts +8 -6
- package/analysis/ama_fitting/fetch_lp_candles.ts +8 -3
- package/analysis/ama_fitting/generate_unified_comparison_chart.ts +30 -67
- package/analysis/ama_fitting/optimizer_high_resolution.ts +22 -13
- package/analysis/ama_fitting/package.json +1 -1
- package/analysis/analyze_derivatives.ts +4 -4
- package/analysis/analyze_dynamic_weight.ts +21 -5
- package/analysis/analyze_kalman.ts +54 -25
- package/analysis/analyze_regime.ts +2 -2
- package/analysis/analyze_regime_windows.ts +27 -19
- package/analysis/analyze_risk_profile.ts +3 -3
- package/analysis/analyze_trade_heatmap.ts +3 -3
- package/analysis/analyze_volatility.ts +2 -2
- package/analysis/bot_fitting/README.md +93 -19
- package/analysis/bot_fitting/backtest_ama_sweep.ts +316 -199
- package/analysis/bot_fitting/backtest_bot_fitting.ts +520 -85
- package/analysis/bot_fitting/shared_utils.ts +16 -10
- package/analysis/bot_key_utils.ts +14 -11
- package/analysis/bot_usage/discover_bot_accounts.ts +5 -3
- package/analysis/bot_usage/kibana_bot_queries.ts +2 -257
- package/analysis/chart_css.ts +6 -4
- package/analysis/chart_ui.ts +0 -1
- package/analysis/chart_utils.ts +11 -2
- package/analysis/derivative_chart_generator.ts +2 -2
- package/analysis/math_utils.ts +1 -8
- package/analysis/price_sources.ts +8 -2
- package/analysis/resolve_source.ts +1 -1
- package/analysis/results/ama_sweep_results_lp_pool_133_1h.json +2455 -0
- package/analysis/results/bot_fitting_results_lp_pool_133_1h.json +218 -0
- package/analysis/trade_profitability.ts +61 -28
- package/analysis/tradingview/analyze_tradingview.ts +1 -1
- package/analysis/tradingview/h-bts_tradingview.html +1570 -0
- package/analysis/tradingview/t-bts_tradingview.html +1570 -0
- package/analysis/tradingview/tradingview_uplot_chart_generator.ts +302 -74
- package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +1 -1
- package/analysis/trend_detection/derivative_analyzer.ts +12 -3
- package/analysis/trend_detection/dynamic_weight_chart_generator.ts +25 -27
- package/analysis/trend_detection/hurst_analyzer.ts +1 -1
- package/analysis/trend_detection/kalman_chart_generator.ts +42 -14
- package/analysis/trend_detection/package.json +1 -1
- package/analysis/trend_detection/regime_chart_generator.ts +39 -19
- package/analysis/trend_detection/tests/test_kalman_trend.ts +1 -1
- package/analysis/trend_detection/tests/test_kalman_velocity_smoothing.ts +1 -1
- package/analysis/trend_detection/volatility_chart_generator.ts +1 -1
- package/claw/ecosystem.config.cjs +2 -3
- package/claw/examples/memu_integration_example.ts +17 -17
- package/claw/index.ts +1 -1
- package/claw/modules/chain_actions.ts +51 -54
- package/claw/modules/chain_broadcast.ts +66 -104
- package/claw/modules/claw_bridge.ts +63 -83
- package/claw/modules/claw_catalog.ts +48 -17
- package/claw/modules/claw_infra.ts +1 -5
- package/claw/modules/claw_launcher.ts +48 -50
- package/claw/modules/claw_skill_md.ts +15 -21
- package/claw/modules/credit_runtime_adapter.ts +3 -19
- package/claw/modules/decision_loop.ts +9 -9
- package/claw/modules/dexbot_bridge.ts +8 -8
- package/claw/modules/dexbot_profiles.ts +5 -21
- package/claw/modules/feed_price_source.ts +1 -1
- package/claw/modules/honest_ecosystem.ts +24 -8
- package/claw/modules/kibana_price_source.ts +1 -1
- package/claw/modules/launcher_mode_detector.ts +1 -1
- package/claw/modules/launcher_paths.ts +1 -1
- package/claw/modules/liquidity_pools.ts +10 -3
- package/claw/modules/mcp_utils.ts +109 -0
- package/claw/modules/memu_bridge.ts +76 -54
- package/claw/modules/mpa_utils.ts +26 -3
- package/claw/modules/position_discovery.ts +17 -28
- package/claw/modules/position_health.ts +1 -1
- package/claw/modules/position_manager.ts +32 -41
- package/claw/modules/position_manager_watch.ts +3 -2
- package/claw/modules/short_mpa_strategy.ts +1 -9
- package/claw/modules/skill_utils.ts +5 -3
- package/claw/modules/utils.ts +9 -1
- package/claw/package.json +3 -3
- package/claw/runtimes/openclaw-plugin/index.ts +27 -10
- package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
- package/claw/runtimes/openclaw-plugin/package.json +1 -1
- package/claw/scripts/claw_bridge.ts +1 -1
- package/claw/scripts/claw_mcp_server.ts +19 -78
- package/claw/scripts/honest_assets_report.ts +19 -84
- package/claw/scripts/memu_mcp_server.ts +57 -155
- package/claw/skills/launcher-ops/references/launcher-workflow.md +2 -2
- package/claw/tests/package.json +1 -1
- package/claw/tests/test_claw_bridge.ts +47 -19
- package/claw/tests/test_claw_catalog_and_credentials.ts +8 -4
- package/claw/tests/test_claw_chain_layer.ts +39 -19
- package/claw/tests/test_claw_data_flow.ts +28 -20
- package/claw/tests/test_claw_domain_logic.ts +25 -19
- package/claw/tests/test_claw_manifest_and_matrix.ts +23 -3
- package/claw/tests/test_claw_mcp_transport.ts +13 -8
- package/claw/tests/test_claw_regressions.ts +254 -128
- package/claw/tests/test_claw_skill_generation.ts +1 -1
- package/claw/tests/test_nullclaw_tmp_integration.ts +2 -3
- package/claw/tests/test_position_health.ts +1 -77
- package/claw/tests/test_position_manager.ts +20 -18
- package/claw/tests/test_position_manager_watch_health.ts +39 -43
- package/claw/tests/test_short_mpa_strategy.ts +20 -17
- package/claw/tsconfig.json +4 -3
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.js +7 -3
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.js.map +1 -1
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +3 -3
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js.map +1 -1
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js +8 -6
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js.map +1 -1
- package/dist/analysis/ama_fitting/fetch_lp_candles.js +8 -3
- package/dist/analysis/ama_fitting/fetch_lp_candles.js.map +1 -1
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts +2 -2
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts.map +1 -1
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js +31 -75
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js.map +1 -1
- package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts.map +1 -1
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js +21 -13
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js.map +1 -1
- package/dist/analysis/analyze_derivatives.d.ts +0 -18
- package/dist/analysis/analyze_derivatives.d.ts.map +1 -1
- package/dist/analysis/analyze_derivatives.js +4 -4
- package/dist/analysis/analyze_derivatives.js.map +1 -1
- package/dist/analysis/analyze_dynamic_weight.d.ts +0 -11
- package/dist/analysis/analyze_dynamic_weight.d.ts.map +1 -1
- package/dist/analysis/analyze_dynamic_weight.js +19 -5
- package/dist/analysis/analyze_dynamic_weight.js.map +1 -1
- package/dist/analysis/analyze_kalman.d.ts +0 -10
- package/dist/analysis/analyze_kalman.d.ts.map +1 -1
- package/dist/analysis/analyze_kalman.js +51 -26
- package/dist/analysis/analyze_kalman.js.map +1 -1
- package/dist/analysis/analyze_regime.d.ts +0 -17
- package/dist/analysis/analyze_regime.d.ts.map +1 -1
- package/dist/analysis/analyze_regime.js +2 -2
- package/dist/analysis/analyze_regime.js.map +1 -1
- package/dist/analysis/analyze_regime_windows.d.ts +0 -16
- package/dist/analysis/analyze_regime_windows.d.ts.map +1 -1
- package/dist/analysis/analyze_regime_windows.js +28 -21
- package/dist/analysis/analyze_regime_windows.js.map +1 -1
- package/dist/analysis/analyze_risk_profile.js +3 -3
- package/dist/analysis/analyze_risk_profile.js.map +1 -1
- package/dist/analysis/analyze_trade_heatmap.js +3 -3
- package/dist/analysis/analyze_trade_heatmap.js.map +1 -1
- package/dist/analysis/analyze_volatility.d.ts +0 -19
- package/dist/analysis/analyze_volatility.d.ts.map +1 -1
- package/dist/analysis/analyze_volatility.js +2 -2
- package/dist/analysis/analyze_volatility.js.map +1 -1
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts +30 -14
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts.map +1 -1
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js +330 -193
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js.map +1 -1
- package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts +136 -1
- package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts.map +1 -1
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js +527 -83
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js.map +1 -1
- package/dist/analysis/bot_fitting/shared_utils.d.ts +2 -13
- package/dist/analysis/bot_fitting/shared_utils.d.ts.map +1 -1
- package/dist/analysis/bot_fitting/shared_utils.js +15 -9
- package/dist/analysis/bot_fitting/shared_utils.js.map +1 -1
- package/dist/analysis/bot_key_utils.d.ts +1 -1
- package/dist/analysis/bot_key_utils.d.ts.map +1 -1
- package/dist/analysis/bot_key_utils.js +14 -11
- package/dist/analysis/bot_key_utils.js.map +1 -1
- package/dist/analysis/bot_usage/discover_bot_accounts.js +5 -3
- package/dist/analysis/bot_usage/discover_bot_accounts.js.map +1 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts +1 -337
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +1 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.js +2 -242
- package/dist/analysis/bot_usage/kibana_bot_queries.js.map +1 -1
- package/dist/analysis/chart_css.d.ts +2 -14
- package/dist/analysis/chart_css.d.ts.map +1 -1
- package/dist/analysis/chart_css.js +6 -3
- package/dist/analysis/chart_css.js.map +1 -1
- package/dist/analysis/chart_ui.d.ts.map +1 -1
- package/dist/analysis/chart_ui.js.map +1 -1
- package/dist/analysis/chart_utils.d.ts.map +1 -1
- package/dist/analysis/chart_utils.js +15 -2
- package/dist/analysis/chart_utils.js.map +1 -1
- package/dist/analysis/derivative_chart_generator.js +2 -2
- package/dist/analysis/derivative_chart_generator.js.map +1 -1
- package/dist/analysis/math_utils.d.ts +3 -5
- package/dist/analysis/math_utils.d.ts.map +1 -1
- package/dist/analysis/math_utils.js +3 -5
- package/dist/analysis/math_utils.js.map +1 -1
- package/dist/analysis/price_sources.d.ts +1 -0
- package/dist/analysis/price_sources.d.ts.map +1 -1
- package/dist/analysis/price_sources.js +8 -2
- package/dist/analysis/price_sources.js.map +1 -1
- package/dist/analysis/resolve_source.d.ts.map +1 -1
- package/dist/analysis/resolve_source.js +1 -1
- package/dist/analysis/resolve_source.js.map +1 -1
- package/dist/analysis/trade_profitability.d.ts.map +1 -1
- package/dist/analysis/trade_profitability.js +58 -29
- package/dist/analysis/trade_profitability.js.map +1 -1
- package/dist/analysis/tradingview/analyze_tradingview.js +1 -1
- package/dist/analysis/tradingview/analyze_tradingview.js.map +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +302 -74
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +1 -1
- package/dist/analysis/trend_detection/derivative_analyzer.d.ts +1 -0
- package/dist/analysis/trend_detection/derivative_analyzer.d.ts.map +1 -1
- package/dist/analysis/trend_detection/derivative_analyzer.js +12 -3
- package/dist/analysis/trend_detection/derivative_analyzer.js.map +1 -1
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +1 -1
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +26 -27
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +1 -1
- package/dist/analysis/trend_detection/hurst_analyzer.d.ts +1 -1
- package/dist/analysis/trend_detection/hurst_analyzer.d.ts.map +1 -1
- package/dist/analysis/trend_detection/hurst_analyzer.js +1 -1
- package/dist/analysis/trend_detection/hurst_analyzer.js.map +1 -1
- package/dist/analysis/trend_detection/kalman_chart_generator.d.ts.map +1 -1
- package/dist/analysis/trend_detection/kalman_chart_generator.js +41 -13
- package/dist/analysis/trend_detection/kalman_chart_generator.js.map +1 -1
- package/dist/analysis/trend_detection/regime_chart_generator.d.ts.map +1 -1
- package/dist/analysis/trend_detection/regime_chart_generator.js +38 -19
- package/dist/analysis/trend_detection/regime_chart_generator.js.map +1 -1
- package/dist/analysis/trend_detection/tests/test_kalman_trend.js +1 -1
- package/dist/analysis/trend_detection/tests/test_kalman_trend.js.map +1 -1
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js +1 -1
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js.map +1 -1
- package/dist/analysis/trend_detection/volatility_chart_generator.js +1 -1
- package/dist/analysis/trend_detection/volatility_chart_generator.js.map +1 -1
- package/dist/bot.js +3 -3
- package/dist/bot.js.map +1 -1
- package/dist/credential-daemon.d.ts +1 -1
- package/dist/credential-daemon.js +2 -2
- package/dist/credential-daemon.js.map +1 -1
- package/dist/dexbot.d.ts.map +1 -1
- package/dist/dexbot.js +25 -22
- package/dist/dexbot.js.map +1 -1
- package/dist/market_adapter/ama_signal_runner.js +6 -4
- package/dist/market_adapter/ama_signal_runner.js.map +1 -1
- package/dist/market_adapter/candle_utils.d.ts +1 -3
- package/dist/market_adapter/candle_utils.d.ts.map +1 -1
- package/dist/market_adapter/candle_utils.js +1 -11
- package/dist/market_adapter/candle_utils.js.map +1 -1
- package/dist/market_adapter/core/asymmetric_bounds.d.ts.map +1 -1
- package/dist/market_adapter/core/asymmetric_bounds.js +33 -30
- package/dist/market_adapter/core/asymmetric_bounds.js.map +1 -1
- package/dist/market_adapter/core/config_normalizers.d.ts.map +1 -1
- package/dist/market_adapter/core/config_normalizers.js +10 -1
- package/dist/market_adapter/core/config_normalizers.js.map +1 -1
- package/dist/market_adapter/core/kibana_candles.d.ts +18 -42
- package/dist/market_adapter/core/kibana_candles.d.ts.map +1 -1
- package/dist/market_adapter/core/kibana_candles.js +101 -7
- package/dist/market_adapter/core/kibana_candles.js.map +1 -1
- package/dist/market_adapter/core/kibana_client.d.ts +1 -17
- package/dist/market_adapter/core/kibana_client.d.ts.map +1 -1
- package/dist/market_adapter/core/kibana_client.js +40 -7
- package/dist/market_adapter/core/kibana_client.js.map +1 -1
- package/dist/market_adapter/core/kibana_market_candles.d.ts +0 -27
- package/dist/market_adapter/core/kibana_market_candles.d.ts.map +1 -1
- package/dist/market_adapter/core/kibana_market_candles.js +1 -1
- package/dist/market_adapter/core/kibana_market_candles.js.map +1 -1
- package/dist/market_adapter/core/market_adapter_service.d.ts +22 -13
- package/dist/market_adapter/core/market_adapter_service.d.ts.map +1 -1
- package/dist/market_adapter/core/market_adapter_service.js +96 -38
- package/dist/market_adapter/core/market_adapter_service.js.map +1 -1
- package/dist/market_adapter/core/signals/hurst_analyzer.d.ts +10 -1
- package/dist/market_adapter/core/signals/hurst_analyzer.d.ts.map +1 -1
- package/dist/market_adapter/core/signals/hurst_analyzer.js +28 -17
- package/dist/market_adapter/core/signals/hurst_analyzer.js.map +1 -1
- package/dist/market_adapter/core/signals/kalman_trend_analyzer.d.ts +5 -0
- package/dist/market_adapter/core/signals/kalman_trend_analyzer.d.ts.map +1 -1
- package/dist/market_adapter/core/signals/kalman_trend_analyzer.js +24 -24
- package/dist/market_adapter/core/signals/kalman_trend_analyzer.js.map +1 -1
- package/dist/market_adapter/core/signals/kalman_velocity_smoothing.d.ts.map +1 -1
- package/dist/market_adapter/core/signals/kalman_velocity_smoothing.js +5 -1
- package/dist/market_adapter/core/signals/kalman_velocity_smoothing.js.map +1 -1
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts.map +1 -1
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js +20 -3
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js.map +1 -1
- package/dist/market_adapter/core/strategies/ama.js +1 -1
- package/dist/market_adapter/core/strategies/ama.js.map +1 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.d.ts +2 -2
- package/dist/market_adapter/core/strategies/ama_slope_model.d.ts.map +1 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.js +16 -4
- package/dist/market_adapter/core/strategies/ama_slope_model.js.map +1 -1
- package/dist/market_adapter/core/strategies/atr/calculator.d.ts +4 -3
- package/dist/market_adapter/core/strategies/atr/calculator.d.ts.map +1 -1
- package/dist/market_adapter/core/strategies/atr/calculator.js +16 -8
- package/dist/market_adapter/core/strategies/atr/calculator.js.map +1 -1
- package/dist/market_adapter/core/strategies/collateral_manager.d.ts.map +1 -1
- package/dist/market_adapter/core/strategies/collateral_manager.js +8 -3
- package/dist/market_adapter/core/strategies/collateral_manager.js.map +1 -1
- package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts +40 -1
- package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts.map +1 -1
- package/dist/market_adapter/core/strategies/dynamic_weight_series.js +116 -2
- package/dist/market_adapter/core/strategies/dynamic_weight_series.js.map +1 -1
- package/dist/market_adapter/core/strategies/regime_gate.d.ts +1 -2
- package/dist/market_adapter/core/strategies/regime_gate.d.ts.map +1 -1
- package/dist/market_adapter/core/strategies/regime_gate.js +27 -21
- package/dist/market_adapter/core/strategies/regime_gate.js.map +1 -1
- package/dist/market_adapter/core/strategies/volatility_shift.d.ts.map +1 -1
- package/dist/market_adapter/core/strategies/volatility_shift.js +3 -0
- package/dist/market_adapter/core/strategies/volatility_shift.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +71 -57
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +0 -26
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js +72 -19
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -1
- package/dist/market_adapter/inputs/kibana_source.d.ts +5 -30
- package/dist/market_adapter/inputs/kibana_source.d.ts.map +1 -1
- package/dist/market_adapter/inputs/kibana_source.js +6 -3
- package/dist/market_adapter/inputs/kibana_source.js.map +1 -1
- package/dist/market_adapter/lp_chart_core.js +1 -1
- package/dist/market_adapter/lp_chart_core.js.map +1 -1
- package/dist/market_adapter/lp_chart_runner.d.ts +10 -1
- package/dist/market_adapter/lp_chart_runner.d.ts.map +1 -1
- package/dist/market_adapter/lp_chart_runner.js +2 -2
- package/dist/market_adapter/lp_chart_runner.js.map +1 -1
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts +1 -2
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts.map +1 -1
- package/dist/market_adapter/lp_chart_strategy_loader.js +5 -5
- package/dist/market_adapter/lp_chart_strategy_loader.js.map +1 -1
- package/dist/market_adapter/market_adapter.d.ts +1 -2
- package/dist/market_adapter/market_adapter.d.ts.map +1 -1
- package/dist/market_adapter/market_adapter.js +5 -7
- package/dist/market_adapter/market_adapter.js.map +1 -1
- package/dist/market_adapter/test_helpers.d.ts +3 -3
- package/dist/market_adapter/test_helpers.d.ts.map +1 -1
- package/dist/market_adapter/test_helpers.js +3 -3
- package/dist/market_adapter/test_helpers.js.map +1 -1
- package/dist/market_adapter/utils/adapter_client.js +1 -1
- package/dist/market_adapter/utils/adapter_client.js.map +1 -1
- package/dist/market_adapter/utils/atomic_write.js +1 -1
- package/dist/market_adapter/utils/atomic_write.js.map +1 -1
- package/dist/market_adapter/utils/chain.d.ts +0 -2
- package/dist/market_adapter/utils/chain.d.ts.map +1 -1
- package/dist/market_adapter/utils/chain.js +2 -3
- package/dist/market_adapter/utils/chain.js.map +1 -1
- package/dist/market_adapter/utils/data_discovery.d.ts.map +1 -1
- package/dist/market_adapter/utils/data_discovery.js +24 -8
- package/dist/market_adapter/utils/data_discovery.js.map +1 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +1 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js +2 -5
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +1 -1
- package/dist/market_adapter/utils/file_lock.d.ts +4 -1
- package/dist/market_adapter/utils/file_lock.d.ts.map +1 -1
- package/dist/market_adapter/utils/file_lock.js +89 -25
- package/dist/market_adapter/utils/file_lock.js.map +1 -1
- package/dist/market_adapter/utils/native_history.d.ts.map +1 -1
- package/dist/market_adapter/utils/native_history.js +5 -1
- package/dist/market_adapter/utils/native_history.js.map +1 -1
- package/dist/modules/account_bots.d.ts +3 -0
- package/dist/modules/account_bots.d.ts.map +1 -1
- package/dist/modules/account_bots.js +157 -47
- package/dist/modules/account_bots.js.map +1 -1
- package/dist/modules/account_orders.d.ts +1 -7
- package/dist/modules/account_orders.d.ts.map +1 -1
- package/dist/modules/account_orders.js +9 -17
- package/dist/modules/account_orders.js.map +1 -1
- package/dist/modules/authority_resolver.js +1 -1
- package/dist/modules/authority_resolver.js.map +1 -1
- package/dist/modules/bitshares-native/chain_client.js +1 -1
- package/dist/modules/bitshares-native/chain_client.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts +0 -12
- package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.js +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.js +1 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.js.map +1 -1
- package/dist/modules/bitshares-native/index.d.ts.map +1 -1
- package/dist/modules/bitshares-native/index.js +1 -1
- package/dist/modules/bitshares-native/index.js.map +1 -1
- package/dist/modules/bitshares-native/lru_cache.js +1 -1
- package/dist/modules/bitshares-native/lru_cache.js.map +1 -1
- package/dist/modules/bitshares-native/resolvers.d.ts +0 -2
- package/dist/modules/bitshares-native/resolvers.d.ts.map +1 -1
- package/dist/modules/bitshares-native/resolvers.js +18 -4
- package/dist/modules/bitshares-native/resolvers.js.map +1 -1
- package/dist/modules/bitshares-native/serial/chain_constants.js +1 -1
- package/dist/modules/bitshares-native/serial/chain_constants.js.map +1 -1
- package/dist/modules/bitshares-native/serial/index.d.ts.map +1 -1
- package/dist/modules/bitshares-native/serial/index.js +1 -1
- package/dist/modules/bitshares-native/serial/index.js.map +1 -1
- package/dist/modules/bitshares-native/serial/operations.js +1 -1
- package/dist/modules/bitshares-native/serial/operations.js.map +1 -1
- package/dist/modules/bitshares-native/serial/serializer.js +1 -1
- package/dist/modules/bitshares-native/serial/serializer.js.map +1 -1
- package/dist/modules/bitshares-native/serial/types.js +1 -1
- package/dist/modules/bitshares-native/serial/types.js.map +1 -1
- package/dist/modules/bitshares-native/signing_client.js +2 -2
- package/dist/modules/bitshares-native/signing_client.js.map +1 -1
- package/dist/modules/bitshares-native/subscriptions.d.ts.map +1 -1
- package/dist/modules/bitshares-native/subscriptions.js +5 -14
- package/dist/modules/bitshares-native/subscriptions.js.map +1 -1
- package/dist/modules/bitshares-native/transport.js +1 -1
- package/dist/modules/bitshares-native/transport.js.map +1 -1
- package/dist/modules/bitshares-native/tx/builder.js +1 -1
- package/dist/modules/bitshares-native/tx/builder.js.map +1 -1
- package/dist/modules/bitshares-native/tx/tx_cache.d.ts +3 -2
- package/dist/modules/bitshares-native/tx/tx_cache.d.ts.map +1 -1
- package/dist/modules/bitshares-native/tx/tx_cache.js +7 -4
- package/dist/modules/bitshares-native/tx/tx_cache.js.map +1 -1
- package/dist/modules/bitshares_client.d.ts +2 -14
- package/dist/modules/bitshares_client.d.ts.map +1 -1
- package/dist/modules/bitshares_client.js +32 -41
- 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 +12 -19
- package/dist/modules/bot_settings.js.map +1 -1
- package/dist/modules/bots_file_lock.d.ts +1 -1
- package/dist/modules/bots_file_lock.js +1 -1
- package/dist/modules/broadcast_failure.d.ts +13 -0
- package/dist/modules/broadcast_failure.d.ts.map +1 -1
- package/dist/modules/broadcast_failure.js +0 -13
- package/dist/modules/broadcast_failure.js.map +1 -1
- package/dist/modules/chain_keys.js +2 -2
- package/dist/modules/chain_keys.js.map +1 -1
- package/dist/modules/chain_orders.d.ts +2 -3
- package/dist/modules/chain_orders.d.ts.map +1 -1
- package/dist/modules/chain_orders.js +23 -42
- package/dist/modules/chain_orders.js.map +1 -1
- package/dist/modules/config.d.ts.map +1 -1
- package/dist/modules/config.js +5 -2
- package/dist/modules/config.js.map +1 -1
- package/dist/modules/constants.d.ts +21 -21
- package/dist/modules/constants.d.ts.map +1 -1
- package/dist/modules/constants.js +53 -60
- package/dist/modules/constants.js.map +1 -1
- package/dist/modules/cr_planner.d.ts +1 -7
- package/dist/modules/cr_planner.d.ts.map +1 -1
- package/dist/modules/cr_planner.js +3 -77
- package/dist/modules/cr_planner.js.map +1 -1
- package/dist/modules/credential_policy.d.ts +0 -4
- package/dist/modules/credential_policy.d.ts.map +1 -1
- package/dist/modules/credential_policy.js +18 -3
- package/dist/modules/credential_policy.js.map +1 -1
- package/dist/modules/credit_runtime.d.ts +0 -7
- package/dist/modules/credit_runtime.d.ts.map +1 -1
- package/dist/modules/credit_runtime.js +21 -60
- package/dist/modules/credit_runtime.js.map +1 -1
- package/dist/modules/crypto/index.d.ts +0 -2
- package/dist/modules/crypto/index.d.ts.map +1 -1
- package/dist/modules/crypto/index.js +0 -2
- package/dist/modules/crypto/index.js.map +1 -1
- package/dist/modules/crypto/sync.js.map +1 -1
- package/dist/modules/daemon_node_health.js +1 -1
- package/dist/modules/daemon_node_health.js.map +1 -1
- package/dist/modules/dexbot_class.d.ts +8 -134
- package/dist/modules/dexbot_class.d.ts.map +1 -1
- package/dist/modules/dexbot_class.js +39 -199
- package/dist/modules/dexbot_class.js.map +1 -1
- package/dist/modules/dexbot_credential_client.js +1 -1
- package/dist/modules/dexbot_credential_client.js.map +1 -1
- package/dist/modules/dexbot_fill_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_fill_runtime.js +3 -6
- package/dist/modules/dexbot_fill_runtime.js.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts +6 -34
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.js +27 -19
- package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
- package/dist/modules/dexbot_startup_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_startup_runtime.js +31 -15
- package/dist/modules/dexbot_startup_runtime.js.map +1 -1
- package/dist/modules/dexbot_state_recovery.d.ts +2 -2
- package/dist/modules/dexbot_state_recovery.d.ts.map +1 -1
- package/dist/modules/dexbot_state_recovery.js +11 -7
- package/dist/modules/dexbot_state_recovery.js.map +1 -1
- package/dist/modules/fund_registry.d.ts.map +1 -1
- package/dist/modules/fund_registry.js +24 -6
- package/dist/modules/fund_registry.js.map +1 -1
- package/dist/modules/general_settings.d.ts +1 -2
- package/dist/modules/general_settings.d.ts.map +1 -1
- package/dist/modules/general_settings.js +1 -2
- package/dist/modules/general_settings.js.map +1 -1
- package/dist/modules/graceful_shutdown.d.ts.map +1 -1
- package/dist/modules/graceful_shutdown.js +10 -1
- package/dist/modules/graceful_shutdown.js.map +1 -1
- package/dist/modules/grid_price_source.d.ts +19 -0
- package/dist/modules/grid_price_source.d.ts.map +1 -0
- package/dist/modules/grid_price_source.js +23 -0
- package/dist/modules/grid_price_source.js.map +1 -0
- package/dist/modules/key_store.d.ts +0 -5
- package/dist/modules/key_store.d.ts.map +1 -1
- package/dist/modules/key_store.js +1 -14
- package/dist/modules/key_store.js.map +1 -1
- package/dist/modules/launcher/bot_supervisor.d.ts.map +1 -1
- package/dist/modules/launcher/bot_supervisor.js +15 -26
- package/dist/modules/launcher/bot_supervisor.js.map +1 -1
- package/dist/modules/launcher/child_env.d.ts +1 -2
- package/dist/modules/launcher/child_env.d.ts.map +1 -1
- package/dist/modules/launcher/child_env.js +1 -1
- package/dist/modules/launcher/child_env.js.map +1 -1
- package/dist/modules/launcher/foreign_cred_daemon.d.ts.map +1 -1
- package/dist/modules/launcher/foreign_cred_daemon.js +7 -13
- package/dist/modules/launcher/foreign_cred_daemon.js.map +1 -1
- package/dist/modules/launcher/market_adapter_runtime.d.ts +3 -4
- package/dist/modules/launcher/market_adapter_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/market_adapter_runtime.js +10 -29
- package/dist/modules/launcher/market_adapter_runtime.js.map +1 -1
- package/dist/modules/launcher/market_adapter_watchdog.d.ts.map +1 -1
- package/dist/modules/launcher/market_adapter_watchdog.js +3 -2
- package/dist/modules/launcher/market_adapter_watchdog.js.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts +0 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.js +4 -18
- package/dist/modules/launcher/monolithic_runtime.js.map +1 -1
- package/dist/modules/launcher/runtime_entry.d.ts.map +1 -1
- package/dist/modules/launcher/runtime_entry.js +4 -5
- package/dist/modules/launcher/runtime_entry.js.map +1 -1
- package/dist/modules/launcher/status_reporting.d.ts +1 -2
- package/dist/modules/launcher/status_reporting.d.ts.map +1 -1
- package/dist/modules/launcher/status_reporting.js +2 -5
- package/dist/modules/launcher/status_reporting.js.map +1 -1
- package/dist/modules/launcher/supervisor_control.js +1 -1
- package/dist/modules/launcher/supervisor_control.js.map +1 -1
- package/dist/modules/market_adapter_whitelist.d.ts +2 -2
- package/dist/modules/market_adapter_whitelist.d.ts.map +1 -1
- package/dist/modules/market_adapter_whitelist.js +12 -6
- package/dist/modules/market_adapter_whitelist.js.map +1 -1
- package/dist/modules/node_failure_ledger.d.ts +23 -0
- package/dist/modules/node_failure_ledger.d.ts.map +1 -1
- package/dist/modules/node_failure_ledger.js +0 -23
- package/dist/modules/node_failure_ledger.js.map +1 -1
- package/dist/modules/node_manager.d.ts.map +1 -1
- package/dist/modules/node_manager.js +3 -3
- package/dist/modules/node_manager.js.map +1 -1
- package/dist/modules/order/accounting.js +3 -3
- package/dist/modules/order/accounting.js.map +1 -1
- package/dist/modules/order/async_lock.d.ts +6 -0
- package/dist/modules/order/async_lock.d.ts.map +1 -1
- package/dist/modules/order/async_lock.js +11 -0
- package/dist/modules/order/async_lock.js.map +1 -1
- package/dist/modules/order/export.d.ts +1 -1
- package/dist/modules/order/export.js +10 -10
- package/dist/modules/order/export.js.map +1 -1
- package/dist/modules/order/format.d.ts +1 -8
- package/dist/modules/order/format.d.ts.map +1 -1
- package/dist/modules/order/format.js +0 -14
- package/dist/modules/order/format.js.map +1 -1
- package/dist/modules/order/grid.d.ts +2 -12
- package/dist/modules/order/grid.d.ts.map +1 -1
- package/dist/modules/order/grid.js +23 -24
- package/dist/modules/order/grid.js.map +1 -1
- package/dist/modules/order/grid_reconcile.d.ts +1 -1
- package/dist/modules/order/grid_reconcile.js +1 -1
- package/dist/modules/order/grid_reconcile_internal.js +1 -1
- package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
- package/dist/modules/order/logger.d.ts +3 -0
- package/dist/modules/order/logger.d.ts.map +1 -1
- package/dist/modules/order/logger.js +23 -14
- package/dist/modules/order/logger.js.map +1 -1
- package/dist/modules/order/logger_state.d.ts +5 -22
- package/dist/modules/order/logger_state.d.ts.map +1 -1
- package/dist/modules/order/logger_state.js +6 -25
- package/dist/modules/order/logger_state.js.map +1 -1
- package/dist/modules/order/manager.d.ts +1 -4
- package/dist/modules/order/manager.d.ts.map +1 -1
- package/dist/modules/order/manager.js +34 -33
- package/dist/modules/order/manager.js.map +1 -1
- package/dist/modules/order/processed_fill_store.d.ts +0 -5
- package/dist/modules/order/processed_fill_store.d.ts.map +1 -1
- package/dist/modules/order/processed_fill_store.js +10 -15
- package/dist/modules/order/processed_fill_store.js.map +1 -1
- package/dist/modules/order/strategy.d.ts +6 -4
- package/dist/modules/order/strategy.d.ts.map +1 -1
- package/dist/modules/order/strategy.js +6 -4
- package/dist/modules/order/strategy.js.map +1 -1
- package/dist/modules/order/sync_engine.d.ts.map +1 -1
- package/dist/modules/order/sync_engine.js +17 -10
- package/dist/modules/order/sync_engine.js.map +1 -1
- package/dist/modules/order/utils/math.d.ts +7 -1
- package/dist/modules/order/utils/math.d.ts.map +1 -1
- package/dist/modules/order/utils/math.js +19 -1
- package/dist/modules/order/utils/math.js.map +1 -1
- package/dist/modules/order/utils/order.d.ts.map +1 -1
- package/dist/modules/order/utils/order.js +11 -4
- package/dist/modules/order/utils/order.js.map +1 -1
- package/dist/modules/order/utils/system.d.ts +3 -8
- package/dist/modules/order/utils/system.d.ts.map +1 -1
- package/dist/modules/order/utils/system.js +14 -4
- package/dist/modules/order/utils/system.js.map +1 -1
- package/dist/modules/order/utils/validate.js +1 -1
- package/dist/modules/order/utils/validate.js.map +1 -1
- package/dist/modules/path_api.js +1 -1
- package/dist/modules/path_api.js.map +1 -1
- package/dist/modules/paths.d.ts +1 -7
- package/dist/modules/paths.d.ts.map +1 -1
- package/dist/modules/paths.js +1 -1
- package/dist/modules/paths.js.map +1 -1
- package/dist/modules/process_discovery.d.ts +3 -0
- package/dist/modules/process_discovery.d.ts.map +1 -1
- package/dist/modules/process_discovery.js +15 -1
- package/dist/modules/process_discovery.js.map +1 -1
- package/dist/modules/runtime_settings.js +4 -2
- package/dist/modules/runtime_settings.js.map +1 -1
- package/dist/modules/settings_merge.d.ts +5 -1
- package/dist/modules/settings_merge.d.ts.map +1 -1
- package/dist/modules/settings_merge.js +17 -4
- package/dist/modules/settings_merge.js.map +1 -1
- package/dist/modules/socket_json_client.d.ts.map +1 -1
- package/dist/modules/socket_json_client.js +12 -2
- package/dist/modules/socket_json_client.js.map +1 -1
- package/dist/modules/storage/browser_adapter.d.ts +8 -3
- package/dist/modules/storage/browser_adapter.d.ts.map +1 -1
- package/dist/modules/storage/browser_adapter.js +58 -7
- package/dist/modules/storage/browser_adapter.js.map +1 -1
- package/dist/modules/storage/index.d.ts +1 -1
- package/dist/modules/storage/index.js +1 -1
- package/dist/modules/types.d.ts +1 -1
- package/dist/modules/types.d.ts.map +1 -1
- package/dist/modules/utils/sanitize_key.d.ts +7 -0
- package/dist/modules/utils/sanitize_key.d.ts.map +1 -0
- package/dist/modules/utils/sanitize_key.js +15 -0
- package/dist/modules/utils/sanitize_key.js.map +1 -0
- package/dist/modules/validate_profiles.d.ts.map +1 -1
- package/dist/modules/validate_profiles.js +6 -8
- package/dist/modules/validate_profiles.js.map +1 -1
- package/dist/pm2.d.ts.map +1 -1
- package/dist/pm2.js +8 -9
- package/dist/pm2.js.map +1 -1
- package/dist/scripts/analyze-git.d.ts +1 -1
- package/dist/scripts/analyze-git.js +1 -1
- package/dist/scripts/analyze-orders.d.ts +2 -2
- package/dist/scripts/analyze-orders.d.ts.map +1 -1
- package/dist/scripts/analyze-orders.js +39 -28
- package/dist/scripts/analyze-orders.js.map +1 -1
- package/dist/scripts/diagnose-pool-history.js +1 -1
- package/dist/scripts/divergence-calc.d.ts +1 -1
- package/dist/scripts/divergence-calc.js +3 -3
- package/dist/scripts/native_release_gates.js +4 -2
- package/dist/scripts/native_release_gates.js.map +1 -1
- package/dist/scripts/print_grid.d.ts +1 -1
- package/dist/scripts/print_grid.js +1 -1
- package/dist/scripts/run-tests.js +38 -19
- package/dist/scripts/run-tests.js.map +1 -1
- package/dist/scripts/runner.d.ts +3 -5
- package/dist/scripts/runner.d.ts.map +1 -1
- package/dist/scripts/runner.js +4 -6
- package/dist/scripts/runner.js.map +1 -1
- package/dist/scripts/sync-version.d.ts +2 -2
- package/dist/scripts/sync-version.js +2 -2
- package/dist/scripts/update.d.ts +1 -1
- package/dist/scripts/update.js +2 -2
- package/dist/scripts/update.js.map +1 -1
- package/dist/scripts/validate_bots.d.ts +1 -1
- package/dist/scripts/validate_bots.js +1 -1
- package/dist/scripts/verify-browser-bundle.d.ts +1 -1
- package/dist/scripts/verify-browser-bundle.js +1 -1
- package/dist/unlock.js +4 -4
- package/dist/unlock.js.map +1 -1
- package/docs/BITSHARES_ONBOARDING.md +63 -18
- package/docs/COPY_ON_WRITE_MASTER_PLAN.md +14 -23
- package/docs/COW_INVARIANTS.md +4 -4
- package/docs/CREDENTIAL_SECURITY.md +0 -11
- package/docs/DEXBOT_COMPARISON.md +12 -12
- package/docs/EVOLUTION.md +17 -43
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +27 -83
- package/docs/GRID_RECALCULATION.md +1 -13
- package/docs/GRID_RECONCILE.md +24 -24
- package/docs/LIFECYCLE.md +4 -4
- package/docs/LOGGING.md +1 -1
- package/docs/MPA_CREDIT_USAGE.md +3 -3
- package/docs/README.md +2 -2
- package/docs/WORKFLOW.md +2 -2
- package/docs/architecture.md +48 -43
- package/docs/developer_guide.md +22 -24
- package/market_adapter/README.md +0 -2
- package/modules/README.md +2 -1
- package/package.json +22 -14
- package/scripts/README.md +34 -8
- package/scripts/clean-dist.js +10 -2
- package/tests/README.md +4 -3
- package/claw/openclaw.plugin.json +0 -13
- package/dist/market_adapter/merge_lp_data.d.ts +0 -3
- package/dist/market_adapter/merge_lp_data.d.ts.map +0 -1
- package/dist/market_adapter/merge_lp_data.js +0 -125
- package/dist/market_adapter/merge_lp_data.js.map +0 -1
- package/dist/market_adapter/utils/paths.d.ts +0 -3
- package/dist/market_adapter/utils/paths.d.ts.map +0 -1
- package/dist/market_adapter/utils/paths.js +0 -5
- package/dist/market_adapter/utils/paths.js.map +0 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
'use strict';
|
|
1
2
|
|
|
2
3
|
import { getStorage } from '../../modules/storage/index.js';
|
|
3
4
|
const { readJSON } = getStorage();
|
|
4
|
-
|
|
5
|
+
import { normalizeCandle } from '../math_utils.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Shared utilities for bot-fitting scripts.
|
|
@@ -9,14 +10,19 @@ const { readJSON } = getStorage();
|
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
function toCandles(arr: any[]) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
// Canonical accessor transform (market_adapter/candle_utils via math_utils)
|
|
14
|
+
// instead of hand-rolled array indexing.
|
|
15
|
+
return arr
|
|
16
|
+
.map((c: any) => normalizeCandle(c))
|
|
17
|
+
.filter(Boolean)
|
|
18
|
+
.map((c: any) => ({
|
|
19
|
+
timestamp: c.time * 1000,
|
|
20
|
+
open: c.open,
|
|
21
|
+
high: c.high,
|
|
22
|
+
low: c.low,
|
|
23
|
+
close: c.close,
|
|
24
|
+
volume: c.volume,
|
|
25
|
+
}));
|
|
20
26
|
}
|
|
21
27
|
|
|
22
28
|
function parseListOrRange(spec: any, fallback: any) {
|
|
@@ -42,5 +48,5 @@ function fmt(x: number, d = 2) {
|
|
|
42
48
|
return Number(x).toFixed(d);
|
|
43
49
|
}
|
|
44
50
|
|
|
45
|
-
export {
|
|
51
|
+
export { parseListOrRange, loadLpData, fmt }
|
|
46
52
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
'use strict';
|
|
1
2
|
|
|
2
3
|
import fs from 'node:fs';
|
|
3
4
|
import path from 'node:path';
|
|
@@ -6,7 +7,10 @@ import { getStorage } from '../modules/storage/index.js';
|
|
|
6
7
|
const { readJSON } = getStorage();
|
|
7
8
|
import { MARKET_ADAPTER } from '../modules/constants.js';
|
|
8
9
|
import { loadMarketProfiles } from './tradingview/tradingview_uplot_chart_generator.js';
|
|
9
|
-
|
|
10
|
+
import { sanitizeKey } from '../modules/utils/sanitize_key.js';
|
|
11
|
+
// Single source of truth for bot keys (named AND unnamed bots) so analysis
|
|
12
|
+
// tools resolve the same files production writes.
|
|
13
|
+
import { createBotKey } from '../modules/account_orders.js';
|
|
10
14
|
|
|
11
15
|
|
|
12
16
|
const DEFAULT_AMA_KEY = String(MARKET_ADAPTER.DEFAULT_AMA_KEY).toUpperCase();
|
|
@@ -22,16 +26,12 @@ function loadBotSettings(filePath = PATHS.PROFILES.BOTS_JSON) {
|
|
|
22
26
|
}
|
|
23
27
|
}
|
|
24
28
|
|
|
25
|
-
function sanitizeKey(source: any) {
|
|
26
|
-
if (!source) return 'bot';
|
|
27
|
-
return String(source).trim().toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'bot';
|
|
28
|
-
}
|
|
29
|
-
|
|
30
29
|
function computeBotKey(bot: any, index: number) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
// Delegate to the production key generator (modules/account_orders.ts):
|
|
31
|
+
// named bots → sanitized name; unnamed bots → sanitized asset pair + index.
|
|
32
|
+
// The previous local fallback produced `bot-<idx>-<idx>` keys that could
|
|
33
|
+
// never match what the bot runtime actually wrote to disk.
|
|
34
|
+
return createBotKey(bot, index);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
function resolveBotKey(botName: any, filePath = PATHS.PROFILES.BOTS_JSON) {
|
|
@@ -72,7 +72,10 @@ function loadBotMeta(botKey: any, filePath = PATHS.PROFILES.BOTS_JSON) {
|
|
|
72
72
|
|
|
73
73
|
function resolveAmaConfig(botKey: any) {
|
|
74
74
|
const botMeta = loadBotMeta(botKey);
|
|
75
|
-
|
|
75
|
+
// Unknown bot key: fall back to the global erSmoothPeriod default (same
|
|
76
|
+
// resolution path production uses) instead of forcing 0 — a typo'd
|
|
77
|
+
// --bot-key must not silently research with different ER smoothing.
|
|
78
|
+
if (!botMeta) return { ...MARKET_ADAPTER.AMAS.AMA3, erSmoothPeriod: Number(MARKET_ADAPTER.AMA_ER_SMOOTH_FAST_PERIOD) };
|
|
76
79
|
|
|
77
80
|
const rawGridPrice = String(botMeta?.gridPrice || '').trim().toLowerCase();
|
|
78
81
|
const isAmaKeyword = AMA_KEYWORDS.has(rawGridPrice);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
2
3
|
import { createRequire } from 'node:module';
|
|
3
4
|
const require = createRequire(import.meta.url);
|
|
4
5
|
|
|
5
|
-
'use strict';
|
|
6
6
|
|
|
7
7
|
import { getStorage } from '../../modules/storage/index.js';
|
|
8
8
|
const { writeJSON } = getStorage();
|
|
@@ -53,6 +53,7 @@ import {
|
|
|
53
53
|
buildTopFilledAccountsQuery,
|
|
54
54
|
DEFAULT_CONFIG,
|
|
55
55
|
} from './kibana_bot_queries.js';
|
|
56
|
+
import { NODE_MANAGEMENT } from '../../modules/constants.js';
|
|
56
57
|
|
|
57
58
|
// ─── Types ────────────────────────────────────────────────────────────────────
|
|
58
59
|
|
|
@@ -83,7 +84,8 @@ interface CandidateInfo {
|
|
|
83
84
|
|
|
84
85
|
// ─── Configuration ────────────────────────────────────────────────────────────
|
|
85
86
|
|
|
86
|
-
|
|
87
|
+
// Node pool from central node management (failover-capable) instead of a
|
|
88
|
+
// single hardcoded WSS endpoint.
|
|
87
89
|
const KIBANA_CFG = { ...DEFAULT_CONFIG, timeout: 30000 };
|
|
88
90
|
|
|
89
91
|
const ASSET_PRECISION = {
|
|
@@ -269,7 +271,7 @@ function dexScore(creates: number, fills: number, _cancels: number, gridScore: n
|
|
|
269
271
|
|
|
270
272
|
async function resolveNames(ids: string[]): Promise<Record<string, string>> {
|
|
271
273
|
const { createReadOnlyClient } = require('../../modules/bitshares-native');
|
|
272
|
-
const client = createReadOnlyClient({ nodes:
|
|
274
|
+
const client = createReadOnlyClient({ nodes: NODE_MANAGEMENT.DEFAULT_NODES });
|
|
273
275
|
|
|
274
276
|
const map: Record<string, any> = {};
|
|
275
277
|
try {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
'use strict';
|
|
1
2
|
/**
|
|
2
3
|
* KIBANA BOT QUERIES
|
|
3
4
|
*
|
|
@@ -34,9 +35,7 @@
|
|
|
34
35
|
*/
|
|
35
36
|
|
|
36
37
|
|
|
37
|
-
import { toIntervalLabel } from '../../market_adapter/interval_utils.js';
|
|
38
38
|
import { kibanaSearch, DEFAULT_CONFIG as BASE_CONFIG } from '../../market_adapter/core/kibana_client.js';
|
|
39
|
-
'use strict';
|
|
40
39
|
|
|
41
40
|
// ─── Constants ────────────────────────────────────────────────────────────────
|
|
42
41
|
|
|
@@ -49,159 +48,6 @@ const DEFAULT_CONFIG = {
|
|
|
49
48
|
timeout: 25000,
|
|
50
49
|
};
|
|
51
50
|
|
|
52
|
-
// ─── Aggregation query builders (size:0, for counts & timelines) ───────────────
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Time-bucketed count of limit_order_create ops for an account.
|
|
56
|
-
* Optionally filtered to orders selling a specific asset.
|
|
57
|
-
*/
|
|
58
|
-
function buildOrderCreateQuery(accountId: string, lookbackHours: number, intervalSeconds: number = 3600, sellAssetId: string | null = null) {
|
|
59
|
-
const filters = [
|
|
60
|
-
{ term: { operation_type: OP_LIMIT_ORDER_CREATE } },
|
|
61
|
-
{ term: { 'operation_history.op_object.seller.keyword': accountId } },
|
|
62
|
-
{ range: { 'block_data.block_time': { gte: `now-${lookbackHours}h`, lte: 'now' } } },
|
|
63
|
-
];
|
|
64
|
-
if (sellAssetId) {
|
|
65
|
-
filters.push({ term: { 'operation_history.op_object.amount_to_sell.asset_id.keyword': sellAssetId } } as any);
|
|
66
|
-
}
|
|
67
|
-
return {
|
|
68
|
-
size: 0,
|
|
69
|
-
query: { bool: { filter: filters } },
|
|
70
|
-
aggs: {
|
|
71
|
-
by_time: {
|
|
72
|
-
date_histogram: {
|
|
73
|
-
field: 'block_data.block_time',
|
|
74
|
-
fixed_interval: toIntervalLabel(intervalSeconds),
|
|
75
|
-
min_doc_count: 1,
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
total: { value_count: { field: 'operation_type' } },
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Time-bucketed count of fill_order ops for an account.
|
|
85
|
-
* Optionally filtered to fills where account pays a specific asset.
|
|
86
|
-
*/
|
|
87
|
-
function buildFillOrderQuery(accountId: string, lookbackHours: number, intervalSeconds: number = 3600, paysAssetId: string | null = null) {
|
|
88
|
-
const filters = [
|
|
89
|
-
{ term: { operation_type: OP_FILL_ORDER } },
|
|
90
|
-
{ term: { 'operation_history.op_object.account_id.keyword': accountId } },
|
|
91
|
-
{ range: { 'block_data.block_time': { gte: `now-${lookbackHours}h`, lte: 'now' } } },
|
|
92
|
-
];
|
|
93
|
-
if (paysAssetId) {
|
|
94
|
-
filters.push({ term: { 'operation_history.op_object.pays.asset_id.keyword': paysAssetId } } as any);
|
|
95
|
-
}
|
|
96
|
-
return {
|
|
97
|
-
size: 0,
|
|
98
|
-
query: { bool: { filter: filters } },
|
|
99
|
-
aggs: {
|
|
100
|
-
by_time: {
|
|
101
|
-
date_histogram: {
|
|
102
|
-
field: 'block_data.block_time',
|
|
103
|
-
fixed_interval: toIntervalLabel(intervalSeconds),
|
|
104
|
-
min_doc_count: 1,
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
total: { value_count: { field: 'operation_type' } },
|
|
108
|
-
},
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Time-bucketed count of limit_order_cancel ops for an account.
|
|
114
|
-
*/
|
|
115
|
-
function buildOrderCancelQuery(accountId: string, lookbackHours: number, intervalSeconds: number = 3600) {
|
|
116
|
-
return {
|
|
117
|
-
size: 0,
|
|
118
|
-
query: {
|
|
119
|
-
bool: {
|
|
120
|
-
filter: [
|
|
121
|
-
{ term: { operation_type: OP_LIMIT_ORDER_CANCEL } },
|
|
122
|
-
{ term: { 'operation_history.op_object.fee_paying_account.keyword': accountId } },
|
|
123
|
-
{ range: { 'block_data.block_time': { gte: `now-${lookbackHours}h`, lte: 'now' } } },
|
|
124
|
-
],
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
aggs: {
|
|
128
|
-
by_time: {
|
|
129
|
-
date_histogram: {
|
|
130
|
-
field: 'block_data.block_time',
|
|
131
|
-
fixed_interval: toIntervalLabel(intervalSeconds),
|
|
132
|
-
min_doc_count: 1,
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
total: { value_count: { field: 'operation_type' } },
|
|
136
|
-
},
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Daily activity breakdown by operation type for an account.
|
|
142
|
-
* Merges creates (by seller), fills (by account_id), cancels (by fee_paying_account)
|
|
143
|
-
* into one aggregation using a filter per op type.
|
|
144
|
-
*/
|
|
145
|
-
function buildDailyActivityQuery(accountId: string, lookbackHours: number) {
|
|
146
|
-
return {
|
|
147
|
-
size: 0,
|
|
148
|
-
query: {
|
|
149
|
-
bool: {
|
|
150
|
-
filter: [
|
|
151
|
-
{ range: { 'block_data.block_time': { gte: `now-${lookbackHours}h`, lte: 'now' } } },
|
|
152
|
-
],
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
aggs: {
|
|
156
|
-
creates: {
|
|
157
|
-
filter: {
|
|
158
|
-
bool: {
|
|
159
|
-
filter: [
|
|
160
|
-
{ term: { operation_type: OP_LIMIT_ORDER_CREATE } },
|
|
161
|
-
{ term: { 'operation_history.op_object.seller.keyword': accountId } },
|
|
162
|
-
],
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
aggs: {
|
|
166
|
-
by_day: {
|
|
167
|
-
date_histogram: { field: 'block_data.block_time', fixed_interval: '1d', min_doc_count: 1 },
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
},
|
|
171
|
-
fills: {
|
|
172
|
-
filter: {
|
|
173
|
-
bool: {
|
|
174
|
-
filter: [
|
|
175
|
-
{ term: { operation_type: OP_FILL_ORDER } },
|
|
176
|
-
{ term: { 'operation_history.op_object.account_id.keyword': accountId } },
|
|
177
|
-
],
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
aggs: {
|
|
181
|
-
by_day: {
|
|
182
|
-
date_histogram: { field: 'block_data.block_time', fixed_interval: '1d', min_doc_count: 1 },
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
cancels: {
|
|
187
|
-
filter: {
|
|
188
|
-
bool: {
|
|
189
|
-
filter: [
|
|
190
|
-
{ term: { operation_type: OP_LIMIT_ORDER_CANCEL } },
|
|
191
|
-
{ term: { 'operation_history.op_object.fee_paying_account.keyword': accountId } },
|
|
192
|
-
],
|
|
193
|
-
},
|
|
194
|
-
},
|
|
195
|
-
aggs: {
|
|
196
|
-
by_day: {
|
|
197
|
-
date_histogram: { field: 'block_data.block_time', fixed_interval: '1d', min_doc_count: 1 },
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
|
|
205
51
|
// ─── Raw document query builders (size>0, for price/grid analysis) ────────────
|
|
206
52
|
|
|
207
53
|
/**
|
|
@@ -236,107 +82,6 @@ function buildOrderPriceQuery(accountId: string, lookbackHours: number, sellAsse
|
|
|
236
82
|
};
|
|
237
83
|
}
|
|
238
84
|
|
|
239
|
-
/**
|
|
240
|
-
* Fetch raw fill_order documents for fill-price analysis.
|
|
241
|
-
*
|
|
242
|
-
* @param {string} accountId
|
|
243
|
-
* @param {number} lookbackHours
|
|
244
|
-
* @param {string} [paysAssetId]
|
|
245
|
-
* @param {number} [maxResults]
|
|
246
|
-
* @returns {Object} Elasticsearch query object
|
|
247
|
-
*/
|
|
248
|
-
function buildFillPriceQuery(accountId: string, lookbackHours: number, paysAssetId: string | null = null, maxResults: number = 500) {
|
|
249
|
-
const filters = [
|
|
250
|
-
{ term: { operation_type: OP_FILL_ORDER } },
|
|
251
|
-
{ term: { 'operation_history.op_object.account_id.keyword': accountId } },
|
|
252
|
-
{ range: { 'block_data.block_time': { gte: `now-${lookbackHours}h`, lte: 'now' } } },
|
|
253
|
-
];
|
|
254
|
-
if (paysAssetId) {
|
|
255
|
-
filters.push({ term: { 'operation_history.op_object.pays.asset_id.keyword': paysAssetId } } as any);
|
|
256
|
-
}
|
|
257
|
-
return {
|
|
258
|
-
size: maxResults,
|
|
259
|
-
_source: [
|
|
260
|
-
'block_data.block_time',
|
|
261
|
-
'operation_history.op_object.pays',
|
|
262
|
-
'operation_history.op_object.receives',
|
|
263
|
-
'operation_history.op_object.order_id',
|
|
264
|
-
],
|
|
265
|
-
query: { bool: { filter: filters } },
|
|
266
|
-
sort: [{ 'block_data.block_time': { order: 'desc' } }],
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Discover which asset pairs an account trades by aggregating the sell asset IDs.
|
|
272
|
-
* Returns top asset IDs by order count.
|
|
273
|
-
*/
|
|
274
|
-
function buildAssetDiscoveryQuery(accountId: string, lookbackHours: number) {
|
|
275
|
-
return {
|
|
276
|
-
size: 0,
|
|
277
|
-
query: {
|
|
278
|
-
bool: {
|
|
279
|
-
filter: [
|
|
280
|
-
{ term: { operation_type: OP_LIMIT_ORDER_CREATE } },
|
|
281
|
-
{ term: { 'operation_history.op_object.seller.keyword': accountId } },
|
|
282
|
-
{ range: { 'block_data.block_time': { gte: `now-${lookbackHours}h`, lte: 'now' } } },
|
|
283
|
-
],
|
|
284
|
-
},
|
|
285
|
-
},
|
|
286
|
-
aggs: {
|
|
287
|
-
sell_assets: {
|
|
288
|
-
terms: {
|
|
289
|
-
field: 'operation_history.op_object.amount_to_sell.asset_id.keyword',
|
|
290
|
-
size: 10,
|
|
291
|
-
},
|
|
292
|
-
},
|
|
293
|
-
recv_assets: {
|
|
294
|
-
terms: {
|
|
295
|
-
field: 'operation_history.op_object.min_to_receive.asset_id.keyword',
|
|
296
|
-
size: 10,
|
|
297
|
-
},
|
|
298
|
-
},
|
|
299
|
-
},
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
// ─── Fetch helpers ────────────────────────────────────────────────────────────
|
|
304
|
-
|
|
305
|
-
async function fetchOrderCreate(accountId: string, lookbackHours: number, config: any = {}, sellAssetId: string | null = null, intervalSeconds: number = 3600) {
|
|
306
|
-
const cfg = { ...DEFAULT_CONFIG, ...config };
|
|
307
|
-
return kibanaSearch(cfg, buildOrderCreateQuery(accountId, lookbackHours, intervalSeconds, sellAssetId));
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
async function fetchFillOrder(accountId: string, lookbackHours: number, config: any = {}, paysAssetId: string | null = null, intervalSeconds: number = 3600) {
|
|
311
|
-
const cfg = { ...DEFAULT_CONFIG, ...config };
|
|
312
|
-
return kibanaSearch(cfg, buildFillOrderQuery(accountId, lookbackHours, intervalSeconds, paysAssetId));
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
async function fetchOrderCancel(accountId: string, lookbackHours: number, config: any = {}, intervalSeconds: number = 3600) {
|
|
316
|
-
const cfg = { ...DEFAULT_CONFIG, ...config };
|
|
317
|
-
return kibanaSearch(cfg, buildOrderCancelQuery(accountId, lookbackHours, intervalSeconds));
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
async function fetchOrderPrices(accountId: string, lookbackHours: number, config: any = {}, sellAssetId: string | null = null, maxResults: number = 1000) {
|
|
321
|
-
const cfg = { ...DEFAULT_CONFIG, ...config };
|
|
322
|
-
return kibanaSearch(cfg, buildOrderPriceQuery(accountId, lookbackHours, sellAssetId, maxResults));
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
async function fetchFillPrices(accountId: string, lookbackHours: number, config: any = {}, paysAssetId: string | null = null, maxResults: number = 500) {
|
|
326
|
-
const cfg = { ...DEFAULT_CONFIG, ...config };
|
|
327
|
-
return kibanaSearch(cfg, buildFillPriceQuery(accountId, lookbackHours, paysAssetId, maxResults));
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
async function fetchDailyActivity(accountId: string, lookbackHours: number, config: any = {}) {
|
|
331
|
-
const cfg = { ...DEFAULT_CONFIG, ...config };
|
|
332
|
-
return kibanaSearch(cfg, buildDailyActivityQuery(accountId, lookbackHours));
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
async function fetchAssetDiscovery(accountId: string, lookbackHours: number, config: any = {}) {
|
|
336
|
-
const cfg = { ...DEFAULT_CONFIG, ...config };
|
|
337
|
-
return kibanaSearch(cfg, buildAssetDiscoveryQuery(accountId, lookbackHours));
|
|
338
|
-
}
|
|
339
|
-
|
|
340
85
|
// ─── Discovery query builders ─────────────────────────────────────────────────
|
|
341
86
|
|
|
342
87
|
/**
|
|
@@ -423,5 +168,5 @@ function buildTopFilledAccountsQuery(lookbackHours: number, topN: number = 100,
|
|
|
423
168
|
|
|
424
169
|
// ─── Exports ──────────────────────────────────────────────────────────────────
|
|
425
170
|
|
|
426
|
-
export {
|
|
171
|
+
export { DEFAULT_CONFIG, kibanaSearch, buildOrderPriceQuery, buildTopSellerAccountsQuery, buildTopCancellerAccountsQuery, buildTopFilledAccountsQuery }
|
|
427
172
|
|
package/analysis/chart_css.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
'use strict';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -21,8 +20,8 @@ function panelsCSS(headerHeight = 45): string {
|
|
|
21
20
|
return `#panels { display: flex; flex-direction: column; height: calc(100vh - ${headerHeight}px); width: 100vw; }`;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
function uplotBgCSS(): string {
|
|
25
|
-
return `.uplot { background:
|
|
23
|
+
function uplotBgCSS(bgColor = '#0b0e14'): string {
|
|
24
|
+
return `.uplot { background: ${bgColor}; }`;
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
function dotCSS(): string {
|
|
@@ -57,4 +56,7 @@ function sharedChartCSS(): string {
|
|
|
57
56
|
].join('\n ');
|
|
58
57
|
}
|
|
59
58
|
|
|
60
|
-
|
|
59
|
+
// Only the composed sheet and the single fragments with external consumers are
|
|
60
|
+
// exported; page-specific generators interpolate these inside their own
|
|
61
|
+
// <style> blocks while keeping their layout rules inline.
|
|
62
|
+
export { sharedChartCSS, uplotBgCSS, cursorCSS }
|
package/analysis/chart_ui.ts
CHANGED
package/analysis/chart_utils.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
1
2
|
|
|
2
3
|
import fs from 'node:fs';
|
|
3
4
|
import path from 'node:path';
|
|
4
5
|
import { getStorage } from '../modules/storage/index.js';
|
|
5
6
|
import { PATHS } from '../modules/paths.js';
|
|
6
7
|
const { ensureDir } = getStorage();
|
|
7
|
-
'use strict';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Chart utilities for analysis HTML generators.
|
|
@@ -58,7 +58,16 @@ function writeChartFile(filePath: any, html: any) {
|
|
|
58
58
|
const chartDir = path.dirname(filePath);
|
|
59
59
|
if (!fs.existsSync(chartDir)) ensureDir(chartDir);
|
|
60
60
|
ensureSiblingUplotAssets(chartDir);
|
|
61
|
-
|
|
61
|
+
// Atomic write (tmp + rename, matching the production storage adapter
|
|
62
|
+
// pattern) so a crash mid-write can never leave a truncated chart file.
|
|
63
|
+
const tmpPath = `${filePath}.${process.pid}.${Date.now()}.${Math.random().toString(36).slice(2, 10)}.tmp`;
|
|
64
|
+
try {
|
|
65
|
+
fs.writeFileSync(tmpPath, html, 'utf8');
|
|
66
|
+
fs.renameSync(tmpPath, filePath);
|
|
67
|
+
} catch (err) {
|
|
68
|
+
try { fs.unlinkSync(tmpPath); } catch (_) { /* best-effort cleanup */ }
|
|
69
|
+
throw err;
|
|
70
|
+
}
|
|
62
71
|
}
|
|
63
72
|
|
|
64
73
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
2
3
|
|
|
3
4
|
import fs from 'node:fs';
|
|
4
5
|
import path from 'node:path';
|
|
@@ -9,7 +10,6 @@ const { ensureDir, readJSON } = getStorage();
|
|
|
9
10
|
import { fixedTo } from '../modules/order/utils/math.js';
|
|
10
11
|
import { bindHoverStateFn, zoomResetScript } from './chart_ui.js';
|
|
11
12
|
import { PATHS } from '../modules/paths.js';
|
|
12
|
-
'use strict';
|
|
13
13
|
function parseArgs(argv = process.argv.slice(2)) {
|
|
14
14
|
const cfg: { inputFile: string | null; outputFile: string; title: string; quiet: boolean } = {
|
|
15
15
|
inputFile: null,
|
|
@@ -39,7 +39,7 @@ function showHelp() {
|
|
|
39
39
|
console.log(`
|
|
40
40
|
Derivative Chart Generator (uPlot)
|
|
41
41
|
Usage:
|
|
42
|
-
|
|
42
|
+
node dist/analysis/derivative_chart_generator.js --input <file.json> [options]
|
|
43
43
|
Options:
|
|
44
44
|
--output FILE Output HTML (default: <analysis charts dir>/derivative_chart.html)
|
|
45
45
|
--title TEXT Chart title
|
package/analysis/math_utils.ts
CHANGED
|
@@ -5,19 +5,15 @@ import { getStorage } from '../modules/storage/index.js';
|
|
|
5
5
|
const { readJSON } = getStorage();
|
|
6
6
|
import {
|
|
7
7
|
getCandleClose,
|
|
8
|
-
getCandleHigh,
|
|
9
|
-
getCandleLow,
|
|
10
8
|
getCandleTimestamp,
|
|
11
9
|
normalizeCandle,
|
|
12
10
|
} from '../market_adapter/candle_utils.js';
|
|
13
|
-
import { computeATRSeries } from '../market_adapter/core/strategies/atr/calculator.js';
|
|
14
11
|
|
|
15
12
|
|
|
16
13
|
/**
|
|
17
14
|
* Math utilities for analysis scripts.
|
|
18
15
|
*
|
|
19
|
-
* Candle accessors
|
|
20
|
-
* market_adapter (candle_utils.ts / strategies/atr/calculator.ts) and
|
|
16
|
+
* Candle accessors are centralized in market_adapter (candle_utils.ts) and
|
|
21
17
|
* re-exported here so analysis tooling shares one logic path with the
|
|
22
18
|
* live adapter and the browser-embedded chart scripts.
|
|
23
19
|
*/
|
|
@@ -50,10 +46,7 @@ function loadCandleFile(filePath: any) {
|
|
|
50
46
|
export {
|
|
51
47
|
range,
|
|
52
48
|
calcStdDev,
|
|
53
|
-
computeATRSeries,
|
|
54
49
|
getCandleClose,
|
|
55
|
-
getCandleHigh,
|
|
56
|
-
getCandleLow,
|
|
57
50
|
getCandleTimestamp,
|
|
58
51
|
normalizeCandle,
|
|
59
52
|
loadCandleFile,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
'use strict';
|
|
1
2
|
|
|
2
3
|
import fs from 'node:fs';
|
|
3
4
|
import path from 'node:path';
|
|
@@ -7,7 +8,6 @@ import { PATHS } from '../modules/paths.js';
|
|
|
7
8
|
import { getStorage } from '../modules/storage/index.js';
|
|
8
9
|
const { readJSON } = getStorage();
|
|
9
10
|
import { getErrorMessage } from '../modules/utils/errors.js';
|
|
10
|
-
'use strict';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Price Source Abstraction
|
|
@@ -70,17 +70,23 @@ interface MarketAdapterConfig {
|
|
|
70
70
|
|
|
71
71
|
class MarketAdapterSource {
|
|
72
72
|
stateDir: string;
|
|
73
|
+
centersFile: string;
|
|
73
74
|
botKey: string;
|
|
74
75
|
name: string;
|
|
75
76
|
|
|
76
77
|
constructor(config: MarketAdapterConfig) {
|
|
77
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;
|
|
78
84
|
this.botKey = config.botKey;
|
|
79
85
|
this.name = `market_adapter:${this.botKey}`;
|
|
80
86
|
}
|
|
81
87
|
|
|
82
88
|
async fetchCandles(): Promise<any[]> {
|
|
83
|
-
const centersFile =
|
|
89
|
+
const centersFile = this.centersFile;
|
|
84
90
|
if (!fs.existsSync(centersFile)) {
|
|
85
91
|
throw new Error(`[MarketAdapterSource] Centers file not found: ${centersFile}`);
|
|
86
92
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
'use strict';
|
|
1
2
|
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
import { PATHS } from '../modules/paths.js';
|
|
@@ -5,7 +6,6 @@ import { MARKET_ADAPTER } from '../modules/constants.js';
|
|
|
5
6
|
import { createSource } from './price_sources.js';
|
|
6
7
|
import { resolveCandleFile, resolveAmaConfig, resolveAmaKey, loadBotSettings, computeBotKey } from './bot_key_utils.js';
|
|
7
8
|
import { findLatestLpData } from '../market_adapter/utils/data_discovery.js';
|
|
8
|
-
'use strict';
|
|
9
9
|
|
|
10
10
|
const INTERVAL_LABEL = MARKET_ADAPTER.RUNTIME_DEFAULTS.intervalLabel;
|
|
11
11
|
|