dexbot 1.4.21 → 1.4.23
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 +52 -0
- package/README.md +8 -5
- package/analysis/ama_fitting/analyze_ama_price_changes.ts +7 -3
- package/analysis/ama_fitting/analyze_lambda_vs_slow.ts +6 -6
- package/analysis/ama_fitting/calibrate_convergence_er.ts +7 -5
- 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 +26 -17
- 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 +15 -9
- package/analysis/bot_key_utils.ts +13 -6
- package/analysis/bot_usage/discover_bot_accounts.ts +5 -3
- package/analysis/bot_usage/kibana_bot_queries.ts +1 -1
- 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/price_sources.ts +8 -2
- package/analysis/resolve_source.ts +1 -1
- package/analysis/trade_profitability.ts +61 -28
- package/analysis/tradingview/README.md +24 -4
- package/analysis/tradingview/analyze_tradingview.ts +1 -1
- package/analysis/tradingview/tradingview_uplot_chart_generator.ts +356 -86
- 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/index.ts +1 -1
- package/claw/modules/claw_bridge.ts +3 -3
- package/claw/modules/claw_catalog.ts +1 -1
- package/claw/modules/claw_launcher.ts +1 -1
- package/claw/modules/claw_skill_md.ts +7 -10
- package/claw/modules/credit_runtime_adapter.ts +1 -1
- package/claw/modules/decision_loop.ts +5 -9
- package/claw/modules/dexbot_bridge.ts +7 -7
- package/claw/modules/feed_price_source.ts +1 -1
- 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/position_discovery.ts +1 -1
- package/claw/modules/position_health.ts +1 -1
- package/claw/package.json +3 -3
- package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
- package/claw/runtimes/openclaw-plugin/package.json +1 -1
- 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 +45 -21
- 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 +6 -6
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js.map +1 -1
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js +7 -5
- 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 +25 -17
- 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 +1 -1
- package/dist/analysis/bot_fitting/shared_utils.d.ts.map +1 -1
- package/dist/analysis/bot_fitting/shared_utils.js +14 -8
- package/dist/analysis/bot_fitting/shared_utils.js.map +1 -1
- package/dist/analysis/bot_key_utils.d.ts.map +1 -1
- package/dist/analysis/bot_key_utils.js +13 -6
- 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.map +1 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.js +1 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.js.map +1 -1
- package/dist/analysis/chart_css.d.ts +3 -1
- 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/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 +356 -86
- 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 +1 -1
- package/dist/bot.js.map +1 -1
- package/dist/credential-daemon.d.ts +1 -1
- package/dist/credential-daemon.js +1 -1
- package/dist/dexbot.d.ts.map +1 -1
- package/dist/dexbot.js +7 -8
- package/dist/dexbot.js.map +1 -1
- package/dist/market_adapter/ama_signal_runner.js +3 -1
- 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 +0 -14
- package/dist/market_adapter/core/kibana_client.d.ts.map +1 -1
- package/dist/market_adapter/core/kibana_client.js +39 -6
- 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 +21 -11
- package/dist/market_adapter/core/market_adapter_service.d.ts.map +1 -1
- package/dist/market_adapter/core/market_adapter_service.js +95 -37
- 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.map +1 -1
- package/dist/market_adapter/core/strategies/regime_gate.js +26 -20
- 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 +69 -55
- 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 +67 -14
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -1
- package/dist/market_adapter/inputs/kibana_source.d.ts +4 -28
- package/dist/market_adapter/inputs/kibana_source.d.ts.map +1 -1
- package/dist/market_adapter/inputs/kibana_source.js +5 -2
- 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.js +1 -1
- 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 +9 -8
- 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.map +1 -1
- package/dist/modules/account_bots.js +47 -12
- package/dist/modules/account_bots.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.js +10 -10
- 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 +11 -18
- 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_orders.d.ts.map +1 -1
- package/dist/modules/chain_orders.js +15 -17
- package/dist/modules/chain_orders.js.map +1 -1
- package/dist/modules/config.js +1 -1
- package/dist/modules/config.js.map +1 -1
- package/dist/modules/constants.d.ts +21 -20
- package/dist/modules/constants.d.ts.map +1 -1
- package/dist/modules/constants.js +60 -63
- 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 +17 -2
- 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 +36 -197
- 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 +9 -6
- 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 +19 -4
- 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 +9 -19
- 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 +2 -14
- package/dist/modules/launcher/foreign_cred_daemon.js.map +1 -1
- package/dist/modules/launcher/market_adapter_runtime.d.ts +1 -1
- package/dist/modules/launcher/market_adapter_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/market_adapter_runtime.js +3 -14
- 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 +3 -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.js +1 -1
- 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 +1 -1
- 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 -0
- package/dist/modules/order/format.d.ts.map +1 -1
- package/dist/modules/order/format.js +0 -6
- 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 +40 -27
- 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 +22 -13
- package/dist/modules/order/logger.js.map +1 -1
- package/dist/modules/order/logger_state.d.ts +4 -9
- package/dist/modules/order/logger_state.d.ts.map +1 -1
- package/dist/modules/order/logger_state.js +5 -14
- 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.map +1 -1
- package/dist/modules/order/processed_fill_store.js +9 -3
- 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.js +7 -7
- package/dist/modules/order/sync_engine.js.map +1 -1
- package/dist/modules/order/utils/math.d.ts +29 -3
- package/dist/modules/order/utils/math.d.ts.map +1 -1
- package/dist/modules/order/utils/math.js +54 -10
- 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 +14 -2
- 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 +1 -1
- 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 +14 -3
- 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.map +1 -1
- package/dist/modules/storage/browser_adapter.js +5 -3
- 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/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 +2 -3
- 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.map +1 -1
- package/dist/scripts/analyze-orders.js +61 -18
- 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 +3 -5
- package/dist/scripts/runner.js.map +1 -1
- package/dist/scripts/sync-version.d.ts +2 -2
- package/dist/scripts/sync-version.js +7 -4
- package/dist/scripts/sync-version.js.map +1 -1
- package/dist/scripts/update.d.ts +1 -1
- package/dist/scripts/update.js +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 +15 -10
- package/docs/COPY_ON_WRITE_MASTER_PLAN.md +9 -9
- package/docs/DEXBOT_COMPARISON.md +19 -19
- package/docs/EVOLUTION.md +18 -44
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
- package/docs/GRID_RECALCULATION.md +1 -1
- package/docs/README.md +3 -3
- package/docs/architecture.md +5 -5
- package/docs/developer_guide.md +6 -6
- package/market_adapter/README.md +13 -8
- package/package.json +22 -14
- package/scripts/README.md +33 -7
- package/scripts/clean-dist.js +10 -2
- package/tests/README.md +4 -3
|
@@ -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) {
|
|
@@ -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,9 @@ 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';
|
|
10
|
-
|
|
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';
|
|
11
14
|
|
|
12
15
|
|
|
13
16
|
const DEFAULT_AMA_KEY = String(MARKET_ADAPTER.DEFAULT_AMA_KEY).toUpperCase();
|
|
@@ -24,10 +27,11 @@ function loadBotSettings(filePath = PATHS.PROFILES.BOTS_JSON) {
|
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
function computeBotKey(bot: any, index: number) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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);
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
function resolveBotKey(botName: any, filePath = PATHS.PROFILES.BOTS_JSON) {
|
|
@@ -68,7 +72,10 @@ function loadBotMeta(botKey: any, filePath = PATHS.PROFILES.BOTS_JSON) {
|
|
|
68
72
|
|
|
69
73
|
function resolveAmaConfig(botKey: any) {
|
|
70
74
|
const botMeta = loadBotMeta(botKey);
|
|
71
|
-
|
|
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) };
|
|
72
79
|
|
|
73
80
|
const rawGridPrice = String(botMeta?.gridPrice || '').trim().toLowerCase();
|
|
74
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
|
*
|
|
@@ -35,7 +36,6 @@
|
|
|
35
36
|
|
|
36
37
|
|
|
37
38
|
import { kibanaSearch, DEFAULT_CONFIG as BASE_CONFIG } from '../../market_adapter/core/kibana_client.js';
|
|
38
|
-
'use strict';
|
|
39
39
|
|
|
40
40
|
// ─── Constants ────────────────────────────────────────────────────────────────
|
|
41
41
|
|
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
|
|
@@ -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
|
|
|
@@ -16,15 +16,15 @@ const { kibanaSearch, DEFAULT_CONFIG: BASE_CONFIG } = KC;
|
|
|
16
16
|
* FIFO or sequential (LIFO) inventory tracking per asset pair.
|
|
17
17
|
*
|
|
18
18
|
* Usage:
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
19
|
+
* node dist/analysis/trade_profitability.js 1.2.3 --start 2025-01-01 --end 2025-06-01
|
|
20
|
+
* node dist/analysis/trade_profitability.js 1.2.3 --hours 720
|
|
21
|
+
* node dist/analysis/trade_profitability.js 1.2.3 --start 2025-01-01T00:00:00Z --end 2025-06-01T00:00:00Z
|
|
22
|
+
* node dist/analysis/trade_profitability.js 1.2.3 --hours 168 --asset 1.3.113
|
|
23
|
+
* node dist/analysis/trade_profitability.js 1.2.3 --hours 168 --csv trades.csv
|
|
24
|
+
* node dist/analysis/trade_profitability.js 1.2.3 --hours 168 --json results.json
|
|
25
|
+
* node dist/analysis/trade_profitability.js "account-name" --lookup
|
|
26
|
+
* node dist/analysis/trade_profitability.js 1.2.3 --hours 168 --trades
|
|
27
|
+
* node dist/analysis/trade_profitability.js 1.2.3 --hours 168 --match-mode fifo
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
30
|
// ─── Constants ────────────────────────────────────────────────────────────────
|
|
@@ -188,7 +188,7 @@ interface PairAnalysis {
|
|
|
188
188
|
|
|
189
189
|
function printHelp() {
|
|
190
190
|
console.log(`\
|
|
191
|
-
Usage:
|
|
191
|
+
Usage: node dist/analysis/trade_profitability.js <accountId> [options]
|
|
192
192
|
|
|
193
193
|
Analyzes filled orders for a BitShares account, computing realized PnL
|
|
194
194
|
via FIFO or sequential (LIFO) inventory tracking.
|
|
@@ -212,11 +212,11 @@ Options:
|
|
|
212
212
|
--help, -h Show this help
|
|
213
213
|
|
|
214
214
|
Examples:
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
215
|
+
node dist/analysis/trade_profitability.js 1.2.123456 --hours 720
|
|
216
|
+
node dist/analysis/trade_profitability.js 1.2.123456 --start 2025-01-01 --end 2025-06-01
|
|
217
|
+
node dist/analysis/trade_profitability.js "my-bot-account" --lookup --hours 168
|
|
218
|
+
node dist/analysis/trade_profitability.js 1.2.123456 --hours 720 --asset 1.3.113 --csv trades.csv
|
|
219
|
+
node dist/analysis/trade_profitability.js 1.2.123456 --hours 720 --match-mode sequential`);
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
function parseArgs() {
|
|
@@ -239,7 +239,7 @@ function parseArgs() {
|
|
|
239
239
|
matchMode: 'sequential',
|
|
240
240
|
showPnlDetail: false,
|
|
241
241
|
verbose: false,
|
|
242
|
-
feePerOrder:
|
|
242
|
+
feePerOrder: null as number | null,
|
|
243
243
|
};
|
|
244
244
|
|
|
245
245
|
for (let i = 1; i < args.length; i++) {
|
|
@@ -423,6 +423,16 @@ async function fetchAllFills(config: any, accountId: string, gte: string, lte: s
|
|
|
423
423
|
|
|
424
424
|
// ─── Fill Classification ─────────────────────────────────────────────────────
|
|
425
425
|
|
|
426
|
+
/**
|
|
427
|
+
* A fill needs strictly positive, finite amounts on both legs. A zero base
|
|
428
|
+
* amount would produce an infinite price (quoteAmount / 0) that poisons
|
|
429
|
+
* downstream inventory lots and PnL aggregates.
|
|
430
|
+
*/
|
|
431
|
+
function isValidFillAmounts(baseAmount: number, quoteAmount: number): boolean {
|
|
432
|
+
return Number.isFinite(baseAmount) && Number.isFinite(quoteAmount)
|
|
433
|
+
&& baseAmount > 0 && quoteAmount > 0;
|
|
434
|
+
}
|
|
435
|
+
|
|
426
436
|
function classifyFills(fills: FillRecord[], filterAsset: string | null): { trades: TradeFill[]; pairs: Set<string> } {
|
|
427
437
|
const trades: TradeFill[] = [];
|
|
428
438
|
const pairs = new Set<string>();
|
|
@@ -450,7 +460,7 @@ function classifyFills(fills: FillRecord[], filterAsset: string | null): { trade
|
|
|
450
460
|
quoteAsset = BTS_ID;
|
|
451
461
|
baseAmount = toReal(f.receives.amount, rAsset);
|
|
452
462
|
quoteAmount = toReal(f.pays.amount, BTS_ID);
|
|
453
|
-
if (
|
|
463
|
+
if (!isValidFillAmounts(baseAmount, quoteAmount)) { skipped++; continue; }
|
|
454
464
|
price = quoteAmount / baseAmount;
|
|
455
465
|
marketFeeReal = feeReal;
|
|
456
466
|
marketFeeAsset = f.fee.asset_id;
|
|
@@ -460,7 +470,7 @@ function classifyFills(fills: FillRecord[], filterAsset: string | null): { trade
|
|
|
460
470
|
quoteAsset = BTS_ID;
|
|
461
471
|
baseAmount = toReal(f.pays.amount, pAsset);
|
|
462
472
|
quoteAmount = toReal(f.receives.amount, BTS_ID);
|
|
463
|
-
if (
|
|
473
|
+
if (!isValidFillAmounts(baseAmount, quoteAmount)) { skipped++; continue; }
|
|
464
474
|
price = quoteAmount / baseAmount;
|
|
465
475
|
marketFeeReal = feeReal;
|
|
466
476
|
marketFeeAsset = f.fee.asset_id;
|
|
@@ -476,7 +486,7 @@ function classifyFills(fills: FillRecord[], filterAsset: string | null): { trade
|
|
|
476
486
|
quoteAsset = isSell ? rAsset : pAsset;
|
|
477
487
|
baseAmount = toReal(isSell ? f.pays.amount : f.receives.amount, baseAsset);
|
|
478
488
|
quoteAmount = toReal(isSell ? f.receives.amount : f.pays.amount, quoteAsset);
|
|
479
|
-
if (
|
|
489
|
+
if (!isValidFillAmounts(baseAmount, quoteAmount)) { skipped++; continue; }
|
|
480
490
|
price = quoteAmount / baseAmount;
|
|
481
491
|
marketFeeReal = feeReal;
|
|
482
492
|
marketFeeAsset = f.fee.asset_id;
|
|
@@ -1295,6 +1305,26 @@ function exportJson(accountId: string, start: string, end: string, pairs: PairAn
|
|
|
1295
1305
|
|
|
1296
1306
|
// ─── Main ────────────────────────────────────────────────────────────────────
|
|
1297
1307
|
|
|
1308
|
+
/**
|
|
1309
|
+
* Normalize a user-supplied time bound into an ES-compatible ISO string.
|
|
1310
|
+
*
|
|
1311
|
+
* Parsing goes through `new Date()` so offset-bearing ISO strings
|
|
1312
|
+
* (e.g. 2026-07-07T12:00:00+02:00) are honored instead of being corrupted by a
|
|
1313
|
+
* blind 'Z' append (+02:00Z). A date-only --end expands to the end of that UTC
|
|
1314
|
+
* day (T23:59:59.999Z) — treating it as midnight silently dropped the final day.
|
|
1315
|
+
*/
|
|
1316
|
+
function normalizeTimeBound(raw: string, isEnd: boolean): string {
|
|
1317
|
+
const parsed = new Date(raw);
|
|
1318
|
+
if (isNaN(parsed.getTime())) {
|
|
1319
|
+
throw new Error(`Invalid ${isEnd ? '--end' : '--start'} time: ${raw}`);
|
|
1320
|
+
}
|
|
1321
|
+
let ms = parsed.getTime();
|
|
1322
|
+
if (isEnd && /^\d{4}-\d{2}-\d{2}$/.test(raw.trim())) {
|
|
1323
|
+
ms += 24 * 3600 * 1000 - 1;
|
|
1324
|
+
}
|
|
1325
|
+
return new Date(ms).toISOString();
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1298
1328
|
async function run() {
|
|
1299
1329
|
const opts = parseArgs();
|
|
1300
1330
|
let accountId = opts.accountId;
|
|
@@ -1313,10 +1343,10 @@ async function run() {
|
|
|
1313
1343
|
let gte: string, lte: string;
|
|
1314
1344
|
|
|
1315
1345
|
if (opts.start && opts.end) {
|
|
1316
|
-
gte = opts.start;
|
|
1317
|
-
lte = opts.end;
|
|
1346
|
+
gte = normalizeTimeBound(opts.start, false);
|
|
1347
|
+
lte = normalizeTimeBound(opts.end, true);
|
|
1318
1348
|
} else if (opts.start) {
|
|
1319
|
-
gte = opts.start;
|
|
1349
|
+
gte = normalizeTimeBound(opts.start, false);
|
|
1320
1350
|
lte = now.toISOString();
|
|
1321
1351
|
} else {
|
|
1322
1352
|
const hours = opts.hours || 168;
|
|
@@ -1325,10 +1355,6 @@ async function run() {
|
|
|
1325
1355
|
lte = now.toISOString();
|
|
1326
1356
|
}
|
|
1327
1357
|
|
|
1328
|
-
// Ensure times end with Z for ES
|
|
1329
|
-
if (!gte.endsWith('Z')) gte += gte.includes('T') ? 'Z' : 'T00:00:00Z';
|
|
1330
|
-
if (!lte.endsWith('Z')) lte += lte.includes('T') ? 'Z' : 'T00:00:00Z';
|
|
1331
|
-
|
|
1332
1358
|
const KIBANA_CFG = { timeout: 60000 };
|
|
1333
1359
|
|
|
1334
1360
|
const fills = await fetchAllFills(KIBANA_CFG, accountId, gte, lte);
|
|
@@ -1358,8 +1384,15 @@ async function run() {
|
|
|
1358
1384
|
}
|
|
1359
1385
|
console.log('');
|
|
1360
1386
|
|
|
1361
|
-
// Override blockchain fee from CLI if provided
|
|
1362
|
-
|
|
1387
|
+
// Override blockchain fee from CLI if provided. Explicit --fee-per-order 0
|
|
1388
|
+
// is valid (free-fee account) and must not be dropped by a falsy check.
|
|
1389
|
+
if (opts.feePerOrder != null) {
|
|
1390
|
+
if (!Number.isFinite(opts.feePerOrder) || opts.feePerOrder < 0) {
|
|
1391
|
+
console.error(`Invalid --fee-per-order: ${opts.feePerOrder}`);
|
|
1392
|
+
process.exit(1);
|
|
1393
|
+
}
|
|
1394
|
+
BLOCKCHAIN_FEE_PER_FILL = opts.feePerOrder;
|
|
1395
|
+
}
|
|
1363
1396
|
|
|
1364
1397
|
// Analyze each pair
|
|
1365
1398
|
const pairMap = new Map<string, TradeFill[]>();
|
|
@@ -74,7 +74,7 @@ node dist/analysis/tradingview/analyze_tradingview.js \
|
|
|
74
74
|
1. Reads `profiles/bots.json` to find the bot's `assetA`, `assetB`, and `ama` settings.
|
|
75
75
|
2. Resolves the candle file at `market_adapter/data/market_adapter_<bot-key>_1h.json`.
|
|
76
76
|
3. Looks up the matching market profile in `profiles/market_profiles.json` for AMA defaults.
|
|
77
|
-
4. AMA settings priority: bot-specific `ama` object > market profile > constants (AMA3, slowPeriod
|
|
77
|
+
4. AMA settings priority: bot-specific `ama` object > market profile > constants (AMA3, slowPeriod 83.6).
|
|
78
78
|
|
|
79
79
|
> The candle file must exist — run the market adapter LP exporter first if needed (see [Getting Blockchain Data](#getting-blockchain-data)).
|
|
80
80
|
|
|
@@ -108,14 +108,34 @@ If you pass a raw JSON file, the runner normalizes the candles before rendering.
|
|
|
108
108
|
Use the market adapter LP exporter to pull blockchain-backed candles before generating the HTML:
|
|
109
109
|
|
|
110
110
|
```bash
|
|
111
|
+
# Auto mode — resolves pool + precisions from bots.json / blockchain
|
|
112
|
+
node dist/market_adapter/inputs/fetch_lp_data.js --bot BTS-USDT --interval 1h --lookback 4392h
|
|
113
|
+
|
|
114
|
+
# Or with an explicit date range
|
|
115
|
+
node dist/market_adapter/inputs/fetch_lp_data.js --bot BTS-USDT --interval 1h --start 2026-02-23 --end 2026-08-23
|
|
116
|
+
|
|
117
|
+
# Manual mode — no blockchain needed
|
|
111
118
|
node dist/market_adapter/inputs/fetch_lp_data.js --pool 133 --precA 4 --precB 5 --interval 1h --lookback 26280h
|
|
112
119
|
```
|
|
113
120
|
|
|
114
121
|
For date range fetching, use `--start` and `--end` (e.g. `--start 2024-03-06 --end 2025-03-06`).
|
|
115
122
|
|
|
116
|
-
That writes a JSON file under `market_adapter/data/lp/` which you can then pass to the TradingView exporter
|
|
123
|
+
That writes a JSON file under `market_adapter/data/lp/` which you can then pass to the TradingView exporter:
|
|
124
|
+
|
|
125
|
+
```text
|
|
126
|
+
market_adapter/data/lp/<pair>/lp_pool_<id>_<interval>.json
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
| Flag | Description |
|
|
130
|
+
|------|-------------|
|
|
131
|
+
| `--bot <name>` | Bot name from `profiles/bots.json` (auto-resolves pool) |
|
|
132
|
+
| `--pool <id>` | Manual mode, no blockchain needed (requires `--precA/--precB`) |
|
|
133
|
+
| `--interval <1m\|5m\|15m\|30m\|1h\|2h\|4h\|6h\|12h\|1d\|1w>` | Candle bucket size (bare numbers = seconds, e.g. `1800` = 30m) |
|
|
134
|
+
| `--lookback <N>h` | Hours back from now |
|
|
135
|
+
| `--start / --end` | Explicit date range (e.g. `2026-02-23`) |
|
|
136
|
+
| `--out <path>` | Custom output path |
|
|
117
137
|
|
|
118
|
-
|
|
138
|
+
> **Note:** the fetcher may not exit on its own after printing `Saved:` (the live BitShares WebSocket + node monitor keep the process alive). It is safe to Ctrl+C once the file is saved.
|
|
119
139
|
|
|
120
140
|
## CLI Flags
|
|
121
141
|
|
|
@@ -129,7 +149,7 @@ For manual pool discovery, use `--pool`, `--precA`, and `--precB` instead of `--
|
|
|
129
149
|
| `--sma-period <n>` | SMA period | `500` |
|
|
130
150
|
| `--ama-er-period <n>` | AMA ER period | `781` |
|
|
131
151
|
| `--ama-fast-period <n>` | AMA fast period | `5.2` |
|
|
132
|
-
| `--ama-slow-period <n>` | AMA slow period | `
|
|
152
|
+
| `--ama-slow-period <n>` | AMA slow period | `83.6` |
|
|
133
153
|
| `--price-scale <log\|linear>` | Price axis scale | `log` |
|
|
134
154
|
| `--scale <log\|linear>` | Alias for `--price-scale` | `log` |
|
|
135
155
|
| `--vwap-bars <n>` | Rolling VWMA window | `500` |
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
import fs from 'node:fs';
|
|
@@ -12,7 +13,6 @@ import { loadBotMeta } from '../bot_key_utils.js';
|
|
|
12
13
|
import { resolveSource, listAvailableBots } from '../resolve_source.js';
|
|
13
14
|
import { writeChartFile } from '../chart_utils.js';
|
|
14
15
|
import { PATHS } from '../../modules/paths.js';
|
|
15
|
-
'use strict';
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
const DEFAULT_CHART_DIR = PATHS.ANALYSIS.CHARTS_DIR;
|