dexbot 1.6.7 → 1.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -1
- package/README.md +3 -3
- package/analysis/README.md +2 -3
- package/analysis/tradingview/README.md +78 -1
- package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +1 -1
- package/claw/package.json +1 -1
- package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
- package/claw/runtimes/openclaw-plugin/package.json +1 -1
- package/dist/analysis/tradingview/analyze_tradingview.d.ts +4 -0
- package/dist/analysis/tradingview/analyze_tradingview.js +55 -0
- package/dist/analysis/tradingview/grid_reset_config.d.ts +61 -0
- package/dist/analysis/tradingview/grid_reset_config.js +235 -0
- package/dist/analysis/tradingview/grid_reset_sim.d.ts +67 -0
- package/dist/analysis/tradingview/grid_reset_sim.js +307 -0
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +419 -3
- package/dist/dexbot.js +22 -6
- package/dist/market_adapter/core/market_adapter_service.js +14 -2
- package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts +8 -1
- package/dist/market_adapter/core/strategies/dynamic_weight_series.js +5 -1
- package/dist/market_adapter/inputs/window_cache.d.ts +97 -19
- package/dist/market_adapter/inputs/window_cache.js +302 -48
- package/dist/market_adapter/market_adapter.d.ts +8 -1
- package/dist/market_adapter/market_adapter.js +22 -4
- package/dist/modules/account_bots.js +10 -0
- package/dist/modules/account_orders.d.ts +24 -2
- package/dist/modules/account_orders.js +41 -4
- package/dist/modules/bot_settings.js +10 -1
- package/dist/modules/config.d.ts +1 -0
- package/dist/modules/config.js +1 -0
- package/dist/modules/constants.d.ts +11 -3
- package/dist/modules/constants.js +116 -37
- package/dist/modules/dexbot_class.d.ts +6 -76
- package/dist/modules/dexbot_class.js +0 -32
- package/dist/modules/dexbot_cow_runtime.d.ts +3 -58
- package/dist/modules/dexbot_cow_runtime.js +4 -87
- package/dist/modules/dexbot_maintenance_runtime.d.ts +15 -1
- package/dist/modules/dexbot_maintenance_runtime.js +59 -11
- package/dist/modules/dexbot_startup_runtime.js +73 -20
- package/dist/modules/dexbot_state_recovery.d.ts +6 -0
- package/dist/modules/dexbot_state_recovery.js +21 -0
- package/dist/modules/order/async_lock.d.ts +8 -0
- package/dist/modules/order/async_lock.js +15 -0
- package/dist/modules/order/genesis_policy.d.ts +162 -0
- package/dist/modules/order/genesis_policy.js +267 -0
- package/dist/modules/order/grid.js +76 -134
- package/dist/modules/order/grid_reconcile.d.ts +9 -0
- package/dist/modules/order/grid_reconcile.js +13 -4
- package/dist/modules/order/grid_reconcile_internal.js +2 -2
- package/dist/modules/order/manager.d.ts +4 -0
- package/dist/modules/order/manager.js +14 -1
- package/dist/modules/order/sync_engine.d.ts +19 -0
- package/dist/modules/order/sync_engine.js +284 -344
- package/dist/modules/order/utils/math.d.ts +22 -1
- package/dist/modules/order/utils/math.js +64 -1
- package/dist/modules/order/utils/order.d.ts +43 -58
- package/dist/modules/order/utils/order.js +220 -197
- package/dist/modules/order/utils/system.js +8 -1
- package/dist/modules/paths.d.ts +1 -0
- package/dist/modules/paths.js +1 -0
- package/dist/modules/version_notice.d.ts +165 -0
- package/dist/modules/version_notice.js +364 -0
- package/dist/pm2.js +9 -0
- package/dist/unlock.js +28 -0
- package/docs/BITSHARES_ONBOARDING.md +8 -1
- package/docs/COW_INVARIANTS.md +3 -2
- package/docs/DEXBOT_COMPARISON.md +4 -4
- package/docs/EVOLUTION.md +20 -19
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
- package/docs/GRID_PRICE_INVARIANT.md +149 -31
- package/docs/GRID_RECALCULATION.md +12 -0
- package/docs/README.md +3 -1
- package/docs/WORKFLOW.md +16 -5
- package/market_adapter/README.md +1 -1
- package/modules/README.md +18 -1
- package/package.json +13 -5
- package/scripts/README.md +28 -2
- package/scripts/clear-all.sh +13 -4
- package/scripts/clear-logs.sh +13 -4
- package/scripts/clear-market-adapter.sh +6 -0
- package/scripts/clear-orders.sh +5 -0
- package/scripts/lib/dexbot-paths.sh +108 -0
- package/tests/README.md +11 -3
- package/analysis/account_resolver.ts +0 -161
- package/analysis/ama_fitting/analyze_ama_price_changes.ts +0 -155
- package/analysis/ama_fitting/analyze_lambda_vs_slow.ts +0 -404
- package/analysis/ama_fitting/calibrate_convergence_er.ts +0 -201
- package/analysis/ama_fitting/fetch_lp_candles.ts +0 -184
- package/analysis/ama_fitting/generate_unified_comparison_chart.ts +0 -232
- package/analysis/ama_fitting/optimizer_high_resolution.ts +0 -802
- package/analysis/analyze_dynamic_weight.ts +0 -243
- package/analysis/analyze_kalman.ts +0 -157
- package/analysis/analyze_regime.ts +0 -158
- package/analysis/analyze_regime_windows.ts +0 -470
- package/analysis/analyze_risk_profile.ts +0 -199
- package/analysis/analyze_trade_heatmap.ts +0 -362
- package/analysis/analyze_volatility.ts +0 -182
- package/analysis/bot_fitting/backtest_ama_sweep.ts +0 -934
- package/analysis/bot_fitting/backtest_bot_fitting.ts +0 -861
- package/analysis/bot_fitting/shared_utils.ts +0 -52
- package/analysis/bot_key_utils.ts +0 -426
- package/analysis/bot_usage/discover_bot_accounts.ts +0 -635
- package/analysis/bot_usage/kibana_bot_queries.ts +0 -211
- package/analysis/chain_pool.ts +0 -47
- package/analysis/chart_css.ts +0 -62
- package/analysis/chart_ui.ts +0 -105
- package/analysis/chart_utils.ts +0 -210
- package/analysis/fills_source.ts +0 -228
- package/analysis/grid_correction_check.ts +0 -786
- package/analysis/math_utils.ts +0 -53
- package/analysis/price_sources.ts +0 -136
- package/analysis/resolve_bot_accounts.ts +0 -199
- package/analysis/resolve_source.ts +0 -99
- package/analysis/results/ama_sweep_results_lp_pool_133_1h.json +0 -2455
- package/analysis/results/bot_fitting_results_lp_pool_133_1h.json +0 -218
- package/analysis/trade_profitability.ts +0 -1335
- package/analysis/tradingview/analyze_tradingview.ts +0 -280
- package/analysis/tradingview/h-bts_tradingview.html +0 -1570
- package/analysis/tradingview/t-bts_tradingview.html +0 -1570
- package/analysis/tradingview/tradingview_uplot_chart_generator.ts +0 -3268
- package/analysis/trend_detection/dynamic_weight_chart_generator.ts +0 -1481
- package/analysis/trend_detection/hurst_analyzer.ts +0 -7
- package/analysis/trend_detection/kalman_chart_generator.ts +0 -398
- package/analysis/trend_detection/kalman_trend_analyzer.ts +0 -9
- package/analysis/trend_detection/kalman_velocity_smoothing.ts +0 -7
- package/analysis/trend_detection/package.json +0 -23
- package/analysis/trend_detection/permutation_entropy_analyzer.ts +0 -7
- package/analysis/trend_detection/regime_chart_generator.ts +0 -338
- package/analysis/trend_detection/tests/test_kalman_trend.ts +0 -153
- package/analysis/trend_detection/tests/test_kalman_velocity_smoothing.ts +0 -64
- package/analysis/trend_detection/volatility_chart_generator.ts +0 -654
- package/analysis/tsconfig.json +0 -29
- package/claw/tests/package.json +0 -3
- package/claw/tests/test_claw_bridge.ts +0 -570
- package/claw/tests/test_claw_catalog_and_credentials.ts +0 -156
- package/claw/tests/test_claw_chain_layer.ts +0 -739
- package/claw/tests/test_claw_data_flow.ts +0 -525
- package/claw/tests/test_claw_domain_logic.ts +0 -471
- package/claw/tests/test_claw_manifest_and_matrix.ts +0 -222
- package/claw/tests/test_claw_mcp_transport.ts +0 -243
- package/claw/tests/test_claw_regressions.ts +0 -711
- package/claw/tests/test_claw_skill_generation.ts +0 -103
- package/claw/tests/test_claw_state_store.ts +0 -44
- package/claw/tests/test_dexbot_profiles.ts +0 -654
- package/claw/tests/test_memu_bridge.ts +0 -189
- package/claw/tests/test_nullclaw_tmp_integration.ts +0 -57
- package/claw/tests/test_position_health.ts +0 -343
- package/claw/tests/test_position_manager.ts +0 -429
- package/claw/tests/test_position_manager_watch_health.ts +0 -100
- package/claw/tests/test_short_mpa_strategy.ts +0 -232
- package/dist/analysis/account_resolver.d.ts.map +0 -1
- package/dist/analysis/account_resolver.js.map +0 -1
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.js.map +0 -1
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js.map +0 -1
- package/dist/analysis/ama_fitting/calibrate_convergence_er.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js.map +0 -1
- package/dist/analysis/ama_fitting/fetch_lp_candles.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/fetch_lp_candles.js.map +0 -1
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js.map +0 -1
- package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js.map +0 -1
- package/dist/analysis/analyze_dynamic_weight.d.ts.map +0 -1
- package/dist/analysis/analyze_dynamic_weight.js.map +0 -1
- package/dist/analysis/analyze_kalman.d.ts.map +0 -1
- package/dist/analysis/analyze_kalman.js.map +0 -1
- package/dist/analysis/analyze_regime.d.ts.map +0 -1
- package/dist/analysis/analyze_regime.js.map +0 -1
- package/dist/analysis/analyze_regime_windows.d.ts.map +0 -1
- package/dist/analysis/analyze_regime_windows.js.map +0 -1
- package/dist/analysis/analyze_risk_profile.d.ts.map +0 -1
- package/dist/analysis/analyze_risk_profile.js.map +0 -1
- package/dist/analysis/analyze_trade_heatmap.d.ts.map +0 -1
- package/dist/analysis/analyze_trade_heatmap.js.map +0 -1
- package/dist/analysis/analyze_volatility.d.ts.map +0 -1
- package/dist/analysis/analyze_volatility.js.map +0 -1
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts.map +0 -1
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js.map +0 -1
- package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts.map +0 -1
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js.map +0 -1
- package/dist/analysis/bot_fitting/shared_utils.d.ts.map +0 -1
- package/dist/analysis/bot_fitting/shared_utils.js.map +0 -1
- package/dist/analysis/bot_key_utils.d.ts.map +0 -1
- package/dist/analysis/bot_key_utils.js.map +0 -1
- package/dist/analysis/bot_usage/discover_bot_accounts.d.ts.map +0 -1
- package/dist/analysis/bot_usage/discover_bot_accounts.js.map +0 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +0 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.js.map +0 -1
- package/dist/analysis/chain_pool.d.ts.map +0 -1
- package/dist/analysis/chain_pool.js.map +0 -1
- package/dist/analysis/chart_css.d.ts.map +0 -1
- package/dist/analysis/chart_css.js.map +0 -1
- package/dist/analysis/chart_ui.d.ts.map +0 -1
- package/dist/analysis/chart_ui.js.map +0 -1
- package/dist/analysis/chart_utils.d.ts.map +0 -1
- package/dist/analysis/chart_utils.js.map +0 -1
- package/dist/analysis/fills_source.d.ts.map +0 -1
- package/dist/analysis/fills_source.js.map +0 -1
- package/dist/analysis/grid_correction_check.d.ts.map +0 -1
- package/dist/analysis/grid_correction_check.js.map +0 -1
- package/dist/analysis/math_utils.d.ts.map +0 -1
- package/dist/analysis/math_utils.js.map +0 -1
- package/dist/analysis/price_sources.d.ts.map +0 -1
- package/dist/analysis/price_sources.js.map +0 -1
- package/dist/analysis/resolve_bot_accounts.d.ts.map +0 -1
- package/dist/analysis/resolve_bot_accounts.js.map +0 -1
- package/dist/analysis/resolve_source.d.ts.map +0 -1
- package/dist/analysis/resolve_source.js.map +0 -1
- package/dist/analysis/trade_profitability.d.ts.map +0 -1
- package/dist/analysis/trade_profitability.js.map +0 -1
- package/dist/analysis/tradingview/analyze_tradingview.d.ts.map +0 -1
- package/dist/analysis/tradingview/analyze_tradingview.js.map +0 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +0 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/hurst_analyzer.d.ts.map +0 -1
- package/dist/analysis/trend_detection/hurst_analyzer.js.map +0 -1
- package/dist/analysis/trend_detection/kalman_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/kalman_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/kalman_trend_analyzer.d.ts.map +0 -1
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js.map +0 -1
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.d.ts.map +0 -1
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js.map +0 -1
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.d.ts.map +0 -1
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js.map +0 -1
- package/dist/analysis/trend_detection/regime_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/regime_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts +0 -2
- package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts.map +0 -1
- package/dist/analysis/trend_detection/tests/test_kalman_trend.js +0 -128
- package/dist/analysis/trend_detection/tests/test_kalman_trend.js.map +0 -1
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts +0 -2
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts.map +0 -1
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js +0 -37
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js.map +0 -1
- package/dist/analysis/trend_detection/volatility_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/volatility_chart_generator.js.map +0 -1
- package/dist/bot.d.ts.map +0 -1
- package/dist/bot.js.map +0 -1
- package/dist/credential-daemon.d.ts.map +0 -1
- package/dist/credential-daemon.js.map +0 -1
- package/dist/dexbot.d.ts.map +0 -1
- package/dist/dexbot.js.map +0 -1
- package/dist/market_adapter/ama_signal_runner.d.ts.map +0 -1
- package/dist/market_adapter/ama_signal_runner.js.map +0 -1
- package/dist/market_adapter/candle_utils.d.ts.map +0 -1
- package/dist/market_adapter/candle_utils.js.map +0 -1
- package/dist/market_adapter/core/asymmetric_bounds.d.ts.map +0 -1
- package/dist/market_adapter/core/asymmetric_bounds.js.map +0 -1
- package/dist/market_adapter/core/config_normalizers.d.ts.map +0 -1
- package/dist/market_adapter/core/config_normalizers.js.map +0 -1
- package/dist/market_adapter/core/kibana_candles.d.ts.map +0 -1
- package/dist/market_adapter/core/kibana_candles.js.map +0 -1
- package/dist/market_adapter/core/kibana_client.d.ts.map +0 -1
- package/dist/market_adapter/core/kibana_client.js.map +0 -1
- package/dist/market_adapter/core/kibana_market_candles.d.ts.map +0 -1
- package/dist/market_adapter/core/kibana_market_candles.js.map +0 -1
- package/dist/market_adapter/core/market_adapter_service.d.ts.map +0 -1
- package/dist/market_adapter/core/market_adapter_service.js.map +0 -1
- package/dist/market_adapter/core/signals/hurst_analyzer.d.ts.map +0 -1
- package/dist/market_adapter/core/signals/hurst_analyzer.js.map +0 -1
- package/dist/market_adapter/core/signals/kalman_trend_analyzer.d.ts.map +0 -1
- package/dist/market_adapter/core/signals/kalman_trend_analyzer.js.map +0 -1
- package/dist/market_adapter/core/signals/kalman_velocity_smoothing.d.ts.map +0 -1
- package/dist/market_adapter/core/signals/kalman_velocity_smoothing.js.map +0 -1
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts.map +0 -1
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js.map +0 -1
- package/dist/market_adapter/core/strategies/ama.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/ama.js.map +0 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.js.map +0 -1
- package/dist/market_adapter/core/strategies/atr/calculator.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/atr/calculator.js.map +0 -1
- package/dist/market_adapter/core/strategies/collateral_manager.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/collateral_manager.js.map +0 -1
- package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/dynamic_weight_series.js.map +0 -1
- package/dist/market_adapter/core/strategies/regime_gate.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/regime_gate.js.map +0 -1
- package/dist/market_adapter/core/strategies/regime_interp.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/regime_interp.js.map +0 -1
- package/dist/market_adapter/core/strategies/volatility_shift.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/volatility_shift.js.map +0 -1
- package/dist/market_adapter/inputs/fetch_book_data.d.ts.map +0 -1
- package/dist/market_adapter/inputs/fetch_book_data.js.map +0 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.d.ts.map +0 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +0 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +0 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +0 -1
- package/dist/market_adapter/inputs/kibana_feed_source.d.ts.map +0 -1
- package/dist/market_adapter/inputs/kibana_feed_source.js.map +0 -1
- package/dist/market_adapter/inputs/kibana_source.d.ts.map +0 -1
- package/dist/market_adapter/inputs/kibana_source.js.map +0 -1
- package/dist/market_adapter/inputs/window_cache.d.ts.map +0 -1
- package/dist/market_adapter/inputs/window_cache.js.map +0 -1
- package/dist/market_adapter/interval_utils.d.ts.map +0 -1
- package/dist/market_adapter/interval_utils.js.map +0 -1
- package/dist/market_adapter/log_format.d.ts.map +0 -1
- package/dist/market_adapter/log_format.js.map +0 -1
- package/dist/market_adapter/lp_chart_core.d.ts.map +0 -1
- package/dist/market_adapter/lp_chart_core.js.map +0 -1
- package/dist/market_adapter/lp_chart_runner.d.ts.map +0 -1
- package/dist/market_adapter/lp_chart_runner.js.map +0 -1
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts.map +0 -1
- package/dist/market_adapter/lp_chart_strategy_loader.js.map +0 -1
- package/dist/market_adapter/market_adapter.d.ts.map +0 -1
- package/dist/market_adapter/market_adapter.js.map +0 -1
- package/dist/market_adapter/test_helpers.d.ts.map +0 -1
- package/dist/market_adapter/test_helpers.js.map +0 -1
- package/dist/market_adapter/utils/adapter_client.d.ts.map +0 -1
- package/dist/market_adapter/utils/adapter_client.js.map +0 -1
- package/dist/market_adapter/utils/atomic_write.d.ts.map +0 -1
- package/dist/market_adapter/utils/atomic_write.js.map +0 -1
- package/dist/market_adapter/utils/chain.d.ts.map +0 -1
- package/dist/market_adapter/utils/chain.js.map +0 -1
- package/dist/market_adapter/utils/data_discovery.d.ts.map +0 -1
- package/dist/market_adapter/utils/data_discovery.js.map +0 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +0 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +0 -1
- package/dist/market_adapter/utils/file_lock.d.ts.map +0 -1
- package/dist/market_adapter/utils/file_lock.js.map +0 -1
- package/dist/market_adapter/utils/native_history.d.ts.map +0 -1
- package/dist/market_adapter/utils/native_history.js.map +0 -1
- package/dist/modules/account_bots.d.ts.map +0 -1
- package/dist/modules/account_bots.js.map +0 -1
- package/dist/modules/account_orders.d.ts.map +0 -1
- package/dist/modules/account_orders.js.map +0 -1
- package/dist/modules/authority_resolver.d.ts.map +0 -1
- package/dist/modules/authority_resolver.js.map +0 -1
- package/dist/modules/bitshares-native/chain_client.d.ts.map +0 -1
- package/dist/modules/bitshares-native/chain_client.js.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc.d.ts.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc.js.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.js.map +0 -1
- package/dist/modules/bitshares-native/index.d.ts.map +0 -1
- package/dist/modules/bitshares-native/index.js.map +0 -1
- package/dist/modules/bitshares-native/lru_cache.d.ts.map +0 -1
- package/dist/modules/bitshares-native/lru_cache.js.map +0 -1
- package/dist/modules/bitshares-native/resolvers.d.ts.map +0 -1
- package/dist/modules/bitshares-native/resolvers.js.map +0 -1
- package/dist/modules/bitshares-native/serial/chain_constants.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/chain_constants.js.map +0 -1
- package/dist/modules/bitshares-native/serial/index.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/index.js.map +0 -1
- package/dist/modules/bitshares-native/serial/operations.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/operations.js.map +0 -1
- package/dist/modules/bitshares-native/serial/serializer.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/serializer.js.map +0 -1
- package/dist/modules/bitshares-native/serial/types.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/types.js.map +0 -1
- package/dist/modules/bitshares-native/signing_client.d.ts.map +0 -1
- package/dist/modules/bitshares-native/signing_client.js.map +0 -1
- package/dist/modules/bitshares-native/subscriptions.d.ts.map +0 -1
- package/dist/modules/bitshares-native/subscriptions.js.map +0 -1
- package/dist/modules/bitshares-native/transport.d.ts.map +0 -1
- package/dist/modules/bitshares-native/transport.js.map +0 -1
- package/dist/modules/bitshares-native/tx/builder.d.ts.map +0 -1
- package/dist/modules/bitshares-native/tx/builder.js.map +0 -1
- package/dist/modules/bitshares-native/tx/tx_cache.d.ts.map +0 -1
- package/dist/modules/bitshares-native/tx/tx_cache.js.map +0 -1
- package/dist/modules/bitshares_client.d.ts.map +0 -1
- package/dist/modules/bitshares_client.js.map +0 -1
- package/dist/modules/bot_defaults.d.ts.map +0 -1
- package/dist/modules/bot_defaults.js.map +0 -1
- package/dist/modules/bot_settings.d.ts.map +0 -1
- package/dist/modules/bot_settings.js.map +0 -1
- package/dist/modules/bots_file_lock.d.ts.map +0 -1
- package/dist/modules/bots_file_lock.js.map +0 -1
- package/dist/modules/broadcast_failure.d.ts.map +0 -1
- package/dist/modules/broadcast_failure.js.map +0 -1
- package/dist/modules/chain_keys.d.ts.map +0 -1
- package/dist/modules/chain_keys.js.map +0 -1
- package/dist/modules/chain_orders.d.ts.map +0 -1
- package/dist/modules/chain_orders.js.map +0 -1
- package/dist/modules/cli_colors.d.ts.map +0 -1
- package/dist/modules/cli_colors.js.map +0 -1
- package/dist/modules/cli_start_onboarding.d.ts.map +0 -1
- package/dist/modules/cli_start_onboarding.js.map +0 -1
- package/dist/modules/cli_start_output.d.ts.map +0 -1
- package/dist/modules/cli_start_output.js.map +0 -1
- package/dist/modules/config.d.ts.map +0 -1
- package/dist/modules/config.js.map +0 -1
- package/dist/modules/constants.d.ts.map +0 -1
- package/dist/modules/constants.js.map +0 -1
- package/dist/modules/cr_planner.d.ts.map +0 -1
- package/dist/modules/cr_planner.js.map +0 -1
- package/dist/modules/credential_policy.d.ts.map +0 -1
- package/dist/modules/credential_policy.js.map +0 -1
- package/dist/modules/credential_runtime.d.ts.map +0 -1
- package/dist/modules/credential_runtime.js.map +0 -1
- package/dist/modules/credential_session_cache.d.ts.map +0 -1
- package/dist/modules/credential_session_cache.js.map +0 -1
- package/dist/modules/credit_pricing.d.ts.map +0 -1
- package/dist/modules/credit_pricing.js.map +0 -1
- package/dist/modules/credit_runtime.d.ts.map +0 -1
- package/dist/modules/credit_runtime.js.map +0 -1
- package/dist/modules/crypto/browser_provider.d.ts.map +0 -1
- package/dist/modules/crypto/browser_provider.js.map +0 -1
- package/dist/modules/crypto/index.d.ts.map +0 -1
- package/dist/modules/crypto/index.js.map +0 -1
- package/dist/modules/crypto/node_provider.d.ts.map +0 -1
- package/dist/modules/crypto/node_provider.js.map +0 -1
- package/dist/modules/crypto/provider.d.ts.map +0 -1
- package/dist/modules/crypto/provider.js.map +0 -1
- package/dist/modules/crypto/pure_ripemd160.d.ts.map +0 -1
- package/dist/modules/crypto/pure_ripemd160.js.map +0 -1
- package/dist/modules/crypto/pure_scrypt.d.ts.map +0 -1
- package/dist/modules/crypto/pure_scrypt.js.map +0 -1
- package/dist/modules/crypto/pure_secp256k1.d.ts.map +0 -1
- package/dist/modules/crypto/pure_secp256k1.js.map +0 -1
- package/dist/modules/crypto/sync.d.ts.map +0 -1
- package/dist/modules/crypto/sync.js.map +0 -1
- package/dist/modules/daemon_node_health.d.ts.map +0 -1
- package/dist/modules/daemon_node_health.js.map +0 -1
- package/dist/modules/dexbot_class.d.ts.map +0 -1
- package/dist/modules/dexbot_class.js.map +0 -1
- package/dist/modules/dexbot_cow_runtime.d.ts.map +0 -1
- package/dist/modules/dexbot_cow_runtime.js.map +0 -1
- package/dist/modules/dexbot_credential_client.d.ts.map +0 -1
- package/dist/modules/dexbot_credential_client.js.map +0 -1
- package/dist/modules/dexbot_fill_runtime.d.ts.map +0 -1
- package/dist/modules/dexbot_fill_runtime.js.map +0 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +0 -1
- package/dist/modules/dexbot_maintenance_runtime.js.map +0 -1
- package/dist/modules/dexbot_startup_runtime.d.ts.map +0 -1
- package/dist/modules/dexbot_startup_runtime.js.map +0 -1
- package/dist/modules/dexbot_state_recovery.d.ts.map +0 -1
- package/dist/modules/dexbot_state_recovery.js.map +0 -1
- package/dist/modules/env.d.ts.map +0 -1
- package/dist/modules/env.js.map +0 -1
- package/dist/modules/fund_registry.d.ts.map +0 -1
- package/dist/modules/fund_registry.js.map +0 -1
- package/dist/modules/general_settings.d.ts.map +0 -1
- package/dist/modules/general_settings.js.map +0 -1
- package/dist/modules/graceful_shutdown.d.ts.map +0 -1
- package/dist/modules/graceful_shutdown.js.map +0 -1
- package/dist/modules/grid_price_source.d.ts.map +0 -1
- package/dist/modules/grid_price_source.js.map +0 -1
- package/dist/modules/key_store.d.ts.map +0 -1
- package/dist/modules/key_store.js.map +0 -1
- package/dist/modules/launcher/adapter_requirement.d.ts.map +0 -1
- package/dist/modules/launcher/adapter_requirement.js.map +0 -1
- package/dist/modules/launcher/bot_supervisor.d.ts.map +0 -1
- package/dist/modules/launcher/bot_supervisor.js.map +0 -1
- package/dist/modules/launcher/child_env.d.ts.map +0 -1
- package/dist/modules/launcher/child_env.js.map +0 -1
- package/dist/modules/launcher/credential_bootstrap.d.ts.map +0 -1
- package/dist/modules/launcher/credential_bootstrap.js.map +0 -1
- package/dist/modules/launcher/credential_daemon.d.ts.map +0 -1
- package/dist/modules/launcher/credential_daemon.js.map +0 -1
- package/dist/modules/launcher/credential_secret.d.ts.map +0 -1
- package/dist/modules/launcher/credential_secret.js.map +0 -1
- package/dist/modules/launcher/foreign_cred_daemon.d.ts.map +0 -1
- package/dist/modules/launcher/foreign_cred_daemon.js.map +0 -1
- package/dist/modules/launcher/headless_password.d.ts.map +0 -1
- package/dist/modules/launcher/headless_password.js.map +0 -1
- package/dist/modules/launcher/launch_modes.d.ts.map +0 -1
- package/dist/modules/launcher/launch_modes.js.map +0 -1
- package/dist/modules/launcher/market_adapter_runtime.d.ts.map +0 -1
- package/dist/modules/launcher/market_adapter_runtime.js.map +0 -1
- package/dist/modules/launcher/market_adapter_watchdog.d.ts.map +0 -1
- package/dist/modules/launcher/market_adapter_watchdog.js.map +0 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts.map +0 -1
- package/dist/modules/launcher/monolithic_runtime.js.map +0 -1
- package/dist/modules/launcher/runtime_entry.d.ts.map +0 -1
- package/dist/modules/launcher/runtime_entry.js.map +0 -1
- package/dist/modules/launcher/status_reporting.d.ts.map +0 -1
- package/dist/modules/launcher/status_reporting.js.map +0 -1
- package/dist/modules/launcher/supervisor_control.d.ts.map +0 -1
- package/dist/modules/launcher/supervisor_control.js.map +0 -1
- package/dist/modules/market_adapter_whitelist.d.ts.map +0 -1
- package/dist/modules/market_adapter_whitelist.js.map +0 -1
- package/dist/modules/node_connect_policy.d.ts.map +0 -1
- package/dist/modules/node_connect_policy.js.map +0 -1
- package/dist/modules/node_failure_ledger.d.ts.map +0 -1
- package/dist/modules/node_failure_ledger.js.map +0 -1
- package/dist/modules/node_health_cache.d.ts.map +0 -1
- package/dist/modules/node_health_cache.js.map +0 -1
- package/dist/modules/node_manager.d.ts.map +0 -1
- package/dist/modules/node_manager.js.map +0 -1
- package/dist/modules/order/accounting.d.ts.map +0 -1
- package/dist/modules/order/accounting.js.map +0 -1
- package/dist/modules/order/async_lock.d.ts.map +0 -1
- package/dist/modules/order/async_lock.js.map +0 -1
- package/dist/modules/order/export.d.ts.map +0 -1
- package/dist/modules/order/export.js.map +0 -1
- package/dist/modules/order/format.d.ts.map +0 -1
- package/dist/modules/order/format.js.map +0 -1
- package/dist/modules/order/grid.d.ts.map +0 -1
- package/dist/modules/order/grid.js.map +0 -1
- package/dist/modules/order/grid_reconcile.d.ts.map +0 -1
- package/dist/modules/order/grid_reconcile.js.map +0 -1
- package/dist/modules/order/grid_reconcile_internal.d.ts.map +0 -1
- package/dist/modules/order/grid_reconcile_internal.js.map +0 -1
- package/dist/modules/order/index.d.ts.map +0 -1
- package/dist/modules/order/index.js.map +0 -1
- package/dist/modules/order/logger.d.ts.map +0 -1
- package/dist/modules/order/logger.js.map +0 -1
- package/dist/modules/order/logger_state.d.ts.map +0 -1
- package/dist/modules/order/logger_state.js.map +0 -1
- package/dist/modules/order/manager.d.ts.map +0 -1
- package/dist/modules/order/manager.js.map +0 -1
- package/dist/modules/order/processed_fill_store.d.ts.map +0 -1
- package/dist/modules/order/processed_fill_store.js.map +0 -1
- package/dist/modules/order/strategy.d.ts.map +0 -1
- package/dist/modules/order/strategy.js.map +0 -1
- package/dist/modules/order/sync_engine.d.ts.map +0 -1
- package/dist/modules/order/sync_engine.js.map +0 -1
- package/dist/modules/order/utils/math.d.ts.map +0 -1
- package/dist/modules/order/utils/math.js.map +0 -1
- package/dist/modules/order/utils/order.d.ts.map +0 -1
- package/dist/modules/order/utils/order.js.map +0 -1
- package/dist/modules/order/utils/slot.d.ts.map +0 -1
- package/dist/modules/order/utils/slot.js.map +0 -1
- package/dist/modules/order/utils/system.d.ts.map +0 -1
- package/dist/modules/order/utils/system.js.map +0 -1
- package/dist/modules/order/utils/timeout.d.ts.map +0 -1
- package/dist/modules/order/utils/timeout.js.map +0 -1
- package/dist/modules/order/utils/validate.d.ts.map +0 -1
- package/dist/modules/order/utils/validate.js.map +0 -1
- package/dist/modules/order/utils/withPoolRef.d.ts.map +0 -1
- package/dist/modules/order/utils/withPoolRef.js.map +0 -1
- package/dist/modules/order/working_grid.d.ts.map +0 -1
- package/dist/modules/order/working_grid.js.map +0 -1
- package/dist/modules/path_api.d.ts.map +0 -1
- package/dist/modules/path_api.js.map +0 -1
- package/dist/modules/paths.d.ts.map +0 -1
- package/dist/modules/paths.js.map +0 -1
- package/dist/modules/process_discovery.d.ts.map +0 -1
- package/dist/modules/process_discovery.js.map +0 -1
- package/dist/modules/runtime.d.ts.map +0 -1
- package/dist/modules/runtime.js.map +0 -1
- package/dist/modules/runtime_settings.d.ts.map +0 -1
- package/dist/modules/runtime_settings.js.map +0 -1
- package/dist/modules/settings_merge.d.ts.map +0 -1
- package/dist/modules/settings_merge.js.map +0 -1
- package/dist/modules/socket_json_client.d.ts.map +0 -1
- package/dist/modules/socket_json_client.js.map +0 -1
- package/dist/modules/storage/browser_adapter.d.ts.map +0 -1
- package/dist/modules/storage/browser_adapter.js.map +0 -1
- package/dist/modules/storage/index.d.ts.map +0 -1
- package/dist/modules/storage/index.js.map +0 -1
- package/dist/modules/storage/node_adapter.d.ts.map +0 -1
- package/dist/modules/storage/node_adapter.js.map +0 -1
- package/dist/modules/storage/types.d.ts.map +0 -1
- package/dist/modules/storage/types.js.map +0 -1
- package/dist/modules/types.d.ts.map +0 -1
- package/dist/modules/types.js.map +0 -1
- package/dist/modules/utils/base58check.d.ts.map +0 -1
- package/dist/modules/utils/base58check.js.map +0 -1
- package/dist/modules/utils/build_dir.d.ts.map +0 -1
- package/dist/modules/utils/build_dir.js.map +0 -1
- package/dist/modules/utils/chain_logs.d.ts.map +0 -1
- package/dist/modules/utils/chain_logs.js.map +0 -1
- package/dist/modules/utils/errors.d.ts.map +0 -1
- package/dist/modules/utils/errors.js.map +0 -1
- package/dist/modules/utils/sanitize_key.d.ts.map +0 -1
- package/dist/modules/utils/sanitize_key.js.map +0 -1
- package/dist/modules/utils/text_width.d.ts.map +0 -1
- package/dist/modules/utils/text_width.js.map +0 -1
- package/dist/modules/validate_profiles.d.ts.map +0 -1
- package/dist/modules/validate_profiles.js.map +0 -1
- package/dist/pm2.d.ts.map +0 -1
- package/dist/pm2.js.map +0 -1
- package/dist/scripts/analyze-credit.d.ts.map +0 -1
- package/dist/scripts/analyze-credit.js.map +0 -1
- package/dist/scripts/analyze-git.d.ts.map +0 -1
- package/dist/scripts/analyze-git.js.map +0 -1
- package/dist/scripts/analyze-orders.d.ts.map +0 -1
- package/dist/scripts/analyze-orders.js.map +0 -1
- package/dist/scripts/chart_command.d.ts.map +0 -1
- package/dist/scripts/chart_command.js.map +0 -1
- package/dist/scripts/diagnose-kibana-candles.d.ts.map +0 -1
- package/dist/scripts/diagnose-kibana-candles.js.map +0 -1
- package/dist/scripts/diagnose-pool-history.d.ts.map +0 -1
- package/dist/scripts/diagnose-pool-history.js.map +0 -1
- package/dist/scripts/divergence-calc.d.ts.map +0 -1
- package/dist/scripts/divergence-calc.js.map +0 -1
- package/dist/scripts/dw.d.ts.map +0 -1
- package/dist/scripts/dw.js.map +0 -1
- package/dist/scripts/generate_lp_chart.d.ts.map +0 -1
- package/dist/scripts/generate_lp_chart.js.map +0 -1
- package/dist/scripts/generate_mainnet_corpus_report.d.ts.map +0 -1
- package/dist/scripts/generate_mainnet_corpus_report.js.map +0 -1
- package/dist/scripts/native_release_gates.d.ts.map +0 -1
- package/dist/scripts/native_release_gates.js.map +0 -1
- package/dist/scripts/print_grid.d.ts.map +0 -1
- package/dist/scripts/print_grid.js.map +0 -1
- package/dist/scripts/run-tests.d.ts.map +0 -1
- package/dist/scripts/run-tests.js.map +0 -1
- package/dist/scripts/runner.d.ts.map +0 -1
- package/dist/scripts/runner.js.map +0 -1
- package/dist/scripts/sync-version.d.ts.map +0 -1
- package/dist/scripts/sync-version.js.map +0 -1
- package/dist/scripts/test-credit-renewal.d.ts.map +0 -1
- package/dist/scripts/test-credit-renewal.js.map +0 -1
- package/dist/scripts/tv.d.ts.map +0 -1
- package/dist/scripts/tv.js.map +0 -1
- package/dist/scripts/update.d.ts.map +0 -1
- package/dist/scripts/update.js.map +0 -1
- package/dist/scripts/update_dist_freshness.d.ts.map +0 -1
- package/dist/scripts/update_dist_freshness.js.map +0 -1
- package/dist/scripts/validate_bots.d.ts.map +0 -1
- package/dist/scripts/validate_bots.js.map +0 -1
- package/dist/scripts/verify-browser-bundle.d.ts.map +0 -1
- package/dist/scripts/verify-browser-bundle.js.map +0 -1
- package/dist/unlock.d.ts.map +0 -1
- package/dist/unlock.js.map +0 -1
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { calculateAMA } from '../../market_adapter/core/strategies/ama.js';
|
|
5
|
-
import { getStorage } from '../../modules/storage/index.js';
|
|
6
|
-
const { readJSON } = getStorage();
|
|
7
|
-
import { normalizeCandle } from '../math_utils.js';
|
|
8
|
-
import { MARKET_ADAPTER } from '../../modules/constants.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* AMA REPOSITION FREQUENCY ANALYSIS
|
|
12
|
-
*
|
|
13
|
-
* Simulates AMA_DELTA_THRESHOLD_PERCENT grid-reposition logic for all four AMA
|
|
14
|
-
* series on LP candle data.
|
|
15
|
-
*
|
|
16
|
-
* Uses the production threshold from MARKET_ADAPTER.AMA_DELTA_THRESHOLD_PERCENT
|
|
17
|
-
* (modules/constants.ts).
|
|
18
|
-
*
|
|
19
|
-
* Usage:
|
|
20
|
-
* node dist/analysis/ama_fitting/analyze_ama_price_changes.js --data <path-to-lp-candles.json> --results <path-to-optimization-results.json>
|
|
21
|
-
*/
|
|
22
|
-
const REPOS_THRESHOLD_PCT = MARKET_ADAPTER.AMA_DELTA_THRESHOLD_PERCENT;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Simulate AMA_DELTA_THRESHOLD_PERCENT reposition logic.
|
|
26
|
-
*
|
|
27
|
-
* Starting from the first post-warmup AMA value, track cumulative drift from
|
|
28
|
-
* the last reposition baseline. When drift ≥ threshold, a reposition fires:
|
|
29
|
-
* record step-count since previous reposition, reset baseline to current AMA.
|
|
30
|
-
*/
|
|
31
|
-
function trackRepositions(amaValues: any, thresholdPct: any, warmup: any) {
|
|
32
|
-
let events = 0;
|
|
33
|
-
const steps: number[] = [];
|
|
34
|
-
let baseline = amaValues[warmup];
|
|
35
|
-
let stepCounter = 0;
|
|
36
|
-
for (let i = warmup + 1; i < amaValues.length; i++) {
|
|
37
|
-
const curr = amaValues[i];
|
|
38
|
-
if (baseline === 0) continue;
|
|
39
|
-
stepCounter++;
|
|
40
|
-
const driftPct = Math.abs((curr - baseline) / baseline) * 100;
|
|
41
|
-
if (driftPct >= thresholdPct) {
|
|
42
|
-
events++;
|
|
43
|
-
steps.push(stepCounter);
|
|
44
|
-
baseline = curr;
|
|
45
|
-
stepCounter = 0;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
const min = steps.length > 0 ? Math.min(...steps) : 0;
|
|
49
|
-
const max = steps.length > 0 ? Math.max(...steps) : 0;
|
|
50
|
-
const avg = steps.length > 0 ? steps.reduce((a, b) => a + b, 0) / steps.length : 0;
|
|
51
|
-
return { events, steps, min, max, avg };
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// ── Load data ─────────────────────────────────────────────────────────────────
|
|
55
|
-
function loadData(filePath: any) {
|
|
56
|
-
const json = readJSON(filePath);
|
|
57
|
-
const candles = json.candles ?? json;
|
|
58
|
-
return {
|
|
59
|
-
candles: candles
|
|
60
|
-
.map((c: any) => normalizeCandle(c))
|
|
61
|
-
.filter(Boolean)
|
|
62
|
-
.map((c: any) => ({ timestamp: c.time * 1000, close: c.close })),
|
|
63
|
-
meta: json.meta ?? null,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
function loadAmaParams(resultsPath: any) {
|
|
67
|
-
const json = readJSON(resultsPath);
|
|
68
|
-
const amas = json.meta?.amas;
|
|
69
|
-
if (!amas) throw new Error('No amas found in results file');
|
|
70
|
-
return [
|
|
71
|
-
{ key: 'AMA1', label: amas.AMA1.label, er: amas.AMA1.er, fast: amas.AMA1.fast, slow: amas.AMA1.slow },
|
|
72
|
-
{ key: 'AMA2', label: amas.AMA2.label, er: amas.AMA2.er, fast: amas.AMA2.fast, slow: amas.AMA2.slow },
|
|
73
|
-
{ key: 'AMA3', label: amas.AMA3.label, er: amas.AMA3.er, fast: amas.AMA3.fast, slow: amas.AMA3.slow },
|
|
74
|
-
{ key: 'AMA4', label: amas.AMA4.label, er: amas.AMA4.er, fast: amas.AMA4.fast, slow: amas.AMA4.slow },
|
|
75
|
-
];
|
|
76
|
-
}
|
|
77
|
-
// ── Analysis ──────────────────────────────────────────────────────────────────
|
|
78
|
-
|
|
79
|
-
// ── Main ──────────────────────────────────────────────────────────────────────
|
|
80
|
-
function run() {
|
|
81
|
-
const dataArgIdx = process.argv.indexOf('--data');
|
|
82
|
-
const resultsArgIdx = process.argv.indexOf('--results');
|
|
83
|
-
if (dataArgIdx === -1) {
|
|
84
|
-
throw new Error('--data <path-to-lp-candles.json> is required');
|
|
85
|
-
}
|
|
86
|
-
if (resultsArgIdx === -1) {
|
|
87
|
-
throw new Error('--results <path-to-optimization-results.json> is required');
|
|
88
|
-
}
|
|
89
|
-
const dataFile = path.resolve(process.argv[dataArgIdx + 1]);
|
|
90
|
-
const resultsFile = path.resolve(process.argv[resultsArgIdx + 1]);
|
|
91
|
-
const { candles, meta } = loadData(dataFile);
|
|
92
|
-
const amaParams = loadAmaParams(resultsFile);
|
|
93
|
-
const closes = candles.map((c: any) => c.close);
|
|
94
|
-
const totalSteps = closes.length - 1; // candle-to-candle transitions
|
|
95
|
-
const label = meta?.pool
|
|
96
|
-
? `LP Pool ${meta.pool}`
|
|
97
|
-
: path.basename(dataFile, '.json');
|
|
98
|
-
const interval = meta?.intervalSeconds
|
|
99
|
-
? `${meta.intervalSeconds / 3600}h`
|
|
100
|
-
: '?h';
|
|
101
|
-
console.log('');
|
|
102
|
-
console.log('════════════════════════════════════════════════════════════════════════════════');
|
|
103
|
-
console.log(' AMA Reposition Frequency Analysis (AMA_DELTA_THRESHOLD_PERCENT simulation)');
|
|
104
|
-
console.log('════════════════════════════════════════════════════════════════════════════════');
|
|
105
|
-
console.log(` Dataset: ${label} (${interval} candles)`);
|
|
106
|
-
console.log(` Candles: ${candles.length} → ${totalSteps} steps total`);
|
|
107
|
-
console.log(` Threshold: ${REPOS_THRESHOLD_PCT}% (from MARKET_ADAPTER.AMA_DELTA_THRESHOLD_PERCENT)`);
|
|
108
|
-
console.log('');
|
|
109
|
-
console.log(' Logic: set baseline at warmup end, count steps until AMA drifts ≥ threshold,');
|
|
110
|
-
console.log(' record reposition + reset baseline. Repeat for full live window.');
|
|
111
|
-
console.log('');
|
|
112
|
-
const results: any[] = [];
|
|
113
|
-
for (const params of amaParams) {
|
|
114
|
-
const values = calculateAMA(closes, {
|
|
115
|
-
erPeriod: params.er,
|
|
116
|
-
fastPeriod: params.fast,
|
|
117
|
-
slowPeriod: params.slow,
|
|
118
|
-
});
|
|
119
|
-
const r = trackRepositions(values, REPOS_THRESHOLD_PCT, params.er);
|
|
120
|
-
const liveSteps = totalSteps - params.er;
|
|
121
|
-
const freq = liveSteps > 0 ? (r.events / liveSteps * 1000).toFixed(1) : '–';
|
|
122
|
-
const avg = r.events > 0 ? r.avg.toFixed(1) : '–';
|
|
123
|
-
const suffix = String(params.label).replace(/^AMA\d\s*/i, '').replace(/^[-:\s]+/, '').trim();
|
|
124
|
-
const rowLabel = `${params.key} ${suffix}`;
|
|
125
|
-
console.log(` ── ${rowLabel} (warmup: ${params.er} live: ${liveSteps} steps) ──`);
|
|
126
|
-
console.log(` ≥${REPOS_THRESHOLD_PCT}% repositions: ${r.events} avg steps: ${avg} min: ${r.events > 0 ? r.min : '–'} max: ${r.events > 0 ? r.max : '–'} freq: ${freq}/1k steps`);
|
|
127
|
-
console.log('');
|
|
128
|
-
results.push({
|
|
129
|
-
label: rowLabel,
|
|
130
|
-
events: r.events,
|
|
131
|
-
avg: r.avg,
|
|
132
|
-
freq: liveSteps > 0 ? r.events / liveSteps * 1000 : 0,
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
console.log(' Note: warmup candles excluded (AMA initializes from SMA of the ER window).');
|
|
136
|
-
console.log('');
|
|
137
|
-
// ── Ranking: fewest repositions ────────────────────────────────────────────
|
|
138
|
-
results.sort((a, b) => a.events - b.events);
|
|
139
|
-
console.log(' Ranking — fewest repositions (least grid changes):');
|
|
140
|
-
console.log('');
|
|
141
|
-
console.log(' ' + '#'.padEnd(4) + 'AMA'.padEnd(20) + 'repositions'.padStart(12) + 'avg steps'.padStart(10) + ' /1000 steps');
|
|
142
|
-
console.log(' ' + '─'.repeat(4 + 20 + 12 + 10 + 12));
|
|
143
|
-
results.forEach((r, i) => {
|
|
144
|
-
console.log(
|
|
145
|
-
' ' +
|
|
146
|
-
String(i + 1).padEnd(4) +
|
|
147
|
-
r.label.padEnd(20) +
|
|
148
|
-
String(r.events).padStart(12) +
|
|
149
|
-
r.avg.toFixed(1).padStart(10) +
|
|
150
|
-
` ${r.freq.toFixed(1)}`
|
|
151
|
-
);
|
|
152
|
-
});
|
|
153
|
-
console.log('');
|
|
154
|
-
}
|
|
155
|
-
run();
|
|
@@ -1,404 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
import fs from 'node:fs';
|
|
5
|
-
import path from 'node:path';
|
|
6
|
-
import { pathToFileURL } from 'node:url';
|
|
7
|
-
import { calculateAMA } from '../../market_adapter/core/strategies/ama.js';
|
|
8
|
-
import { loadLpDataFile } from '../../market_adapter/lp_chart_runner.js';
|
|
9
|
-
import { ensureDir } from '../../modules/order/utils/system.js';
|
|
10
|
-
import { PATHS } from '../../modules/paths.js';
|
|
11
|
-
import { MARKET_ADAPTER } from '../../modules/constants.js';
|
|
12
|
-
import { getErrorMessage } from '../../modules/utils/errors.js';
|
|
13
|
-
import { uplotInlineTags } from '../chart_utils.js';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* LAMBDA vs SLOW ANALYSIS
|
|
17
|
-
*
|
|
18
|
-
* Fixes ER and Fast, then scans lambda values over a linear range.
|
|
19
|
-
* For each lambda, finds the optimal Slow period that minimizes
|
|
20
|
-
* score = amaMovementTotal + lambda * distanceTotal.
|
|
21
|
-
*
|
|
22
|
-
* The start lambda is derived from --maxSlow: finds the lambda at
|
|
23
|
-
* which the optimal slow first drops below maxSlow. Only --lambdaEnd
|
|
24
|
-
* needs to be set as the upper bound.
|
|
25
|
-
*
|
|
26
|
-
* Output: console table + interactive HTML chart (uPlot).
|
|
27
|
-
*
|
|
28
|
-
* Defaults: ER/Fast from MARKET_ADAPTER.AMAS.AMA1 (constants.ts).
|
|
29
|
-
*
|
|
30
|
-
* Usage:
|
|
31
|
-
* node dist/analysis/ama_fitting/analyze_lambda_vs_slow.js \
|
|
32
|
-
* --data market_adapter/data/lp/1_3_5537_1_3_0/lp_pool_133_1h_3y.json \
|
|
33
|
-
* --maxSlow 1000 --lambdaEnd 0.0045 --lambdaSteps 50
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const DEFAULT_ER = MARKET_ADAPTER.AMAS.AMA1.erPeriod;
|
|
39
|
-
const DEFAULT_FAST = MARKET_ADAPTER.AMAS.AMA1.fastPeriod;
|
|
40
|
-
|
|
41
|
-
// ── CLI ────────────────────────────────────────────────────────────────────────
|
|
42
|
-
|
|
43
|
-
function parseArgs(argv = process.argv.slice(2)) {
|
|
44
|
-
const out: {
|
|
45
|
-
dataFile: string | null;
|
|
46
|
-
fixEr: number;
|
|
47
|
-
fixFast: number;
|
|
48
|
-
maxSlow: number;
|
|
49
|
-
lambdaEnd: number;
|
|
50
|
-
lambdaSteps: number;
|
|
51
|
-
outFile: string | null;
|
|
52
|
-
} = {
|
|
53
|
-
dataFile: null,
|
|
54
|
-
fixEr: DEFAULT_ER,
|
|
55
|
-
fixFast: DEFAULT_FAST,
|
|
56
|
-
maxSlow: 1000,
|
|
57
|
-
lambdaEnd: 0.0045,
|
|
58
|
-
lambdaSteps: 50,
|
|
59
|
-
outFile: null,
|
|
60
|
-
};
|
|
61
|
-
for (let i = 0; i < argv.length; i++) {
|
|
62
|
-
const a = argv[i], v = argv[i + 1];
|
|
63
|
-
switch (a) {
|
|
64
|
-
case '--data': out.dataFile = v; i++; break;
|
|
65
|
-
case '--fixEr': out.fixEr = Number(v); i++; break;
|
|
66
|
-
case '--fixFast': out.fixFast = Number(v); i++; break;
|
|
67
|
-
case '--maxSlow': out.maxSlow = Number(v); i++; break;
|
|
68
|
-
case '--lambdaEnd': out.lambdaEnd = Number(v); i++; break;
|
|
69
|
-
case '--lambdaSteps': out.lambdaSteps = Math.floor(Number(v)); i++; break;
|
|
70
|
-
case '--out': case '--output': out.outFile = v; i++; break;
|
|
71
|
-
case '--help': case '-h': showHelp(); process.exit(0);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
if (!out.dataFile) throw new Error('--data <file> is required');
|
|
75
|
-
return out;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function showHelp() {
|
|
79
|
-
console.log(`
|
|
80
|
-
Lambda vs Slow Analysis
|
|
81
|
-
Fixes ER + Fast, varies lambda, finds optimal Slow per lambda.
|
|
82
|
-
Start lambda derived from --maxSlow; only --lambdaEnd is the upper bound.
|
|
83
|
-
|
|
84
|
-
Usage:
|
|
85
|
-
node dist/analysis/ama_fitting/analyze_lambda_vs_slow.js --data <lp-file.json> [options]
|
|
86
|
-
|
|
87
|
-
Options:
|
|
88
|
-
--data FILE LP candle JSON file (required)
|
|
89
|
-
--fixEr N Fixed ER period (default: ${DEFAULT_ER})
|
|
90
|
-
--fixFast N Fixed Fast period (default: ${DEFAULT_FAST})
|
|
91
|
-
--maxSlow N Max slow value; start lambda derived from it (default: 1000)
|
|
92
|
-
--lambdaEnd N End lambda / distanceWeight (default: 0.0045)
|
|
93
|
-
--lambdaSteps N Number of lambda steps (default: 50)
|
|
94
|
-
--output FILE Output HTML chart path (optional)
|
|
95
|
-
--help Show this help
|
|
96
|
-
`);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// ── Metrics ─────────────────────────────────────────────────────────────────────
|
|
100
|
-
|
|
101
|
-
function calcTotalAmaMovement(amaValues: any, erPeriod: any) {
|
|
102
|
-
const skip = erPeriod + 1;
|
|
103
|
-
let total = 0;
|
|
104
|
-
for (let i = skip + 1; i < amaValues.length; i++) {
|
|
105
|
-
total += Math.abs(amaValues[i] - amaValues[i - 1]) / amaValues[i - 1];
|
|
106
|
-
}
|
|
107
|
-
return total;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function calcTotalRelativeDistance(amaValues: any, candles: any, erPeriod: any) {
|
|
111
|
-
const skip = erPeriod + 1;
|
|
112
|
-
let total = 0;
|
|
113
|
-
for (let i = skip; i < candles.length; i++) {
|
|
114
|
-
const ama = amaValues[i];
|
|
115
|
-
total += Math.abs(candles[i].close - ama) / ama;
|
|
116
|
-
}
|
|
117
|
-
return total;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// ── Geometric range ─────────────────────────────────────────────────────────────
|
|
121
|
-
|
|
122
|
-
function geometricRange(min: any, max: any, count: any) {
|
|
123
|
-
const ratio = Math.pow(max / min, 1 / (count - 1));
|
|
124
|
-
const out: number[] = [];
|
|
125
|
-
for (let i = 0; i < count; i++) {
|
|
126
|
-
let v = min * Math.pow(ratio, i);
|
|
127
|
-
if (i === 0) v = min;
|
|
128
|
-
if (i === count - 1) v = max;
|
|
129
|
-
out.push(parseFloat(v.toFixed(10)));
|
|
130
|
-
}
|
|
131
|
-
return [...new Set(out)].sort((a, b) => a - b);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// ── Precompute (movement, distance) per slow ───────────────────────────────────
|
|
135
|
-
|
|
136
|
-
function precomputeMetrics(closes: any, candles: any, erPeriod: any, fastPeriod: any, slowValues: any) {
|
|
137
|
-
const cache: any[] = [];
|
|
138
|
-
for (const slow of slowValues) {
|
|
139
|
-
if (fastPeriod >= slow) continue;
|
|
140
|
-
const ama = calculateAMA(closes, { erPeriod, fastPeriod, slowPeriod: slow });
|
|
141
|
-
const movement = calcTotalAmaMovement(ama, erPeriod);
|
|
142
|
-
const distance = calcTotalRelativeDistance(ama, candles, erPeriod);
|
|
143
|
-
cache.push({ slow, movement, distance });
|
|
144
|
-
}
|
|
145
|
-
return cache;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function findBestForLambda(lambda: any, metricCache: any) {
|
|
149
|
-
let best: any = null;
|
|
150
|
-
for (const m of metricCache) {
|
|
151
|
-
const score = m.movement + lambda * m.distance;
|
|
152
|
-
if (!best || score < best.score) {
|
|
153
|
-
best = { slow: m.slow, movement: m.movement, distance: m.distance, score, lambda };
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
return best;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// ── Derive start lambda from maxSlow ───────────────────────────────────────────
|
|
160
|
-
// Binary search: find the smallest lambda where optimal slow < maxSlow.
|
|
161
|
-
|
|
162
|
-
function findStartLambda(metricCache: any, maxSlow: any, lambdaEnd: any) {
|
|
163
|
-
let lo = 0;
|
|
164
|
-
let hi = 1;
|
|
165
|
-
// Expand hi until the best slow drops below maxSlow
|
|
166
|
-
while ((findBestForLambda(hi, metricCache)?.slow ?? Infinity) >= maxSlow && hi < 1e6) hi *= 2;
|
|
167
|
-
if (hi >= 1e6) return null;
|
|
168
|
-
|
|
169
|
-
for (let i = 0; i < 60; i++) {
|
|
170
|
-
const mid = (lo + hi) / 2;
|
|
171
|
-
const best = findBestForLambda(mid, metricCache);
|
|
172
|
-
if (best && best.slow < maxSlow) hi = mid;
|
|
173
|
-
else lo = mid;
|
|
174
|
-
}
|
|
175
|
-
// When cache max equals maxSlow, hi converges near 0 — ensure a minimum gap
|
|
176
|
-
if (hi < lambdaEnd / 1e6) hi = lambdaEnd / 1000;
|
|
177
|
-
return hi;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// ── HTML Chart (λ → Slow) ──────────────────────────────────────────────────────
|
|
181
|
-
|
|
182
|
-
function generateChartHtml(results: any, metricCache: any, fixEr: any, fixFast: any, dataLabel: any, _chartOutPath: any) {
|
|
183
|
-
const xs = results.map((r: any) => r.lambda);
|
|
184
|
-
const ys = results.map((r: any) => r.slow);
|
|
185
|
-
const dist = results.map((r: any) => r.distance);
|
|
186
|
-
const move = results.map((r: any) => r.movement);
|
|
187
|
-
const cacheSlow = metricCache.map((m: any) => m.slow);
|
|
188
|
-
const cacheMove = metricCache.map((m: any) => m.movement);
|
|
189
|
-
|
|
190
|
-
const amaAnnotations = [
|
|
191
|
-
{ label: 'AMA1', lambda: 0.0031, slow: 62.1, color: '#ef5350' },
|
|
192
|
-
{ label: 'AMA2', lambda: 0.0025, slow: 72.0, color: '#fb8c00' },
|
|
193
|
-
{ label: 'AMA3', lambda: 0.00185, slow: 83.6, color: '#5c9ee6' },
|
|
194
|
-
{ label: 'AMA4', lambda: 0.0013, slow: 96.9, color: '#26a69a' },
|
|
195
|
-
].filter(a => a.lambda >= xs[0] && a.lambda <= xs[xs.length - 1]);
|
|
196
|
-
|
|
197
|
-
return `<!DOCTYPE html>
|
|
198
|
-
<html lang="en">
|
|
199
|
-
<head>
|
|
200
|
-
<meta charset="UTF-8">
|
|
201
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
202
|
-
<title>λ → Slow — ER=${fixEr} Fast=${fixFast}</title>
|
|
203
|
-
<style>
|
|
204
|
-
body { font-family: system-ui, sans-serif; margin: 20px; background: #1e1e2e; color: #cdd6f4; }
|
|
205
|
-
h1 { font-size: 16px; margin: 0 0 2px 0; }
|
|
206
|
-
.subtitle { color: #a6adc8; font-size: 12px; margin-bottom: 12px; }
|
|
207
|
-
.chart-wrap { background: #181825; padding: 20px; border-radius: 8px; display: inline-block; min-width: 1140px; }
|
|
208
|
-
.chart-row { display: flex; gap: 8px; flex-direction: column; }
|
|
209
|
-
.legend { display: flex; gap: 20px; margin: 10px 0; font-size: 12px; }
|
|
210
|
-
.legend-item { display: flex; align-items: center; gap: 4px; }
|
|
211
|
-
.legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
|
|
212
|
-
.legend-line { width: 16px; height: 2px; display: inline-block; }
|
|
213
|
-
</style>
|
|
214
|
-
</head>
|
|
215
|
-
<body>
|
|
216
|
-
<div class="chart-wrap">
|
|
217
|
-
<h1>λ (distanceWeight) Analysis</h1>
|
|
218
|
-
<div class="subtitle">${dataLabel} · ER=${fixEr} · Fast=${fixFast} · ${results.length} λ steps</div>
|
|
219
|
-
<div class="chart-row">
|
|
220
|
-
<div id="chart-slow"></div>
|
|
221
|
-
<div id="chart-dist"></div>
|
|
222
|
-
<div id="chart-compare"></div>
|
|
223
|
-
</div>
|
|
224
|
-
<div class="legend">
|
|
225
|
-
<span class="legend-item"><span class="legend-line" style="background:#26a69a"></span> Slow</span>
|
|
226
|
-
<span class="legend-item"><span class="legend-line" style="background:#fb8c00"></span> Movement (λ)</span>
|
|
227
|
-
<span class="legend-item"><span class="legend-line" style="background:#5c9ee6"></span> Movement (Slow)</span>
|
|
228
|
-
${amaAnnotations.map(a => `<span class="legend-item"><span class="legend-dot" style="background:${a.color}"></span> ${a.label}</span>`).join('\n')}
|
|
229
|
-
</div>
|
|
230
|
-
</div>
|
|
231
|
-
${uplotInlineTags()}
|
|
232
|
-
<script>
|
|
233
|
-
(function() {
|
|
234
|
-
const xs = ${JSON.stringify(xs)};
|
|
235
|
-
const slow = ${JSON.stringify(ys)};
|
|
236
|
-
const dist = ${JSON.stringify(dist)};
|
|
237
|
-
const move = ${JSON.stringify(move)};
|
|
238
|
-
const amaPts = ${JSON.stringify(amaAnnotations)};
|
|
239
|
-
const cacheSlow = ${JSON.stringify(cacheSlow)};
|
|
240
|
-
const cacheMove = ${JSON.stringify(cacheMove)};
|
|
241
|
-
const revSlow = slow.slice().reverse();
|
|
242
|
-
const revMove = move.slice().reverse();
|
|
243
|
-
const revDist = dist.slice().reverse();
|
|
244
|
-
|
|
245
|
-
const slowOpts = {
|
|
246
|
-
width: 1100, height: 440,
|
|
247
|
-
cursor: { drag: { x: true, y: true } },
|
|
248
|
-
select: { show: true },
|
|
249
|
-
legend: { show: true },
|
|
250
|
-
axes: [
|
|
251
|
-
{ label: "λ", stroke: "#cdd6f4", grid: { stroke: "rgba(205,214,244,0.06)" }, size: 50 },
|
|
252
|
-
{ label: "Slow Period", stroke: "#cdd6f4", grid: { stroke: "rgba(205,214,244,0.06)" }, size: 50 },
|
|
253
|
-
],
|
|
254
|
-
series: [
|
|
255
|
-
{ label: "λ" },
|
|
256
|
-
{ label: "Slow", stroke: "#26a69a", width: 2, fill: "rgba(38,166,154,0.06)", points: { show: false } },
|
|
257
|
-
],
|
|
258
|
-
scales: { x: { time: false }, y: { range: [10, null] } },
|
|
259
|
-
};
|
|
260
|
-
new uPlot(slowOpts, [xs, slow], document.getElementById('chart-slow'));
|
|
261
|
-
|
|
262
|
-
const moveOpts = {
|
|
263
|
-
width: 1100, height: 280,
|
|
264
|
-
cursor: { drag: { x: true, y: true } },
|
|
265
|
-
select: { show: true },
|
|
266
|
-
legend: { show: true },
|
|
267
|
-
axes: [
|
|
268
|
-
{ label: "λ", stroke: "#cdd6f4", grid: { stroke: "rgba(205,214,244,0.06)" }, size: 50 },
|
|
269
|
-
{ label: "AMA Movement (path length)", stroke: "#cdd6f4", grid: { stroke: "rgba(205,214,244,0.06)" }, size: 50 },
|
|
270
|
-
],
|
|
271
|
-
series: [
|
|
272
|
-
{ label: "λ" },
|
|
273
|
-
{ label: "Movement", stroke: "#fb8c00", width: 2, points: { show: false } },
|
|
274
|
-
],
|
|
275
|
-
scales: { x: { time: false }, y: { range: [0, null] } },
|
|
276
|
-
};
|
|
277
|
-
new uPlot(moveOpts, [xs, move], document.getElementById('chart-dist'));
|
|
278
|
-
|
|
279
|
-
try {
|
|
280
|
-
new uPlot({
|
|
281
|
-
width: 1100, height: 300,
|
|
282
|
-
cursor: { drag: { x: true, y: true } },
|
|
283
|
-
select: { show: true },
|
|
284
|
-
legend: { show: true },
|
|
285
|
-
axes: [
|
|
286
|
-
{ label: "Slow Period", stroke: "#cdd6f4", grid: { stroke: "rgba(205,214,244,0.06)" }, size: 50 },
|
|
287
|
-
{ label: "AMA Movement (path length)", stroke: "#cdd6f4", grid: { stroke: "rgba(205,214,244,0.06)" }, size: 50 },
|
|
288
|
-
],
|
|
289
|
-
series: [
|
|
290
|
-
{ label: "Slow" },
|
|
291
|
-
{ label: "Movement", stroke: "#5c9ee6", width: 2, points: { show: false } },
|
|
292
|
-
],
|
|
293
|
-
scales: { x: { time: false }, y: { range: [0, null] } },
|
|
294
|
-
}, [cacheSlow, cacheMove], document.getElementById('chart-compare'));
|
|
295
|
-
} catch(e) {
|
|
296
|
-
const el = document.getElementById('chart-compare');
|
|
297
|
-
el.textContent = 'Chart error: ' + e.message;
|
|
298
|
-
el.style.color = '#ef5350';
|
|
299
|
-
}
|
|
300
|
-
})();
|
|
301
|
-
</script>
|
|
302
|
-
</body>
|
|
303
|
-
</html>`;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// ── Main ────────────────────────────────────────────────────────────────────────
|
|
307
|
-
|
|
308
|
-
async function run() {
|
|
309
|
-
const cfg = parseArgs();
|
|
310
|
-
|
|
311
|
-
// Load data
|
|
312
|
-
const dataFile = cfg.dataFile!;
|
|
313
|
-
const loaded = loadLpDataFile(path.resolve(dataFile));
|
|
314
|
-
const candles = loaded.candleObjects;
|
|
315
|
-
const meta = loaded.meta;
|
|
316
|
-
const dataLabel = meta
|
|
317
|
-
? `LP Pool ${meta.pool} (${meta.assetA?.symbol || '?'}/${meta.assetB?.symbol || '?'})`
|
|
318
|
-
: path.basename(dataFile);
|
|
319
|
-
const closes = candles.map(c => c.close);
|
|
320
|
-
|
|
321
|
-
console.log('══════════════════════════════════════════════════════════');
|
|
322
|
-
console.log(' Lambda vs Slow Analysis');
|
|
323
|
-
console.log('══════════════════════════════════════════════════════════');
|
|
324
|
-
console.log(` Data: ${cfg.dataFile} (${candles.length} candles)`);
|
|
325
|
-
console.log(` Fixed: ER=${cfg.fixEr} Fast=${cfg.fixFast}`);
|
|
326
|
-
console.log(` MaxSlow: ${cfg.maxSlow}`);
|
|
327
|
-
console.log(` Lambda end: ${cfg.lambdaEnd} (${cfg.lambdaSteps} steps)`);
|
|
328
|
-
console.log('');
|
|
329
|
-
|
|
330
|
-
// Build internal slow range (geometric, extends past maxSlow)
|
|
331
|
-
const internalSlowMax = cfg.maxSlow;
|
|
332
|
-
const internalSlowCount = Math.max(200, Math.ceil(internalSlowMax / 2.5));
|
|
333
|
-
const slowValues = geometricRange(10, internalSlowMax, internalSlowCount);
|
|
334
|
-
|
|
335
|
-
// Precompute movement + distance per slow (once)
|
|
336
|
-
console.log(' Precomputing AMA metrics per slow value...');
|
|
337
|
-
const metricCache = precomputeMetrics(closes, candles, cfg.fixEr, cfg.fixFast, slowValues);
|
|
338
|
-
console.log(` Cached ${metricCache.length} slow profiles`);
|
|
339
|
-
|
|
340
|
-
// Derive start lambda from maxSlow
|
|
341
|
-
const lambdaStart = findStartLambda(metricCache, cfg.maxSlow, cfg.lambdaEnd);
|
|
342
|
-
if (lambdaStart === null) {
|
|
343
|
-
console.log(' Could not determine start lambda — maxSlow too low.');
|
|
344
|
-
process.exit(1);
|
|
345
|
-
}
|
|
346
|
-
if (lambdaStart >= cfg.lambdaEnd) {
|
|
347
|
-
console.log(` Start lambda (${lambdaStart.toFixed(6)}) >= end lambda (${cfg.lambdaEnd}) — increase --lambdaEnd or decrease --maxSlow.`);
|
|
348
|
-
process.exit(1);
|
|
349
|
-
}
|
|
350
|
-
console.log(` Derived start λ: ${lambdaStart.toFixed(6)} (optimal slow first drops below ${cfg.maxSlow})`);
|
|
351
|
-
|
|
352
|
-
// Verify start lambda produces slow ~= maxSlow
|
|
353
|
-
const checkStart = findBestForLambda(lambdaStart, metricCache)!;
|
|
354
|
-
console.log(` At start λ: slow=${checkStart.slow.toFixed(1)} (should be near ${cfg.maxSlow})\n`);
|
|
355
|
-
|
|
356
|
-
// Build geometric lambda range
|
|
357
|
-
const lambdaValues = geometricRange(lambdaStart, cfg.lambdaEnd, cfg.lambdaSteps);
|
|
358
|
-
|
|
359
|
-
// Score each lambda against the cache — no AMA recalculation
|
|
360
|
-
const results: any[] = [];
|
|
361
|
-
for (let idx = 0; idx < lambdaValues.length; idx++) {
|
|
362
|
-
const lambda = lambdaValues[idx];
|
|
363
|
-
const best = findBestForLambda(lambda, metricCache);
|
|
364
|
-
|
|
365
|
-
if (!best) {
|
|
366
|
-
console.log(` λ=${lambda.toFixed(6)} → NO VALID`);
|
|
367
|
-
continue;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
results.push(best);
|
|
371
|
-
|
|
372
|
-
const pct = ((idx + 1) / lambdaValues.length * 100).toFixed(0);
|
|
373
|
-
console.log(` [${pct}%] λ=${best.lambda.toFixed(6)} → slow=${best.slow.toFixed(1)} move=${best.movement.toFixed(4)} dist=${best.distance.toFixed(4)} score=${best.score.toFixed(4)}`);
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
console.log('\n═══ Summary ═══');
|
|
377
|
-
console.log(' λ (input) | Slow (output) | Movement | Distance | Score');
|
|
378
|
-
console.log(' ──────────────┼───────────────┼──────────┼──────────┼────────');
|
|
379
|
-
for (const r of results) {
|
|
380
|
-
console.log(` ${r.lambda.toFixed(8).padStart(12)} | ${r.slow.toFixed(1).padStart(13)} | ${r.movement.toFixed(4).padStart(8)} | ${r.distance.toFixed(4).padStart(8)} | ${r.score.toFixed(4).padStart(8)}`);
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
// Generate chart
|
|
384
|
-
const chartName = cfg.outFile || path.join(
|
|
385
|
-
PATHS.ANALYSIS.CHARTS_DIR,
|
|
386
|
-
`lambda_vs_slow_er${cfg.fixEr}_fast${cfg.fixFast}_${cfg.lambdaSteps}steps.html`
|
|
387
|
-
);
|
|
388
|
-
const chartPath = path.resolve(chartName);
|
|
389
|
-
ensureDir(path.dirname(chartPath));
|
|
390
|
-
const html = generateChartHtml(results, metricCache, cfg.fixEr, cfg.fixFast, dataLabel, chartPath);
|
|
391
|
-
fs.writeFileSync(chartPath, html, 'utf8');
|
|
392
|
-
console.log(`\n Chart: ${path.relative(process.cwd(), chartPath)}`);
|
|
393
|
-
console.log('');
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
397
|
-
run().catch(err => {
|
|
398
|
-
console.error('Fatal:', getErrorMessage(err));
|
|
399
|
-
process.exit(1);
|
|
400
|
-
});
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
export { parseArgs }
|
|
404
|
-
|