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,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* DYNAMIC WEIGHT RESEARCH TOOL
|
|
@@ -7,7 +8,7 @@
|
|
|
7
8
|
* interactive HTML chart for researching dynamic weight parameters.
|
|
8
9
|
*
|
|
9
10
|
* Usage:
|
|
10
|
-
*
|
|
11
|
+
* node dist/analysis/analyze_dynamic_weight.js \
|
|
11
12
|
* --source json \
|
|
12
13
|
* --file market_adapter/data/lp/<path>/<to>/<lp-candles>.json
|
|
13
14
|
*/
|
|
@@ -18,14 +19,13 @@ import { HurstAnalyzer } from './trend_detection/hurst_analyzer.js';
|
|
|
18
19
|
import { PermutationEntropyAnalyzer } from './trend_detection/permutation_entropy_analyzer.js';
|
|
19
20
|
import { generateHTML } from './trend_detection/dynamic_weight_chart_generator.js';
|
|
20
21
|
import { calculateAMA } from '../market_adapter/core/strategies/ama.js';
|
|
21
|
-
import { computeAmaSlopeWeights } from '../market_adapter/core/strategies/ama_slope_model.js';
|
|
22
|
+
import { computeAmaSlopeWeights, createAmaSlopeClipTracker } from '../market_adapter/core/strategies/ama_slope_model.js';
|
|
22
23
|
import { MARKET_ADAPTER } from '../modules/constants.js';
|
|
23
24
|
import { PATHS } from '../modules/paths.js';
|
|
24
25
|
import { writeChartFile } from './chart_utils.js';
|
|
25
26
|
import { getCandleClose } from './math_utils.js';
|
|
26
27
|
import { resolveSource, listAvailableBots, type SourceConfig } from './resolve_source.js';
|
|
27
28
|
|
|
28
|
-
'use strict';
|
|
29
29
|
|
|
30
30
|
// AMA Slope weight calculation config — use DEFAULTS from market adapter
|
|
31
31
|
const AMA_WEIGHT_CONFIG = {
|
|
@@ -149,15 +149,30 @@ async function main() {
|
|
|
149
149
|
// ── AMA weight calculation ───────────────────────────────────────────
|
|
150
150
|
const closes = candles.map(c => getCandleClose(c) ?? 0);
|
|
151
151
|
const amaValues = calculateAMA(closes, AMA_CONFIG);
|
|
152
|
+
const lbBars = config.lookbackBars ?? AMA_WEIGHT_CONFIG.lookbackBars;
|
|
153
|
+
const clipPercentile = config.clipPct ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_CLIP_PERCENTILE;
|
|
154
|
+
|
|
155
|
+
// Incremental percentile clip threshold (shared with the market adapter)
|
|
156
|
+
// so the research offset matches the live asymmetry. Feeding bar-by-bar
|
|
157
|
+
// keeps the pool prefix-only — no look-ahead, same thresholds the live
|
|
158
|
+
// service would have seen at each point in time.
|
|
159
|
+
const clipTracker = createAmaSlopeClipTracker(AMA_CONFIG.erPeriod, lbBars, clipPercentile);
|
|
160
|
+
// Minimal history window computeAmaSlopeWeights can act on (guard is
|
|
161
|
+
// erPeriod + lookbackBars + 1 and it only reads the last two sampled
|
|
162
|
+
// bars), so a rolling slice avoids O(n²) prefix copies.
|
|
163
|
+
const weightWindowBars = Math.ceil(AMA_CONFIG.erPeriod) + lbBars + 1;
|
|
164
|
+
|
|
152
165
|
for (let i = 0; i < allResults.length; i++) {
|
|
153
166
|
// The research chart keeps ATR out of the Kalman branch on purpose.
|
|
154
167
|
// Production applies ATR later as a separate symmetric volatility penalty.
|
|
155
168
|
const atr = 0;
|
|
156
169
|
const weightVariance = 0;
|
|
170
|
+
const amaClipThreshold = clipTracker.push(amaValues[i] ?? NaN);
|
|
171
|
+
const slice = amaValues.slice(Math.max(0, i + 1 - weightWindowBars), i + 1);
|
|
157
172
|
|
|
158
|
-
const weights = computeAmaSlopeWeights(
|
|
173
|
+
const weights = computeAmaSlopeWeights(slice, weightVariance, {
|
|
159
174
|
erPeriod: AMA_CONFIG.erPeriod,
|
|
160
|
-
lookbackBars:
|
|
175
|
+
lookbackBars: lbBars,
|
|
161
176
|
maxSlopePct: AMA_WEIGHT_CONFIG.amaMaxSlopePct,
|
|
162
177
|
neutralZonePct: AMA_WEIGHT_CONFIG.neutralZonePct,
|
|
163
178
|
volatilityExponent: AMA_WEIGHT_CONFIG.volatilityExponent,
|
|
@@ -165,6 +180,7 @@ async function main() {
|
|
|
165
180
|
volatilityThreshold: AMA_WEIGHT_CONFIG.volatilityThreshold,
|
|
166
181
|
maxSlopeOffset: AMA_WEIGHT_CONFIG.maxSlopeOffset,
|
|
167
182
|
maxVolatilityOffset: AMA_WEIGHT_CONFIG.maxVolatilityOffset,
|
|
183
|
+
clipThreshold: amaClipThreshold,
|
|
168
184
|
});
|
|
169
185
|
|
|
170
186
|
(allResults[i] as any).ama3Price = amaValues[i] ?? null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* KALMAN TREND ANALYSIS RUNNER
|
|
@@ -6,7 +7,7 @@
|
|
|
6
7
|
* Runs KalmanTrendAnalyzer over candle data and generates an interactive HTML chart.
|
|
7
8
|
*
|
|
8
9
|
* Usage:
|
|
9
|
-
*
|
|
10
|
+
* node dist/analysis/analyze_kalman.js \
|
|
10
11
|
* --source json \
|
|
11
12
|
* --file market_adapter/data/lp/<path>/<to>/<lp-candles>.json
|
|
12
13
|
*/
|
|
@@ -15,32 +16,35 @@ import path from 'node:path';
|
|
|
15
16
|
import { KalmanTrendAnalyzer } from './trend_detection/kalman_trend_analyzer.js';
|
|
16
17
|
import { generateHTML } from './trend_detection/kalman_chart_generator.js';
|
|
17
18
|
import { calculateAMA } from '../market_adapter/core/strategies/ama.js';
|
|
18
|
-
import {
|
|
19
|
+
import { computeAmaSlopeWeights, createAmaSlopeClipTracker } from '../market_adapter/core/strategies/ama_slope_model.js';
|
|
20
|
+
import { MARKET_ADAPTER } from '../modules/constants.js';
|
|
19
21
|
import { getCandleClose } from './math_utils.js';
|
|
20
22
|
import { writeChartFile } from './chart_utils.js';
|
|
21
23
|
import { PATHS } from '../modules/paths.js';
|
|
22
24
|
import { resolveSource, listAvailableBots, type SourceConfig } from './resolve_source.js';
|
|
23
25
|
|
|
24
|
-
'use strict';
|
|
25
26
|
|
|
26
|
-
const LOOKBACK_BARS = 72;
|
|
27
|
-
const NEUTRAL_ZONE = 0.15;
|
|
28
|
-
const MAX_SLOPE_PCT = 3.0;
|
|
29
|
-
const MAX_SLOPE_OFFSET = 0.5;
|
|
30
27
|
|
|
31
28
|
function parseArgs() {
|
|
32
29
|
const args = process.argv.slice(2);
|
|
33
30
|
const config: {
|
|
34
31
|
source: { type: string; config: SourceConfig };
|
|
35
|
-
rNoise: number;
|
|
36
|
-
|
|
32
|
+
rNoise: number | null;
|
|
33
|
+
qTactical: number | null;
|
|
34
|
+
qModal: number | null;
|
|
35
|
+
qNoise: number | null;
|
|
37
36
|
chartFile: string;
|
|
38
37
|
quiet: boolean;
|
|
39
38
|
listBots: boolean;
|
|
40
39
|
} = {
|
|
41
40
|
source: { type: 'market_adapter', config: { botKey: '' } },
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
// Defaults resolve to the live MARKET_ADAPTER Kalman constants so
|
|
42
|
+
// runs are directly comparable with production (qTactical 0.01,
|
|
43
|
+
// qModal 0.0001 — NOT a single shared Q for both filters).
|
|
44
|
+
rNoise: null,
|
|
45
|
+
qTactical: null,
|
|
46
|
+
qModal: null,
|
|
47
|
+
qNoise: null,
|
|
44
48
|
chartFile: path.join(PATHS.ANALYSIS.CHARTS_DIR, 'kalman_chart.html'),
|
|
45
49
|
quiet: false,
|
|
46
50
|
listBots: false,
|
|
@@ -56,6 +60,8 @@ function parseArgs() {
|
|
|
56
60
|
}
|
|
57
61
|
else if (arg === '--r') config.rNoise = parseFloat(args[++i]);
|
|
58
62
|
else if (arg === '--q') config.qNoise = parseFloat(args[++i]);
|
|
63
|
+
else if (arg === '--q-tactical') config.qTactical = parseFloat(args[++i]);
|
|
64
|
+
else if (arg === '--q-modal') config.qModal = parseFloat(args[++i]);
|
|
59
65
|
else if (arg === '--chart') config.chartFile = args[++i];
|
|
60
66
|
else if (arg === '--list-bots') config.listBots = true;
|
|
61
67
|
else if (arg === '--quiet') config.quiet = true;
|
|
@@ -82,9 +88,15 @@ async function main() {
|
|
|
82
88
|
}
|
|
83
89
|
|
|
84
90
|
// ── Kalman analysis ──────────────────────────────────────────────────
|
|
91
|
+
// Unset flags fall through to the live KalmanTrendAnalyzer defaults
|
|
92
|
+
// (MARKET_ADAPTER.DYNAMIC_WEIGHT_KALMAN_*_DEFAULT). --q still maps to
|
|
93
|
+
// both filters for quick what-ifs, but per-filter overrides
|
|
94
|
+
// (--q-tactical / --q-modal) exist so runs can mirror production
|
|
95
|
+
// exactly: Q = (0.01 tactical, 0.0001 modal).
|
|
85
96
|
const analyzer = new KalmanTrendAnalyzer({
|
|
86
|
-
rNoise: config.rNoise,
|
|
87
|
-
|
|
97
|
+
rNoise: config.rNoise ?? undefined,
|
|
98
|
+
qTactical: config.qTactical ?? config.qNoise ?? undefined,
|
|
99
|
+
qModal: config.qModal ?? config.qNoise ?? undefined,
|
|
88
100
|
});
|
|
89
101
|
|
|
90
102
|
const allResults: any[] = [];
|
|
@@ -96,26 +108,43 @@ async function main() {
|
|
|
96
108
|
}
|
|
97
109
|
|
|
98
110
|
// ── AMA weight offset (for comparison panel) ─────────────────────────
|
|
111
|
+
// Runs the production path (computeAmaSlopeWeights + percentile clip)
|
|
112
|
+
// so this panel is directly comparable to the live amaSlopeOffset.
|
|
99
113
|
const closes = candles.map(c => getCandleClose(c) ?? 0);
|
|
100
114
|
const amaValues = calculateAMA(closes, amaConfig);
|
|
101
|
-
const
|
|
115
|
+
const amaLb = MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_LOOKBACK_BARS;
|
|
116
|
+
const clipPct = MARKET_ADAPTER.DYNAMIC_WEIGHT_CLIP_PERCENTILE;
|
|
117
|
+
// Ceil to match the readiness guard in computeAmaSlopeWeights
|
|
118
|
+
// (it uses Math.ceil(opts.erPeriod)), so fractional ER periods don't
|
|
119
|
+
// leave a 1-bar window that computes a weight where the model is not ready.
|
|
120
|
+
const warmup = Math.ceil(amaConfig.erPeriod) + amaLb + 1;
|
|
121
|
+
|
|
122
|
+
// Incremental, prefix-only clip pool (no look-ahead) — same thresholds
|
|
123
|
+
// the live service would have seen at each point in time.
|
|
124
|
+
const clipTracker = createAmaSlopeClipTracker(amaConfig.erPeriod, amaLb, clipPct);
|
|
125
|
+
const weightWindowBars = Math.ceil(amaConfig.erPeriod) + amaLb + 1;
|
|
102
126
|
|
|
103
127
|
for (let i = 0; i < allResults.length; i++) {
|
|
128
|
+
const amaClipThreshold = clipTracker.push(amaValues[i] ?? NaN);
|
|
104
129
|
if (i < warmup) { allResults[i].amaWeightOffset = null; continue; }
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
130
|
+
const slice = amaValues.slice(Math.max(0, i + 1 - weightWindowBars), i + 1);
|
|
131
|
+
const weights = computeAmaSlopeWeights(slice, 0, {
|
|
132
|
+
erPeriod: amaConfig.erPeriod,
|
|
133
|
+
lookbackBars: amaLb,
|
|
134
|
+
maxSlopePct: MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_MAX_SLOPE_PCT,
|
|
135
|
+
neutralZonePct: MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_NEUTRAL_ZONE_PCT,
|
|
136
|
+
volatilityExponent: MARKET_ADAPTER.DYNAMIC_WEIGHT_VOLATILITY_EXPONENT,
|
|
137
|
+
volatilityScaleX: MARKET_ADAPTER.DYNAMIC_WEIGHT_VOLATILITY_SCALE_X_DEFAULT,
|
|
138
|
+
volatilityThreshold: MARKET_ADAPTER.DYNAMIC_WEIGHT_SYMMETRIC_SHIFT_THRESHOLD,
|
|
139
|
+
maxSlopeOffset: MARKET_ADAPTER.DYNAMIC_WEIGHT_ASYMMETRIC_OFFSET_CLAMP,
|
|
140
|
+
maxVolatilityOffset: MARKET_ADAPTER.DYNAMIC_WEIGHT_SYMMETRIC_SHIFT_CLAMP,
|
|
141
|
+
clipThreshold: amaClipThreshold,
|
|
142
|
+
});
|
|
143
|
+
allResults[i].amaWeightOffset = weights.rawSlopeOffset;
|
|
115
144
|
}
|
|
116
145
|
|
|
117
146
|
// ── Generate chart ───────────────────────────────────────────────────
|
|
118
|
-
const html = generateHTML({ allResults }, 'Kalman Trend Analysis');
|
|
147
|
+
const html = generateHTML({ allResults, amaConfig, clipPct: MARKET_ADAPTER.DYNAMIC_WEIGHT_CLIP_PERCENTILE }, 'Kalman Trend Analysis');
|
|
119
148
|
writeChartFile(config.chartFile, html);
|
|
120
149
|
|
|
121
150
|
if (!config.quiet) console.log(`[Kalman] ✓ Chart saved to ${config.chartFile}`);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* REGIME ANALYSIS TOOL
|
|
@@ -13,7 +14,7 @@
|
|
|
13
14
|
* Norm. PE > 0.85 = noise → no exploitable structure
|
|
14
15
|
*
|
|
15
16
|
* Usage:
|
|
16
|
-
*
|
|
17
|
+
* node dist/analysis/analyze_regime.js \
|
|
17
18
|
* --source json \
|
|
18
19
|
* --file market_adapter/data/lp/<path>/<to>/<lp-candles>.json
|
|
19
20
|
*/
|
|
@@ -32,7 +33,6 @@ import { resolveSource, listAvailableBots, type SourceConfig } from './resolve_s
|
|
|
32
33
|
const HURST_CONFIG = MARKET_ADAPTER.HURST_CONFIG;
|
|
33
34
|
const PE_CONFIG = MARKET_ADAPTER.PE_CONFIG;
|
|
34
35
|
|
|
35
|
-
'use strict';
|
|
36
36
|
|
|
37
37
|
function parseArgs() {
|
|
38
38
|
const args = process.argv.slice(2);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* REGIME WINDOW OPTIMIZER
|
|
@@ -12,13 +13,13 @@
|
|
|
12
13
|
* - entropyDefect: penalty for being stuck in the "random" band (H 0.45–0.55)
|
|
13
14
|
*
|
|
14
15
|
* Usage:
|
|
15
|
-
*
|
|
16
|
+
* node dist/analysis/analyze_regime_windows.js \
|
|
16
17
|
* --source json \
|
|
17
18
|
* --file market_adapter/data/lp/<path>/<to>/<lp-candles>.json
|
|
18
19
|
*/
|
|
19
20
|
|
|
20
21
|
import path from 'node:path';
|
|
21
|
-
import { HurstAnalyzer }
|
|
22
|
+
import { HurstAnalyzer, classifyHurst } from './trend_detection/hurst_analyzer.js';
|
|
22
23
|
import { PermutationEntropyAnalyzer } from './trend_detection/permutation_entropy_analyzer.js';
|
|
23
24
|
import { MARKET_ADAPTER } from '../modules/constants.js';
|
|
24
25
|
import { PATHS } from '../modules/paths.js';
|
|
@@ -30,7 +31,6 @@ import { resolveSource, listAvailableBots, type SourceConfig } from './resolve_s
|
|
|
30
31
|
const HURST_CONFIG = MARKET_ADAPTER.HURST_CONFIG;
|
|
31
32
|
const PE_CONFIG = MARKET_ADAPTER.PE_CONFIG;
|
|
32
33
|
|
|
33
|
-
'use strict';
|
|
34
34
|
|
|
35
35
|
const HURST_CENTER = HURST_CONFIG.window;
|
|
36
36
|
const PE_CENTER = PE_CONFIG.window;
|
|
@@ -48,9 +48,9 @@ function geoRange(center: number, factor: number, n: number) {
|
|
|
48
48
|
|
|
49
49
|
const HURST_WINDOWS = geoRange(HURST_CENTER, RANGE_FACTOR, N_POINTS);
|
|
50
50
|
const PE_WINDOWS = geoRange(PE_CENTER, RANGE_FACTOR, N_POINTS);
|
|
51
|
-
const HURST_SCALES =
|
|
52
|
-
const PE_M =
|
|
53
|
-
const PE_DELAY =
|
|
51
|
+
const HURST_SCALES = HURST_CONFIG.scales;
|
|
52
|
+
const PE_M = PE_CONFIG.m;
|
|
53
|
+
const PE_DELAY = PE_CONFIG.delay;
|
|
54
54
|
|
|
55
55
|
function parseArgs() {
|
|
56
56
|
const args = process.argv.slice(2);
|
|
@@ -82,14 +82,16 @@ function parseArgs() {
|
|
|
82
82
|
return config;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
const
|
|
85
|
+
// Signal-quality bands from MARKET_ADAPTER.PE_NODES (structured / mixed / noise).
|
|
86
|
+
const PE_STRUCTURED = MARKET_ADAPTER.PE_NODES[0];
|
|
87
|
+
const PE_NOISE = MARKET_ADAPTER.PE_NODES[MARKET_ADAPTER.PE_NODES.length - 1];
|
|
87
88
|
|
|
89
|
+
// Hurst band classification delegates to the production classifyHurst
|
|
90
|
+
// (market_adapter/core/signals/hurst_analyzer.ts) so boundary semantics
|
|
91
|
+
// (inclusive >=/<=) and zone width stay on one logic path.
|
|
88
92
|
function regimeBand(H: number | null): string {
|
|
89
93
|
if (H === null) return 'RANDOM';
|
|
90
|
-
|
|
91
|
-
if (H < H_LOWER) return 'MEAN_REVERTING';
|
|
92
|
-
return 'RANDOM';
|
|
94
|
+
return classifyHurst(H).regime;
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
function rankNormalize(arr: number[]) {
|
|
@@ -119,14 +121,20 @@ function scoreWindowPair(prices: number[], hurstWindow: number, peWindow: number
|
|
|
119
121
|
const firstReady = hArr.findIndex(v => v !== null);
|
|
120
122
|
if (firstReady < 0) return null;
|
|
121
123
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
124
|
+
// ── Regime sequences ──────────────────────────────────────────────────
|
|
125
|
+
// Pair H and PE strictly per bar: both analyzers become ready on different
|
|
126
|
+
// schedules (PE window vs Hurst window), so slicing from Hurst readiness
|
|
127
|
+
// and independently null-filtering PE would index-shift the pairing.
|
|
128
|
+
const hBands: string[] = [];
|
|
129
|
+
const pBands: string[] = [];
|
|
130
|
+
for (let i = 0; i < n; i++) {
|
|
131
|
+
if (hArr[i] === null || pArr[i] === null) continue;
|
|
132
|
+
hBands.push(regimeBand(hArr[i]));
|
|
133
|
+
pBands.push(pArr[i]! < PE_STRUCTURED ? 'STRUCTURED' : pArr[i]! > PE_NOISE ? 'NOISE' : 'MIXED');
|
|
134
|
+
}
|
|
135
|
+
const m = hBands.length;
|
|
125
136
|
if (m < 50) return null;
|
|
126
137
|
|
|
127
|
-
// ── Regime sequences ──────────────────────────────────────────────────
|
|
128
|
-
const hBands = readyH.map(regimeBand);
|
|
129
|
-
const pBands = readyP.map(v => v < 0.60 ? 'STRUCTURED' : v > 0.85 ? 'NOISE' : 'MIXED');
|
|
130
138
|
const combined = hBands.map((h, i) => `${h}|${pBands[i]}`);
|
|
131
139
|
|
|
132
140
|
// ── Stability: mean run-length of combined regime ───────────────────
|
|
@@ -397,8 +405,8 @@ noise=${(r.entropyDefect*100).toFixed(1)}%">
|
|
|
397
405
|
<table class="params-table">
|
|
398
406
|
<tr><td>Hurst range</td><td>${Math.round(hurstVals[0])} – ${Math.round(hurstVals[hurstVals.length-1])} (center=${defaultH})</td></tr>
|
|
399
407
|
<tr><td>PE range</td><td>${Math.round(peVals[0])} – ${Math.round(peVals[peVals.length-1])} (center=${defaultP})</td></tr>
|
|
400
|
-
<tr><td>Hurst scales</td><td>[
|
|
401
|
-
<tr><td>PE embedding</td><td>m
|
|
408
|
+
<tr><td>Hurst scales</td><td>[${HURST_SCALES.join(', ')}]</td></tr>
|
|
409
|
+
<tr><td>PE embedding</td><td>m=${PE_M}, delay=${PE_DELAY}</td></tr>
|
|
402
410
|
<tr><td>Spacing</td><td>geometric (ratio=${geoRatio.toFixed(3)})</td></tr>
|
|
403
411
|
</table>
|
|
404
412
|
</div>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
2
3
|
/**
|
|
3
4
|
* RISK PROFILE ANALYZER
|
|
4
5
|
*
|
|
@@ -9,8 +10,8 @@
|
|
|
9
10
|
* (σ_ama_delta) for calibrating AMA_DELTA_THRESHOLD_PERCENT.
|
|
10
11
|
*
|
|
11
12
|
* Usage:
|
|
12
|
-
*
|
|
13
|
-
*
|
|
13
|
+
* node dist/analysis/analyze_risk_profile.js --source market_adapter --bot-key <key> [options]
|
|
14
|
+
* node dist/analysis/analyze_risk_profile.js --file <path_to_json> [options]
|
|
14
15
|
*/
|
|
15
16
|
import { calculateAMA } from '../market_adapter/core/strategies/ama.js';
|
|
16
17
|
import { MARKET_ADAPTER } from '../modules/constants.js';
|
|
@@ -19,7 +20,6 @@ import { calcStdDev, getCandleClose } from './math_utils.js';
|
|
|
19
20
|
import { writeChartFile } from './chart_utils.js';
|
|
20
21
|
import { resolveSource, listAvailableBots, type SourceConfig } from './resolve_source.js';
|
|
21
22
|
|
|
22
|
-
'use strict';
|
|
23
23
|
|
|
24
24
|
function normSInv(p: number) {
|
|
25
25
|
if (p <= 0 || p >= 1) return p <= 0 ? -Infinity : Infinity;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
2
3
|
/**
|
|
3
4
|
* TRADE HEATMAP ANALYZER
|
|
4
5
|
*
|
|
@@ -7,8 +8,8 @@
|
|
|
7
8
|
* a summed volume histogram with threshold annotations.
|
|
8
9
|
*
|
|
9
10
|
* Usage:
|
|
10
|
-
*
|
|
11
|
-
*
|
|
11
|
+
* node dist/analysis/analyze_trade_heatmap.js --source market_adapter --bot-key <key> [options]
|
|
12
|
+
* node dist/analysis/analyze_trade_heatmap.js --file <path> [options]
|
|
12
13
|
*
|
|
13
14
|
* Output:
|
|
14
15
|
* Self-contained HTML file with inline CSS (no JS dependencies).
|
|
@@ -20,7 +21,6 @@ import { calcStdDev, getCandleClose } from './math_utils.js';
|
|
|
20
21
|
import { writeChartFile } from './chart_utils.js';
|
|
21
22
|
import { resolveSource, listAvailableBots, type SourceConfig } from './resolve_source.js';
|
|
22
23
|
|
|
23
|
-
'use strict';
|
|
24
24
|
|
|
25
25
|
function parseArgs() {
|
|
26
26
|
const args = process.argv.slice(2);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* VOLATILITY / SYMMETRIC SHIFT RESEARCH TOOL
|
|
@@ -16,7 +17,7 @@
|
|
|
16
17
|
* effect can be researched in isolation.
|
|
17
18
|
*
|
|
18
19
|
* Usage:
|
|
19
|
-
*
|
|
20
|
+
* node dist/analysis/analyze_volatility.js \
|
|
20
21
|
* --file market_adapter/data/lp/<path>/<to>/<lp-candles>.json
|
|
21
22
|
*/
|
|
22
23
|
|
|
@@ -33,7 +34,6 @@ import { getCandleClose } from './math_utils.js';
|
|
|
33
34
|
import { writeChartFile } from './chart_utils.js';
|
|
34
35
|
import { resolveSource, listAvailableBots, type SourceConfig } from './resolve_source.js';
|
|
35
36
|
|
|
36
|
-
'use strict';
|
|
37
37
|
|
|
38
38
|
const DEFAULT_ATR_PERIOD = MARKET_ADAPTER.DYNAMIC_WEIGHT_ATR_PERIOD_DEFAULT;
|
|
39
39
|
const MIN_WEIGHT = MARKET_ADAPTER.DYNAMIC_WEIGHT_MIN_WEIGHT;
|
|
@@ -6,15 +6,65 @@ This folder contains parameter sweep backtests that simulate grid fills for the
|
|
|
6
6
|
|
|
7
7
|
For each of the 4 AMA strategies, it searches for best:
|
|
8
8
|
|
|
9
|
-
- `spread` (% target
|
|
10
|
-
- `increment` (%
|
|
9
|
+
- `spread` (% target spread for the gapSlots spread zone)
|
|
10
|
+
- `increment` (% geometric rail step)
|
|
11
11
|
- `max/min ratio` (symmetric range around AMA, e.g. `2.0` means `[AMA/2, AMA*2]`)
|
|
12
12
|
|
|
13
13
|
### Scripts
|
|
14
14
|
|
|
15
|
-
- `backtest_bot_fitting.ts` — lightweight sweep across spread / increment / ratio with
|
|
16
|
-
- `backtest_ama_sweep.ts` — persistent grid simulation with
|
|
17
|
-
- `shared_utils.ts` — shared helpers (argument parsing, data loading, formatting)
|
|
15
|
+
- `backtest_bot_fitting.ts` — lightweight sweep across spread / increment / ratio with unit-size percentage-point accounting and risk scoring
|
|
16
|
+
- `backtest_ama_sweep.ts` — persistent grid simulation with capital-weighted sizing, weight profiles, and worker-thread parallelization
|
|
17
|
+
- `shared_utils.ts` — shared helpers (argument parsing, data loading, formatting)
|
|
18
|
+
|
|
19
|
+
Both simulators share the same production grid model (ported once in
|
|
20
|
+
`backtest_bot_fitting.ts` and imported by the sweep), so identical params
|
|
21
|
+
build byte-identical grids in both tools.
|
|
22
|
+
|
|
23
|
+
### Production alignment
|
|
24
|
+
|
|
25
|
+
Both simulators port the live bot lifecycle end to end:
|
|
26
|
+
|
|
27
|
+
- **Grid geometry** — `createOrderGrid` (modules/order/grid.ts): master rail at
|
|
28
|
+
`√(1±inc)` offsets bounded by `[center/ratio, center×ratio]` with a
|
|
29
|
+
`calculateGapSlots` spread zone centered on the placement price; order prices
|
|
30
|
+
are placement-time constants.
|
|
31
|
+
- **Slot rotation (anchor-&-refill)** — a filled buy at rail node `k` instantly
|
|
32
|
+
re-offers its base at the adjacent master-rail node `k+1`; when that refill
|
|
33
|
+
sells, exactly one rail hop minus the round-trip fee is booked and the freed
|
|
34
|
+
quote re-bids node `k−1`. A slot keeps cycling on small oscillations between
|
|
35
|
+
resets — this is what a refilled live slot earns, not a cross-gap
|
|
36
|
+
differential. Re-armed orders carry a one-bar replacement-lag cooldown.
|
|
37
|
+
Sub-note: because rails chain by `×(1+inc)` above center and `×(1−inc)`
|
|
38
|
+
below, a down-chain hop equals `inc/(1−inc)` (e.g. 1.0101% at inc=1%), not
|
|
39
|
+
exactly `inc` — matching real rail adjacency.
|
|
40
|
+
- **Inventory-funded selling** — unlinked (initial-grid) sells execute only
|
|
41
|
+
against held base, priced against the weighted-average entry of the position;
|
|
42
|
+
unfundable sells stay open and retry (never shorting).
|
|
43
|
+
- **Inventory carry** — resets cancel ALL live orders (initial leftovers plus
|
|
44
|
+
armed refills/rebids); bought-and-held base merges into a weighted-average-
|
|
45
|
+
entry pool that survives resets (production resync never market-sells). The
|
|
46
|
+
end-of-run inventory mark is reported as an INFORMATIONAL field — it is real
|
|
47
|
+
carried risk but excluded from scoring/ranking.
|
|
48
|
+
- **Reset triggers** (MARKET_ADAPTER):
|
|
49
|
+
- Trigger A: AMA drift ≥ `AMA_DELTA_THRESHOLD_PERCENT` (1%) from the recorded
|
|
50
|
+
center, ratchet semantics — always on.
|
|
51
|
+
- Trigger B: slope-delta reset (`|slope − baseline| ≥
|
|
52
|
+
AMA_SLOPE_DELTA_THRESHOLD_PERCENT/100 × DYNAMIC_WEIGHT_AMA_MAX_SLOPE_PCT`
|
|
53
|
+
over the `DYNAMIC_WEIGHT_AMA_LOOKBACK_BARS` average-slope series, baseline
|
|
54
|
+
re-seeded every reset) plus the slope-ratio grid price offset
|
|
55
|
+
(`direction × min(|slope|/maxSlopePct,1) × targetSpread/2`, applied to the
|
|
56
|
+
placement center). Both are gated behind `--asymmetric-bounds`, mirroring
|
|
57
|
+
the production per-bot asymmetricBounds whitelist — default OFF for a
|
|
58
|
+
typical non-whitelisted bot.
|
|
59
|
+
- **BTS operation fees** — every order placement (initial grid + armed
|
|
60
|
+
refills + rebids) pays a maker create fee, every reset cancel pays a cancel
|
|
61
|
+
fee; totals are deducted from net capture (bot_fitting converts against
|
|
62
|
+
`--bts-fee-capital`, the sweep converts via `--tx-fee-price` in capital units).
|
|
63
|
+
|
|
64
|
+
Documented remaining deltas (inherent to OHLC research sims): bar-granularity
|
|
65
|
+
triggers, all-or-nothing fills on raw hi/lo touch, unit/capital sizing instead
|
|
66
|
+
of live balance + dynamic-weight sizing, pool-price fills without
|
|
67
|
+
microstructure, and no consolidation/dust-cancel/COW/collision mechanics.
|
|
18
68
|
|
|
19
69
|
### Input dependencies
|
|
20
70
|
|
|
@@ -53,6 +103,7 @@ node dist/analysis/bot_fitting/backtest_bot_fitting.js \
|
|
|
53
103
|
--active-orders 5 \
|
|
54
104
|
--fee 0.20 \
|
|
55
105
|
--min-spread-factor 2.1 \
|
|
106
|
+
--asymmetric-bounds \
|
|
56
107
|
--risk-duration 1.0 \
|
|
57
108
|
--risk-peak-open 2.0 \
|
|
58
109
|
--risk-imbalance 1.2 \
|
|
@@ -60,32 +111,53 @@ node dist/analysis/bot_fitting/backtest_bot_fitting.js \
|
|
|
60
111
|
```
|
|
61
112
|
|
|
62
113
|
> Default `--ratio` is `1.5,1.75,2,2.5,3,4,5,8,10` (includes `1.75`).
|
|
114
|
+
> Default `--active-orders` sizes EVERY rail slot in bounds (production
|
|
115
|
+
> behavior); pass a number to cap the search to the slots nearest the gap.
|
|
63
116
|
|
|
64
117
|
### Output
|
|
65
118
|
|
|
66
|
-
Results are written to `analysis/
|
|
119
|
+
Results are written to `analysis/results/` (filenames derived from the input
|
|
120
|
+
data file: `bot_fitting_results_<base>.json` and `ama_sweep_results_<base>.json`).
|
|
67
121
|
|
|
68
|
-
The console also prints best parameter set per AMA with matched pairs
|
|
122
|
+
The console also prints best parameter set per AMA with matched pairs (cycles),
|
|
123
|
+
fill efficiency, net capture and score.
|
|
69
124
|
|
|
70
125
|
### Notes
|
|
71
126
|
|
|
72
127
|
- This is an offline simulation proxy, not a full chain execution model.
|
|
73
|
-
-
|
|
74
|
-
|
|
75
|
-
(
|
|
76
|
-
-
|
|
77
|
-
|
|
78
|
-
|
|
128
|
+
- Hop granularity: the sim arms each refill at the ADJACENT master-rail node
|
|
129
|
+
(one increment). Production derives leg spacing from the gap-aware
|
|
130
|
+
boundary crawl (`deriveTargetBoundary`: one slot per non-partial fill,
|
|
131
|
+
burst-capped), so for wide-gap configs live legs may span `gapSlots` rail
|
|
132
|
+
steps (~targetSpread) instead of one. Calibrate against real bot fills
|
|
133
|
+
before trusting absolute magnitudes; rankings remain internally consistent.
|
|
134
|
+
- `--min-spread-factor 2.1` enforces `spread >= 2.1 x increment`
|
|
135
|
+
(`GRID_LIMITS.MIN_SPREAD_FACTOR`), matching `calculateGapSlots`.
|
|
136
|
+
- Score used for ranking (bot_fitting):
|
|
137
|
+
- `totalNetCaptureAfterFeesPct` = realized per-rotation gross (one rail hop
|
|
138
|
+
or weighted-average-entry sale) − round-trip fee − BTS op fees; the
|
|
139
|
+
end-of-run inventory mark is NOT included
|
|
140
|
+
- `baseScore = totalNetCaptureAfterFeesPct * (fillEfficiency / 100)`
|
|
79
141
|
- `riskPenalty = avgOpenDurationBars*1.0 + peakOpenOrders*2.0 + avgImbalance*1.2 + canceledOnReposition*0.15`
|
|
80
142
|
- `finalScore = baseScore - riskPenalty`
|
|
143
|
+
- Score used for ranking (sweep): realized profit only —
|
|
144
|
+
- `netProfitPerCapital * 100 * log10(max(1, matchedPairs)) - maxDrawdownPct * 0.5`
|
|
145
|
+
(`maxDrawdown` tracks REALIZED equity swings; carried-bag risk stays
|
|
146
|
+
visible through `finalInventoryUnits` / `finalInventoryMarkUnits`)
|
|
81
147
|
|
|
82
148
|
## Persistent Grid Simulation Details
|
|
83
149
|
|
|
84
150
|
`backtest_ama_sweep.ts` models the real bot mechanics:
|
|
85
151
|
|
|
86
152
|
- Orders sit at FIXED chain prices until canceled or filled
|
|
87
|
-
-
|
|
88
|
-
|
|
153
|
+
- Slot rotation: a filled buy re-offers the adjacent rail node above; its fill
|
|
154
|
+
books one rail hop net of fees and re-bids the node below (anchor-&-refill)
|
|
155
|
+
- Unlinked sells execute only against held inventory at weighted-average entry;
|
|
156
|
+
bought-and-held base carries across resets and is marked to close
|
|
157
|
+
informationally (excluded from profit; drawdown also tracks realized equity
|
|
158
|
+
only — bag risk stays visible through the info fields)
|
|
159
|
+
- When triggers fire (A drift, B slope under `--asymmetric-bounds`), the grid
|
|
160
|
+
re-centers and all live orders cancel
|
|
89
161
|
- Order sizing depends on capital, ratio (range width), and weight profile
|
|
90
162
|
- Three weight profiles: valley, neutral, mountain (symmetric buy/sell)
|
|
91
163
|
|
|
@@ -96,8 +168,8 @@ Search grid defaults — centered around bot defaults (spread=2%, increment=0.5%
|
|
|
96
168
|
| Spread | 0.5:4:0.25 + 5:12:1 (%) |
|
|
97
169
|
| Increment | 0.2:2:0.1 + 2.5:8:0.5 (%) |
|
|
98
170
|
| Max/min ratio | 1.05, 1.1, 1.15, 1.2, 1.3, 1.5, 2, 3, 5, 10 |
|
|
99
|
-
| Reposition threshold |
|
|
100
|
-
| Max orders per side | 20 |
|
|
171
|
+
| Reposition threshold | 1% (production `AMA_DELTA_THRESHOLD_PERCENT`) |
|
|
172
|
+
| Max orders per side | 20 (size cap) |
|
|
101
173
|
| Round-trip fee | 0.20% |
|
|
102
174
|
| Spread ≥ factor × increment | 2.1 |
|
|
103
175
|
|
|
@@ -106,7 +178,8 @@ All parameters above are tunable via CLI flags. Additional tuning flags:
|
|
|
106
178
|
| Flag | Default | Description |
|
|
107
179
|
|------|---------|-------------|
|
|
108
180
|
| `--capital <n>` | 10000 | Notional capital per side |
|
|
109
|
-
| `--reposition <pct>` |
|
|
181
|
+
| `--reposition <pct>` | 1 | AMA drift % to trigger re-center |
|
|
182
|
+
| `--asymmetric-bounds` | off | Enable slope-delta reset (B) + grid price offset |
|
|
110
183
|
| `--bts-create-fee <n>` | 0.48260 | BTS create order fee |
|
|
111
184
|
| `--bts-cancel-fee <n>` | 0.00482 | BTS cancel order fee |
|
|
112
185
|
| `--maker-create-factor <n>` | 0.10 | Maker share of create fee |
|
|
@@ -114,7 +187,8 @@ All parameters above are tunable via CLI flags. Additional tuning flags:
|
|
|
114
187
|
| `--top <n>` | 15 | Top N results displayed per AMA |
|
|
115
188
|
| `--help` | — | Print full usage |
|
|
116
189
|
|
|
117
|
-
The sweep parallelizes across
|
|
190
|
+
The sweep parallelizes across AMAs using worker threads (one per AMA strategy).
|
|
191
|
+
Use `--help` for the complete option list.
|
|
118
192
|
|
|
119
193
|
```bash
|
|
120
194
|
node dist/analysis/bot_fitting/backtest_ama_sweep.js \
|