dexbot 1.6.7 → 1.6.9
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 +73 -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 +55 -16
- package/dist/market_adapter/core/market_adapter_service.d.ts +81 -1
- package/dist/market_adapter/core/market_adapter_service.js +239 -20
- package/dist/market_adapter/core/signals/hurst_analyzer.d.ts +10 -1
- package/dist/market_adapter/core/signals/hurst_analyzer.js +40 -18
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts +26 -2
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js +132 -29
- 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/core/strategies/regime_gate.d.ts +61 -3
- package/dist/market_adapter/core/strategies/regime_gate.js +207 -7
- 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/interval_utils.d.ts +18 -1
- package/dist/market_adapter/interval_utils.js +31 -1
- package/dist/market_adapter/market_adapter.d.ts +158 -2
- package/dist/market_adapter/market_adapter.js +399 -65
- package/dist/market_adapter/test_helpers.d.ts +2 -2
- package/dist/market_adapter/test_helpers.js +2 -2
- package/dist/market_adapter/utils/file_json_cache.d.ts +29 -0
- package/dist/market_adapter/utils/file_json_cache.js +106 -0
- 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 +7 -0
- package/dist/modules/config.js +2 -0
- package/dist/modules/constants.d.ts +16 -4
- package/dist/modules/constants.js +144 -38
- 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 +172 -160
- 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 +311 -0
- package/dist/modules/version_notice.js +709 -0
- package/dist/pm2.js +16 -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 +22 -20
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
- package/docs/GRID_PRICE_INVARIANT.md +149 -31
- package/docs/GRID_RECALCULATION.md +18 -2
- package/docs/README.md +3 -1
- package/docs/WORKFLOW.md +16 -5
- package/market_adapter/README.md +29 -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
|
@@ -6,6 +6,157 @@ import { roundTo } from '../../../modules/order/utils/math.js';
|
|
|
6
6
|
import { bilinearInterpolate } from './regime_interp.js';
|
|
7
7
|
const HURST_CONFIG = MARKET_ADAPTER.HURST_CONFIG;
|
|
8
8
|
const PE_CONFIG = MARKET_ADAPTER.PE_CONFIG;
|
|
9
|
+
/**
|
|
10
|
+
* Cross-cycle memoization for the regime gate.
|
|
11
|
+
*
|
|
12
|
+
* The adapter runs one cycle per hour per bot, but only ONE new candle closes in
|
|
13
|
+
* that window, and the Hurst/PE state at bar i depends solely on the previous
|
|
14
|
+
* `window` prices. Re-creating both analyzers and re-feeding all ~780 closes
|
|
15
|
+
* every hour therefore recomputed ~99.8% of the same numbers — the single
|
|
16
|
+
* largest CPU item in a cycle.
|
|
17
|
+
*
|
|
18
|
+
* When the caller supplies a stable `cacheKey` (the adapter passes
|
|
19
|
+
* `<botKey>:<intervalSeconds>`), the analyzers and the already-computed
|
|
20
|
+
* per-bar series are kept per key. The next cycle resumes the memoized state
|
|
21
|
+
* when the regime parameters are unchanged and the incoming window is the
|
|
22
|
+
* cached one advanced: same bars, with k leading bars dropped and m new bars
|
|
23
|
+
* appended. A gap repair, a corrected bar, a rewritten value, a different
|
|
24
|
+
* market or a config change all fail that check and fall back to a full
|
|
25
|
+
* recomputation. The resumed result is bit-identical to a from-scratch run in
|
|
26
|
+
* the headline multiplier and in every bar from that run's first ready bar
|
|
27
|
+
* onwards; the pre-warmup prefix can differ by the one-bar readiness offset
|
|
28
|
+
* described below. See tests/test_market_adapter_entropy_equivalence.ts.
|
|
29
|
+
*
|
|
30
|
+
* The leading-drop tolerance is what makes this worthwhile in production: the
|
|
31
|
+
* adapter caps the analysis window (rawKeepCount + analysisKeepCount), so once
|
|
32
|
+
* history saturates every hourly cycle SLIDES the window by one bar. A
|
|
33
|
+
* strict "cached is a prefix of incoming" test misses every one of those
|
|
34
|
+
* cycles. It is safe because both analyzers are rolling: their state depends
|
|
35
|
+
* only on the last `bufferSize` bars, so as long as the shared region still
|
|
36
|
+
* covers that much history, feeding only the new bars lands on exactly the
|
|
37
|
+
* state a cold replay of the whole window would produce.
|
|
38
|
+
*
|
|
39
|
+
* What a resume does NOT reproduce: the warmup boundary in the historical
|
|
40
|
+
* prefix. A warm analyzer pair has been fed one more bar in total than a freshly
|
|
41
|
+
* created one, so it reports its first value one bar earlier. Only the prefix
|
|
42
|
+
* is affected — the headline multiplier and every bar from the cold run's first
|
|
43
|
+
* ready index onwards are identical, which is every bar the service can act on
|
|
44
|
+
* (regimeMultipliers scales a per-bar offset that is itself zero before the
|
|
45
|
+
* AMA/Kalman channels are ready). See
|
|
46
|
+
* tests/test_market_adapter_entropy_equivalence.ts.
|
|
47
|
+
*
|
|
48
|
+
* Without a `cacheKey` the function is stateless, exactly as before.
|
|
49
|
+
*/
|
|
50
|
+
const REGIME_CACHE_LIMIT = 32;
|
|
51
|
+
const _regimeCache = new Map();
|
|
52
|
+
/**
|
|
53
|
+
* How many bars of history the analyzers' rolling state can depend on.
|
|
54
|
+
*
|
|
55
|
+
* Taken from the analyzer INSTANCES (each exposes `bufferBars`), never from a
|
|
56
|
+
* second copy of their constructor defaults: a mirrored formula silently
|
|
57
|
+
* under-estimates whenever a default or a buffer formula changes. Being too
|
|
58
|
+
* large only costs a missed resume; being too small would let the resume carry
|
|
59
|
+
* `cached.series` entries that were computed from bars the incoming window no
|
|
60
|
+
* longer contains (the analyzers' final state is unaffected either way — see
|
|
61
|
+
* _locateResume). An analyzer that does not report a usable size fails closed
|
|
62
|
+
* (MAX_SAFE_INTEGER), which disables resuming for that cache entry.
|
|
63
|
+
*/
|
|
64
|
+
function _analyzerBufferSize(hurst, pe) {
|
|
65
|
+
const sizes = [Number(hurst?.bufferBars), Number(pe?.bufferBars)]
|
|
66
|
+
.filter((value) => Number.isFinite(value) && value > 0);
|
|
67
|
+
if (sizes.length !== 2)
|
|
68
|
+
return Number.MAX_SAFE_INTEGER;
|
|
69
|
+
return Math.max(sizes[0], sizes[1]);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Locate how `closes` advances the cached window, or null when they are not
|
|
73
|
+
* related that way.
|
|
74
|
+
*
|
|
75
|
+
* Returns `{ k, shared }` where `closes[0..shared)` is exactly
|
|
76
|
+
* `cached[k..cached.length)` — i.e. the incoming window dropped k leading bars
|
|
77
|
+
* and appended `closes.length - shared` new ones. `k = 0, shared =
|
|
78
|
+
* cached.length` is the plain "one or more bars were added" case.
|
|
79
|
+
*
|
|
80
|
+
* The shift is pinned by matching the cached window's newest bar inside the
|
|
81
|
+
* incoming window, then the ENTIRE shared region is verified, so a coincidental
|
|
82
|
+
* price match cannot pass. NaN-aware, like the pre-cache implementation.
|
|
83
|
+
*
|
|
84
|
+
* When the cached newest bar occurs at more than one position and more than one
|
|
85
|
+
* candidate alignment verifies, the window is ambiguous and the function
|
|
86
|
+
* declines to resume. This is hygiene, not a safety requirement: any verified
|
|
87
|
+
* alignment with `shared >= minShared` is exact by construction, because that
|
|
88
|
+
* requirement guarantees the resumed stream's last `bufferBars` values are the
|
|
89
|
+
* same values the incoming stream ends with — the analyzers are rolling, so
|
|
90
|
+
* their final state (and every series entry from that point on) is identical
|
|
91
|
+
* whichever alignment is chosen. Declining only avoids anchoring the
|
|
92
|
+
* `cached.series` carry-over — whose early entries rest on bars the window may
|
|
93
|
+
* no longer contain — to a pattern match we did not intend. It can only arise
|
|
94
|
+
* on degenerate periodic windows, and a cold recompute there is cheap and
|
|
95
|
+
* honest.
|
|
96
|
+
*/
|
|
97
|
+
function _locateResume(cached, closes, minShared) {
|
|
98
|
+
if (cached.length === 0 || closes.length === 0)
|
|
99
|
+
return null;
|
|
100
|
+
if (cached.length > closes.length)
|
|
101
|
+
return null;
|
|
102
|
+
// Unchanged window: no scan needed, and no ambiguity to resolve.
|
|
103
|
+
if (cached.length === closes.length) {
|
|
104
|
+
let identical = true;
|
|
105
|
+
for (let i = 0; i < cached.length; i++) {
|
|
106
|
+
if (cached[i] === closes[i] || (Number.isNaN(cached[i]) && Number.isNaN(closes[i])))
|
|
107
|
+
continue;
|
|
108
|
+
identical = false;
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
if (identical)
|
|
112
|
+
return minShared <= cached.length ? { k: 0, shared: cached.length } : null;
|
|
113
|
+
}
|
|
114
|
+
const newest = cached[cached.length - 1];
|
|
115
|
+
let found = null;
|
|
116
|
+
// Newest match first, so the alignment that drops the fewest bars wins.
|
|
117
|
+
for (let p = closes.length - 1; p >= 0; p--) {
|
|
118
|
+
if (!(closes[p] === newest || (Number.isNaN(closes[p]) && Number.isNaN(newest))))
|
|
119
|
+
continue;
|
|
120
|
+
const k = cached.length - 1 - p;
|
|
121
|
+
// k < 0 means the match sits beyond the cached window: not this
|
|
122
|
+
// alignment, but a smaller p may still hold the right one.
|
|
123
|
+
if (k < 0)
|
|
124
|
+
continue;
|
|
125
|
+
const shared = cached.length - k;
|
|
126
|
+
if (shared < minShared)
|
|
127
|
+
return null; // too little history survives the slide
|
|
128
|
+
let ok = true;
|
|
129
|
+
for (let j = k; j < cached.length; j++) {
|
|
130
|
+
const a = cached[j];
|
|
131
|
+
const b = closes[j - k];
|
|
132
|
+
if (a === b || (Number.isNaN(a) && Number.isNaN(b)))
|
|
133
|
+
continue;
|
|
134
|
+
ok = false;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
if (!ok)
|
|
138
|
+
continue;
|
|
139
|
+
if (found)
|
|
140
|
+
return null; // ambiguous: repeated closes
|
|
141
|
+
found = { k, shared };
|
|
142
|
+
}
|
|
143
|
+
return found;
|
|
144
|
+
}
|
|
145
|
+
function regimeParamsKey(sensitivity, regimeTable, hurstZoneBand, peNodes, hurstCfg, peCfg) {
|
|
146
|
+
return JSON.stringify([sensitivity, regimeTable, hurstZoneBand, peNodes, hurstCfg, peCfg]);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Drop all memoized analyzer state.
|
|
150
|
+
*
|
|
151
|
+
* A test seam today, not a runtime path: the cycle resolves its parameters once
|
|
152
|
+
* per run, so there is no in-process config reload to invalidate state for, and
|
|
153
|
+
* a parameter change is already detected by `regimeParamsKey` (it forces a full
|
|
154
|
+
* recompute). Production never calls this — it exists so a test can assert a
|
|
155
|
+
* cold run against a warm cache without leaking entries between cases.
|
|
156
|
+
*/
|
|
157
|
+
function _resetRegimeCache() {
|
|
158
|
+
_regimeCache.clear();
|
|
159
|
+
}
|
|
9
160
|
function resolvePeNodes(peNodes = null) {
|
|
10
161
|
if (Array.isArray(peNodes) && peNodes.length === 3 && peNodes.every(Number.isFinite)) {
|
|
11
162
|
return peNodes;
|
|
@@ -39,9 +190,13 @@ function classifyPeRegime(pe, peNodes = null) {
|
|
|
39
190
|
* canonical pure implementation in strategies/regime_interp.ts (shared with the
|
|
40
191
|
* browser-embedded chart scripts).
|
|
41
192
|
*
|
|
42
|
-
* Feeds
|
|
193
|
+
* Feeds prices through HurstAnalyzer and PermutationEntropyAnalyzer,
|
|
43
194
|
* then bilinear-interpolates the regime table to produce a multiplier that
|
|
44
|
-
* gates the AMA slope offset in production weight computation.
|
|
195
|
+
* gates the AMA slope offset in production weight computation. When
|
|
196
|
+
* `opts.cacheKey` is set, a window that ADVANCES the memoized one (k leading
|
|
197
|
+
* bars dropped, m appended) resumes from the cached analyzer state and feeds
|
|
198
|
+
* only the appended bars; anything else recomputes from scratch. See the cache
|
|
199
|
+
* notes above.
|
|
45
200
|
*
|
|
46
201
|
* @param {number[]} closes - Full close price series (same array used for AMA)
|
|
47
202
|
* @param {Object} [opts]
|
|
@@ -49,6 +204,7 @@ function classifyPeRegime(pe, peNodes = null) {
|
|
|
49
204
|
* @param {Array} [opts.regimeTable] - Custom 3x3 regime multiplier table
|
|
50
205
|
* @param {number} [opts.hurstZoneBand] - Override Hurst neutral-zone width
|
|
51
206
|
* @param {Array} [opts.peNodes] - Override entropy thresholds
|
|
207
|
+
* @param {string} [opts.cacheKey] - Stable per-market key enabling cross-cycle reuse
|
|
52
208
|
* @param {Object} [opts.hurstConfig] - Override for HurstAnalyzer config
|
|
53
209
|
* @param {Object} [opts.peConfig] - Override for PermutationEntropyAnalyzer config
|
|
54
210
|
* @returns {{ multiplier: number, hurst: number|null, pe: number|null,
|
|
@@ -67,6 +223,7 @@ function computeRegimeMultiplier(closes, opts = {}) {
|
|
|
67
223
|
const peNodes = Array.isArray(opts.peNodes) ? opts.peNodes : MARKET_ADAPTER.PE_NODES;
|
|
68
224
|
const hurstCfg = opts.hurstConfig ?? HURST_CONFIG;
|
|
69
225
|
const peCfg = opts.peConfig ?? PE_CONFIG;
|
|
226
|
+
const cacheKey = typeof opts.cacheKey === 'string' && opts.cacheKey !== '' ? opts.cacheKey : null;
|
|
70
227
|
// Clamp to 1.0 max: regime only dampens, never amplifies. The
|
|
71
228
|
// sensitivity exponent is applied in one place for both the per-bar
|
|
72
229
|
// series and the final value.
|
|
@@ -82,12 +239,31 @@ function computeRegimeMultiplier(closes, opts = {}) {
|
|
|
82
239
|
};
|
|
83
240
|
if (!Array.isArray(closes) || closes.length === 0)
|
|
84
241
|
return notReady;
|
|
85
|
-
const
|
|
86
|
-
const
|
|
242
|
+
const paramsKey = regimeParamsKey(sensitivity, regimeTable, hurstZoneBand, peNodes, hurstCfg, peCfg);
|
|
243
|
+
const cached = cacheKey ? _regimeCache.get(cacheKey) : null;
|
|
244
|
+
const resume = (cached && cached.paramsKey === paramsKey)
|
|
245
|
+
? _locateResume(cached.closes, closes, _analyzerBufferSize(cached.hurst, cached.pe))
|
|
246
|
+
: null;
|
|
247
|
+
const resumable = !!resume;
|
|
248
|
+
const hurst = resumable ? cached.hurst : new HurstAnalyzer(hurstCfg);
|
|
249
|
+
const pe = resumable ? cached.pe : new PermutationEntropyAnalyzer(peCfg);
|
|
250
|
+
// Index-aligned with `closes`, exactly like the pre-cache implementation.
|
|
251
|
+
// The neutral 1.0 fill also covers bars the loop below does not produce a
|
|
252
|
+
// value for (warmup, or a non-finite price it skips): a resumed run must
|
|
253
|
+
// never come back with a hole the cold path would have filled.
|
|
254
|
+
const series = new Array(closes.length).fill(1.0);
|
|
255
|
+
// cached.series[i] was computed for cached.closes[i] === closes[i - k].
|
|
256
|
+
const startIndex = resumable ? resume.shared : 0;
|
|
257
|
+
if (resumable) {
|
|
258
|
+
for (let i = 0; i < startIndex; i++) {
|
|
259
|
+
const carried = cached.series[i + resume.k];
|
|
260
|
+
if (carried !== undefined)
|
|
261
|
+
series[i] = carried;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
87
264
|
let hurstResult = null;
|
|
88
265
|
let peResult = null;
|
|
89
|
-
|
|
90
|
-
for (let i = 0; i < closes.length; i++) {
|
|
266
|
+
for (let i = startIndex; i < closes.length; i++) {
|
|
91
267
|
const price = closes[i];
|
|
92
268
|
if (!Number.isFinite(price) || price <= 0)
|
|
93
269
|
continue;
|
|
@@ -105,6 +281,30 @@ function computeRegimeMultiplier(closes, opts = {}) {
|
|
|
105
281
|
// skip invalid prices (analyzers throw only on non-positive prices)
|
|
106
282
|
}
|
|
107
283
|
}
|
|
284
|
+
if (cacheKey) {
|
|
285
|
+
const entry = {
|
|
286
|
+
paramsKey,
|
|
287
|
+
closes: closes.slice(),
|
|
288
|
+
series: series.slice(),
|
|
289
|
+
hurst,
|
|
290
|
+
pe,
|
|
291
|
+
};
|
|
292
|
+
// Re-insert so the Map's insertion order stays a usable LRU order.
|
|
293
|
+
_regimeCache.delete(cacheKey);
|
|
294
|
+
_regimeCache.set(cacheKey, entry);
|
|
295
|
+
while (_regimeCache.size > REGIME_CACHE_LIMIT) {
|
|
296
|
+
const oldest = _regimeCache.keys().next();
|
|
297
|
+
if (oldest.done)
|
|
298
|
+
break;
|
|
299
|
+
_regimeCache.delete(oldest.value);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
// A resumed cycle can legitimately have no new bar to feed (the window is
|
|
303
|
+
// unchanged since the last call); the analyzers already hold that state.
|
|
304
|
+
if (!hurstResult)
|
|
305
|
+
hurstResult = hurst.getAnalysis();
|
|
306
|
+
if (!peResult)
|
|
307
|
+
peResult = pe.getAnalysis();
|
|
108
308
|
if (!hurstResult?.isReady || !peResult?.isReady)
|
|
109
309
|
return notReady;
|
|
110
310
|
const h = hurstResult.hurst;
|
|
@@ -121,5 +321,5 @@ function computeRegimeMultiplier(closes, opts = {}) {
|
|
|
121
321
|
series: series.map((value) => roundTo(value, 1000)),
|
|
122
322
|
};
|
|
123
323
|
}
|
|
124
|
-
export { computeRegimeMultiplier };
|
|
324
|
+
export { computeRegimeMultiplier, _resetRegimeCache, _locateResume, _analyzerBufferSize };
|
|
125
325
|
//# sourceMappingURL=regime_gate.js.map
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
declare const TAIL_REFRESH_HOURS = 48;
|
|
2
|
-
declare const
|
|
2
|
+
declare const TAIL_SETTLE_LAG_MS: number;
|
|
3
|
+
declare const GAP_SETTLE_HORIZON_MS: number;
|
|
4
|
+
declare const GAP_MERGE_TOLERANCE_BUCKETS = 2;
|
|
5
|
+
declare const MAX_SUBFETCH_RANGES = 8;
|
|
6
|
+
declare const MAX_SUBFETCH_SPAN_RATIO = 0.5;
|
|
7
|
+
declare const MAX_COVERAGE_SPANS = 64;
|
|
3
8
|
declare function shardKeyForTimestamp(tsMs: any): string;
|
|
4
9
|
declare function shardBoundsForKey(key: any): {
|
|
5
10
|
start: number;
|
|
@@ -13,7 +18,7 @@ declare function readCacheChunk(chunkFile: any, requestKey: any, isMatch: (meta:
|
|
|
13
18
|
file: any;
|
|
14
19
|
rangeGte: number | null;
|
|
15
20
|
rangeLte: number | null;
|
|
16
|
-
queried:
|
|
21
|
+
queried: QueriedRange[];
|
|
17
22
|
} | null;
|
|
18
23
|
declare function loadBucketCache(outPath: any, requestKey: any, isMatch: (meta: any, requestKey: any) => boolean, range?: {
|
|
19
24
|
gte: number;
|
|
@@ -25,29 +30,42 @@ declare function loadBucketCache(outPath: any, requestKey: any, isMatch: (meta:
|
|
|
25
30
|
gte: number | null;
|
|
26
31
|
lte: number | null;
|
|
27
32
|
count: number;
|
|
28
|
-
queried:
|
|
29
|
-
gte: number;
|
|
30
|
-
lte: number;
|
|
31
|
-
}[];
|
|
33
|
+
queried: QueriedRange[];
|
|
32
34
|
}[];
|
|
33
35
|
shards: {
|
|
34
36
|
file: string;
|
|
35
37
|
shardKey: string;
|
|
36
38
|
candles: any[];
|
|
37
|
-
queried:
|
|
38
|
-
gte: number;
|
|
39
|
-
lte: number;
|
|
40
|
-
}[];
|
|
39
|
+
queried: QueriedRange[];
|
|
41
40
|
}[];
|
|
42
41
|
};
|
|
43
42
|
declare function cachedCandlesInRange(localCache: any, gteMs: number, lteMs: number): any[];
|
|
44
|
-
|
|
43
|
+
/** Span of time actually queried, plus when the query ran (null = unknown). */
|
|
44
|
+
type QueriedRange = {
|
|
45
45
|
gte: number;
|
|
46
46
|
lte: number;
|
|
47
|
-
|
|
47
|
+
at: number | null;
|
|
48
|
+
};
|
|
49
|
+
/** Parse a verification timestamp: epoch ms or ISO. Anything else is unknown. */
|
|
50
|
+
declare function timestampMs(raw: any): number | null;
|
|
51
|
+
declare function verifiedAt(range: any): number | null;
|
|
52
|
+
/**
|
|
53
|
+
* Normalize recorded spans: sort, then merge overlapping / bucket-adjacent
|
|
54
|
+
* ones — but ONLY when they assert the same verification time. Merging spans
|
|
55
|
+
* with different `at` would have to pick one verdict for the whole union, and
|
|
56
|
+
* either pick loses (min → the merged span vouches for buckets the older
|
|
57
|
+
* query never saw; max → buckets verified long ago look freshly verified).
|
|
58
|
+
* Keeping them separate preserves exact per-bucket freshness, which is the
|
|
59
|
+
* whole point of `at`. Spans therefore accumulate ~1 per tail run, each a few
|
|
60
|
+
* dozen bytes — negligible next to the candles in the same file, and the
|
|
61
|
+
* same-`at` case (bulk fetches, and every pre-`at` shard) still collapses to
|
|
62
|
+
* one span as before.
|
|
63
|
+
*/
|
|
64
|
+
declare function unionQueriedRanges(ranges: {
|
|
48
65
|
gte: number;
|
|
49
66
|
lte: number;
|
|
50
|
-
|
|
67
|
+
at?: number | null;
|
|
68
|
+
}[], bucketMs: number): QueriedRange[];
|
|
51
69
|
declare function rangesCoveredBy(have: {
|
|
52
70
|
gte: number;
|
|
53
71
|
lte: number;
|
|
@@ -55,24 +73,83 @@ declare function rangesCoveredBy(have: {
|
|
|
55
73
|
gte: number;
|
|
56
74
|
lte: number;
|
|
57
75
|
}[]): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Change detection for shard writes: `have` already accounts for every span in
|
|
78
|
+
* `want`, in extent AND in verification time. Without the `at` half, a run
|
|
79
|
+
* whose only news is "these buckets were re-verified 1h later" would skip the
|
|
80
|
+
* write and the next run would fall back to the wide fixed refresh window.
|
|
81
|
+
* An unknown `at` on either side is never treated as fresh.
|
|
82
|
+
*/
|
|
83
|
+
declare function coverageSatisfied(have: QueriedRange[], want: QueriedRange[]): boolean;
|
|
84
|
+
/** Every recorded span across the loaded files, newest verification included. */
|
|
85
|
+
declare function allQueriedRanges(fileCover: {
|
|
86
|
+
queried?: QueriedRange[] | null;
|
|
87
|
+
}[]): QueriedRange[];
|
|
88
|
+
/**
|
|
89
|
+
* How settled a window is, given the recorded coverage.
|
|
90
|
+
*
|
|
91
|
+
* A bucket is settled when some recorded query covering it ran at least
|
|
92
|
+
* `lagMs` after the bucket closed — late indexing has certainly landed by
|
|
93
|
+
* then, so re-querying it can only re-confirm cached data. Returns
|
|
94
|
+
* `hasTimestamps: false` when no coverage carries a verification time (all
|
|
95
|
+
* pre-`at` shards), which tells the caller to fall back to the fixed window.
|
|
96
|
+
* Otherwise `firstUnsettled` is the earliest bucket that still needs a query
|
|
97
|
+
* (null when the whole window is settled).
|
|
98
|
+
*/
|
|
99
|
+
declare function settleCoverage(opts: {
|
|
100
|
+
gteMs: number;
|
|
101
|
+
lteMs: number;
|
|
102
|
+
bucketMs: number;
|
|
103
|
+
queried: QueriedRange[];
|
|
104
|
+
lagMs: number;
|
|
105
|
+
}): {
|
|
106
|
+
hasTimestamps: boolean;
|
|
107
|
+
firstUnsettled: number | null;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Bound the persisted span list. Because spans merge only when they assert
|
|
111
|
+
* the same `at`, a shard that is re-verified on every run gains one span per
|
|
112
|
+
* run and would grow without limit (and `settleCoverage` scans the list once
|
|
113
|
+
* per tail window). Dropping the OLDEST spans never invents emptiness, but it
|
|
114
|
+
* is not free: coverage is consulted by BOTH `pruneImmutableGaps` (to skip a
|
|
115
|
+
* query) and `settleCoverage` (to decide a bucket is fresh). A dropped span
|
|
116
|
+
* makes its buckets look unsettled, and the tail refresh would otherwise start
|
|
117
|
+
* at the earliest of them. That is why the refresh is capped at
|
|
118
|
+
* TAIL_REFRESH_HOURS: the worst a dropped span can cost is the legacy 48h
|
|
119
|
+
* overlap, never weeks. The input is already sorted by extent, so the tail of
|
|
120
|
+
* the list is the newest.
|
|
121
|
+
*/
|
|
122
|
+
declare function compactCoverage(spans: QueriedRange[], maxSpans: number): QueriedRange[];
|
|
58
123
|
declare function buildFetchWindowsFromRange(timeRange: any, chunkMonths: any): any[];
|
|
59
124
|
declare function findMissingBucketRanges(gteMs: number, lteMs: number, bucketMs: number, haveTs: Set<number>): {
|
|
60
125
|
gte: number;
|
|
61
126
|
lte: number;
|
|
62
127
|
hours: number;
|
|
63
128
|
}[];
|
|
129
|
+
/**
|
|
130
|
+
* Merge gap ranges that sit closer together than `toleranceBuckets`, so a
|
|
131
|
+
* cluster of one-bucket holes costs one query instead of one per hole. Only
|
|
132
|
+
* the bounding span widens (the buckets in between get queried too — they are
|
|
133
|
+
* local anyway, so the over-claim is harmless), and input order is preserved.
|
|
134
|
+
*/
|
|
135
|
+
declare function mergeGapRanges(missing: {
|
|
136
|
+
gte: number;
|
|
137
|
+
lte: number;
|
|
138
|
+
hours: number;
|
|
139
|
+
}[], bucketMs: number, toleranceBuckets: number): {
|
|
140
|
+
gte: number;
|
|
141
|
+
lte: number;
|
|
142
|
+
hours: number;
|
|
143
|
+
}[];
|
|
64
144
|
declare function pruneImmutableGaps(missing: {
|
|
65
145
|
gte: number;
|
|
66
146
|
lte: number;
|
|
67
147
|
hours: number;
|
|
68
|
-
}[],
|
|
148
|
+
}[], fileCover: {
|
|
69
149
|
gte: number | null;
|
|
70
150
|
lte: number | null;
|
|
71
151
|
count: number;
|
|
72
|
-
queried:
|
|
73
|
-
gte: number;
|
|
74
|
-
lte: number;
|
|
75
|
-
}[];
|
|
152
|
+
queried: QueriedRange[];
|
|
76
153
|
}[], nowMs?: number): {
|
|
77
154
|
gte: number;
|
|
78
155
|
lte: number;
|
|
@@ -147,5 +224,6 @@ declare function runCachedWindows(opts: {
|
|
|
147
224
|
lte: string;
|
|
148
225
|
}) => void;
|
|
149
226
|
}): Promise<any[]>;
|
|
150
|
-
export { TAIL_REFRESH_HOURS,
|
|
227
|
+
export { TAIL_REFRESH_HOURS, TAIL_SETTLE_LAG_MS, GAP_SETTLE_HORIZON_MS, GAP_MERGE_TOLERANCE_BUCKETS, MAX_SUBFETCH_RANGES, MAX_SUBFETCH_SPAN_RATIO, MAX_COVERAGE_SPANS, shardKeyForTimestamp, shardBoundsForKey, shardKeysForRange, shardPathFor, readCacheChunk, loadBucketCache, cachedCandlesInRange, unionQueriedRanges, compactCoverage, rangesCoveredBy, coverageSatisfied, verifiedAt, timestampMs, allQueriedRanges, settleCoverage, buildFetchWindowsFromRange, findMissingBucketRanges, mergeGapRanges, pruneImmutableGaps, persistCacheChunk, planWindowReuse, formatWindowLine, runCachedWindows, };
|
|
228
|
+
export type { QueriedRange };
|
|
151
229
|
//# sourceMappingURL=window_cache.d.ts.map
|