dexbot 1.6.6 → 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 +89 -1
- package/README.md +8 -5
- 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 +44 -15
- 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 +20 -9
- package/dist/modules/account_orders.d.ts +44 -4
- package/dist/modules/account_orders.js +104 -7
- package/dist/modules/bitshares-native/chain_client.d.ts +10 -0
- package/dist/modules/bitshares-native/chain_client.js +197 -28
- package/dist/modules/bitshares-native/subscriptions.js +312 -10
- package/dist/modules/bitshares-native/transport.d.ts +1 -0
- package/dist/modules/bitshares-native/transport.js +97 -3
- package/dist/modules/bitshares_client.d.ts +20 -0
- package/dist/modules/bitshares_client.js +29 -0
- package/dist/modules/bot_settings.js +10 -1
- package/dist/modules/chain_keys.d.ts +37 -22
- package/dist/modules/chain_keys.js +145 -44
- package/dist/modules/cli_start_onboarding.d.ts +10 -0
- package/dist/modules/cli_start_onboarding.js +15 -0
- package/dist/modules/cli_start_output.d.ts +6 -0
- package/dist/modules/cli_start_output.js +8 -0
- package/dist/modules/config.d.ts +1 -0
- package/dist/modules/config.js +1 -0
- package/dist/modules/constants.d.ts +23 -2
- package/dist/modules/constants.js +196 -15
- 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 +53 -96
- package/dist/modules/dexbot_fill_runtime.d.ts +6 -1
- package/dist/modules/dexbot_fill_runtime.js +22 -3
- package/dist/modules/dexbot_maintenance_runtime.d.ts +38 -1
- package/dist/modules/dexbot_maintenance_runtime.js +103 -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 +34 -1
- 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 +109 -135
- 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 +13 -2
- package/dist/modules/order/logger.d.ts +12 -2
- package/dist/modules/order/logger.js +29 -7
- package/dist/modules/order/manager.d.ts +53 -0
- package/dist/modules/order/manager.js +86 -25
- 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 +302 -194
- package/dist/modules/order/utils/system.d.ts +97 -0
- package/dist/modules/order/utils/system.js +282 -3
- package/dist/modules/paths.d.ts +8 -1
- package/dist/modules/paths.js +11 -3
- package/dist/modules/utils/text_width.d.ts +19 -0
- package/dist/modules/utils/text_width.js +97 -0
- package/dist/modules/version_notice.d.ts +165 -0
- package/dist/modules/version_notice.js +364 -0
- package/dist/pm2.js +104 -18
- package/dist/scripts/update.js +62 -13
- package/dist/unlock.d.ts +14 -2
- package/dist/unlock.js +101 -4
- package/docs/BITSHARES_ONBOARDING.md +8 -1
- package/docs/COW_INVARIANTS.md +11 -2
- package/docs/CREDENTIAL_SECURITY.md +26 -0
- package/docs/DEXBOT_COMPARISON.md +4 -4
- package/docs/EVOLUTION.md +20 -18
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
- package/docs/GRID_PRICE_INVARIANT.md +204 -31
- package/docs/GRID_RECALCULATION.md +12 -0
- package/docs/LOGGING.md +17 -2
- package/docs/ORDER_ENGINE_POST_1.0_RETROSPECTIVE.md +6 -7
- 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 +14 -6
- 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/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/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,338 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
import { MARKET_ADAPTER } from '../../modules/constants.js';
|
|
4
|
-
import { escapeHtml, serializeJsonForScript, toEpochSeconds, UPLOT_SHARED_SCRIPT, uplotInlineTags } from '../chart_utils.js';
|
|
5
|
-
import { sharedChartCSS } from '../chart_css.js';
|
|
6
|
-
import { Y_AXIS_SIZE, makeCursorConfig, bindHoverStateFn, wireChartEvents, zoomResetScript, sizeChartsFn, fmtDateFn } from '../chart_ui.js';
|
|
7
|
-
|
|
8
|
-
// Zone boundaries sourced from MARKET_ADAPTER (single source of truth shared
|
|
9
|
-
// with the live adapter) instead of hardcoded copies. Hurst classification
|
|
10
|
-
// uses inclusive >=/<= bounds matching market_adapter/core/signals/hurst_analyzer.ts.
|
|
11
|
-
const HURST_WINDOW_DEFAULT = MARKET_ADAPTER.HURST_CONFIG.window;
|
|
12
|
-
const HURST_SCALES_DEFAULT = MARKET_ADAPTER.HURST_CONFIG.scales;
|
|
13
|
-
const PE_M_DEFAULT = MARKET_ADAPTER.PE_CONFIG.m;
|
|
14
|
-
const PE_WINDOW_DEFAULT = MARKET_ADAPTER.PE_CONFIG.window;
|
|
15
|
-
const H_UPPER = 0.5 + MARKET_ADAPTER.HURST_ZONE_BAND;
|
|
16
|
-
const H_LOWER = 0.5 - MARKET_ADAPTER.HURST_ZONE_BAND;
|
|
17
|
-
const PE_STRUCTURED = MARKET_ADAPTER.PE_NODES[0];
|
|
18
|
-
const PE_NOISE = MARKET_ADAPTER.PE_NODES[MARKET_ADAPTER.PE_NODES.length - 1];
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Build background-shading segments for a value array.
|
|
23
|
-
* greenFn/redFn return true when the value falls in that zone.
|
|
24
|
-
* Returns an array of { from, to, color } objects (null-color segments omitted).
|
|
25
|
-
*/
|
|
26
|
-
function buildSegments(values: any[], greenFn: any, redFn: any) {
|
|
27
|
-
const segments: { from: number; to: number; color: string }[] = [];
|
|
28
|
-
let start = 0, color: string | null = null;
|
|
29
|
-
|
|
30
|
-
for (let i = 0; i < values.length; i++) {
|
|
31
|
-
const v = values[i];
|
|
32
|
-
let next: string | null = null;
|
|
33
|
-
if (v != null) {
|
|
34
|
-
if (greenFn(v)) next = 'rgba(46,160,67,0.13)';
|
|
35
|
-
else if (redFn(v)) next = 'rgba(248,81,73,0.13)';
|
|
36
|
-
}
|
|
37
|
-
if (next !== color) {
|
|
38
|
-
if (color !== null) segments.push({ from: start, to: i - 1, color });
|
|
39
|
-
color = next;
|
|
40
|
-
start = i;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
if (color !== null) segments.push({ from: start, to: values.length - 1, color });
|
|
44
|
-
return segments;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function generateRegimeHTML(data: any, title = 'Regime Analysis') {
|
|
48
|
-
const results = data.allResults || [];
|
|
49
|
-
if (results.length === 0) throw new Error('No analysis results in input');
|
|
50
|
-
|
|
51
|
-
const hurstConfig = data.hurstConfig || {};
|
|
52
|
-
const peConfig = data.peConfig || {};
|
|
53
|
-
|
|
54
|
-
const interval = results.length > 1
|
|
55
|
-
? (new Date(results[1].timestamp).getTime() - new Date(results[0].timestamp).getTime()) / 1000
|
|
56
|
-
: 3600;
|
|
57
|
-
|
|
58
|
-
const dates = results.map((r: any, i: number) => toEpochSeconds(r.timestamp, i));
|
|
59
|
-
const prices = results.map((r: any) => r.price);
|
|
60
|
-
const ama3Prices = results.map((r: any) => r.ama3Price ?? null);
|
|
61
|
-
const hurstArr = results.map((r: any) => r.hurstReady ? r.hurst : null);
|
|
62
|
-
const peArr = results.map((r: any) => r.peReady ? r.normalizedEntropy : null);
|
|
63
|
-
|
|
64
|
-
const realBarCount = results.length;
|
|
65
|
-
|
|
66
|
-
// Extend arrays with null padding so the last real bar is not glued to chart right edge
|
|
67
|
-
const lastDate = dates[dates.length - 1];
|
|
68
|
-
for (let i = 1; i <= 80; i++) {
|
|
69
|
-
dates.push(lastDate + i * interval);
|
|
70
|
-
prices.push(null);
|
|
71
|
-
ama3Prices.push(null);
|
|
72
|
-
hurstArr.push(null);
|
|
73
|
-
peArr.push(null);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Background shading segments (server-side, passed to browser via JSON payload)
|
|
77
|
-
const hurstSegments = buildSegments(hurstArr.slice(0, realBarCount), (v: any) => v >= H_UPPER, (v: any) => v <= H_LOWER);
|
|
78
|
-
const peSegments = buildSegments(peArr.slice(0, realBarCount), (v: any) => v < PE_STRUCTURED, (v: any) => v > PE_NOISE);
|
|
79
|
-
|
|
80
|
-
const payload = {
|
|
81
|
-
dates, prices, ama3Prices, hurstArr, peArr,
|
|
82
|
-
hurstSegments, peSegments,
|
|
83
|
-
realBarCount,
|
|
84
|
-
hurstWindow: hurstConfig.window ?? HURST_WINDOW_DEFAULT,
|
|
85
|
-
peM: peConfig.m ?? PE_M_DEFAULT,
|
|
86
|
-
peWindow: peConfig.window ?? PE_WINDOW_DEFAULT,
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
return `<!DOCTYPE html>
|
|
90
|
-
<html lang="en">
|
|
91
|
-
<head>
|
|
92
|
-
<meta charset="UTF-8">
|
|
93
|
-
<title>${escapeHtml(title)}</title>
|
|
94
|
-
${uplotInlineTags()}
|
|
95
|
-
<style>
|
|
96
|
-
${sharedChartCSS()}
|
|
97
|
-
#price-panel { flex: 0 0 34%; min-height: 0; position: relative; border-bottom: 1px solid #30363d; }
|
|
98
|
-
#hurst-panel { flex: 0 0 28%; min-height: 0; position: relative; border-bottom: 1px solid #30363d; }
|
|
99
|
-
#pe-panel { flex: 1 1 0; min-height: 0; position: relative; }
|
|
100
|
-
.badge { display: inline-block; padding: 1px 7px; border-radius: 3px; font-size: 10px; font-weight: bold; }
|
|
101
|
-
.badge-green { background: rgba(46,160,67,0.25); color: #3fb950; }
|
|
102
|
-
.badge-red { background: rgba(248,81,73,0.25); color: #ff7b72; }
|
|
103
|
-
.badge-grey { background: rgba(110,118,129,0.2); color: #adbac7; }
|
|
104
|
-
</style>
|
|
105
|
-
</head>
|
|
106
|
-
<body>
|
|
107
|
-
<div id="header">
|
|
108
|
-
<div style="font-weight:bold;color:#fff;">${escapeHtml(title)}</div>
|
|
109
|
-
<div style="display:flex;align-items:center;gap:16px;">
|
|
110
|
-
<span style="font-size:10px;color:#8b949e;font-family:monospace;">
|
|
111
|
-
Hurst: window=${escapeHtml(String(hurstConfig.window ?? HURST_WINDOW_DEFAULT))} bars · scales=[${escapeHtml((hurstConfig.scales ?? HURST_SCALES_DEFAULT).join(','))}]
|
|
112
|
-
|
|
|
113
|
-
PE: m=${escapeHtml(String(peConfig.m ?? PE_M_DEFAULT))} · window=${escapeHtml(String(peConfig.window ?? PE_WINDOW_DEFAULT))} bars
|
|
114
|
-
</span>
|
|
115
|
-
<span style="font-size:11px;color:#adbac7;text-transform:uppercase;">
|
|
116
|
-
H≥${H_UPPER.toFixed(2)}=trend · H≤${H_LOWER.toFixed(2)}=revert · PE<${PE_STRUCTURED.toFixed(2)}=structured · PE>${PE_NOISE.toFixed(2)}=noise
|
|
117
|
-
| Scroll · Drag · Ctrl+0
|
|
118
|
-
</span>
|
|
119
|
-
</div>
|
|
120
|
-
</div>
|
|
121
|
-
|
|
122
|
-
<div id="panels">
|
|
123
|
-
<div id="price-panel">
|
|
124
|
-
<div class="section-label">PRICE (LOG)</div>
|
|
125
|
-
<div class="legend">
|
|
126
|
-
<div class="legend-item" style="color:#555;"><span id="l-date">-</span></div>
|
|
127
|
-
<div class="legend-item"><div class="dot" style="background:#58a6ff;"></div>Price: <span id="l-price" style="font-weight:bold;color:#58a6ff;">-</span></div>
|
|
128
|
-
<div class="legend-item"><div class="dot" style="background:#e3b341;"></div>AMA3: <span id="l-ama3" style="color:#e3b341;">-</span></div>
|
|
129
|
-
</div>
|
|
130
|
-
<div id="price-chart"></div>
|
|
131
|
-
</div>
|
|
132
|
-
<div id="hurst-panel">
|
|
133
|
-
<div class="section-label">HURST EXPONENT</div>
|
|
134
|
-
<div class="legend">
|
|
135
|
-
<div class="legend-item"><div class="dot" style="background:#4dc3ff;"></div>H: <span id="l-hurst" style="font-weight:bold;color:#4dc3ff;">-</span></div>
|
|
136
|
-
<div class="legend-item">Regime: <span id="l-hurst-regime" style="font-weight:bold;">-</span></div>
|
|
137
|
-
<div class="legend-item" style="color:#555;font-size:10px;">window=${escapeHtml(String(hurstConfig.window ?? HURST_WINDOW_DEFAULT))} bars</div>
|
|
138
|
-
</div>
|
|
139
|
-
<div id="hurst-chart"></div>
|
|
140
|
-
</div>
|
|
141
|
-
<div id="pe-panel">
|
|
142
|
-
<div class="section-label">PERMUTATION ENTROPY (NORM.)</div>
|
|
143
|
-
<div class="legend">
|
|
144
|
-
<div class="legend-item"><div class="dot" style="background:#d2a8ff;"></div>PE: <span id="l-pe" style="font-weight:bold;color:#d2a8ff;">-</span></div>
|
|
145
|
-
<div class="legend-item">Regime: <span id="l-pe-regime" style="font-weight:bold;">-</span></div>
|
|
146
|
-
<div class="legend-item" style="color:#555;font-size:10px;">m=${escapeHtml(String(peConfig.m ?? PE_M_DEFAULT))}, window=${escapeHtml(String(peConfig.window ?? PE_WINDOW_DEFAULT))} bars</div>
|
|
147
|
-
</div>
|
|
148
|
-
<div id="pe-chart"></div>
|
|
149
|
-
</div>
|
|
150
|
-
</div>
|
|
151
|
-
|
|
152
|
-
<script id="payload" type="application/json">${serializeJsonForScript(payload)}</script>
|
|
153
|
-
|
|
154
|
-
<script>
|
|
155
|
-
(function () {
|
|
156
|
-
const data = JSON.parse(document.getElementById('payload').textContent);
|
|
157
|
-
const SYNC_KEY = 'regime-v1';
|
|
158
|
-
const X_AXIS_CFG = { show: false, stroke: '#ffffff', grid: { stroke: '#1c2128' }, ticks: { stroke: '#30363d', width: 1 }, size: 28, font: '11px Segoe UI, sans-serif' };
|
|
159
|
-
const cursorCfg = ${makeCursorConfig()};
|
|
160
|
-
|
|
161
|
-
// ── helpers ──────────────────────────────────────────────────────────
|
|
162
|
-
function fmtPrice(v) {
|
|
163
|
-
if (v == null) return '-';
|
|
164
|
-
return v < 0.01 ? v.toPrecision(4) : v < 100 ? v.toFixed(4) : v.toFixed(2);
|
|
165
|
-
}
|
|
166
|
-
function fmtH(v) { return v == null ? '-' : v.toFixed(3); }
|
|
167
|
-
function fmtPE(v) { return v == null ? '-' : v.toFixed(3); }
|
|
168
|
-
${fmtDateFn()}
|
|
169
|
-
${bindHoverStateFn()}
|
|
170
|
-
|
|
171
|
-
// Inclusive zone boundaries — same semantics as the live classifier
|
|
172
|
-
// (market_adapter/core/signals/hurst_analyzer.ts classifyHurst).
|
|
173
|
-
const H_UPPER = ${JSON.stringify(H_UPPER)};
|
|
174
|
-
const H_LOWER = ${JSON.stringify(H_LOWER)};
|
|
175
|
-
const PE_STRUCTURED = ${JSON.stringify(PE_STRUCTURED)};
|
|
176
|
-
const PE_NOISE = ${JSON.stringify(PE_NOISE)};
|
|
177
|
-
|
|
178
|
-
function hurstRegimeLabel(v) {
|
|
179
|
-
if (v == null) return '<span class="badge badge-grey">-</span>';
|
|
180
|
-
if (v >= H_UPPER) return '<span class="badge badge-green">TRENDING</span>';
|
|
181
|
-
if (v <= H_LOWER) return '<span class="badge badge-red">MEAN REV</span>';
|
|
182
|
-
return '<span class="badge badge-grey">RANDOM</span>';
|
|
183
|
-
}
|
|
184
|
-
function peRegimeLabel(v) {
|
|
185
|
-
if (v == null) return '<span class="badge badge-grey">-</span>';
|
|
186
|
-
if (v < PE_STRUCTURED) return '<span class="badge badge-green">STRUCTURED</span>';
|
|
187
|
-
if (v > PE_NOISE) return '<span class="badge badge-red">NOISE</span>';
|
|
188
|
-
return '<span class="badge badge-grey">MIXED</span>';
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// ── background-shading + reference-lines draw hook ───────────────────
|
|
192
|
-
// Uses valToPos(..., true) = CSS pixels, matching how u.bbox works in draw hooks.
|
|
193
|
-
function makeBgHook(segments, refLines, yScaleKey) {
|
|
194
|
-
return (u) => {
|
|
195
|
-
const { ctx, bbox } = u;
|
|
196
|
-
ctx.save();
|
|
197
|
-
ctx.beginPath(); ctx.rect(bbox.left, bbox.top, bbox.width, bbox.height); ctx.clip();
|
|
198
|
-
|
|
199
|
-
for (const seg of segments) {
|
|
200
|
-
if (!seg.color) continue;
|
|
201
|
-
const x0 = u.valToPos(data.dates[seg.from], 'x', true);
|
|
202
|
-
const toIdx = Math.min(seg.to + 1, data.dates.length - 1);
|
|
203
|
-
const x1 = u.valToPos(data.dates[toIdx], 'x', true);
|
|
204
|
-
ctx.fillStyle = seg.color;
|
|
205
|
-
ctx.fillRect(x0, bbox.top, x1 - x0, bbox.height);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
for (const rl of refLines) {
|
|
209
|
-
const yPos = u.valToPos(rl.y, yScaleKey, true);
|
|
210
|
-
ctx.strokeStyle = rl.color;
|
|
211
|
-
ctx.lineWidth = 1;
|
|
212
|
-
ctx.setLineDash([4, 4]);
|
|
213
|
-
ctx.beginPath();
|
|
214
|
-
ctx.moveTo(bbox.left, yPos);
|
|
215
|
-
ctx.lineTo(bbox.left + bbox.width, yPos);
|
|
216
|
-
ctx.stroke();
|
|
217
|
-
ctx.setLineDash([]);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
ctx.restore();
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
function yAxis(scaleKey) {
|
|
225
|
-
return { side: 1, scale: scaleKey, stroke: '#ffffff', grid: { stroke: '#1c2128', dash: [4, 4] }, ticks: { stroke: '#30363d', width: 1 }, size: ${Y_AXIS_SIZE}, font: '11px Segoe UI, sans-serif' };
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// ── x-range sync (shared across all panels) ─────────────────────────
|
|
229
|
-
const xMin = data.dates[0];
|
|
230
|
-
const xMax = data.dates[data.dates.length - 1];
|
|
231
|
-
let pendingRange = null, pendingRangeRaf = 0;
|
|
232
|
-
let priceChart, hurstChart, peChart;
|
|
233
|
-
let charts;
|
|
234
|
-
|
|
235
|
-
${UPLOT_SHARED_SCRIPT}
|
|
236
|
-
|
|
237
|
-
// ── chart instances ──────────────────────────────────────────────────
|
|
238
|
-
|
|
239
|
-
const hurstRefLines = [
|
|
240
|
-
{ y: H_UPPER, color: 'rgba(46,160,67,0.5)' },
|
|
241
|
-
{ y: 0.50, color: 'rgba(110,118,129,0.3)' },
|
|
242
|
-
{ y: H_LOWER, color: 'rgba(248,81,73,0.5)' },
|
|
243
|
-
];
|
|
244
|
-
const peRefLines = [
|
|
245
|
-
{ y: PE_NOISE, color: 'rgba(248,81,73,0.5)' },
|
|
246
|
-
{ y: PE_STRUCTURED, color: 'rgba(46,160,67,0.5)' },
|
|
247
|
-
];
|
|
248
|
-
|
|
249
|
-
const hurstBgFn = makeBgHook(data.hurstSegments, hurstRefLines, 'h');
|
|
250
|
-
const peBgFn = makeBgHook(data.peSegments, peRefLines, 'p');
|
|
251
|
-
|
|
252
|
-
function init() {
|
|
253
|
-
const priceEl = document.getElementById('price-panel');
|
|
254
|
-
const hurstEl = document.getElementById('hurst-panel');
|
|
255
|
-
const peEl = document.getElementById('pe-panel');
|
|
256
|
-
|
|
257
|
-
priceChart = new uPlot({
|
|
258
|
-
width: priceEl.offsetWidth, height: priceEl.offsetHeight,
|
|
259
|
-
padding: [4, 4, 2, 4], select: { show: false }, legend: { show: false },
|
|
260
|
-
scales: { x: { time: true }, y: { auto: true, distr: 3, log: 10, range: (u, min, max) => [min * 0.95, max * 1.05] } },
|
|
261
|
-
series: [
|
|
262
|
-
{ label: 'Time' },
|
|
263
|
-
{ label: 'Price', stroke: '#58a6ff', width: 1.5, scale: 'y', points: { show: false } },
|
|
264
|
-
{ label: 'AMA3', stroke: '#e3b341', width: 1, scale: 'y', points: { show: false } },
|
|
265
|
-
],
|
|
266
|
-
axes: [
|
|
267
|
-
X_AXIS_CFG,
|
|
268
|
-
{ ...yAxis('y'), values: (u, v) => v.map(x => x != null ? fmtPrice(x) : '') },
|
|
269
|
-
],
|
|
270
|
-
cursor: cursorCfg,
|
|
271
|
-
hooks: { draw: [(u) => { updateLegend(u.cursor.idx); }] },
|
|
272
|
-
}, [data.dates, data.prices, data.ama3Prices], document.getElementById('price-chart'));
|
|
273
|
-
|
|
274
|
-
hurstChart = new uPlot({
|
|
275
|
-
width: hurstEl.offsetWidth, height: hurstEl.offsetHeight,
|
|
276
|
-
padding: [4, 4, 2, 4], select: { show: false }, legend: { show: false },
|
|
277
|
-
scales: { x: { time: true }, h: { auto: true } },
|
|
278
|
-
series: [
|
|
279
|
-
{ label: 'Time' },
|
|
280
|
-
{ label: 'Hurst', stroke: '#4dc3ff', width: 1.5, scale: 'h', points: { show: false } },
|
|
281
|
-
],
|
|
282
|
-
axes: [
|
|
283
|
-
X_AXIS_CFG,
|
|
284
|
-
{ ...yAxis('h'), values: (u, v) => v.map(x => x != null ? x.toFixed(2) : '') },
|
|
285
|
-
],
|
|
286
|
-
cursor: cursorCfg,
|
|
287
|
-
hooks: { draw: [hurstBgFn] },
|
|
288
|
-
}, [data.dates, data.hurstArr], document.getElementById('hurst-chart'));
|
|
289
|
-
|
|
290
|
-
peChart = new uPlot({
|
|
291
|
-
width: peEl.offsetWidth, height: peEl.offsetHeight,
|
|
292
|
-
padding: [4, 4, 4, 4], select: { show: false }, legend: { show: false },
|
|
293
|
-
scales: { x: { time: true }, p: { range: [0, 1] } },
|
|
294
|
-
series: [
|
|
295
|
-
{ label: 'Time' },
|
|
296
|
-
{ label: 'PE', stroke: '#d2a8ff', width: 1.5, scale: 'p', points: { show: false } },
|
|
297
|
-
],
|
|
298
|
-
axes: [
|
|
299
|
-
{ ...X_AXIS_CFG, show: true },
|
|
300
|
-
{ ...yAxis('p'), values: (u, v) => v.map(x => x != null ? x.toFixed(2) : '') },
|
|
301
|
-
],
|
|
302
|
-
cursor: cursorCfg,
|
|
303
|
-
hooks: { draw: [peBgFn] },
|
|
304
|
-
}, [data.dates, data.peArr], document.getElementById('pe-chart'));
|
|
305
|
-
|
|
306
|
-
charts = [priceChart, hurstChart, peChart];
|
|
307
|
-
${wireChartEvents('charts', 'updateLegend', 'null')}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
// ── cursor legend update ─────────────────────────────────────────────
|
|
311
|
-
function updateLegend(idx) {
|
|
312
|
-
if (idx == null || idx >= data.realBarCount) return;
|
|
313
|
-
document.getElementById('l-date').textContent = fmtDate(data.dates[idx]);
|
|
314
|
-
document.getElementById('l-price').textContent = fmtPrice(data.prices[idx]);
|
|
315
|
-
document.getElementById('l-ama3').textContent = fmtPrice(data.ama3Prices[idx]);
|
|
316
|
-
document.getElementById('l-hurst').textContent = fmtH(data.hurstArr[idx]);
|
|
317
|
-
document.getElementById('l-pe').textContent = fmtPE(data.peArr[idx]);
|
|
318
|
-
document.getElementById('l-hurst-regime').innerHTML = hurstRegimeLabel(data.hurstArr[idx]);
|
|
319
|
-
document.getElementById('l-pe-regime').innerHTML = peRegimeLabel(data.peArr[idx]);
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
// ── resize ───────────────────────────────────────────────────────────
|
|
323
|
-
${sizeChartsFn([['priceChart', 'price-panel'], ['hurstChart', 'hurst-panel'], ['peChart', 'pe-panel']])}
|
|
324
|
-
|
|
325
|
-
window.addEventListener('resize', sizeCharts);
|
|
326
|
-
${zoomResetScript()}
|
|
327
|
-
|
|
328
|
-
init();
|
|
329
|
-
requestAnimationFrame(() => requestAnimationFrame(() => sizeCharts()));
|
|
330
|
-
|
|
331
|
-
})();
|
|
332
|
-
</script>
|
|
333
|
-
</body>
|
|
334
|
-
</html>`;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
export { generateRegimeHTML }
|
|
338
|
-
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
import { KalmanTrendAnalyzer, KalmanFilter } from '../kalman_trend_analyzer.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Test Suite for Kalman Trend Detection
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
async function runTests() {
|
|
11
|
-
console.log('Running Kalman Trend Analyzer tests...');
|
|
12
|
-
|
|
13
|
-
testFilterInitialization();
|
|
14
|
-
testConstantTrendConvergence();
|
|
15
|
-
testNoiseFiltering();
|
|
16
|
-
testTrajectoryProjection();
|
|
17
|
-
testTrendDetectionSign();
|
|
18
|
-
testResetPreservesFilterConfig();
|
|
19
|
-
testFilterRejectsInvalidMeasurements();
|
|
20
|
-
testInitialCovarianceScalesWithPrice();
|
|
21
|
-
testNearZeroModalPriceDoesNotExplodePercentages();
|
|
22
|
-
|
|
23
|
-
console.log('All Kalman tests passed!');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function testFilterInitialization() {
|
|
27
|
-
console.log(' - Testing initialization');
|
|
28
|
-
const kf = new KalmanFilter();
|
|
29
|
-
const state = kf.update(100);
|
|
30
|
-
assert.strictEqual(state.x, 100);
|
|
31
|
-
assert.strictEqual(state.v, 0);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function testConstantTrendConvergence() {
|
|
35
|
-
console.log(' - Testing constant trend convergence');
|
|
36
|
-
const analyzer = new KalmanTrendAnalyzer({ rNoise: 0.01, qNoise: 0.01 });
|
|
37
|
-
|
|
38
|
-
// Simulate price moving from 100 to 200 in 100 steps (velocity = 1.0)
|
|
39
|
-
let price = 100;
|
|
40
|
-
let lastAnalysis;
|
|
41
|
-
for (let i = 0; i < 100; i++) {
|
|
42
|
-
price += 1.0;
|
|
43
|
-
lastAnalysis = analyzer.update(price);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Velocity should be very close to 1.0
|
|
47
|
-
assert.ok(Math.abs(lastAnalysis!.velocity - 1.0) < 0.05, `Velocity ${lastAnalysis!.velocity} should be near 1.0`);
|
|
48
|
-
assert.strictEqual(lastAnalysis!.trend, 'UP');
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function testNoiseFiltering() {
|
|
52
|
-
console.log(' - Testing noise filtering (wicks)');
|
|
53
|
-
const analyzer = new KalmanTrendAnalyzer({ rNoise: 10.0, qNoise: 0.01 }); // High R = ignore noise
|
|
54
|
-
|
|
55
|
-
// 50 steps of steady price
|
|
56
|
-
for (let i = 0; i < 50; i++) analyzer.update(100);
|
|
57
|
-
|
|
58
|
-
// One big "wick" to 150
|
|
59
|
-
const noisyAnalysis = analyzer.update(150);
|
|
60
|
-
|
|
61
|
-
// Kalman price should NOT jump to 150 immediately due to high R
|
|
62
|
-
assert.ok(noisyAnalysis.kalmanPrice < 115, `Kalman price ${noisyAnalysis.kalmanPrice} should stay low despite noise`);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function testTrajectoryProjection() {
|
|
66
|
-
console.log(' - Testing trajectory projection (beams)');
|
|
67
|
-
const analyzer = new KalmanTrendAnalyzer();
|
|
68
|
-
|
|
69
|
-
// Upward trend: velocity 2.0
|
|
70
|
-
for (let i = 0; i < 50; i++) analyzer.update(100 + (i * 2.0));
|
|
71
|
-
|
|
72
|
-
const analysis = analyzer.getAnalysis();
|
|
73
|
-
|
|
74
|
-
// Current price is ~200. The built-in projections field covers forward projection.
|
|
75
|
-
// project() method does not exist; use the projections object instead.
|
|
76
|
-
assert.ok(analysis.projections != null, 'Projections should be present');
|
|
77
|
-
assert.ok(Number.isFinite(analysis.projections.tactical), 'Tactical projection should be finite');
|
|
78
|
-
assert.ok(Number.isFinite(analysis.projections.modal), 'Modal projection should be finite');
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function testTrendDetectionSign() {
|
|
82
|
-
console.log(' - Testing trend detection signs');
|
|
83
|
-
const analyzer = new KalmanTrendAnalyzer();
|
|
84
|
-
|
|
85
|
-
for (let i = 0; i < 20; i++) analyzer.update(100 - i); // Downward
|
|
86
|
-
assert.strictEqual(analyzer.getAnalysis().trend, 'DOWN');
|
|
87
|
-
|
|
88
|
-
analyzer.reset();
|
|
89
|
-
for (let i = 0; i < 20; i++) analyzer.update(100 + i); // Upward
|
|
90
|
-
assert.strictEqual(analyzer.getAnalysis().trend, 'UP');
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function testResetPreservesFilterConfig() {
|
|
94
|
-
console.log(' - Testing reset preserves filter config');
|
|
95
|
-
const analyzer = new KalmanTrendAnalyzer({
|
|
96
|
-
rNoise: 0.25,
|
|
97
|
-
qTactical: 0.02,
|
|
98
|
-
qModal: 0.0002,
|
|
99
|
-
dt: 2
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
analyzer.update(100);
|
|
103
|
-
analyzer.reset();
|
|
104
|
-
|
|
105
|
-
assert.strictEqual(analyzer.tacticalKf.R, 0.25);
|
|
106
|
-
assert.strictEqual(analyzer.tacticalKf.Q, 0.02);
|
|
107
|
-
assert.strictEqual(analyzer.tacticalKf.dt, 2);
|
|
108
|
-
assert.strictEqual(analyzer.modalKf.R, 0.25);
|
|
109
|
-
assert.strictEqual(analyzer.modalKf.Q, 0.0002);
|
|
110
|
-
assert.strictEqual(analyzer.modalKf.dt, 2);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function testFilterRejectsInvalidMeasurements() {
|
|
114
|
-
console.log(' - Testing invalid measurement guard');
|
|
115
|
-
const kf = new KalmanFilter();
|
|
116
|
-
const initial = kf.update(100);
|
|
117
|
-
const state = kf.update(Number.NaN);
|
|
118
|
-
|
|
119
|
-
assert.deepStrictEqual(state, initial);
|
|
120
|
-
assert.strictEqual(kf.x, 100);
|
|
121
|
-
assert.strictEqual(kf.v, 0);
|
|
122
|
-
assert.strictEqual(kf.isInitialized, true);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function testInitialCovarianceScalesWithPrice() {
|
|
126
|
-
console.log(' - Testing price-scaled covariance initialization');
|
|
127
|
-
const kf = new KalmanFilter();
|
|
128
|
-
kf.update(0.0001);
|
|
129
|
-
|
|
130
|
-
assert.strictEqual(kf.P00, 0.0001 * 0.0001 * 100);
|
|
131
|
-
assert.strictEqual(kf.P11, 0.0001 * 0.0001);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function testNearZeroModalPriceDoesNotExplodePercentages() {
|
|
135
|
-
console.log(' - Testing near-zero percentage guard');
|
|
136
|
-
const analyzer = new KalmanTrendAnalyzer({ warmupBars: 0 });
|
|
137
|
-
analyzer.currPrice = 1;
|
|
138
|
-
analyzer.modal = { x: 1e-12, v: 0 };
|
|
139
|
-
analyzer.tactical = { x: 1, v: 1 };
|
|
140
|
-
analyzer.velocityFilteredPct = Number.NaN;
|
|
141
|
-
|
|
142
|
-
const analysis = analyzer.getAnalysis();
|
|
143
|
-
assert.strictEqual(analysis.velocityRawPct, 0);
|
|
144
|
-
assert.strictEqual(analysis.displacementRawPct, 0);
|
|
145
|
-
assert.ok(Number.isFinite(analysis.velocityPct));
|
|
146
|
-
assert.ok(Number.isFinite(analysis.displacementPct));
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
runTests().catch(err => {
|
|
150
|
-
console.error('Tests failed!');
|
|
151
|
-
console.error(err);
|
|
152
|
-
process.exit(1);
|
|
153
|
-
});
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
import assert from 'node:assert';
|
|
3
|
-
import {
|
|
4
|
-
buildKalmanVelocitySeries,
|
|
5
|
-
smoothKalmanVelocityPoint,
|
|
6
|
-
} from '../kalman_velocity_smoothing.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const baseline = smoothKalmanVelocityPoint(
|
|
10
|
-
0,
|
|
11
|
-
1,
|
|
12
|
-
10,
|
|
13
|
-
{
|
|
14
|
-
kalmanSmoothPct: 100,
|
|
15
|
-
kalmanDispScaleMult: 1.5,
|
|
16
|
-
kalmanDispThresholdMult: 1.5,
|
|
17
|
-
kalmanSmoothSpanPct: 100,
|
|
18
|
-
}
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
const maxed = smoothKalmanVelocityPoint(
|
|
22
|
-
0,
|
|
23
|
-
1,
|
|
24
|
-
10,
|
|
25
|
-
{
|
|
26
|
-
kalmanSmoothPct: 200,
|
|
27
|
-
kalmanDispScaleMult: 1.5,
|
|
28
|
-
kalmanDispThresholdMult: 1.5,
|
|
29
|
-
kalmanSmoothSpanPct: 100,
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
const clamped = smoothKalmanVelocityPoint(
|
|
34
|
-
0,
|
|
35
|
-
1,
|
|
36
|
-
10,
|
|
37
|
-
{
|
|
38
|
-
kalmanSmoothPct: 300,
|
|
39
|
-
kalmanDispScaleMult: 1.5,
|
|
40
|
-
kalmanDispThresholdMult: 1.5,
|
|
41
|
-
kalmanSmoothSpanPct: 100,
|
|
42
|
-
}
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
assert.ok(baseline.smoothedVelocityPct! > 0 && baseline.smoothedVelocityPct! < 10);
|
|
46
|
-
assert.strictEqual(clamped.smoothedVelocityPct!, maxed.smoothedVelocityPct!);
|
|
47
|
-
assert.ok(clamped.smoothedVelocityPct! > baseline.smoothedVelocityPct!);
|
|
48
|
-
|
|
49
|
-
const rawSeries = buildKalmanVelocitySeries(
|
|
50
|
-
[
|
|
51
|
-
{ velocityPct: 1.25, displacementPct: 0.4 },
|
|
52
|
-
{ velocityPct: -0.5, displacementPct: -0.3 },
|
|
53
|
-
{ velocityPct: null, displacementPct: 0.1 },
|
|
54
|
-
],
|
|
55
|
-
{
|
|
56
|
-
kalmanSmoothPct: 0,
|
|
57
|
-
kalmanDispScaleMult: 1.5,
|
|
58
|
-
kalmanDispThresholdMult: 1.5,
|
|
59
|
-
kalmanSmoothSpanPct: 100,
|
|
60
|
-
}
|
|
61
|
-
);
|
|
62
|
-
assert.deepStrictEqual(rawSeries, [1.25, -0.5, null], 'zero Kalman smoothing should short-circuit to the raw velocity series');
|
|
63
|
-
|
|
64
|
-
console.log('kalman_velocity_smoothing tests passed');
|