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,243 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* DYNAMIC WEIGHT RESEARCH TOOL
|
|
6
|
-
*
|
|
7
|
-
* Computes AMA slope + Kalman + Hurst + PE signals and generates an
|
|
8
|
-
* interactive HTML chart for researching dynamic weight parameters.
|
|
9
|
-
*
|
|
10
|
-
* Usage:
|
|
11
|
-
* node dist/analysis/analyze_dynamic_weight.js \
|
|
12
|
-
* --source json \
|
|
13
|
-
* --file market_adapter/data/lp/<path>/<to>/<lp-candles>.json
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import path from 'node:path';
|
|
17
|
-
import { KalmanTrendAnalyzer } from './trend_detection/kalman_trend_analyzer.js';
|
|
18
|
-
import { HurstAnalyzer } from './trend_detection/hurst_analyzer.js';
|
|
19
|
-
import { PermutationEntropyAnalyzer } from './trend_detection/permutation_entropy_analyzer.js';
|
|
20
|
-
import { generateHTML } from './trend_detection/dynamic_weight_chart_generator.js';
|
|
21
|
-
import { calculateAMA } from '../market_adapter/core/strategies/ama.js';
|
|
22
|
-
import { computeAmaSlopeWeights, createAmaSlopeClipTracker } from '../market_adapter/core/strategies/ama_slope_model.js';
|
|
23
|
-
import { MARKET_ADAPTER } from '../modules/constants.js';
|
|
24
|
-
import { PATHS } from '../modules/paths.js';
|
|
25
|
-
import { writeChartFile, toFileUrl } from './chart_utils.js';
|
|
26
|
-
import { getCandleClose } from './math_utils.js';
|
|
27
|
-
import { resolveSource, listAvailableBots, type SourceConfig } from './resolve_source.js';
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// AMA Slope weight calculation config — use DEFAULTS from market adapter
|
|
31
|
-
const AMA_WEIGHT_CONFIG = {
|
|
32
|
-
lookbackBars: MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_LOOKBACK_BARS,
|
|
33
|
-
amaMaxSlopePct: MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_MAX_SLOPE_PCT,
|
|
34
|
-
kalmanMaxSlopePct: MARKET_ADAPTER.DYNAMIC_WEIGHT_KALMAN_MAX_SLOPE_PCT,
|
|
35
|
-
neutralZonePct: MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_NEUTRAL_ZONE_PCT,
|
|
36
|
-
volatilityExponent: MARKET_ADAPTER.DYNAMIC_WEIGHT_VOLATILITY_EXPONENT,
|
|
37
|
-
volatilityScaleX: MARKET_ADAPTER.DYNAMIC_WEIGHT_VOLATILITY_SCALE_X_DEFAULT,
|
|
38
|
-
volatilityThreshold: MARKET_ADAPTER.DYNAMIC_WEIGHT_SYMMETRIC_SHIFT_THRESHOLD,
|
|
39
|
-
maxSlopeOffset: MARKET_ADAPTER.DYNAMIC_WEIGHT_ASYMMETRIC_OFFSET_CLAMP,
|
|
40
|
-
maxVolatilityOffset: MARKET_ADAPTER.DYNAMIC_WEIGHT_SYMMETRIC_SHIFT_CLAMP,
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// Kalman configuration
|
|
44
|
-
const KALMAN_CONFIG = {
|
|
45
|
-
rNoise: MARKET_ADAPTER.DYNAMIC_WEIGHT_KALMAN_R_NOISE_DEFAULT,
|
|
46
|
-
qTactical: MARKET_ADAPTER.DYNAMIC_WEIGHT_KALMAN_Q_TACTICAL_DEFAULT,
|
|
47
|
-
qModal: MARKET_ADAPTER.DYNAMIC_WEIGHT_KALMAN_Q_MODAL_DEFAULT,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// Regime analyzers configuration (Hurst + Permutation Entropy)
|
|
51
|
-
const { HURST_CONFIG, PE_CONFIG } = MARKET_ADAPTER;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
function parseArgs() {
|
|
55
|
-
const args = process.argv.slice(2);
|
|
56
|
-
const config: {
|
|
57
|
-
source: { type: string; config: SourceConfig };
|
|
58
|
-
chartFile: string;
|
|
59
|
-
title: string | null;
|
|
60
|
-
alpha: any;
|
|
61
|
-
gain: any;
|
|
62
|
-
dispWeight: any;
|
|
63
|
-
clipPct: any;
|
|
64
|
-
quiet: boolean;
|
|
65
|
-
listBots: boolean;
|
|
66
|
-
lookbackBars?: number;
|
|
67
|
-
dispScaleMinPct?: number;
|
|
68
|
-
amaEmaSpan?: number;
|
|
69
|
-
} = {
|
|
70
|
-
source: { type: 'market_adapter', config: { botKey: '' } },
|
|
71
|
-
chartFile: path.join(PATHS.ANALYSIS.CHARTS_DIR, 'dynamic_weight_chart.html'),
|
|
72
|
-
title: null,
|
|
73
|
-
alpha: MARKET_ADAPTER.DYNAMIC_WEIGHT_ALPHA,
|
|
74
|
-
gain: MARKET_ADAPTER.DYNAMIC_WEIGHT_GAIN,
|
|
75
|
-
dispWeight: MARKET_ADAPTER.DYNAMIC_WEIGHT_DW,
|
|
76
|
-
clipPct: MARKET_ADAPTER.DYNAMIC_WEIGHT_CLIP_PERCENTILE,
|
|
77
|
-
quiet: false,
|
|
78
|
-
listBots: false,
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
for (let i = 0; i < args.length; i++) {
|
|
82
|
-
const arg = args[i];
|
|
83
|
-
if (arg === '--source') config.source.type = args[++i];
|
|
84
|
-
else if (arg === '--bot-key') config.source.config.botKey = args[++i];
|
|
85
|
-
else if (arg === '--file') {
|
|
86
|
-
config.source.config.filePath = args[++i];
|
|
87
|
-
config.source.type = 'json';
|
|
88
|
-
}
|
|
89
|
-
else if (arg === '--chart') config.chartFile = args[++i];
|
|
90
|
-
else if (arg === '--title') config.title = args[++i] ?? null;
|
|
91
|
-
else if (arg === '--alpha') config.alpha = parseFloat(args[++i]);
|
|
92
|
-
else if (arg === '--gain') config.gain = parseFloat(args[++i]);
|
|
93
|
-
else if (arg === '--dw') config.dispWeight = parseFloat(args[++i]);
|
|
94
|
-
else if (arg === '--lb') config.lookbackBars = parseInt(args[++i], 10);
|
|
95
|
-
else if (arg === '--ema') config.amaEmaSpan = parseInt(args[++i], 10);
|
|
96
|
-
else if (arg === '--clip') config.clipPct = parseFloat(args[++i]);
|
|
97
|
-
else if (arg === '--list-bots') config.listBots = true;
|
|
98
|
-
else if (arg === '--quiet') config.quiet = true;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return config;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
async function main() {
|
|
105
|
-
try {
|
|
106
|
-
const config = parseArgs();
|
|
107
|
-
|
|
108
|
-
if (config.listBots) {
|
|
109
|
-
listAvailableBots();
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const { source, amaConfig, amaKey } = resolveSource({ ...config.source.config, type: config.source.type }, { quiet: config.quiet });
|
|
114
|
-
|
|
115
|
-
const AMA_CONFIG = amaConfig;
|
|
116
|
-
if (!config.quiet) console.log(`[DynamicWeight] Loading candles from ${source.name}...`);
|
|
117
|
-
|
|
118
|
-
const candles = await source.fetchCandles();
|
|
119
|
-
if (!Array.isArray(candles) || candles.length === 0) {
|
|
120
|
-
throw new Error('No candles returned from source');
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// ── Kalman analysis ──────────────────────────────────────────────────
|
|
124
|
-
const analyzer = new KalmanTrendAnalyzer({
|
|
125
|
-
rNoise: KALMAN_CONFIG.rNoise,
|
|
126
|
-
qTactical: KALMAN_CONFIG.qTactical,
|
|
127
|
-
qModal: KALMAN_CONFIG.qModal,
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
// ── Hurst & PE analyzers ──────────────────────────────────────────────
|
|
131
|
-
const hurstAnalyzer = new HurstAnalyzer({
|
|
132
|
-
window: HURST_CONFIG.window,
|
|
133
|
-
scales: HURST_CONFIG.scales,
|
|
134
|
-
});
|
|
135
|
-
const peAnalyzer = new PermutationEntropyAnalyzer({
|
|
136
|
-
m: PE_CONFIG.m,
|
|
137
|
-
delay: PE_CONFIG.delay,
|
|
138
|
-
window: PE_CONFIG.window,
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
const allResults: any[] = [];
|
|
142
|
-
for (let i = 0; i < candles.length; i++) {
|
|
143
|
-
const { marketPrice, timestamp } = source.extractMarketPrice(candles[i]);
|
|
144
|
-
const result = analyzer.update(marketPrice);
|
|
145
|
-
const hurst = hurstAnalyzer.update(marketPrice);
|
|
146
|
-
const pe = peAnalyzer.update(marketPrice);
|
|
147
|
-
result.timestamp = timestamp;
|
|
148
|
-
result.price = marketPrice;
|
|
149
|
-
(result as any).hurst = hurst.isReady ? (hurst as any).hurst : null;
|
|
150
|
-
(result as any).pe = pe.isReady ? (pe as any).normalizedEntropy : null;
|
|
151
|
-
allResults.push(result);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// ── AMA weight calculation ───────────────────────────────────────────
|
|
155
|
-
const closes = candles.map(c => getCandleClose(c) ?? 0);
|
|
156
|
-
const amaValues = calculateAMA(closes, AMA_CONFIG);
|
|
157
|
-
const lbBars = config.lookbackBars ?? AMA_WEIGHT_CONFIG.lookbackBars;
|
|
158
|
-
const clipPercentile = config.clipPct ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_CLIP_PERCENTILE;
|
|
159
|
-
|
|
160
|
-
// Incremental percentile clip threshold (shared with the market adapter)
|
|
161
|
-
// so the research offset matches the live asymmetry. Feeding bar-by-bar
|
|
162
|
-
// keeps the pool prefix-only — no look-ahead, same thresholds the live
|
|
163
|
-
// service would have seen at each point in time.
|
|
164
|
-
const clipTracker = createAmaSlopeClipTracker(AMA_CONFIG.erPeriod, lbBars, clipPercentile);
|
|
165
|
-
// Minimal history window computeAmaSlopeWeights can act on (guard is
|
|
166
|
-
// erPeriod + lookbackBars + 1 and it only reads the last two sampled
|
|
167
|
-
// bars), so a rolling slice avoids O(n²) prefix copies.
|
|
168
|
-
const weightWindowBars = Math.ceil(AMA_CONFIG.erPeriod) + lbBars + 1;
|
|
169
|
-
|
|
170
|
-
for (let i = 0; i < allResults.length; i++) {
|
|
171
|
-
// The research chart keeps ATR out of the Kalman branch on purpose.
|
|
172
|
-
// Production applies ATR later as a separate symmetric volatility penalty.
|
|
173
|
-
const atr = 0;
|
|
174
|
-
const weightVariance = 0;
|
|
175
|
-
const amaClipThreshold = clipTracker.push(amaValues[i] ?? NaN);
|
|
176
|
-
const slice = amaValues.slice(Math.max(0, i + 1 - weightWindowBars), i + 1);
|
|
177
|
-
|
|
178
|
-
const weights = computeAmaSlopeWeights(slice, weightVariance, {
|
|
179
|
-
erPeriod: AMA_CONFIG.erPeriod,
|
|
180
|
-
lookbackBars: lbBars,
|
|
181
|
-
maxSlopePct: AMA_WEIGHT_CONFIG.amaMaxSlopePct,
|
|
182
|
-
neutralZonePct: AMA_WEIGHT_CONFIG.neutralZonePct,
|
|
183
|
-
volatilityExponent: AMA_WEIGHT_CONFIG.volatilityExponent,
|
|
184
|
-
volatilityScaleX: AMA_WEIGHT_CONFIG.volatilityScaleX,
|
|
185
|
-
volatilityThreshold: AMA_WEIGHT_CONFIG.volatilityThreshold,
|
|
186
|
-
maxSlopeOffset: AMA_WEIGHT_CONFIG.maxSlopeOffset,
|
|
187
|
-
maxVolatilityOffset: AMA_WEIGHT_CONFIG.maxVolatilityOffset,
|
|
188
|
-
clipThreshold: amaClipThreshold,
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
(allResults[i] as any).ama3Price = amaValues[i] ?? null;
|
|
192
|
-
(allResults[i] as any).atr = atr;
|
|
193
|
-
(allResults[i] as any).weightVariance = weightVariance;
|
|
194
|
-
(allResults[i] as any).amaSlopePct = weights.slopePct;
|
|
195
|
-
(allResults[i] as any).amaWeightReady = weights.isReady;
|
|
196
|
-
(allResults[i] as any).amaSlopeOffset = weights.slopeOffset;
|
|
197
|
-
(allResults[i] as any).amaSymmetricDelta = weights.symmetricDelta;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// ── Generate chart ───────────────────────────────────────────────────
|
|
201
|
-
const html = generateHTML({
|
|
202
|
-
allResults,
|
|
203
|
-
amaConfig: AMA_CONFIG,
|
|
204
|
-
amaKey,
|
|
205
|
-
amaWeightConfig: {
|
|
206
|
-
...AMA_WEIGHT_CONFIG,
|
|
207
|
-
lookbackBars: config.lookbackBars ?? AMA_WEIGHT_CONFIG.lookbackBars,
|
|
208
|
-
},
|
|
209
|
-
amaEmaSpan: config.amaEmaSpan,
|
|
210
|
-
alpha: config.alpha,
|
|
211
|
-
gain: config.gain,
|
|
212
|
-
dispWeight: config.dispWeight,
|
|
213
|
-
clipPct: config.clipPct,
|
|
214
|
-
regimeSensitivity: MARKET_ADAPTER.DYNAMIC_WEIGHT_REGIME_SENSITIVITY,
|
|
215
|
-
dispScaleMinPct: config.dispScaleMinPct ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_DISP_SCALE_MIN_PCT,
|
|
216
|
-
minOutputThreshold: MARKET_ADAPTER.DYNAMIC_WEIGHT_ASYMMETRIC_TREND_THRESHOLD,
|
|
217
|
-
outputClamp: MARKET_ADAPTER.DYNAMIC_WEIGHT_ASYMMETRIC_OFFSET_CLAMP,
|
|
218
|
-
marketAdapter: {
|
|
219
|
-
alpha: MARKET_ADAPTER.DYNAMIC_WEIGHT_ALPHA,
|
|
220
|
-
gain: MARKET_ADAPTER.DYNAMIC_WEIGHT_GAIN,
|
|
221
|
-
dispWeight: MARKET_ADAPTER.DYNAMIC_WEIGHT_DW,
|
|
222
|
-
clipPercentile: MARKET_ADAPTER.DYNAMIC_WEIGHT_CLIP_PERCENTILE,
|
|
223
|
-
regimeSensitivity: MARKET_ADAPTER.DYNAMIC_WEIGHT_REGIME_SENSITIVITY,
|
|
224
|
-
minOutputThreshold: MARKET_ADAPTER.DYNAMIC_WEIGHT_ASYMMETRIC_TREND_THRESHOLD,
|
|
225
|
-
outputClamp: MARKET_ADAPTER.DYNAMIC_WEIGHT_ASYMMETRIC_OFFSET_CLAMP,
|
|
226
|
-
amaLookbackBars: MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_LOOKBACK_BARS,
|
|
227
|
-
amaMaxSlopePct: MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_MAX_SLOPE_PCT,
|
|
228
|
-
kalmanMaxSlopePct: MARKET_ADAPTER.DYNAMIC_WEIGHT_KALMAN_MAX_SLOPE_PCT,
|
|
229
|
-
amaNeutralZonePct: MARKET_ADAPTER.DYNAMIC_WEIGHT_AMA_NEUTRAL_ZONE_PCT,
|
|
230
|
-
dispScaleMinPct: MARKET_ADAPTER.DYNAMIC_WEIGHT_DISP_SCALE_MIN_PCT,
|
|
231
|
-
},
|
|
232
|
-
}, config.title || 'Dynamic Weight Research Tool');
|
|
233
|
-
|
|
234
|
-
writeChartFile(config.chartFile, html);
|
|
235
|
-
|
|
236
|
-
if (!config.quiet) console.log(`\n[DynamicWeight] ✓ Chart saved. Open chart: (${toFileUrl(config.chartFile)})`);
|
|
237
|
-
} catch (err: unknown) {
|
|
238
|
-
console.error(`[DynamicWeight] Error: ${(err as any)?.message ?? err}`);
|
|
239
|
-
process.exit(1);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
main().catch((err: unknown) => { console.error(err); process.exit(1); });
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* KALMAN TREND ANALYSIS RUNNER
|
|
6
|
-
*
|
|
7
|
-
* Runs KalmanTrendAnalyzer over candle data and generates an interactive HTML chart.
|
|
8
|
-
*
|
|
9
|
-
* Usage:
|
|
10
|
-
* node dist/analysis/analyze_kalman.js \
|
|
11
|
-
* --source json \
|
|
12
|
-
* --file market_adapter/data/lp/<path>/<to>/<lp-candles>.json
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import path from 'node:path';
|
|
16
|
-
import { KalmanTrendAnalyzer } from './trend_detection/kalman_trend_analyzer.js';
|
|
17
|
-
import { generateHTML } from './trend_detection/kalman_chart_generator.js';
|
|
18
|
-
import { calculateAMA } from '../market_adapter/core/strategies/ama.js';
|
|
19
|
-
import { computeAmaSlopeWeights, createAmaSlopeClipTracker } from '../market_adapter/core/strategies/ama_slope_model.js';
|
|
20
|
-
import { MARKET_ADAPTER } from '../modules/constants.js';
|
|
21
|
-
import { getCandleClose } from './math_utils.js';
|
|
22
|
-
import { writeChartFile } from './chart_utils.js';
|
|
23
|
-
import { PATHS } from '../modules/paths.js';
|
|
24
|
-
import { resolveSource, listAvailableBots, type SourceConfig } from './resolve_source.js';
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
function parseArgs() {
|
|
29
|
-
const args = process.argv.slice(2);
|
|
30
|
-
const config: {
|
|
31
|
-
source: { type: string; config: SourceConfig };
|
|
32
|
-
rNoise: number | null;
|
|
33
|
-
qTactical: number | null;
|
|
34
|
-
qModal: number | null;
|
|
35
|
-
qNoise: number | null;
|
|
36
|
-
chartFile: string;
|
|
37
|
-
quiet: boolean;
|
|
38
|
-
listBots: boolean;
|
|
39
|
-
} = {
|
|
40
|
-
source: { type: 'market_adapter', config: { botKey: '' } },
|
|
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,
|
|
48
|
-
chartFile: path.join(PATHS.ANALYSIS.CHARTS_DIR, 'kalman_chart.html'),
|
|
49
|
-
quiet: false,
|
|
50
|
-
listBots: false,
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
for (let i = 0; i < args.length; i++) {
|
|
54
|
-
const arg = args[i];
|
|
55
|
-
if (arg === '--source') config.source.type = args[++i];
|
|
56
|
-
else if (arg === '--bot-key') config.source.config.botKey = args[++i];
|
|
57
|
-
else if (arg === '--file') {
|
|
58
|
-
config.source.config.filePath = args[++i];
|
|
59
|
-
config.source.type = 'json';
|
|
60
|
-
}
|
|
61
|
-
else if (arg === '--r') config.rNoise = parseFloat(args[++i]);
|
|
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]);
|
|
65
|
-
else if (arg === '--chart') config.chartFile = args[++i];
|
|
66
|
-
else if (arg === '--list-bots') config.listBots = true;
|
|
67
|
-
else if (arg === '--quiet') config.quiet = true;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return config;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
async function main() {
|
|
74
|
-
const config = parseArgs();
|
|
75
|
-
|
|
76
|
-
try {
|
|
77
|
-
if (config.listBots) {
|
|
78
|
-
listAvailableBots();
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const { source, amaConfig } = resolveSource({ ...config.source.config, type: config.source.type }, { quiet: config.quiet });
|
|
83
|
-
if (!config.quiet) console.log(`[Kalman] Loading candles from ${source.name}...`);
|
|
84
|
-
|
|
85
|
-
const candles = await source.fetchCandles();
|
|
86
|
-
if (!Array.isArray(candles) || candles.length === 0) {
|
|
87
|
-
throw new Error('No candles returned from source');
|
|
88
|
-
}
|
|
89
|
-
|
|
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).
|
|
96
|
-
const analyzer = new KalmanTrendAnalyzer({
|
|
97
|
-
rNoise: config.rNoise ?? undefined,
|
|
98
|
-
qTactical: config.qTactical ?? config.qNoise ?? undefined,
|
|
99
|
-
qModal: config.qModal ?? config.qNoise ?? undefined,
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
const allResults: any[] = [];
|
|
103
|
-
for (let i = 0; i < candles.length; i++) {
|
|
104
|
-
const { marketPrice, timestamp } = source.extractMarketPrice(candles[i]);
|
|
105
|
-
const result = analyzer.update(marketPrice);
|
|
106
|
-
result.timestamp = timestamp;
|
|
107
|
-
allResults.push(result);
|
|
108
|
-
}
|
|
109
|
-
|
|
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.
|
|
113
|
-
const closes = candles.map(c => getCandleClose(c) ?? 0);
|
|
114
|
-
const amaValues = calculateAMA(closes, amaConfig);
|
|
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;
|
|
126
|
-
|
|
127
|
-
for (let i = 0; i < allResults.length; i++) {
|
|
128
|
-
const amaClipThreshold = clipTracker.push(amaValues[i] ?? NaN);
|
|
129
|
-
if (i < warmup) { allResults[i].amaWeightOffset = null; continue; }
|
|
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;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// ── Generate chart ───────────────────────────────────────────────────
|
|
147
|
-
const html = generateHTML({ allResults, amaConfig, clipPct: MARKET_ADAPTER.DYNAMIC_WEIGHT_CLIP_PERCENTILE }, 'Kalman Trend Analysis');
|
|
148
|
-
writeChartFile(config.chartFile, html);
|
|
149
|
-
|
|
150
|
-
if (!config.quiet) console.log(`[Kalman] ✓ Chart saved to ${config.chartFile}`);
|
|
151
|
-
} catch (err: unknown) {
|
|
152
|
-
console.error(`[Kalman] Error: ${(err as any)?.message ?? err}`);
|
|
153
|
-
process.exit(1);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
main().catch((err: unknown) => { console.error(err); process.exit(1); });
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* REGIME ANALYSIS TOOL
|
|
6
|
-
*
|
|
7
|
-
* Computes Hurst Exponent and Permutation Entropy over historical candle data.
|
|
8
|
-
*
|
|
9
|
-
* Hurst H > 0.55 = trending (persistent) → trust trend-following signals
|
|
10
|
-
* Hurst H ≈ 0.50 = random walk → no edge, stay flat
|
|
11
|
-
* Hurst H < 0.45 = mean-reverting → suppress or invert trend signals
|
|
12
|
-
*
|
|
13
|
-
* Norm. PE < 0.60 = structured → signals are reliable
|
|
14
|
-
* Norm. PE > 0.85 = noise → no exploitable structure
|
|
15
|
-
*
|
|
16
|
-
* Usage:
|
|
17
|
-
* node dist/analysis/analyze_regime.js \
|
|
18
|
-
* --source json \
|
|
19
|
-
* --file market_adapter/data/lp/<path>/<to>/<lp-candles>.json
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
import path from 'node:path';
|
|
23
|
-
import { MARKET_ADAPTER } from '../modules/constants.js';
|
|
24
|
-
import { PATHS } from '../modules/paths.js';
|
|
25
|
-
import { HurstAnalyzer } from './trend_detection/hurst_analyzer.js';
|
|
26
|
-
import { PermutationEntropyAnalyzer } from './trend_detection/permutation_entropy_analyzer.js';
|
|
27
|
-
import { generateRegimeHTML } from './trend_detection/regime_chart_generator.js';
|
|
28
|
-
import { calculateAMA } from '../market_adapter/core/strategies/ama.js';
|
|
29
|
-
import { writeChartFile } from './chart_utils.js';
|
|
30
|
-
import { getCandleClose } from './math_utils.js';
|
|
31
|
-
import { resolveSource, listAvailableBots, type SourceConfig } from './resolve_source.js';
|
|
32
|
-
|
|
33
|
-
const HURST_CONFIG = MARKET_ADAPTER.HURST_CONFIG;
|
|
34
|
-
const PE_CONFIG = MARKET_ADAPTER.PE_CONFIG;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
function parseArgs() {
|
|
38
|
-
const args = process.argv.slice(2);
|
|
39
|
-
const config: {
|
|
40
|
-
source: { type: string; config: SourceConfig };
|
|
41
|
-
chartFile: string;
|
|
42
|
-
hurstWindow: number;
|
|
43
|
-
peWindow: number;
|
|
44
|
-
peM: number;
|
|
45
|
-
quiet: boolean;
|
|
46
|
-
listBots: boolean;
|
|
47
|
-
} = {
|
|
48
|
-
source: { type: 'market_adapter', config: { botKey: '' } },
|
|
49
|
-
chartFile: path.join(PATHS.ANALYSIS.CHARTS_DIR, 'regime_chart.html'),
|
|
50
|
-
hurstWindow: HURST_CONFIG.window,
|
|
51
|
-
peWindow: PE_CONFIG.window,
|
|
52
|
-
peM: PE_CONFIG.m,
|
|
53
|
-
quiet: false,
|
|
54
|
-
listBots: false,
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
for (let i = 0; i < args.length; i++) {
|
|
58
|
-
const arg = args[i];
|
|
59
|
-
if (arg === '--source') config.source.type = args[++i];
|
|
60
|
-
else if (arg === '--bot-key') config.source.config.botKey = args[++i];
|
|
61
|
-
else if (arg === '--file') {
|
|
62
|
-
config.source.config.filePath = args[++i];
|
|
63
|
-
config.source.type = 'json';
|
|
64
|
-
}
|
|
65
|
-
else if (arg === '--chart') config.chartFile = args[++i];
|
|
66
|
-
else if (arg === '--hurst-window') config.hurstWindow = parseInt(args[++i], 10);
|
|
67
|
-
else if (arg === '--pe-window') config.peWindow = parseInt(args[++i], 10);
|
|
68
|
-
else if (arg === '--pe-m') config.peM = parseInt(args[++i], 10);
|
|
69
|
-
else if (arg === '--list-bots') config.listBots = true;
|
|
70
|
-
else if (arg === '--quiet') config.quiet = true;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return config;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async function main() {
|
|
77
|
-
const config = parseArgs();
|
|
78
|
-
|
|
79
|
-
try {
|
|
80
|
-
if (config.listBots) {
|
|
81
|
-
listAvailableBots();
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const { source, amaConfig } = resolveSource({ ...config.source.config, type: config.source.type }, { quiet: config.quiet });
|
|
86
|
-
if (!config.quiet) console.log(`[Regime] Loading candles from ${source.name}...`);
|
|
87
|
-
|
|
88
|
-
const candles = await source.fetchCandles();
|
|
89
|
-
if (!Array.isArray(candles) || candles.length === 0) {
|
|
90
|
-
throw new Error('No candles returned from source');
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// ── Regime analyzers ─────────────────────────────────────────────────
|
|
94
|
-
const hurstAnalyzer = new HurstAnalyzer({
|
|
95
|
-
window: config.hurstWindow,
|
|
96
|
-
scales: HURST_CONFIG.scales,
|
|
97
|
-
});
|
|
98
|
-
const peAnalyzer = new PermutationEntropyAnalyzer({
|
|
99
|
-
m: config.peM,
|
|
100
|
-
delay: PE_CONFIG.delay,
|
|
101
|
-
window: config.peWindow,
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
const allResults: any[] = [];
|
|
105
|
-
for (let i = 0; i < candles.length; i++) {
|
|
106
|
-
const { marketPrice, timestamp } = source.extractMarketPrice(candles[i]);
|
|
107
|
-
const hurst = hurstAnalyzer.update(marketPrice);
|
|
108
|
-
const pe = peAnalyzer.update(marketPrice);
|
|
109
|
-
|
|
110
|
-
allResults.push({
|
|
111
|
-
timestamp,
|
|
112
|
-
price: marketPrice,
|
|
113
|
-
hurst: hurst.hurst,
|
|
114
|
-
hurstRegime: hurst.regime,
|
|
115
|
-
hurstRegimeStrength: hurst.regimeStrength,
|
|
116
|
-
hurstReady: hurst.isReady,
|
|
117
|
-
normalizedEntropy: pe.normalizedEntropy,
|
|
118
|
-
entropy: pe.entropy,
|
|
119
|
-
peRegime: pe.regime,
|
|
120
|
-
peRegimeStrength: pe.regimeStrength,
|
|
121
|
-
peReady: pe.isReady,
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// ── AMA3 overlay for price panel ─────────────────────────────────────
|
|
126
|
-
const closes = candles.map(c => getCandleClose(c) ?? 0);
|
|
127
|
-
const ama3Values = calculateAMA(closes, amaConfig);
|
|
128
|
-
for (let i = 0; i < allResults.length; i++) {
|
|
129
|
-
(allResults[i] as any).ama3Price = ama3Values[i] ?? null;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// ── Print tail summary ───────────────────────────────────────────────
|
|
133
|
-
if (!config.quiet) {
|
|
134
|
-
const last = allResults[allResults.length - 1];
|
|
135
|
-
console.log(`[Regime] ${candles.length} bars processed`);
|
|
136
|
-
console.log(`[Regime] Last bar:`);
|
|
137
|
-
console.log(` Hurst H=${last.hurst} regime=${last.hurstRegime}`);
|
|
138
|
-
console.log(` PE e=${last.normalizedEntropy} regime=${last.peRegime}`);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// ── Generate chart ───────────────────────────────────────────────────
|
|
142
|
-
const html = generateRegimeHTML({
|
|
143
|
-
allResults,
|
|
144
|
-
hurstConfig: { window: config.hurstWindow, scales: HURST_CONFIG.scales },
|
|
145
|
-
peConfig: { m: config.peM, window: config.peWindow },
|
|
146
|
-
}, 'Regime Analysis \u2014 Hurst \u00b7 Permutation Entropy');
|
|
147
|
-
|
|
148
|
-
writeChartFile(config.chartFile, html);
|
|
149
|
-
|
|
150
|
-
if (!config.quiet) console.log(`[Regime] \u2713 Chart saved to ${config.chartFile}`);
|
|
151
|
-
|
|
152
|
-
} catch (err: unknown) {
|
|
153
|
-
console.error(`[Regime] Error: ${(err as any)?.message ?? err}`);
|
|
154
|
-
process.exit(1);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
main().catch((err: unknown) => { console.error(err); process.exit(1); });
|