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.
Files changed (626) hide show
  1. package/CHANGELOG.md +73 -1
  2. package/README.md +3 -3
  3. package/analysis/README.md +2 -3
  4. package/analysis/tradingview/README.md +78 -1
  5. package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +1 -1
  6. package/claw/package.json +1 -1
  7. package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
  8. package/claw/runtimes/openclaw-plugin/package.json +1 -1
  9. package/dist/analysis/tradingview/analyze_tradingview.d.ts +4 -0
  10. package/dist/analysis/tradingview/analyze_tradingview.js +55 -0
  11. package/dist/analysis/tradingview/grid_reset_config.d.ts +61 -0
  12. package/dist/analysis/tradingview/grid_reset_config.js +235 -0
  13. package/dist/analysis/tradingview/grid_reset_sim.d.ts +67 -0
  14. package/dist/analysis/tradingview/grid_reset_sim.js +307 -0
  15. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +419 -3
  16. package/dist/dexbot.js +55 -16
  17. package/dist/market_adapter/core/market_adapter_service.d.ts +81 -1
  18. package/dist/market_adapter/core/market_adapter_service.js +239 -20
  19. package/dist/market_adapter/core/signals/hurst_analyzer.d.ts +10 -1
  20. package/dist/market_adapter/core/signals/hurst_analyzer.js +40 -18
  21. package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts +26 -2
  22. package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js +132 -29
  23. package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts +8 -1
  24. package/dist/market_adapter/core/strategies/dynamic_weight_series.js +5 -1
  25. package/dist/market_adapter/core/strategies/regime_gate.d.ts +61 -3
  26. package/dist/market_adapter/core/strategies/regime_gate.js +207 -7
  27. package/dist/market_adapter/inputs/window_cache.d.ts +97 -19
  28. package/dist/market_adapter/inputs/window_cache.js +302 -48
  29. package/dist/market_adapter/interval_utils.d.ts +18 -1
  30. package/dist/market_adapter/interval_utils.js +31 -1
  31. package/dist/market_adapter/market_adapter.d.ts +158 -2
  32. package/dist/market_adapter/market_adapter.js +399 -65
  33. package/dist/market_adapter/test_helpers.d.ts +2 -2
  34. package/dist/market_adapter/test_helpers.js +2 -2
  35. package/dist/market_adapter/utils/file_json_cache.d.ts +29 -0
  36. package/dist/market_adapter/utils/file_json_cache.js +106 -0
  37. package/dist/modules/account_bots.js +10 -0
  38. package/dist/modules/account_orders.d.ts +24 -2
  39. package/dist/modules/account_orders.js +41 -4
  40. package/dist/modules/bot_settings.js +10 -1
  41. package/dist/modules/config.d.ts +7 -0
  42. package/dist/modules/config.js +2 -0
  43. package/dist/modules/constants.d.ts +16 -4
  44. package/dist/modules/constants.js +144 -38
  45. package/dist/modules/dexbot_class.d.ts +6 -76
  46. package/dist/modules/dexbot_class.js +0 -32
  47. package/dist/modules/dexbot_cow_runtime.d.ts +3 -58
  48. package/dist/modules/dexbot_cow_runtime.js +4 -87
  49. package/dist/modules/dexbot_maintenance_runtime.d.ts +15 -1
  50. package/dist/modules/dexbot_maintenance_runtime.js +59 -11
  51. package/dist/modules/dexbot_startup_runtime.js +73 -20
  52. package/dist/modules/dexbot_state_recovery.d.ts +6 -0
  53. package/dist/modules/dexbot_state_recovery.js +21 -0
  54. package/dist/modules/order/async_lock.d.ts +8 -0
  55. package/dist/modules/order/async_lock.js +15 -0
  56. package/dist/modules/order/genesis_policy.d.ts +162 -0
  57. package/dist/modules/order/genesis_policy.js +267 -0
  58. package/dist/modules/order/grid.js +172 -160
  59. package/dist/modules/order/grid_reconcile.d.ts +9 -0
  60. package/dist/modules/order/grid_reconcile.js +13 -4
  61. package/dist/modules/order/grid_reconcile_internal.js +2 -2
  62. package/dist/modules/order/manager.d.ts +4 -0
  63. package/dist/modules/order/manager.js +14 -1
  64. package/dist/modules/order/sync_engine.d.ts +19 -0
  65. package/dist/modules/order/sync_engine.js +284 -344
  66. package/dist/modules/order/utils/math.d.ts +22 -1
  67. package/dist/modules/order/utils/math.js +64 -1
  68. package/dist/modules/order/utils/order.d.ts +43 -58
  69. package/dist/modules/order/utils/order.js +220 -197
  70. package/dist/modules/order/utils/system.js +8 -1
  71. package/dist/modules/paths.d.ts +1 -0
  72. package/dist/modules/paths.js +1 -0
  73. package/dist/modules/version_notice.d.ts +311 -0
  74. package/dist/modules/version_notice.js +709 -0
  75. package/dist/pm2.js +16 -0
  76. package/dist/unlock.js +28 -0
  77. package/docs/BITSHARES_ONBOARDING.md +8 -1
  78. package/docs/COW_INVARIANTS.md +3 -2
  79. package/docs/DEXBOT_COMPARISON.md +4 -4
  80. package/docs/EVOLUTION.md +22 -20
  81. package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
  82. package/docs/GRID_PRICE_INVARIANT.md +149 -31
  83. package/docs/GRID_RECALCULATION.md +18 -2
  84. package/docs/README.md +3 -1
  85. package/docs/WORKFLOW.md +16 -5
  86. package/market_adapter/README.md +29 -1
  87. package/modules/README.md +18 -1
  88. package/package.json +13 -5
  89. package/scripts/README.md +28 -2
  90. package/scripts/clear-all.sh +13 -4
  91. package/scripts/clear-logs.sh +13 -4
  92. package/scripts/clear-market-adapter.sh +6 -0
  93. package/scripts/clear-orders.sh +5 -0
  94. package/scripts/lib/dexbot-paths.sh +108 -0
  95. package/tests/README.md +11 -3
  96. package/analysis/account_resolver.ts +0 -161
  97. package/analysis/ama_fitting/analyze_ama_price_changes.ts +0 -155
  98. package/analysis/ama_fitting/analyze_lambda_vs_slow.ts +0 -404
  99. package/analysis/ama_fitting/calibrate_convergence_er.ts +0 -201
  100. package/analysis/ama_fitting/fetch_lp_candles.ts +0 -184
  101. package/analysis/ama_fitting/generate_unified_comparison_chart.ts +0 -232
  102. package/analysis/ama_fitting/optimizer_high_resolution.ts +0 -802
  103. package/analysis/analyze_dynamic_weight.ts +0 -243
  104. package/analysis/analyze_kalman.ts +0 -157
  105. package/analysis/analyze_regime.ts +0 -158
  106. package/analysis/analyze_regime_windows.ts +0 -470
  107. package/analysis/analyze_risk_profile.ts +0 -199
  108. package/analysis/analyze_trade_heatmap.ts +0 -362
  109. package/analysis/analyze_volatility.ts +0 -182
  110. package/analysis/bot_fitting/backtest_ama_sweep.ts +0 -934
  111. package/analysis/bot_fitting/backtest_bot_fitting.ts +0 -861
  112. package/analysis/bot_fitting/shared_utils.ts +0 -52
  113. package/analysis/bot_key_utils.ts +0 -426
  114. package/analysis/bot_usage/discover_bot_accounts.ts +0 -635
  115. package/analysis/bot_usage/kibana_bot_queries.ts +0 -211
  116. package/analysis/chain_pool.ts +0 -47
  117. package/analysis/chart_css.ts +0 -62
  118. package/analysis/chart_ui.ts +0 -105
  119. package/analysis/chart_utils.ts +0 -210
  120. package/analysis/fills_source.ts +0 -228
  121. package/analysis/grid_correction_check.ts +0 -786
  122. package/analysis/math_utils.ts +0 -53
  123. package/analysis/price_sources.ts +0 -136
  124. package/analysis/resolve_bot_accounts.ts +0 -199
  125. package/analysis/resolve_source.ts +0 -99
  126. package/analysis/results/ama_sweep_results_lp_pool_133_1h.json +0 -2455
  127. package/analysis/results/bot_fitting_results_lp_pool_133_1h.json +0 -218
  128. package/analysis/trade_profitability.ts +0 -1335
  129. package/analysis/tradingview/analyze_tradingview.ts +0 -280
  130. package/analysis/tradingview/h-bts_tradingview.html +0 -1570
  131. package/analysis/tradingview/t-bts_tradingview.html +0 -1570
  132. package/analysis/tradingview/tradingview_uplot_chart_generator.ts +0 -3268
  133. package/analysis/trend_detection/dynamic_weight_chart_generator.ts +0 -1481
  134. package/analysis/trend_detection/hurst_analyzer.ts +0 -7
  135. package/analysis/trend_detection/kalman_chart_generator.ts +0 -398
  136. package/analysis/trend_detection/kalman_trend_analyzer.ts +0 -9
  137. package/analysis/trend_detection/kalman_velocity_smoothing.ts +0 -7
  138. package/analysis/trend_detection/package.json +0 -23
  139. package/analysis/trend_detection/permutation_entropy_analyzer.ts +0 -7
  140. package/analysis/trend_detection/regime_chart_generator.ts +0 -338
  141. package/analysis/trend_detection/tests/test_kalman_trend.ts +0 -153
  142. package/analysis/trend_detection/tests/test_kalman_velocity_smoothing.ts +0 -64
  143. package/analysis/trend_detection/volatility_chart_generator.ts +0 -654
  144. package/analysis/tsconfig.json +0 -29
  145. package/claw/tests/package.json +0 -3
  146. package/claw/tests/test_claw_bridge.ts +0 -570
  147. package/claw/tests/test_claw_catalog_and_credentials.ts +0 -156
  148. package/claw/tests/test_claw_chain_layer.ts +0 -739
  149. package/claw/tests/test_claw_data_flow.ts +0 -525
  150. package/claw/tests/test_claw_domain_logic.ts +0 -471
  151. package/claw/tests/test_claw_manifest_and_matrix.ts +0 -222
  152. package/claw/tests/test_claw_mcp_transport.ts +0 -243
  153. package/claw/tests/test_claw_regressions.ts +0 -711
  154. package/claw/tests/test_claw_skill_generation.ts +0 -103
  155. package/claw/tests/test_claw_state_store.ts +0 -44
  156. package/claw/tests/test_dexbot_profiles.ts +0 -654
  157. package/claw/tests/test_memu_bridge.ts +0 -189
  158. package/claw/tests/test_nullclaw_tmp_integration.ts +0 -57
  159. package/claw/tests/test_position_health.ts +0 -343
  160. package/claw/tests/test_position_manager.ts +0 -429
  161. package/claw/tests/test_position_manager_watch_health.ts +0 -100
  162. package/claw/tests/test_short_mpa_strategy.ts +0 -232
  163. package/dist/analysis/account_resolver.d.ts.map +0 -1
  164. package/dist/analysis/account_resolver.js.map +0 -1
  165. package/dist/analysis/ama_fitting/analyze_ama_price_changes.d.ts.map +0 -1
  166. package/dist/analysis/ama_fitting/analyze_ama_price_changes.js.map +0 -1
  167. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.d.ts.map +0 -1
  168. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js.map +0 -1
  169. package/dist/analysis/ama_fitting/calibrate_convergence_er.d.ts.map +0 -1
  170. package/dist/analysis/ama_fitting/calibrate_convergence_er.js.map +0 -1
  171. package/dist/analysis/ama_fitting/fetch_lp_candles.d.ts.map +0 -1
  172. package/dist/analysis/ama_fitting/fetch_lp_candles.js.map +0 -1
  173. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts.map +0 -1
  174. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js.map +0 -1
  175. package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts.map +0 -1
  176. package/dist/analysis/ama_fitting/optimizer_high_resolution.js.map +0 -1
  177. package/dist/analysis/analyze_dynamic_weight.d.ts.map +0 -1
  178. package/dist/analysis/analyze_dynamic_weight.js.map +0 -1
  179. package/dist/analysis/analyze_kalman.d.ts.map +0 -1
  180. package/dist/analysis/analyze_kalman.js.map +0 -1
  181. package/dist/analysis/analyze_regime.d.ts.map +0 -1
  182. package/dist/analysis/analyze_regime.js.map +0 -1
  183. package/dist/analysis/analyze_regime_windows.d.ts.map +0 -1
  184. package/dist/analysis/analyze_regime_windows.js.map +0 -1
  185. package/dist/analysis/analyze_risk_profile.d.ts.map +0 -1
  186. package/dist/analysis/analyze_risk_profile.js.map +0 -1
  187. package/dist/analysis/analyze_trade_heatmap.d.ts.map +0 -1
  188. package/dist/analysis/analyze_trade_heatmap.js.map +0 -1
  189. package/dist/analysis/analyze_volatility.d.ts.map +0 -1
  190. package/dist/analysis/analyze_volatility.js.map +0 -1
  191. package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts.map +0 -1
  192. package/dist/analysis/bot_fitting/backtest_ama_sweep.js.map +0 -1
  193. package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts.map +0 -1
  194. package/dist/analysis/bot_fitting/backtest_bot_fitting.js.map +0 -1
  195. package/dist/analysis/bot_fitting/shared_utils.d.ts.map +0 -1
  196. package/dist/analysis/bot_fitting/shared_utils.js.map +0 -1
  197. package/dist/analysis/bot_key_utils.d.ts.map +0 -1
  198. package/dist/analysis/bot_key_utils.js.map +0 -1
  199. package/dist/analysis/bot_usage/discover_bot_accounts.d.ts.map +0 -1
  200. package/dist/analysis/bot_usage/discover_bot_accounts.js.map +0 -1
  201. package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +0 -1
  202. package/dist/analysis/bot_usage/kibana_bot_queries.js.map +0 -1
  203. package/dist/analysis/chain_pool.d.ts.map +0 -1
  204. package/dist/analysis/chain_pool.js.map +0 -1
  205. package/dist/analysis/chart_css.d.ts.map +0 -1
  206. package/dist/analysis/chart_css.js.map +0 -1
  207. package/dist/analysis/chart_ui.d.ts.map +0 -1
  208. package/dist/analysis/chart_ui.js.map +0 -1
  209. package/dist/analysis/chart_utils.d.ts.map +0 -1
  210. package/dist/analysis/chart_utils.js.map +0 -1
  211. package/dist/analysis/fills_source.d.ts.map +0 -1
  212. package/dist/analysis/fills_source.js.map +0 -1
  213. package/dist/analysis/grid_correction_check.d.ts.map +0 -1
  214. package/dist/analysis/grid_correction_check.js.map +0 -1
  215. package/dist/analysis/math_utils.d.ts.map +0 -1
  216. package/dist/analysis/math_utils.js.map +0 -1
  217. package/dist/analysis/price_sources.d.ts.map +0 -1
  218. package/dist/analysis/price_sources.js.map +0 -1
  219. package/dist/analysis/resolve_bot_accounts.d.ts.map +0 -1
  220. package/dist/analysis/resolve_bot_accounts.js.map +0 -1
  221. package/dist/analysis/resolve_source.d.ts.map +0 -1
  222. package/dist/analysis/resolve_source.js.map +0 -1
  223. package/dist/analysis/trade_profitability.d.ts.map +0 -1
  224. package/dist/analysis/trade_profitability.js.map +0 -1
  225. package/dist/analysis/tradingview/analyze_tradingview.d.ts.map +0 -1
  226. package/dist/analysis/tradingview/analyze_tradingview.js.map +0 -1
  227. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +0 -1
  228. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +0 -1
  229. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +0 -1
  230. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +0 -1
  231. package/dist/analysis/trend_detection/hurst_analyzer.d.ts.map +0 -1
  232. package/dist/analysis/trend_detection/hurst_analyzer.js.map +0 -1
  233. package/dist/analysis/trend_detection/kalman_chart_generator.d.ts.map +0 -1
  234. package/dist/analysis/trend_detection/kalman_chart_generator.js.map +0 -1
  235. package/dist/analysis/trend_detection/kalman_trend_analyzer.d.ts.map +0 -1
  236. package/dist/analysis/trend_detection/kalman_trend_analyzer.js.map +0 -1
  237. package/dist/analysis/trend_detection/kalman_velocity_smoothing.d.ts.map +0 -1
  238. package/dist/analysis/trend_detection/kalman_velocity_smoothing.js.map +0 -1
  239. package/dist/analysis/trend_detection/permutation_entropy_analyzer.d.ts.map +0 -1
  240. package/dist/analysis/trend_detection/permutation_entropy_analyzer.js.map +0 -1
  241. package/dist/analysis/trend_detection/regime_chart_generator.d.ts.map +0 -1
  242. package/dist/analysis/trend_detection/regime_chart_generator.js.map +0 -1
  243. package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts +0 -2
  244. package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts.map +0 -1
  245. package/dist/analysis/trend_detection/tests/test_kalman_trend.js +0 -128
  246. package/dist/analysis/trend_detection/tests/test_kalman_trend.js.map +0 -1
  247. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts +0 -2
  248. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts.map +0 -1
  249. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js +0 -37
  250. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js.map +0 -1
  251. package/dist/analysis/trend_detection/volatility_chart_generator.d.ts.map +0 -1
  252. package/dist/analysis/trend_detection/volatility_chart_generator.js.map +0 -1
  253. package/dist/bot.d.ts.map +0 -1
  254. package/dist/bot.js.map +0 -1
  255. package/dist/credential-daemon.d.ts.map +0 -1
  256. package/dist/credential-daemon.js.map +0 -1
  257. package/dist/dexbot.d.ts.map +0 -1
  258. package/dist/dexbot.js.map +0 -1
  259. package/dist/market_adapter/ama_signal_runner.d.ts.map +0 -1
  260. package/dist/market_adapter/ama_signal_runner.js.map +0 -1
  261. package/dist/market_adapter/candle_utils.d.ts.map +0 -1
  262. package/dist/market_adapter/candle_utils.js.map +0 -1
  263. package/dist/market_adapter/core/asymmetric_bounds.d.ts.map +0 -1
  264. package/dist/market_adapter/core/asymmetric_bounds.js.map +0 -1
  265. package/dist/market_adapter/core/config_normalizers.d.ts.map +0 -1
  266. package/dist/market_adapter/core/config_normalizers.js.map +0 -1
  267. package/dist/market_adapter/core/kibana_candles.d.ts.map +0 -1
  268. package/dist/market_adapter/core/kibana_candles.js.map +0 -1
  269. package/dist/market_adapter/core/kibana_client.d.ts.map +0 -1
  270. package/dist/market_adapter/core/kibana_client.js.map +0 -1
  271. package/dist/market_adapter/core/kibana_market_candles.d.ts.map +0 -1
  272. package/dist/market_adapter/core/kibana_market_candles.js.map +0 -1
  273. package/dist/market_adapter/core/market_adapter_service.d.ts.map +0 -1
  274. package/dist/market_adapter/core/market_adapter_service.js.map +0 -1
  275. package/dist/market_adapter/core/signals/hurst_analyzer.d.ts.map +0 -1
  276. package/dist/market_adapter/core/signals/hurst_analyzer.js.map +0 -1
  277. package/dist/market_adapter/core/signals/kalman_trend_analyzer.d.ts.map +0 -1
  278. package/dist/market_adapter/core/signals/kalman_trend_analyzer.js.map +0 -1
  279. package/dist/market_adapter/core/signals/kalman_velocity_smoothing.d.ts.map +0 -1
  280. package/dist/market_adapter/core/signals/kalman_velocity_smoothing.js.map +0 -1
  281. package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts.map +0 -1
  282. package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js.map +0 -1
  283. package/dist/market_adapter/core/strategies/ama.d.ts.map +0 -1
  284. package/dist/market_adapter/core/strategies/ama.js.map +0 -1
  285. package/dist/market_adapter/core/strategies/ama_slope_model.d.ts.map +0 -1
  286. package/dist/market_adapter/core/strategies/ama_slope_model.js.map +0 -1
  287. package/dist/market_adapter/core/strategies/atr/calculator.d.ts.map +0 -1
  288. package/dist/market_adapter/core/strategies/atr/calculator.js.map +0 -1
  289. package/dist/market_adapter/core/strategies/collateral_manager.d.ts.map +0 -1
  290. package/dist/market_adapter/core/strategies/collateral_manager.js.map +0 -1
  291. package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts.map +0 -1
  292. package/dist/market_adapter/core/strategies/dynamic_weight_series.js.map +0 -1
  293. package/dist/market_adapter/core/strategies/regime_gate.d.ts.map +0 -1
  294. package/dist/market_adapter/core/strategies/regime_gate.js.map +0 -1
  295. package/dist/market_adapter/core/strategies/regime_interp.d.ts.map +0 -1
  296. package/dist/market_adapter/core/strategies/regime_interp.js.map +0 -1
  297. package/dist/market_adapter/core/strategies/volatility_shift.d.ts.map +0 -1
  298. package/dist/market_adapter/core/strategies/volatility_shift.js.map +0 -1
  299. package/dist/market_adapter/inputs/fetch_book_data.d.ts.map +0 -1
  300. package/dist/market_adapter/inputs/fetch_book_data.js.map +0 -1
  301. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.d.ts.map +0 -1
  302. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +0 -1
  303. package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +0 -1
  304. package/dist/market_adapter/inputs/fetch_lp_data.js.map +0 -1
  305. package/dist/market_adapter/inputs/kibana_feed_source.d.ts.map +0 -1
  306. package/dist/market_adapter/inputs/kibana_feed_source.js.map +0 -1
  307. package/dist/market_adapter/inputs/kibana_source.d.ts.map +0 -1
  308. package/dist/market_adapter/inputs/kibana_source.js.map +0 -1
  309. package/dist/market_adapter/inputs/window_cache.d.ts.map +0 -1
  310. package/dist/market_adapter/inputs/window_cache.js.map +0 -1
  311. package/dist/market_adapter/interval_utils.d.ts.map +0 -1
  312. package/dist/market_adapter/interval_utils.js.map +0 -1
  313. package/dist/market_adapter/log_format.d.ts.map +0 -1
  314. package/dist/market_adapter/log_format.js.map +0 -1
  315. package/dist/market_adapter/lp_chart_core.d.ts.map +0 -1
  316. package/dist/market_adapter/lp_chart_core.js.map +0 -1
  317. package/dist/market_adapter/lp_chart_runner.d.ts.map +0 -1
  318. package/dist/market_adapter/lp_chart_runner.js.map +0 -1
  319. package/dist/market_adapter/lp_chart_strategy_loader.d.ts.map +0 -1
  320. package/dist/market_adapter/lp_chart_strategy_loader.js.map +0 -1
  321. package/dist/market_adapter/market_adapter.d.ts.map +0 -1
  322. package/dist/market_adapter/market_adapter.js.map +0 -1
  323. package/dist/market_adapter/test_helpers.d.ts.map +0 -1
  324. package/dist/market_adapter/test_helpers.js.map +0 -1
  325. package/dist/market_adapter/utils/adapter_client.d.ts.map +0 -1
  326. package/dist/market_adapter/utils/adapter_client.js.map +0 -1
  327. package/dist/market_adapter/utils/atomic_write.d.ts.map +0 -1
  328. package/dist/market_adapter/utils/atomic_write.js.map +0 -1
  329. package/dist/market_adapter/utils/chain.d.ts.map +0 -1
  330. package/dist/market_adapter/utils/chain.js.map +0 -1
  331. package/dist/market_adapter/utils/data_discovery.d.ts.map +0 -1
  332. package/dist/market_adapter/utils/data_discovery.js.map +0 -1
  333. package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +0 -1
  334. package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +0 -1
  335. package/dist/market_adapter/utils/file_lock.d.ts.map +0 -1
  336. package/dist/market_adapter/utils/file_lock.js.map +0 -1
  337. package/dist/market_adapter/utils/native_history.d.ts.map +0 -1
  338. package/dist/market_adapter/utils/native_history.js.map +0 -1
  339. package/dist/modules/account_bots.d.ts.map +0 -1
  340. package/dist/modules/account_bots.js.map +0 -1
  341. package/dist/modules/account_orders.d.ts.map +0 -1
  342. package/dist/modules/account_orders.js.map +0 -1
  343. package/dist/modules/authority_resolver.d.ts.map +0 -1
  344. package/dist/modules/authority_resolver.js.map +0 -1
  345. package/dist/modules/bitshares-native/chain_client.d.ts.map +0 -1
  346. package/dist/modules/bitshares-native/chain_client.js.map +0 -1
  347. package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +0 -1
  348. package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +0 -1
  349. package/dist/modules/bitshares-native/crypto/ecc.d.ts.map +0 -1
  350. package/dist/modules/bitshares-native/crypto/ecc.js.map +0 -1
  351. package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts.map +0 -1
  352. package/dist/modules/bitshares-native/crypto/ecc_selector.js.map +0 -1
  353. package/dist/modules/bitshares-native/index.d.ts.map +0 -1
  354. package/dist/modules/bitshares-native/index.js.map +0 -1
  355. package/dist/modules/bitshares-native/lru_cache.d.ts.map +0 -1
  356. package/dist/modules/bitshares-native/lru_cache.js.map +0 -1
  357. package/dist/modules/bitshares-native/resolvers.d.ts.map +0 -1
  358. package/dist/modules/bitshares-native/resolvers.js.map +0 -1
  359. package/dist/modules/bitshares-native/serial/chain_constants.d.ts.map +0 -1
  360. package/dist/modules/bitshares-native/serial/chain_constants.js.map +0 -1
  361. package/dist/modules/bitshares-native/serial/index.d.ts.map +0 -1
  362. package/dist/modules/bitshares-native/serial/index.js.map +0 -1
  363. package/dist/modules/bitshares-native/serial/operations.d.ts.map +0 -1
  364. package/dist/modules/bitshares-native/serial/operations.js.map +0 -1
  365. package/dist/modules/bitshares-native/serial/serializer.d.ts.map +0 -1
  366. package/dist/modules/bitshares-native/serial/serializer.js.map +0 -1
  367. package/dist/modules/bitshares-native/serial/types.d.ts.map +0 -1
  368. package/dist/modules/bitshares-native/serial/types.js.map +0 -1
  369. package/dist/modules/bitshares-native/signing_client.d.ts.map +0 -1
  370. package/dist/modules/bitshares-native/signing_client.js.map +0 -1
  371. package/dist/modules/bitshares-native/subscriptions.d.ts.map +0 -1
  372. package/dist/modules/bitshares-native/subscriptions.js.map +0 -1
  373. package/dist/modules/bitshares-native/transport.d.ts.map +0 -1
  374. package/dist/modules/bitshares-native/transport.js.map +0 -1
  375. package/dist/modules/bitshares-native/tx/builder.d.ts.map +0 -1
  376. package/dist/modules/bitshares-native/tx/builder.js.map +0 -1
  377. package/dist/modules/bitshares-native/tx/tx_cache.d.ts.map +0 -1
  378. package/dist/modules/bitshares-native/tx/tx_cache.js.map +0 -1
  379. package/dist/modules/bitshares_client.d.ts.map +0 -1
  380. package/dist/modules/bitshares_client.js.map +0 -1
  381. package/dist/modules/bot_defaults.d.ts.map +0 -1
  382. package/dist/modules/bot_defaults.js.map +0 -1
  383. package/dist/modules/bot_settings.d.ts.map +0 -1
  384. package/dist/modules/bot_settings.js.map +0 -1
  385. package/dist/modules/bots_file_lock.d.ts.map +0 -1
  386. package/dist/modules/bots_file_lock.js.map +0 -1
  387. package/dist/modules/broadcast_failure.d.ts.map +0 -1
  388. package/dist/modules/broadcast_failure.js.map +0 -1
  389. package/dist/modules/chain_keys.d.ts.map +0 -1
  390. package/dist/modules/chain_keys.js.map +0 -1
  391. package/dist/modules/chain_orders.d.ts.map +0 -1
  392. package/dist/modules/chain_orders.js.map +0 -1
  393. package/dist/modules/cli_colors.d.ts.map +0 -1
  394. package/dist/modules/cli_colors.js.map +0 -1
  395. package/dist/modules/cli_start_onboarding.d.ts.map +0 -1
  396. package/dist/modules/cli_start_onboarding.js.map +0 -1
  397. package/dist/modules/cli_start_output.d.ts.map +0 -1
  398. package/dist/modules/cli_start_output.js.map +0 -1
  399. package/dist/modules/config.d.ts.map +0 -1
  400. package/dist/modules/config.js.map +0 -1
  401. package/dist/modules/constants.d.ts.map +0 -1
  402. package/dist/modules/constants.js.map +0 -1
  403. package/dist/modules/cr_planner.d.ts.map +0 -1
  404. package/dist/modules/cr_planner.js.map +0 -1
  405. package/dist/modules/credential_policy.d.ts.map +0 -1
  406. package/dist/modules/credential_policy.js.map +0 -1
  407. package/dist/modules/credential_runtime.d.ts.map +0 -1
  408. package/dist/modules/credential_runtime.js.map +0 -1
  409. package/dist/modules/credential_session_cache.d.ts.map +0 -1
  410. package/dist/modules/credential_session_cache.js.map +0 -1
  411. package/dist/modules/credit_pricing.d.ts.map +0 -1
  412. package/dist/modules/credit_pricing.js.map +0 -1
  413. package/dist/modules/credit_runtime.d.ts.map +0 -1
  414. package/dist/modules/credit_runtime.js.map +0 -1
  415. package/dist/modules/crypto/browser_provider.d.ts.map +0 -1
  416. package/dist/modules/crypto/browser_provider.js.map +0 -1
  417. package/dist/modules/crypto/index.d.ts.map +0 -1
  418. package/dist/modules/crypto/index.js.map +0 -1
  419. package/dist/modules/crypto/node_provider.d.ts.map +0 -1
  420. package/dist/modules/crypto/node_provider.js.map +0 -1
  421. package/dist/modules/crypto/provider.d.ts.map +0 -1
  422. package/dist/modules/crypto/provider.js.map +0 -1
  423. package/dist/modules/crypto/pure_ripemd160.d.ts.map +0 -1
  424. package/dist/modules/crypto/pure_ripemd160.js.map +0 -1
  425. package/dist/modules/crypto/pure_scrypt.d.ts.map +0 -1
  426. package/dist/modules/crypto/pure_scrypt.js.map +0 -1
  427. package/dist/modules/crypto/pure_secp256k1.d.ts.map +0 -1
  428. package/dist/modules/crypto/pure_secp256k1.js.map +0 -1
  429. package/dist/modules/crypto/sync.d.ts.map +0 -1
  430. package/dist/modules/crypto/sync.js.map +0 -1
  431. package/dist/modules/daemon_node_health.d.ts.map +0 -1
  432. package/dist/modules/daemon_node_health.js.map +0 -1
  433. package/dist/modules/dexbot_class.d.ts.map +0 -1
  434. package/dist/modules/dexbot_class.js.map +0 -1
  435. package/dist/modules/dexbot_cow_runtime.d.ts.map +0 -1
  436. package/dist/modules/dexbot_cow_runtime.js.map +0 -1
  437. package/dist/modules/dexbot_credential_client.d.ts.map +0 -1
  438. package/dist/modules/dexbot_credential_client.js.map +0 -1
  439. package/dist/modules/dexbot_fill_runtime.d.ts.map +0 -1
  440. package/dist/modules/dexbot_fill_runtime.js.map +0 -1
  441. package/dist/modules/dexbot_maintenance_runtime.d.ts.map +0 -1
  442. package/dist/modules/dexbot_maintenance_runtime.js.map +0 -1
  443. package/dist/modules/dexbot_startup_runtime.d.ts.map +0 -1
  444. package/dist/modules/dexbot_startup_runtime.js.map +0 -1
  445. package/dist/modules/dexbot_state_recovery.d.ts.map +0 -1
  446. package/dist/modules/dexbot_state_recovery.js.map +0 -1
  447. package/dist/modules/env.d.ts.map +0 -1
  448. package/dist/modules/env.js.map +0 -1
  449. package/dist/modules/fund_registry.d.ts.map +0 -1
  450. package/dist/modules/fund_registry.js.map +0 -1
  451. package/dist/modules/general_settings.d.ts.map +0 -1
  452. package/dist/modules/general_settings.js.map +0 -1
  453. package/dist/modules/graceful_shutdown.d.ts.map +0 -1
  454. package/dist/modules/graceful_shutdown.js.map +0 -1
  455. package/dist/modules/grid_price_source.d.ts.map +0 -1
  456. package/dist/modules/grid_price_source.js.map +0 -1
  457. package/dist/modules/key_store.d.ts.map +0 -1
  458. package/dist/modules/key_store.js.map +0 -1
  459. package/dist/modules/launcher/adapter_requirement.d.ts.map +0 -1
  460. package/dist/modules/launcher/adapter_requirement.js.map +0 -1
  461. package/dist/modules/launcher/bot_supervisor.d.ts.map +0 -1
  462. package/dist/modules/launcher/bot_supervisor.js.map +0 -1
  463. package/dist/modules/launcher/child_env.d.ts.map +0 -1
  464. package/dist/modules/launcher/child_env.js.map +0 -1
  465. package/dist/modules/launcher/credential_bootstrap.d.ts.map +0 -1
  466. package/dist/modules/launcher/credential_bootstrap.js.map +0 -1
  467. package/dist/modules/launcher/credential_daemon.d.ts.map +0 -1
  468. package/dist/modules/launcher/credential_daemon.js.map +0 -1
  469. package/dist/modules/launcher/credential_secret.d.ts.map +0 -1
  470. package/dist/modules/launcher/credential_secret.js.map +0 -1
  471. package/dist/modules/launcher/foreign_cred_daemon.d.ts.map +0 -1
  472. package/dist/modules/launcher/foreign_cred_daemon.js.map +0 -1
  473. package/dist/modules/launcher/headless_password.d.ts.map +0 -1
  474. package/dist/modules/launcher/headless_password.js.map +0 -1
  475. package/dist/modules/launcher/launch_modes.d.ts.map +0 -1
  476. package/dist/modules/launcher/launch_modes.js.map +0 -1
  477. package/dist/modules/launcher/market_adapter_runtime.d.ts.map +0 -1
  478. package/dist/modules/launcher/market_adapter_runtime.js.map +0 -1
  479. package/dist/modules/launcher/market_adapter_watchdog.d.ts.map +0 -1
  480. package/dist/modules/launcher/market_adapter_watchdog.js.map +0 -1
  481. package/dist/modules/launcher/monolithic_runtime.d.ts.map +0 -1
  482. package/dist/modules/launcher/monolithic_runtime.js.map +0 -1
  483. package/dist/modules/launcher/runtime_entry.d.ts.map +0 -1
  484. package/dist/modules/launcher/runtime_entry.js.map +0 -1
  485. package/dist/modules/launcher/status_reporting.d.ts.map +0 -1
  486. package/dist/modules/launcher/status_reporting.js.map +0 -1
  487. package/dist/modules/launcher/supervisor_control.d.ts.map +0 -1
  488. package/dist/modules/launcher/supervisor_control.js.map +0 -1
  489. package/dist/modules/market_adapter_whitelist.d.ts.map +0 -1
  490. package/dist/modules/market_adapter_whitelist.js.map +0 -1
  491. package/dist/modules/node_connect_policy.d.ts.map +0 -1
  492. package/dist/modules/node_connect_policy.js.map +0 -1
  493. package/dist/modules/node_failure_ledger.d.ts.map +0 -1
  494. package/dist/modules/node_failure_ledger.js.map +0 -1
  495. package/dist/modules/node_health_cache.d.ts.map +0 -1
  496. package/dist/modules/node_health_cache.js.map +0 -1
  497. package/dist/modules/node_manager.d.ts.map +0 -1
  498. package/dist/modules/node_manager.js.map +0 -1
  499. package/dist/modules/order/accounting.d.ts.map +0 -1
  500. package/dist/modules/order/accounting.js.map +0 -1
  501. package/dist/modules/order/async_lock.d.ts.map +0 -1
  502. package/dist/modules/order/async_lock.js.map +0 -1
  503. package/dist/modules/order/export.d.ts.map +0 -1
  504. package/dist/modules/order/export.js.map +0 -1
  505. package/dist/modules/order/format.d.ts.map +0 -1
  506. package/dist/modules/order/format.js.map +0 -1
  507. package/dist/modules/order/grid.d.ts.map +0 -1
  508. package/dist/modules/order/grid.js.map +0 -1
  509. package/dist/modules/order/grid_reconcile.d.ts.map +0 -1
  510. package/dist/modules/order/grid_reconcile.js.map +0 -1
  511. package/dist/modules/order/grid_reconcile_internal.d.ts.map +0 -1
  512. package/dist/modules/order/grid_reconcile_internal.js.map +0 -1
  513. package/dist/modules/order/index.d.ts.map +0 -1
  514. package/dist/modules/order/index.js.map +0 -1
  515. package/dist/modules/order/logger.d.ts.map +0 -1
  516. package/dist/modules/order/logger.js.map +0 -1
  517. package/dist/modules/order/logger_state.d.ts.map +0 -1
  518. package/dist/modules/order/logger_state.js.map +0 -1
  519. package/dist/modules/order/manager.d.ts.map +0 -1
  520. package/dist/modules/order/manager.js.map +0 -1
  521. package/dist/modules/order/processed_fill_store.d.ts.map +0 -1
  522. package/dist/modules/order/processed_fill_store.js.map +0 -1
  523. package/dist/modules/order/strategy.d.ts.map +0 -1
  524. package/dist/modules/order/strategy.js.map +0 -1
  525. package/dist/modules/order/sync_engine.d.ts.map +0 -1
  526. package/dist/modules/order/sync_engine.js.map +0 -1
  527. package/dist/modules/order/utils/math.d.ts.map +0 -1
  528. package/dist/modules/order/utils/math.js.map +0 -1
  529. package/dist/modules/order/utils/order.d.ts.map +0 -1
  530. package/dist/modules/order/utils/order.js.map +0 -1
  531. package/dist/modules/order/utils/slot.d.ts.map +0 -1
  532. package/dist/modules/order/utils/slot.js.map +0 -1
  533. package/dist/modules/order/utils/system.d.ts.map +0 -1
  534. package/dist/modules/order/utils/system.js.map +0 -1
  535. package/dist/modules/order/utils/timeout.d.ts.map +0 -1
  536. package/dist/modules/order/utils/timeout.js.map +0 -1
  537. package/dist/modules/order/utils/validate.d.ts.map +0 -1
  538. package/dist/modules/order/utils/validate.js.map +0 -1
  539. package/dist/modules/order/utils/withPoolRef.d.ts.map +0 -1
  540. package/dist/modules/order/utils/withPoolRef.js.map +0 -1
  541. package/dist/modules/order/working_grid.d.ts.map +0 -1
  542. package/dist/modules/order/working_grid.js.map +0 -1
  543. package/dist/modules/path_api.d.ts.map +0 -1
  544. package/dist/modules/path_api.js.map +0 -1
  545. package/dist/modules/paths.d.ts.map +0 -1
  546. package/dist/modules/paths.js.map +0 -1
  547. package/dist/modules/process_discovery.d.ts.map +0 -1
  548. package/dist/modules/process_discovery.js.map +0 -1
  549. package/dist/modules/runtime.d.ts.map +0 -1
  550. package/dist/modules/runtime.js.map +0 -1
  551. package/dist/modules/runtime_settings.d.ts.map +0 -1
  552. package/dist/modules/runtime_settings.js.map +0 -1
  553. package/dist/modules/settings_merge.d.ts.map +0 -1
  554. package/dist/modules/settings_merge.js.map +0 -1
  555. package/dist/modules/socket_json_client.d.ts.map +0 -1
  556. package/dist/modules/socket_json_client.js.map +0 -1
  557. package/dist/modules/storage/browser_adapter.d.ts.map +0 -1
  558. package/dist/modules/storage/browser_adapter.js.map +0 -1
  559. package/dist/modules/storage/index.d.ts.map +0 -1
  560. package/dist/modules/storage/index.js.map +0 -1
  561. package/dist/modules/storage/node_adapter.d.ts.map +0 -1
  562. package/dist/modules/storage/node_adapter.js.map +0 -1
  563. package/dist/modules/storage/types.d.ts.map +0 -1
  564. package/dist/modules/storage/types.js.map +0 -1
  565. package/dist/modules/types.d.ts.map +0 -1
  566. package/dist/modules/types.js.map +0 -1
  567. package/dist/modules/utils/base58check.d.ts.map +0 -1
  568. package/dist/modules/utils/base58check.js.map +0 -1
  569. package/dist/modules/utils/build_dir.d.ts.map +0 -1
  570. package/dist/modules/utils/build_dir.js.map +0 -1
  571. package/dist/modules/utils/chain_logs.d.ts.map +0 -1
  572. package/dist/modules/utils/chain_logs.js.map +0 -1
  573. package/dist/modules/utils/errors.d.ts.map +0 -1
  574. package/dist/modules/utils/errors.js.map +0 -1
  575. package/dist/modules/utils/sanitize_key.d.ts.map +0 -1
  576. package/dist/modules/utils/sanitize_key.js.map +0 -1
  577. package/dist/modules/utils/text_width.d.ts.map +0 -1
  578. package/dist/modules/utils/text_width.js.map +0 -1
  579. package/dist/modules/validate_profiles.d.ts.map +0 -1
  580. package/dist/modules/validate_profiles.js.map +0 -1
  581. package/dist/pm2.d.ts.map +0 -1
  582. package/dist/pm2.js.map +0 -1
  583. package/dist/scripts/analyze-credit.d.ts.map +0 -1
  584. package/dist/scripts/analyze-credit.js.map +0 -1
  585. package/dist/scripts/analyze-git.d.ts.map +0 -1
  586. package/dist/scripts/analyze-git.js.map +0 -1
  587. package/dist/scripts/analyze-orders.d.ts.map +0 -1
  588. package/dist/scripts/analyze-orders.js.map +0 -1
  589. package/dist/scripts/chart_command.d.ts.map +0 -1
  590. package/dist/scripts/chart_command.js.map +0 -1
  591. package/dist/scripts/diagnose-kibana-candles.d.ts.map +0 -1
  592. package/dist/scripts/diagnose-kibana-candles.js.map +0 -1
  593. package/dist/scripts/diagnose-pool-history.d.ts.map +0 -1
  594. package/dist/scripts/diagnose-pool-history.js.map +0 -1
  595. package/dist/scripts/divergence-calc.d.ts.map +0 -1
  596. package/dist/scripts/divergence-calc.js.map +0 -1
  597. package/dist/scripts/dw.d.ts.map +0 -1
  598. package/dist/scripts/dw.js.map +0 -1
  599. package/dist/scripts/generate_lp_chart.d.ts.map +0 -1
  600. package/dist/scripts/generate_lp_chart.js.map +0 -1
  601. package/dist/scripts/generate_mainnet_corpus_report.d.ts.map +0 -1
  602. package/dist/scripts/generate_mainnet_corpus_report.js.map +0 -1
  603. package/dist/scripts/native_release_gates.d.ts.map +0 -1
  604. package/dist/scripts/native_release_gates.js.map +0 -1
  605. package/dist/scripts/print_grid.d.ts.map +0 -1
  606. package/dist/scripts/print_grid.js.map +0 -1
  607. package/dist/scripts/run-tests.d.ts.map +0 -1
  608. package/dist/scripts/run-tests.js.map +0 -1
  609. package/dist/scripts/runner.d.ts.map +0 -1
  610. package/dist/scripts/runner.js.map +0 -1
  611. package/dist/scripts/sync-version.d.ts.map +0 -1
  612. package/dist/scripts/sync-version.js.map +0 -1
  613. package/dist/scripts/test-credit-renewal.d.ts.map +0 -1
  614. package/dist/scripts/test-credit-renewal.js.map +0 -1
  615. package/dist/scripts/tv.d.ts.map +0 -1
  616. package/dist/scripts/tv.js.map +0 -1
  617. package/dist/scripts/update.d.ts.map +0 -1
  618. package/dist/scripts/update.js.map +0 -1
  619. package/dist/scripts/update_dist_freshness.d.ts.map +0 -1
  620. package/dist/scripts/update_dist_freshness.js.map +0 -1
  621. package/dist/scripts/validate_bots.d.ts.map +0 -1
  622. package/dist/scripts/validate_bots.js.map +0 -1
  623. package/dist/scripts/verify-browser-bundle.d.ts.map +0 -1
  624. package/dist/scripts/verify-browser-bundle.js.map +0 -1
  625. package/dist/unlock.d.ts.map +0 -1
  626. package/dist/unlock.js.map +0 -1
@@ -1,654 +0,0 @@
1
- 'use strict';
2
-
3
- import { MARKET_ADAPTER } from '../../modules/constants.js';
4
- import { computeATRSeries } from '../../market_adapter/core/strategies/atr/calculator.js';
5
- import { computeVolatilityShift } from '../../market_adapter/core/strategies/volatility_shift.js';
6
- import { embedFunctionSources, escapeHtml, serializeJsonForScript, toEpochSeconds, UPLOT_SHARED_SCRIPT, uplotInlineTags } from '../chart_utils.js';
7
- import { sharedChartCSS } from '../chart_css.js';
8
- import { Y_AXIS_SIZE, makeCursorConfig, bindHoverStateFn, wireChartEvents, zoomResetScript, sizeChartsFn } from '../chart_ui.js';
9
-
10
- const EMBEDDED_SHARED_FUNCS = embedFunctionSources([computeATRSeries, computeVolatilityShift]);
11
-
12
-
13
- function generateHTML(data: any, title = 'ATR Volatility Research') {
14
- const results = data.allResults || [];
15
- if (results.length === 0) throw new Error('No analysis results in input');
16
-
17
- const volatilityCfg = data.volatilityConfig || {};
18
- const defaultThreshold = data.volatilityThreshold ?? volatilityCfg.volatilityThreshold
19
- ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_SYMMETRIC_SHIFT_THRESHOLD;
20
- const defaultAtrPeriod = data.atrPeriod ?? volatilityCfg.atrPeriod ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_ATR_PERIOD_DEFAULT;
21
- const defaultExponent = data.volatilityExponent ?? volatilityCfg.volatilityExponent ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_VOLATILITY_EXPONENT;
22
- const defaultScaleX = data.volatilityScaleX ?? volatilityCfg.volatilityScaleX ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_VOLATILITY_SCALE_X_DEFAULT;
23
- const defaultClamp = data.volatilityClamp ?? volatilityCfg.volatilityClamp ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_SYMMETRIC_SHIFT_CLAMP;
24
- const defaultMinWeight = data.minWeight ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_MIN_WEIGHT;
25
- const defaultMaxWeight = data.maxWeight ?? MARKET_ADAPTER.DYNAMIC_WEIGHT_MAX_WEIGHT;
26
- const interval = results.length > 1
27
- ? (new Date(results[1].timestamp).getTime() - new Date(results[0].timestamp).getTime()) / 1000
28
- : 3600;
29
-
30
- const dates = results.map((r: any, i: number) => toEpochSeconds(r.timestamp || Date.now(), i));
31
- const prices = results.map((r: any) => r.price);
32
- const ama3Prices = results.map((r: any) => r.ama3Price ?? null);
33
- const baseVarianceSeries = results.map((r: any) => r.weightVariance ?? null);
34
- const candleRows = Array.isArray(data.candles) ? data.candles : [];
35
-
36
- const realBarCount = results.length;
37
- const lastDate = dates[dates.length - 1];
38
- for (let i = 1; i <= 120; i++) {
39
- dates.push(lastDate + (i * interval));
40
- prices.push(null);
41
- ama3Prices.push(null);
42
- baseVarianceSeries.push(null);
43
- }
44
-
45
- const payload = {
46
- dates,
47
- prices,
48
- ama3Prices,
49
- candles: candleRows,
50
- atrPeriod: defaultAtrPeriod,
51
- varianceSeries: baseVarianceSeries,
52
- realBarCount,
53
- volatilityThreshold: defaultThreshold,
54
- volatilityExponent: defaultExponent,
55
- volatilityScaleX: defaultScaleX,
56
- volatilityClamp: defaultClamp,
57
- minWeight: defaultMinWeight,
58
- maxWeight: defaultMaxWeight,
59
- marketAdapter: MARKET_ADAPTER,
60
- };
61
-
62
- return `<!DOCTYPE html>
63
- <html lang="en">
64
- <head>
65
- <meta charset="UTF-8">
66
- <meta name="color-scheme" content="dark">
67
- <meta name="darkreader-lock">
68
- <title>${escapeHtml(title)}</title>
69
- ${uplotInlineTags()}
70
- <style>
71
- ${sharedChartCSS()}
72
- :root { color-scheme: dark; }
73
- #header-left { font-weight: bold; color: #fff; }
74
- #hint { font-size: 11px; color: #8b949e; text-transform: uppercase; letter-spacing: 0.4px; white-space: nowrap; }
75
- #price-panel { flex: 0 0 33%; min-height: 0; position: relative; border-bottom: 1px solid #30363d; }
76
- #variance-panel { flex: 0 0 27%; min-height: 0; position: relative; border-bottom: 1px solid #30363d; }
77
- #variance-panel .legend { top: 10px; }
78
- #variance-chart { margin-top: 0; height: 100%; }
79
- #shift-panel { flex: 0 0 40%; min-height: 0; position: relative; }
80
- #shift-panel .legend { top: 18px; }
81
- #shift-chart { margin-top: 0; height: calc(100% - 30px); }
82
- .legend { position: absolute; top: 8px; left: 12px; right: 12px; font-size: 11px; pointer-events: none; z-index: 10; display: flex; gap: 12px; color: #adbac7; white-space: nowrap; align-items: center; flex-wrap: wrap; }
83
- .legend-val { font-family: monospace; font-weight: bold; }
84
- .ctrl { pointer-events: auto; display: inline-flex; align-items: center; gap: 3px; margin-left: 0; }
85
- .ctrl label { color: #8b949e; font-size: 11px; min-width: 34px; text-align: right; }
86
- .ctrl input[type="range"] { width: 138px; height: 3px; margin-right: 0; }
87
- .ctrl .val { font-weight: bold; font-size: 11px; min-width: 36px; display: inline-block; text-align: right; margin-left: 0; }
88
- .ctrl.thr label { min-width: 26px; }
89
- .ctrl.atr label { min-width: 28px; }
90
- .ctrl.exp label { min-width: 24px; }
91
- .ctrl.scale label { min-width: 38px; }
92
- .ctrl.clamp label { min-width: 36px; }
93
- .ctrl.thr input[type="range"] { accent-color: #8b949e; }
94
- .ctrl.thr .val { color: #8b949e; }
95
- .ctrl.atr input[type="range"] { accent-color: #3fb950; }
96
- .ctrl.atr .val { color: #3fb950; }
97
- .ctrl.atr input[type="range"] { margin-right: -6px; }
98
- .ctrl.exp input[type="range"] { accent-color: #58a6ff; }
99
- .ctrl.exp .val { color: #58a6ff; }
100
- .ctrl.thr input[type="range"],
101
- .ctrl.atr input[type="range"],
102
- .ctrl.exp input[type="range"],
103
- .ctrl.scale input[type="range"],
104
- .ctrl.clamp input[type="range"] { width: 138px; }
105
- .ctrl.scale input[type="range"] { accent-color: #f0883e; }
106
- .ctrl.scale input[type="range"] { margin-right: 8px; }
107
- .ctrl.scale .val { color: #f0883e; }
108
- .ctrl.clamp input[type="range"] { accent-color: #a371f7; }
109
- .ctrl.clamp .val { color: #a371f7; }
110
- .group-sep { border-left: 1px solid #30363d; margin-left: 2px; padding-left: 2px; display: inline-flex; align-items: center; height: 18px; }
111
- .signal-summary { margin-left: 8px; min-width: 313px; max-width: 450px; flex: 0 0 338px; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; justify-content: center; }
112
- .signal-bar { display: flex; width: 100%; height: 15px; overflow: hidden; border-radius: 999px; background: #10151d; border: 1px solid #30363d; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03), 0 0 10px rgba(88,166,255,0.08); }
113
- .signal-seg { position: relative; height: 100%; min-width: 1px; transition: width 0.18s ease; box-shadow: inset 0 0 8px rgba(255,255,255,0.14), 0 0 8px currentColor; }
114
- .signal-seg:not(:last-child) { border-right: 1px solid rgba(255,255,255,0.34); }
115
- .signal-seg.below { color: #58a6ff; background: linear-gradient(90deg, #3b82f6 0%, #7dd3fc 100%); box-shadow: inset 0 0 4px rgba(255,255,255,0.14); }
116
- .signal-seg.mid { color: #ffd24a; background: linear-gradient(90deg, #ffe066 0%, #fff3a0 100%); box-shadow: inset 0 0 4px rgba(255,255,255,0.18); }
117
- .signal-seg.over { color: #f85149; background: linear-gradient(90deg, #ff4d4d 0%, #ff8a8a 100%); box-shadow: inset 0 0 4px rgba(255,255,255,0.12); }
118
- .signal-labels { position: relative; width: 100%; height: 12px; font-size: 10px; color: #8b949e; white-space: nowrap; }
119
- .signal-labels span { position: absolute; top: 0; transform: translateY(0); pointer-events: none; }
120
- .signal-labels span:nth-child(1) { left: 2px; color: #58a6ff; }
121
- .signal-labels span:nth-child(2) { left: 50%; transform: translate(-50%, 0); color: #ffd24a; }
122
- .signal-labels span:nth-child(3) { right: 2px; color: #f85149; }
123
- </style>
124
- </head>
125
- <body>
126
- <div id="header">
127
- <div id="header-left">${escapeHtml(title)}</div>
128
- <div id="hint">Log price only · weight variance · symmetric shift · wheel zoom · drag pan · Ctrl+0 reset</div>
129
- </div>
130
-
131
- <div id="panels">
132
- <div id="price-panel">
133
- <div class="section-label">PRICE (LOG)</div>
134
- <div class="legend">
135
- <div class="legend-item"><div class="dot" style="background:#58a6ff;"></div>Price: <span id="l-price" class="legend-val" style="color:#58a6ff;">-</span></div>
136
- <div class="legend-item"><div class="dot" style="background:#e3b341;"></div>AMA3: <span id="l-ama3" class="legend-val" style="color:#e3b341;">-</span></div>
137
- </div>
138
- <div id="price-chart"></div>
139
- </div>
140
- <div id="variance-panel">
141
- <div class="section-label">WEIGHT VARIANCE</div>
142
- <div class="legend">
143
- <div class="legend-item"><div class="dot" style="background:#d2a8ff;"></div>Weight variance: <span id="l-var" class="legend-val" style="color:#d2a8ff;">-</span></div>
144
- </div>
145
- <div id="variance-chart"></div>
146
- </div>
147
- <div id="shift-panel">
148
- <div class="section-label">SYMMETRIC SHIFT</div>
149
- <div class="legend" style="gap: 10px;">
150
- <div class="legend-item"><div class="dot" style="background:#f85149;"></div>Δ: <span id="l-delta" class="legend-val" style="color:#f85149;">-</span></div>
151
- <div class="legend-item">Weff: <span id="l-weff" class="legend-val" style="color:#3fb950;">-</span></div>
152
- <div class="group-sep"></div>
153
- <div class="ctrl thr"><label for="threshold-slider">thr</label><input type="range" id="threshold-slider" min="0" max="500" step="1" value="${Math.round(defaultThreshold * 1000)}"><span class="val" id="threshold-value">${defaultThreshold.toFixed(3)}</span></div>
154
- <div class="ctrl atr"><label for="atr-slider">atr</label><input type="range" id="atr-slider" min="${MARKET_ADAPTER.DYNAMIC_WEIGHT_ATR_PERIOD_MIN}" max="${MARKET_ADAPTER.DYNAMIC_WEIGHT_ATR_PERIOD_MAX}" step="1" value="${Math.round(defaultAtrPeriod)}"><span class="val" id="atr-value">${Math.round(defaultAtrPeriod)}</span></div>
155
- <div class="ctrl clamp"><label for="clamp-slider">clamp</label><input type="range" id="clamp-slider" min="100" max="1000" step="1" value="${Math.round(defaultClamp * 1000)}"><span class="val" id="clamp-value">${defaultClamp.toFixed(3)}</span></div>
156
- <div class="ctrl exp"><label for="exponent-slider">exp</label><input type="range" id="exponent-slider" min="500" max="1000" step="1" value="${Math.round(defaultExponent * 1000)}"><span class="val" id="exponent-value">${defaultExponent.toFixed(3)}</span></div>
157
- <div class="ctrl scale"><label for="scale-slider">scaleX</label><input type="range" id="scale-slider" min="100" max="10000" step="1" value="${Math.round(defaultScaleX * 100)}"><span class="val" id="scale-value">${defaultScaleX.toFixed(2)}x</span></div>
158
- <div class="signal-summary">
159
- <div class="signal-bar" id="signal-bar" title="Signal distribution">
160
- <div id="signal-below" class="signal-seg below" style="width:0%"></div>
161
- <div id="signal-mid" class="signal-seg mid" style="width:0%"></div>
162
- <div id="signal-over" class="signal-seg over" style="width:0%"></div>
163
- </div>
164
- <div class="signal-labels">
165
- <span id="signal-below-label">below 0%</span>
166
- <span id="signal-mid-label">in 0%</span>
167
- <span id="signal-over-label">over 0%</span>
168
- </div>
169
- </div>
170
- </div>
171
- <div id="shift-chart"></div>
172
- </div>
173
- </div>
174
-
175
- <script id="payload" type="application/json">${serializeJsonForScript(payload)}</script>
176
- <script>
177
- (function () {
178
- const data = JSON.parse(document.getElementById('payload').textContent);
179
-
180
- ${EMBEDDED_SHARED_FUNCS}
181
-
182
- const SYNC_KEY = 'volatility-det-v1';
183
- const Y_AXIS_SIZE = ${Y_AXIS_SIZE};
184
- const MARKET_ADAPTER = data.marketAdapter || {};
185
- const MIN_WEIGHT = data.minWeight ?? ${JSON.stringify(defaultMinWeight)};
186
- const MAX_WEIGHT = data.maxWeight ?? ${JSON.stringify(defaultMaxWeight)};
187
- const BASELINE_WEIGHT = 0.5;
188
- const EXP_LOG_MIN = Math.log(0.5);
189
- const EXP_LOG_MAX = Math.log(1.0);
190
- const SCALE_LOG_MIN = Math.log(1.0);
191
- const SCALE_LOG_MAX = Math.log(100.0);
192
- const candleRows = Array.isArray(data.candles) ? data.candles : [];
193
- const baseVarianceSeries = Array.isArray(data.varianceSeries) ? data.varianceSeries : [];
194
-
195
- let currentAtrPeriod = Math.max(${MARKET_ADAPTER.DYNAMIC_WEIGHT_ATR_PERIOD_MIN}, Math.min(${MARKET_ADAPTER.DYNAMIC_WEIGHT_ATR_PERIOD_MAX}, Math.round(data.atrPeriod ?? ${JSON.stringify(defaultAtrPeriod)})));
196
- let currentThreshold = data.volatilityThreshold;
197
- let currentExponent = data.volatilityExponent;
198
- let currentScaleX = data.volatilityScaleX;
199
- let currentClamp = Math.max(0.1, data.volatilityClamp ?? ${JSON.stringify(defaultClamp)});
200
-
201
- const xMin = data.dates[0];
202
- const xMax = data.dates[data.dates.length - 1];
203
- let pendingRange = null;
204
- let pendingRangeRaf = 0;
205
- let priceChart, varianceChart, shiftChart;
206
- let charts;
207
-
208
- ${UPLOT_SHARED_SCRIPT}
209
-
210
- function fmtNum(v, digits = 4) {
211
- if (v == null || !Number.isFinite(v)) return '-';
212
- const abs = Math.abs(v);
213
- if (abs >= 1000) return v.toFixed(2);
214
- if (abs >= 1) return v.toFixed(Math.min(4, digits));
215
- return v.toPrecision(Math.min(6, digits + 2));
216
- }
217
-
218
- function fmtSigned(v, digits = 3) {
219
- if (v == null || !Number.isFinite(v)) return '-';
220
- const s = v >= 0 ? '+' : '';
221
- return s + v.toFixed(digits);
222
- }
223
-
224
- function expSliderToVal(pos) {
225
- return Math.exp(EXP_LOG_MIN + (pos / 1000) * (EXP_LOG_MAX - EXP_LOG_MIN));
226
- }
227
-
228
- function expValToSlider(val) {
229
- const clamped = Math.max(Math.exp(EXP_LOG_MIN), Math.min(Math.exp(EXP_LOG_MAX), val));
230
- return Math.round((Math.log(clamped) - EXP_LOG_MIN) / (EXP_LOG_MAX - EXP_LOG_MIN) * 1000);
231
- }
232
-
233
- function scaleSliderToVal(pos) {
234
- return Math.exp(SCALE_LOG_MIN + (pos / 1000) * (SCALE_LOG_MAX - SCALE_LOG_MIN));
235
- }
236
-
237
- function scaleValToSlider(val) {
238
- const clamped = Math.max(Math.exp(SCALE_LOG_MIN), Math.min(Math.exp(SCALE_LOG_MAX), val));
239
- return Math.round((Math.log(clamped) - SCALE_LOG_MIN) / (SCALE_LOG_MAX - SCALE_LOG_MIN) * 1000);
240
- }
241
-
242
- function clampValToSlider(val) {
243
- const clamped = Math.max(0.1, Math.min(1.0, val));
244
- return Math.round(clamped * 1000);
245
- }
246
-
247
- function clampSliderToVal(pos) {
248
- return Math.max(0.1, Math.min(1.0, pos / 1000));
249
- }
250
-
251
- /* Sync with market_adapter/core/strategies/atr/calculator.ts computeATRSeries() — injected above */
252
- function rebuildVarianceSeries() {
253
- if (!candleRows.length) return baseVarianceSeries.slice();
254
-
255
- const atrSeries = computeATRSeries(candleRows, currentAtrPeriod);
256
- const next = new Array(data.dates.length).fill(null);
257
- for (let i = 0; i < data.realBarCount; i++) {
258
- const amaPrice = data.ama3Prices[i];
259
- const atr = atrSeries[i] ?? 0;
260
- next[i] = amaPrice > 0 ? atr / amaPrice : 0;
261
- }
262
- return next;
263
- }
264
-
265
- function toPlotLog(values) {
266
- return values.map((v) => (v != null && v > 0 ? v : null));
267
- }
268
-
269
- let varianceSeries = rebuildVarianceSeries();
270
- const variancePlot = toPlotLog(varianceSeries);
271
-
272
- let rawDeltaArr = new Array(data.dates.length).fill(null);
273
- let deltaArr = new Array(data.dates.length).fill(null);
274
- let weffArr = new Array(data.dates.length).fill(null);
275
- let signalSummary = { below: 0, mid: 0, over: 0, total: 0 };
276
-
277
- function calcShift(weightVariance) {
278
- const r = computeVolatilityShift(weightVariance, {
279
- exponent: currentExponent,
280
- scaleX: currentScaleX,
281
- threshold: currentThreshold,
282
- clampValue: currentClamp,
283
- minWeight: MIN_WEIGHT,
284
- maxWeight: MAX_WEIGHT,
285
- baselineWeight: BASELINE_WEIGHT,
286
- });
287
- return { raw: r.rawSymmetricDelta, rawAbs: Math.abs(r.rawSymmetricDelta), delta: r.symmetricDelta, weff: r.effectiveWeight, sellW: r.sellW, buyW: r.buyW };
288
- }
289
-
290
- function recalcShift() {
291
- varianceSeries = rebuildVarianceSeries();
292
- const effectiveClamp = Number.isFinite(currentClamp) && currentClamp >= 0.1 ? currentClamp : ${JSON.stringify(defaultClamp)};
293
- let below = 0;
294
- let mid = 0;
295
- let over = 0;
296
- let total = 0;
297
- for (let i = 0; i < data.dates.length; i++) {
298
- if (i >= data.realBarCount) {
299
- rawDeltaArr[i] = null;
300
- deltaArr[i] = null;
301
- weffArr[i] = null;
302
- continue;
303
- }
304
- const r = calcShift(varianceSeries[i]);
305
- rawDeltaArr[i] = r.raw;
306
- deltaArr[i] = r.delta;
307
- weffArr[i] = r.weff;
308
- if (Number.isFinite(r.rawAbs)) {
309
- total++;
310
- if (r.rawAbs >= effectiveClamp) over++;
311
- else if (r.rawAbs < currentThreshold) below++;
312
- else mid++;
313
- }
314
- }
315
- signalSummary = { below, mid, over, total };
316
- }
317
-
318
- function updateSignalSummary() {
319
- const total = signalSummary.total || 0;
320
- const belowPct = total > 0 ? (signalSummary.below / total) * 100 : 0;
321
- const midPct = total > 0 ? (signalSummary.mid / total) * 100 : 0;
322
- const overPct = total > 0 ? (signalSummary.over / total) * 100 : 0;
323
-
324
- const belowEl = document.getElementById('signal-below');
325
- const midEl = document.getElementById('signal-mid');
326
- const overEl = document.getElementById('signal-over');
327
- belowEl.style.width = belowPct + '%';
328
- midEl.style.width = midPct + '%';
329
- overEl.style.width = overPct + '%';
330
- belowEl.title = 'below: ' + signalSummary.below + '/' + total + ' (' + belowPct.toFixed(1) + '%)';
331
- midEl.title = 'in: ' + signalSummary.mid + '/' + total + ' (' + midPct.toFixed(1) + '%)';
332
- overEl.title = 'over: ' + signalSummary.over + '/' + total + ' (' + overPct.toFixed(1) + '%)';
333
-
334
- const title = 'below: ' + signalSummary.below + '/' + total + ' (' + belowPct.toFixed(1) + '%) | in: ' + signalSummary.mid + '/' + total + ' (' + midPct.toFixed(1) + '%) | over: ' + signalSummary.over + '/' + total + ' (' + overPct.toFixed(1) + '%)';
335
- document.getElementById('signal-bar').title = title;
336
- document.getElementById('signal-below-label').textContent = 'below ' + belowPct.toFixed(1) + '%';
337
- document.getElementById('signal-mid-label').textContent = 'in ' + midPct.toFixed(1) + '%';
338
- document.getElementById('signal-over-label').textContent = 'over ' + overPct.toFixed(1) + '%';
339
- }
340
-
341
- function rangeFrom(values, fallbackMin, fallbackMax, padFrac = 0.12) {
342
- let min = Infinity;
343
- let max = -Infinity;
344
- for (let i = 0; i < values.length; i++) {
345
- const v = values[i];
346
- if (v == null || !Number.isFinite(v)) continue;
347
- if (v < min) min = v;
348
- if (v > max) max = v;
349
- }
350
- if (!Number.isFinite(min) || !Number.isFinite(max)) return [fallbackMin, fallbackMax];
351
- if (min === max) {
352
- const pad = Math.max(Math.abs(min) * padFrac, 0.02);
353
- return [min - pad, max + pad];
354
- }
355
- const span = max - min;
356
- const pad = span * padFrac;
357
- return [min - pad, max + pad];
358
- }
359
-
360
- function buildRawDeltaSplits(u) {
361
- const scale = u.scales.d || {};
362
- const r = rangeFrom(rawDeltaArr, -0.5, 0.04);
363
- const min = Number.isFinite(scale.min) ? scale.min : r[0];
364
- const max = Number.isFinite(scale.max) ? scale.max : r[1];
365
- const lo = Math.min(min, max);
366
- const hi = Math.max(min, max);
367
- const step = 0.05;
368
- const start = Math.floor(lo / step) * step;
369
- const end = Math.ceil(hi / step) * step;
370
- const splits = [];
371
- for (let v = start; v <= end + 1e-9; v += step) {
372
- const rounded = Math.round(v * 100) / 100;
373
- if (!splits.includes(rounded)) splits.push(rounded);
374
- }
375
- if (!splits.includes(0)) splits.push(0);
376
- if (!splits.includes(-currentThreshold)) splits.push(-currentThreshold);
377
- return splits.sort((a, b) => a - b);
378
- }
379
-
380
- function makeDeltaHook(values, scaleKey, thresholdGetter) {
381
- return (u) => {
382
- const { ctx, bbox } = u;
383
- ctx.save();
384
- ctx.beginPath();
385
- ctx.rect(bbox.left, bbox.top, bbox.width, bbox.height);
386
- ctx.clip();
387
-
388
- const zeroY = u.valToPos(0, scaleKey, true);
389
- const thresholdY = u.valToPos(-thresholdGetter(), scaleKey, true);
390
-
391
- ctx.strokeStyle = '#ffd24a';
392
- ctx.shadowColor = 'rgba(255,210,74,0.85)';
393
- ctx.shadowBlur = 6;
394
- ctx.lineWidth = 2.5;
395
- ctx.setLineDash([4, 3]);
396
- ctx.beginPath();
397
- ctx.moveTo(bbox.left, thresholdY);
398
- ctx.lineTo(bbox.left + bbox.width, thresholdY);
399
- ctx.stroke();
400
- ctx.shadowBlur = 0;
401
- ctx.shadowColor = 'transparent';
402
- ctx.font = 'bold 10px Segoe UI, sans-serif';
403
- ctx.textBaseline = 'middle';
404
- const label = 'threshold';
405
- const labelX = Math.max(bbox.left + 4, bbox.left + bbox.width - 60);
406
- const labelY = thresholdY - 8;
407
- const labelW = ctx.measureText(label).width + 8;
408
- ctx.fillStyle = 'rgba(11,14,20,0.82)';
409
- ctx.fillRect(labelX - 4, labelY - 7, labelW, 14);
410
- ctx.fillStyle = '#ffd24a';
411
- ctx.fillText(label, labelX, labelY);
412
-
413
- const clampY = u.valToPos(-currentClamp, scaleKey, true);
414
- ctx.strokeStyle = '#a371f7';
415
- ctx.shadowColor = 'rgba(163,113,247,0.85)';
416
- ctx.shadowBlur = 6;
417
- ctx.lineWidth = 2;
418
- ctx.setLineDash([4, 3]);
419
- ctx.beginPath();
420
- ctx.moveTo(bbox.left, clampY);
421
- ctx.lineTo(bbox.left + bbox.width, clampY);
422
- ctx.stroke();
423
- ctx.shadowBlur = 0;
424
- ctx.shadowColor = 'transparent';
425
- ctx.font = 'bold 10px Segoe UI, sans-serif';
426
- ctx.textBaseline = 'middle';
427
- const clampLabel = 'clamp';
428
- const clampLabelX = Math.max(bbox.left + 4, bbox.left + bbox.width - 52);
429
- const clampLabelY = clampY - 8;
430
- const clampLabelW = ctx.measureText(clampLabel).width + 8;
431
- ctx.fillStyle = 'rgba(11,14,20,0.82)';
432
- ctx.fillRect(clampLabelX - 4, clampLabelY - 7, clampLabelW, 14);
433
- ctx.fillStyle = '#a371f7';
434
- ctx.fillText(clampLabel, clampLabelX, clampLabelY);
435
-
436
- ctx.strokeStyle = 'rgba(139,148,158,0.4)';
437
- ctx.setLineDash([4, 4]);
438
- ctx.beginPath();
439
- ctx.moveTo(bbox.left, zeroY);
440
- ctx.lineTo(bbox.left + bbox.width, zeroY);
441
- ctx.stroke();
442
- ctx.setLineDash([]);
443
-
444
- const path = new Path2D();
445
- let started = false;
446
- let lastX = 0;
447
- for (let i = 0; i < values.length; i++) {
448
- const v = values[i];
449
- if (v == null) { if (started) { path.lineTo(lastX, zeroY); started = false; } continue; }
450
- const x = u.valToPos(data.dates[i], 'x', true);
451
- const y = u.valToPos(v, scaleKey, true);
452
- if (!started) {
453
- path.moveTo(x, zeroY);
454
- path.lineTo(x, y);
455
- started = true;
456
- } else {
457
- path.lineTo(x, y);
458
- }
459
- lastX = x;
460
- }
461
- if (started) path.lineTo(lastX, zeroY);
462
-
463
- ctx.save();
464
- ctx.beginPath();
465
- ctx.rect(bbox.left, zeroY, bbox.width, bbox.top + bbox.height - zeroY);
466
- ctx.clip();
467
- ctx.fillStyle = 'rgba(248,81,73,0.16)';
468
- ctx.fill(path);
469
- ctx.restore();
470
-
471
- ctx.strokeStyle = 'rgba(248,81,73,0.9)';
472
- ctx.lineWidth = 1.7;
473
- ctx.stroke(path);
474
- ctx.restore();
475
- };
476
- }
477
-
478
- const cursorCfg = ${makeCursorConfig()};
479
-
480
- function updateLegend(idx) {
481
- if (idx == null || idx >= data.realBarCount) return;
482
- document.getElementById('l-price').textContent = fmtNum(data.prices[idx], 6);
483
- document.getElementById('l-ama3').textContent = fmtNum(data.ama3Prices[idx], 6);
484
- const variance = varianceSeries[idx];
485
- document.getElementById('l-var').textContent = variance == null ? '-' : fmtNum(variance, 6) + ' (' + fmtNum(variance * 100, 4) + '%)';
486
- document.getElementById('l-delta').textContent = fmtSigned(deltaArr[idx], 3);
487
- document.getElementById('l-weff').textContent = fmtNum(weffArr[idx], 3);
488
- }
489
-
490
- function init() {
491
- currentAtrPeriod = Math.max(${MARKET_ADAPTER.DYNAMIC_WEIGHT_ATR_PERIOD_MIN}, Math.min(${MARKET_ADAPTER.DYNAMIC_WEIGHT_ATR_PERIOD_MAX}, Math.round(currentAtrPeriod)));
492
- currentExponent = Math.max(Math.exp(EXP_LOG_MIN), Math.min(Math.exp(EXP_LOG_MAX), currentExponent));
493
- currentScaleX = Math.max(Math.exp(SCALE_LOG_MIN), Math.min(Math.exp(SCALE_LOG_MAX), currentScaleX));
494
- currentClamp = Math.max(0.1, Math.min(1.0, currentClamp));
495
- document.getElementById('atr-slider').value = currentAtrPeriod;
496
- document.getElementById('atr-value').textContent = String(currentAtrPeriod);
497
- document.getElementById('threshold-slider').value = Math.round(currentThreshold * 1000);
498
- document.getElementById('exponent-slider').value = expValToSlider(currentExponent);
499
- document.getElementById('scale-slider').value = scaleValToSlider(currentScaleX);
500
- document.getElementById('clamp-slider').value = clampValToSlider(currentClamp);
501
- document.getElementById('exponent-value').textContent = currentExponent.toFixed(3);
502
- document.getElementById('scale-value').textContent = currentScaleX.toFixed(2) + 'x';
503
- document.getElementById('clamp-value').textContent = currentClamp.toFixed(3);
504
-
505
- const priceEl = document.getElementById('price-panel');
506
- const varianceEl = document.getElementById('variance-panel');
507
- const shiftEl = document.getElementById('shift-panel');
508
-
509
- recalcShift();
510
- updateSignalSummary();
511
-
512
- priceChart = new uPlot({
513
- width: priceEl.offsetWidth,
514
- height: priceEl.offsetHeight,
515
- padding: [4, 8, 2, 4],
516
- select: { show: false },
517
- legend: { show: false },
518
- scales: {
519
- x: { time: true },
520
- y: { auto: true, distr: 3, log: 10, range: (u, min, max) => [min * 0.95, max * 1.05] },
521
- },
522
- series: [
523
- { label: 'Time' },
524
- { label: 'Price', stroke: '#58a6ff', width: 1.5, scale: 'y', points: { show: false } },
525
- { label: 'AMA3', stroke: '#e3b341', width: 1.5, scale: 'y', points: { show: false } },
526
- ],
527
- axes: [
528
- { show: false, stroke: '#ffffff', grid: { stroke: '#1c2128' }, ticks: { stroke: '#30363d', width: 1 }, size: 28, font: '11px Segoe UI, sans-serif' },
529
- { scale: 'y', stroke: '#ffffff', grid: { stroke: '#1c2128' }, ticks: { stroke: '#30363d', width: 1 }, size: Y_AXIS_SIZE, font: '11px Segoe UI, sans-serif',
530
- values: (u, v) => v.map(x => x != null ? fmtNum(x, 6) : '') },
531
- ],
532
- cursor: cursorCfg,
533
- }, [data.dates, data.prices, data.ama3Prices], document.getElementById('price-chart'));
534
-
535
- varianceChart = new uPlot({
536
- width: varianceEl.offsetWidth,
537
- height: varianceEl.offsetHeight,
538
- padding: [14, 8, 2, 4],
539
- select: { show: false },
540
- legend: { show: false },
541
- scales: {
542
- x: { time: true },
543
- v: { auto: true, range: (u, min, max) => [min * 0.95, max * 1.05] },
544
- },
545
- series: [
546
- { label: 'Time' },
547
- { label: 'Weight variance', stroke: '#d2a8ff', width: 1.5, scale: 'v', points: { show: false } },
548
- ],
549
- axes: [
550
- { show: false, stroke: '#ffffff', grid: { stroke: '#1c2128' }, ticks: { stroke: '#30363d', width: 1 }, size: 28, font: '11px Segoe UI, sans-serif' },
551
- { scale: 'v', stroke: '#ffffff', grid: { stroke: '#1c2128' }, ticks: { stroke: '#30363d', width: 1 }, size: Y_AXIS_SIZE, font: '11px Segoe UI, sans-serif',
552
- values: (u, v) => v.map(x => x != null ? fmtNum(x, 6) : '') },
553
- ],
554
- cursor: cursorCfg,
555
- }, [data.dates, variancePlot], document.getElementById('variance-chart'));
556
-
557
- shiftChart = new uPlot({
558
- width: shiftEl.offsetWidth,
559
- height: shiftEl.offsetHeight,
560
- padding: [26, 8, 4, 4],
561
- select: { show: false },
562
- legend: { show: false },
563
- scales: {
564
- x: { time: true },
565
- d: { auto: true, range: () => rangeFrom(rawDeltaArr, -0.5, 0.04) },
566
- },
567
- series: [
568
- { label: 'Time' },
569
- { label: 'Raw Δ', stroke: '#8b949e', width: 1.2, dash: [5, 4], scale: 'd', points: { show: false } },
570
- { label: 'Δ', stroke: '#f85149', width: 1.7, scale: 'd', points: { show: false } },
571
- ],
572
- axes: [
573
- { show: true, stroke: '#ffffff', grid: { stroke: '#1c2128' }, ticks: { stroke: '#30363d', width: 1 }, size: 28, font: '11px Segoe UI, sans-serif' },
574
- { scale: 'd', stroke: '#ffffff', grid: { stroke: '#1c2128', dash: [4, 4] }, ticks: { stroke: '#30363d', width: 1 }, size: Y_AXIS_SIZE, font: '11px Segoe UI, sans-serif',
575
- values: (u, v) => v.map(x => x != null ? fmtSigned(x, 3) : ''),
576
- splits: buildRawDeltaSplits },
577
- ],
578
- cursor: cursorCfg,
579
- hooks: {
580
- draw: [makeDeltaHook(deltaArr, 'd', () => currentThreshold)],
581
- },
582
- }, [data.dates, rawDeltaArr, deltaArr], document.getElementById('shift-chart'));
583
-
584
- ${bindHoverStateFn()}
585
-
586
- charts = [priceChart, varianceChart, shiftChart];
587
- ${wireChartEvents('charts', 'updateLegend', 'shiftChart.cursor.idx ?? data.realBarCount - 1')}
588
-
589
- function refreshChartsPreservingZoom() {
590
- const xs = shiftChart.scales.x;
591
- const savedX = xs ? { min: Number.isFinite(xs.min) ? xs.min : xMin, max: Number.isFinite(xs.max) ? xs.max : xMax } : null;
592
- varianceChart.setData([data.dates, toPlotLog(varianceSeries)], false);
593
- shiftChart.setData([data.dates, rawDeltaArr, deltaArr], false);
594
- if (savedX) {
595
- [varianceChart, shiftChart].forEach((chart) => chart.batch(() => chart.setScale('x', savedX)));
596
- }
597
- }
598
-
599
- function applyShiftFromSliders() {
600
- recalcShift();
601
- updateSignalSummary();
602
- refreshChartsPreservingZoom();
603
- updateLegend(shiftChart.cursor.idx ?? data.realBarCount - 1);
604
- }
605
-
606
- document.getElementById('atr-slider').addEventListener('input', (e) => {
607
- currentAtrPeriod = parseInt(e.target.value, 10);
608
- document.getElementById('atr-value').textContent = String(currentAtrPeriod);
609
- applyShiftFromSliders();
610
- });
611
-
612
- document.getElementById('threshold-slider').addEventListener('input', (e) => {
613
- currentThreshold = parseInt(e.target.value, 10) / 1000;
614
- document.getElementById('threshold-value').textContent = currentThreshold.toFixed(3);
615
- applyShiftFromSliders();
616
- });
617
-
618
- document.getElementById('exponent-slider').addEventListener('input', (e) => {
619
- currentExponent = expSliderToVal(parseInt(e.target.value, 10));
620
- document.getElementById('exponent-value').textContent = currentExponent.toFixed(3);
621
- applyShiftFromSliders();
622
- });
623
-
624
- document.getElementById('scale-slider').addEventListener('input', (e) => {
625
- currentScaleX = scaleSliderToVal(parseInt(e.target.value, 10));
626
- document.getElementById('scale-value').textContent = currentScaleX.toFixed(2) + 'x';
627
- applyShiftFromSliders();
628
- });
629
-
630
- document.getElementById('clamp-slider').addEventListener('input', (e) => {
631
- currentClamp = clampSliderToVal(parseInt(e.target.value, 10));
632
- document.getElementById('clamp-value').textContent = currentClamp.toFixed(3);
633
- applyShiftFromSliders();
634
- });
635
- }
636
-
637
- ${sizeChartsFn([['priceChart', 'price-panel'], ['varianceChart', 'variance-panel'], ['shiftChart', 'shift-panel']])}
638
-
639
- window.addEventListener('resize', sizeCharts);
640
- ${zoomResetScript()}
641
-
642
- init();
643
- requestAnimationFrame(() => requestAnimationFrame(() => {
644
- sizeCharts();
645
- updateLegend(data.realBarCount - 1);
646
- }));
647
- })();
648
- </script>
649
- </body>
650
- </html>`;
651
- }
652
-
653
- export { generateHTML }
654
-