@363045841yyt/klinechart-core 0.7.12-alpha.1 → 0.7.13

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 (277) hide show
  1. package/dist/controllers/createIndicatorSelectorController.d.ts.map +1 -1
  2. package/dist/controllers/createIndicatorSelectorController.js +4 -6
  3. package/dist/controllers/createIndicatorSelectorController.js.map +1 -1
  4. package/dist/controllers/index.d.ts +0 -1
  5. package/dist/controllers/index.d.ts.map +1 -1
  6. package/dist/controllers/index.js +0 -1
  7. package/dist/controllers/index.js.map +1 -1
  8. package/dist/engine/chart.d.ts +6 -2
  9. package/dist/engine/chart.d.ts.map +1 -1
  10. package/dist/engine/chart.js +26 -23
  11. package/dist/engine/chart.js.map +1 -1
  12. package/dist/engine/indicators/indicator.worker.js +32 -4
  13. package/dist/engine/indicators/indicator.worker.js.map +1 -1
  14. package/dist/engine/indicators/indicatorDefinitionRegistry.d.ts +5 -3
  15. package/dist/engine/indicators/indicatorDefinitionRegistry.d.ts.map +1 -1
  16. package/dist/engine/indicators/indicatorDefinitionRegistry.js +26 -1
  17. package/dist/engine/indicators/indicatorDefinitionRegistry.js.map +1 -1
  18. package/dist/engine/indicators/indicatorMetadata.d.ts +54 -1
  19. package/dist/engine/indicators/indicatorMetadata.d.ts.map +1 -1
  20. package/dist/engine/indicators/indicatorMetadata.js.map +1 -1
  21. package/dist/engine/indicators/indicatorRuntime.d.ts +12 -117
  22. package/dist/engine/indicators/indicatorRuntime.d.ts.map +1 -1
  23. package/dist/engine/indicators/indicatorRuntime.js +124 -1308
  24. package/dist/engine/indicators/indicatorRuntime.js.map +1 -1
  25. package/dist/engine/indicators/scheduler.d.ts +19 -143
  26. package/dist/engine/indicators/scheduler.d.ts.map +1 -1
  27. package/dist/engine/indicators/scheduler.js +81 -434
  28. package/dist/engine/indicators/scheduler.js.map +1 -1
  29. package/dist/engine/indicators/stateComposer.d.ts.map +1 -1
  30. package/dist/engine/indicators/stateComposer.js +15 -47
  31. package/dist/engine/indicators/stateComposer.js.map +1 -1
  32. package/dist/engine/indicators/workerProtocol.d.ts +12 -36
  33. package/dist/engine/indicators/workerProtocol.d.ts.map +1 -1
  34. package/dist/engine/indicators/workerProtocol.js.map +1 -1
  35. package/dist/engine/renderers/Indicator/atr.d.ts +2 -1
  36. package/dist/engine/renderers/Indicator/atr.d.ts.map +1 -1
  37. package/dist/engine/renderers/Indicator/atr.js +11 -9
  38. package/dist/engine/renderers/Indicator/atr.js.map +1 -1
  39. package/dist/engine/renderers/Indicator/boll.d.ts +4 -1
  40. package/dist/engine/renderers/Indicator/boll.d.ts.map +1 -1
  41. package/dist/engine/renderers/Indicator/boll.js +24 -10
  42. package/dist/engine/renderers/Indicator/boll.js.map +1 -1
  43. package/dist/engine/renderers/Indicator/cci.d.ts +2 -1
  44. package/dist/engine/renderers/Indicator/cci.d.ts.map +1 -1
  45. package/dist/engine/renderers/Indicator/cci.js +12 -10
  46. package/dist/engine/renderers/Indicator/cci.js.map +1 -1
  47. package/dist/engine/renderers/Indicator/chaikinVol.d.ts +4 -1
  48. package/dist/engine/renderers/Indicator/chaikinVol.d.ts.map +1 -1
  49. package/dist/engine/renderers/Indicator/chaikinVol.js +21 -7
  50. package/dist/engine/renderers/Indicator/chaikinVol.js.map +1 -1
  51. package/dist/engine/renderers/Indicator/cmf.d.ts +4 -1
  52. package/dist/engine/renderers/Indicator/cmf.d.ts.map +1 -1
  53. package/dist/engine/renderers/Indicator/cmf.js +20 -7
  54. package/dist/engine/renderers/Indicator/cmf.js.map +1 -1
  55. package/dist/engine/renderers/Indicator/dema.d.ts +2 -0
  56. package/dist/engine/renderers/Indicator/dema.d.ts.map +1 -1
  57. package/dist/engine/renderers/Indicator/dema.js +19 -8
  58. package/dist/engine/renderers/Indicator/dema.js.map +1 -1
  59. package/dist/engine/renderers/Indicator/donchian.d.ts +4 -1
  60. package/dist/engine/renderers/Indicator/donchian.d.ts.map +1 -1
  61. package/dist/engine/renderers/Indicator/donchian.js +20 -8
  62. package/dist/engine/renderers/Indicator/donchian.js.map +1 -1
  63. package/dist/engine/renderers/Indicator/ene.d.ts +12 -1
  64. package/dist/engine/renderers/Indicator/ene.d.ts.map +1 -1
  65. package/dist/engine/renderers/Indicator/ene.js +25 -11
  66. package/dist/engine/renderers/Indicator/ene.js.map +1 -1
  67. package/dist/engine/renderers/Indicator/expma.d.ts +4 -1
  68. package/dist/engine/renderers/Indicator/expma.d.ts.map +1 -1
  69. package/dist/engine/renderers/Indicator/expma.js +22 -9
  70. package/dist/engine/renderers/Indicator/expma.js.map +1 -1
  71. package/dist/engine/renderers/Indicator/fastk.d.ts +2 -1
  72. package/dist/engine/renderers/Indicator/fastk.d.ts.map +1 -1
  73. package/dist/engine/renderers/Indicator/fastk.js +12 -10
  74. package/dist/engine/renderers/Indicator/fastk.js.map +1 -1
  75. package/dist/engine/renderers/Indicator/fib.d.ts +2 -0
  76. package/dist/engine/renderers/Indicator/fib.d.ts.map +1 -1
  77. package/dist/engine/renderers/Indicator/fib.js +26 -8
  78. package/dist/engine/renderers/Indicator/fib.js.map +1 -1
  79. package/dist/engine/renderers/Indicator/hma.d.ts +2 -0
  80. package/dist/engine/renderers/Indicator/hma.d.ts.map +1 -1
  81. package/dist/engine/renderers/Indicator/hma.js +19 -8
  82. package/dist/engine/renderers/Indicator/hma.js.map +1 -1
  83. package/dist/engine/renderers/Indicator/hv.d.ts +4 -1
  84. package/dist/engine/renderers/Indicator/hv.d.ts.map +1 -1
  85. package/dist/engine/renderers/Indicator/hv.js +18 -8
  86. package/dist/engine/renderers/Indicator/hv.js.map +1 -1
  87. package/dist/engine/renderers/Indicator/ichimoku.d.ts +4 -1
  88. package/dist/engine/renderers/Indicator/ichimoku.d.ts.map +1 -1
  89. package/dist/engine/renderers/Indicator/ichimoku.js +27 -8
  90. package/dist/engine/renderers/Indicator/ichimoku.js.map +1 -1
  91. package/dist/engine/renderers/Indicator/index.d.ts +27 -28
  92. package/dist/engine/renderers/Indicator/index.d.ts.map +1 -1
  93. package/dist/engine/renderers/Indicator/index.js +27 -28
  94. package/dist/engine/renderers/Indicator/index.js.map +1 -1
  95. package/dist/engine/renderers/Indicator/kama.d.ts +2 -0
  96. package/dist/engine/renderers/Indicator/kama.d.ts.map +1 -1
  97. package/dist/engine/renderers/Indicator/kama.js +19 -8
  98. package/dist/engine/renderers/Indicator/kama.js.map +1 -1
  99. package/dist/engine/renderers/Indicator/keltner.d.ts +4 -1
  100. package/dist/engine/renderers/Indicator/keltner.d.ts.map +1 -1
  101. package/dist/engine/renderers/Indicator/keltner.js +20 -8
  102. package/dist/engine/renderers/Indicator/keltner.js.map +1 -1
  103. package/dist/engine/renderers/Indicator/kst.d.ts +2 -1
  104. package/dist/engine/renderers/Indicator/kst.d.ts.map +1 -1
  105. package/dist/engine/renderers/Indicator/kst.js +13 -11
  106. package/dist/engine/renderers/Indicator/kst.js.map +1 -1
  107. package/dist/engine/renderers/Indicator/ma.d.ts +4 -1
  108. package/dist/engine/renderers/Indicator/ma.d.ts.map +1 -1
  109. package/dist/engine/renderers/Indicator/ma.js +36 -8
  110. package/dist/engine/renderers/Indicator/ma.js.map +1 -1
  111. package/dist/engine/renderers/Indicator/macd.d.ts +1 -1
  112. package/dist/engine/renderers/Indicator/macd.d.ts.map +1 -1
  113. package/dist/engine/renderers/Indicator/macd.js +9 -10
  114. package/dist/engine/renderers/Indicator/macd.js.map +1 -1
  115. package/dist/engine/renderers/Indicator/mainIndicatorLegend.d.ts.map +1 -1
  116. package/dist/engine/renderers/Indicator/mainIndicatorLegend.js +38 -136
  117. package/dist/engine/renderers/Indicator/mainIndicatorLegend.js.map +1 -1
  118. package/dist/engine/renderers/Indicator/mfi.d.ts +4 -1
  119. package/dist/engine/renderers/Indicator/mfi.d.ts.map +1 -1
  120. package/dist/engine/renderers/Indicator/mfi.js +20 -7
  121. package/dist/engine/renderers/Indicator/mfi.js.map +1 -1
  122. package/dist/engine/renderers/Indicator/mom.d.ts +2 -1
  123. package/dist/engine/renderers/Indicator/mom.d.ts.map +1 -1
  124. package/dist/engine/renderers/Indicator/mom.js +12 -10
  125. package/dist/engine/renderers/Indicator/mom.js.map +1 -1
  126. package/dist/engine/renderers/Indicator/obv.d.ts +4 -1
  127. package/dist/engine/renderers/Indicator/obv.d.ts.map +1 -1
  128. package/dist/engine/renderers/Indicator/obv.js +19 -7
  129. package/dist/engine/renderers/Indicator/obv.js.map +1 -1
  130. package/dist/engine/renderers/Indicator/parkinson.d.ts +4 -1
  131. package/dist/engine/renderers/Indicator/parkinson.d.ts.map +1 -1
  132. package/dist/engine/renderers/Indicator/parkinson.js +18 -8
  133. package/dist/engine/renderers/Indicator/parkinson.js.map +1 -1
  134. package/dist/engine/renderers/Indicator/pivot.d.ts +2 -0
  135. package/dist/engine/renderers/Indicator/pivot.d.ts.map +1 -1
  136. package/dist/engine/renderers/Indicator/pivot.js +43 -8
  137. package/dist/engine/renderers/Indicator/pivot.js.map +1 -1
  138. package/dist/engine/renderers/Indicator/pvt.d.ts +4 -1
  139. package/dist/engine/renderers/Indicator/pvt.d.ts.map +1 -1
  140. package/dist/engine/renderers/Indicator/pvt.js +19 -7
  141. package/dist/engine/renderers/Indicator/pvt.js.map +1 -1
  142. package/dist/engine/renderers/Indicator/roc.d.ts +4 -1
  143. package/dist/engine/renderers/Indicator/roc.d.ts.map +1 -1
  144. package/dist/engine/renderers/Indicator/roc.js +20 -7
  145. package/dist/engine/renderers/Indicator/roc.js.map +1 -1
  146. package/dist/engine/renderers/Indicator/rsi.d.ts +2 -1
  147. package/dist/engine/renderers/Indicator/rsi.d.ts.map +1 -1
  148. package/dist/engine/renderers/Indicator/rsi.js +14 -11
  149. package/dist/engine/renderers/Indicator/rsi.js.map +1 -1
  150. package/dist/engine/renderers/Indicator/sar.d.ts +4 -1
  151. package/dist/engine/renderers/Indicator/sar.d.ts.map +1 -1
  152. package/dist/engine/renderers/Indicator/sar.js +18 -8
  153. package/dist/engine/renderers/Indicator/sar.js.map +1 -1
  154. package/dist/engine/renderers/Indicator/stoch.d.ts +2 -1
  155. package/dist/engine/renderers/Indicator/stoch.d.ts.map +1 -1
  156. package/dist/engine/renderers/Indicator/stoch.js +10 -11
  157. package/dist/engine/renderers/Indicator/stoch.js.map +1 -1
  158. package/dist/engine/renderers/Indicator/structure.d.ts +4 -1
  159. package/dist/engine/renderers/Indicator/structure.d.ts.map +1 -1
  160. package/dist/engine/renderers/Indicator/structure.js +21 -8
  161. package/dist/engine/renderers/Indicator/structure.js.map +1 -1
  162. package/dist/engine/renderers/Indicator/supertrend.d.ts +4 -1
  163. package/dist/engine/renderers/Indicator/supertrend.d.ts.map +1 -1
  164. package/dist/engine/renderers/Indicator/supertrend.js +18 -8
  165. package/dist/engine/renderers/Indicator/supertrend.js.map +1 -1
  166. package/dist/engine/renderers/Indicator/tema.d.ts +2 -0
  167. package/dist/engine/renderers/Indicator/tema.d.ts.map +1 -1
  168. package/dist/engine/renderers/Indicator/tema.js +19 -8
  169. package/dist/engine/renderers/Indicator/tema.js.map +1 -1
  170. package/dist/engine/renderers/Indicator/trix.d.ts +4 -1
  171. package/dist/engine/renderers/Indicator/trix.d.ts.map +1 -1
  172. package/dist/engine/renderers/Indicator/trix.js +30 -8
  173. package/dist/engine/renderers/Indicator/trix.js.map +1 -1
  174. package/dist/engine/renderers/Indicator/vma.d.ts +4 -1
  175. package/dist/engine/renderers/Indicator/vma.d.ts.map +1 -1
  176. package/dist/engine/renderers/Indicator/vma.js +20 -7
  177. package/dist/engine/renderers/Indicator/vma.js.map +1 -1
  178. package/dist/engine/renderers/Indicator/volumeProfile.d.ts +4 -1
  179. package/dist/engine/renderers/Indicator/volumeProfile.d.ts.map +1 -1
  180. package/dist/engine/renderers/Indicator/volumeProfile.js +28 -8
  181. package/dist/engine/renderers/Indicator/volumeProfile.js.map +1 -1
  182. package/dist/engine/renderers/Indicator/vwap.d.ts +4 -1
  183. package/dist/engine/renderers/Indicator/vwap.d.ts.map +1 -1
  184. package/dist/engine/renderers/Indicator/vwap.js +19 -7
  185. package/dist/engine/renderers/Indicator/vwap.js.map +1 -1
  186. package/dist/engine/renderers/Indicator/wma.d.ts +2 -0
  187. package/dist/engine/renderers/Indicator/wma.d.ts.map +1 -1
  188. package/dist/engine/renderers/Indicator/wma.js +19 -8
  189. package/dist/engine/renderers/Indicator/wma.js.map +1 -1
  190. package/dist/engine/renderers/Indicator/wmsr.d.ts +2 -1
  191. package/dist/engine/renderers/Indicator/wmsr.d.ts.map +1 -1
  192. package/dist/engine/renderers/Indicator/wmsr.js +12 -10
  193. package/dist/engine/renderers/Indicator/wmsr.js.map +1 -1
  194. package/dist/engine/renderers/Indicator/zones.d.ts +2 -0
  195. package/dist/engine/renderers/Indicator/zones.d.ts.map +1 -1
  196. package/dist/engine/renderers/Indicator/zones.js +24 -8
  197. package/dist/engine/renderers/Indicator/zones.js.map +1 -1
  198. package/dist/engine/renderers/paneTitle.d.ts +4 -10
  199. package/dist/engine/renderers/paneTitle.d.ts.map +1 -1
  200. package/dist/engine/renderers/paneTitle.js +28 -6
  201. package/dist/engine/renderers/paneTitle.js.map +1 -1
  202. package/dist/engine/renderers/subVolume.js +0 -3
  203. package/dist/engine/renderers/subVolume.js.map +1 -1
  204. package/dist/version.d.ts +1 -1
  205. package/dist/version.d.ts.map +1 -1
  206. package/dist/version.js +1 -1
  207. package/dist/version.js.map +1 -1
  208. package/package.json +4 -4
  209. package/src/controllers/__tests__/indicatorSelector.test.ts +4 -3
  210. package/src/controllers/createIndicatorSelectorController.ts +4 -6
  211. package/src/controllers/index.ts +0 -4
  212. package/src/engine/chart.ts +30 -22
  213. package/src/engine/indicators/__tests__/registerBuiltins.test.ts +14 -23
  214. package/src/engine/indicators/__tests__/scheduler.test.ts +14 -14
  215. package/src/engine/indicators/__tests__/stateComposer.test.ts +7 -4
  216. package/src/engine/indicators/indicator.worker.ts +36 -4
  217. package/src/engine/indicators/indicatorDefinitionRegistry.ts +38 -3
  218. package/src/engine/indicators/indicatorMetadata.ts +66 -1
  219. package/src/engine/indicators/indicatorRuntime.ts +121 -1447
  220. package/src/engine/indicators/scheduler.ts +85 -489
  221. package/src/engine/indicators/stateComposer.ts +16 -60
  222. package/src/engine/indicators/workerProtocol.ts +14 -36
  223. package/src/engine/renderers/Indicator/atr.ts +14 -11
  224. package/src/engine/renderers/Indicator/boll.ts +33 -10
  225. package/src/engine/renderers/Indicator/cci.ts +15 -14
  226. package/src/engine/renderers/Indicator/chaikinVol.ts +29 -7
  227. package/src/engine/renderers/Indicator/cmf.ts +28 -7
  228. package/src/engine/renderers/Indicator/dema.ts +28 -9
  229. package/src/engine/renderers/Indicator/donchian.ts +28 -9
  230. package/src/engine/renderers/Indicator/ene.ts +34 -11
  231. package/src/engine/renderers/Indicator/expma.ts +31 -9
  232. package/src/engine/renderers/Indicator/fastk.ts +15 -14
  233. package/src/engine/renderers/Indicator/fib.ts +29 -9
  234. package/src/engine/renderers/Indicator/hma.ts +28 -9
  235. package/src/engine/renderers/Indicator/hv.ts +27 -8
  236. package/src/engine/renderers/Indicator/ichimoku.ts +31 -9
  237. package/src/engine/renderers/Indicator/index.ts +27 -28
  238. package/src/engine/renderers/Indicator/kama.ts +28 -9
  239. package/src/engine/renderers/Indicator/keltner.ts +28 -9
  240. package/src/engine/renderers/Indicator/kst.ts +16 -19
  241. package/src/engine/renderers/Indicator/ma.ts +44 -9
  242. package/src/engine/renderers/Indicator/macd.ts +31 -36
  243. package/src/engine/renderers/Indicator/mainIndicatorLegend.ts +43 -162
  244. package/src/engine/renderers/Indicator/mfi.ts +28 -7
  245. package/src/engine/renderers/Indicator/mom.ts +15 -14
  246. package/src/engine/renderers/Indicator/obv.ts +27 -7
  247. package/src/engine/renderers/Indicator/parkinson.ts +27 -8
  248. package/src/engine/renderers/Indicator/pivot.ts +47 -9
  249. package/src/engine/renderers/Indicator/pvt.ts +27 -7
  250. package/src/engine/renderers/Indicator/roc.ts +29 -7
  251. package/src/engine/renderers/Indicator/rsi.ts +14 -17
  252. package/src/engine/renderers/Indicator/sar.ts +26 -9
  253. package/src/engine/renderers/Indicator/stoch.ts +13 -16
  254. package/src/engine/renderers/Indicator/structure.ts +31 -8
  255. package/src/engine/renderers/Indicator/supertrend.ts +26 -9
  256. package/src/engine/renderers/Indicator/tema.ts +28 -9
  257. package/src/engine/renderers/Indicator/trix.ts +39 -8
  258. package/src/engine/renderers/Indicator/vma.ts +28 -7
  259. package/src/engine/renderers/Indicator/volumeProfile.ts +40 -8
  260. package/src/engine/renderers/Indicator/vwap.ts +27 -7
  261. package/src/engine/renderers/Indicator/wma.ts +28 -9
  262. package/src/engine/renderers/Indicator/wmsr.ts +15 -14
  263. package/src/engine/renderers/Indicator/zones.ts +29 -9
  264. package/src/engine/renderers/__tests__/mainIndicatorLegend.renderer.test.ts +142 -79
  265. package/src/engine/renderers/paneTitle.ts +43 -18
  266. package/src/engine/renderers/subVolume.ts +0 -2
  267. package/src/version.ts +1 -1
  268. package/dist/engine/renderers/Indicator/macdLegend.d.ts +0 -13
  269. package/dist/engine/renderers/Indicator/macdLegend.d.ts.map +0 -1
  270. package/dist/engine/renderers/Indicator/macdLegend.js +0 -116
  271. package/dist/engine/renderers/Indicator/macdLegend.js.map +0 -1
  272. package/dist/engine/renderers/Indicator/subPaneConfig.d.ts +0 -16
  273. package/dist/engine/renderers/Indicator/subPaneConfig.d.ts.map +0 -1
  274. package/dist/engine/renderers/Indicator/subPaneConfig.js +0 -194
  275. package/dist/engine/renderers/Indicator/subPaneConfig.js.map +0 -1
  276. package/src/engine/renderers/Indicator/macdLegend.ts +0 -141
  277. package/src/engine/renderers/Indicator/subPaneConfig.ts +0 -265
@@ -1,290 +1,99 @@
1
- /**
2
- * Indicator 纯计算运行时
3
- * 不依赖 PluginHost/StateStore,只负责计算和缓存
4
- * 可被主线程(inline fallback)或 Worker 使用
5
- */
6
- import { calcMAData, calcBOLLData, calcEXPMAData, calcENEData, calcRSIData, calcCCIData, calcSTOCHData, calcMOMData, calcWMSRData, calcKSTData, calcFASTKData, calcMACDData, calcATRData, calcWMAData, calcDEMAData, calcTEMAData, calcHMAData, calcKAMAData, calcSARData, calcSuperTrendData, calcKeltnerData, calcDonchianData, calcIchimokuData, calcROCData, calcTRIXData, calcHVData, calcParkinsonData, calcChaikinVolData, calcVMAData, calcOBVData, calcPVTData, calcVWAPData, calcCMFData, calcMFIData, calcPivotData, calcFibData, calcStructureData, calcZonesData, calcVolumeProfileData, DEFAULT_MA_PERIODS, DEFAULT_ATR_PERIOD, DEFAULT_VMA_PERIOD, DEFAULT_STRUCTURE_LEFT, DEFAULT_STRUCTURE_RIGHT, DEFAULT_ZONES_OB_LOOKBACK, DEFAULT_VP_BINS, DEFAULT_VP_LOOKBACK, DEFAULT_VP_VALUE_AREA, DEFAULT_VWAP_SESSION_GAP_MS, DEFAULT_CMF_PERIOD, DEFAULT_MFI_PERIOD, DEFAULT_FIB_PERIOD, DEFAULT_WMA_PERIOD, DEFAULT_DEMA_PERIOD, DEFAULT_TEMA_PERIOD, DEFAULT_HMA_PERIOD, DEFAULT_KAMA_PERIOD, DEFAULT_KAMA_FAST_PERIOD, DEFAULT_KAMA_SLOW_PERIOD, DEFAULT_SAR_STEP, DEFAULT_SAR_MAX_STEP, DEFAULT_SUPERTREND_ATR_PERIOD, DEFAULT_SUPERTREND_MULTIPLIER, DEFAULT_KELTNER_EMA_PERIOD, DEFAULT_KELTNER_ATR_PERIOD, DEFAULT_KELTNER_MULTIPLIER, DEFAULT_DONCHIAN_PERIOD, DEFAULT_ICHIMOKU_TENKAN, DEFAULT_ICHIMOKU_KIJUN, DEFAULT_ICHIMOKU_SPAN_B, DEFAULT_ICHIMOKU_DISPLACEMENT, DEFAULT_ROC_PERIOD, DEFAULT_TRIX_PERIOD, DEFAULT_TRIX_SIGNAL_PERIOD, DEFAULT_HV_PERIOD, DEFAULT_HV_ANNUALIZATION, DEFAULT_PARKINSON_PERIOD, DEFAULT_PARKINSON_ANNUALIZATION, DEFAULT_CHAIKIN_VOL_EMA_PERIOD, DEFAULT_CHAIKIN_VOL_ROC_PERIOD, } from './calculators';
7
- /**
8
- * 计算运行时
9
- * 管理数据、配置、缓存和脏标记
10
- */
1
+ import { calcMAData, calcBOLLData, calcEXPMAData, calcENEData, calcRSIData, calcCCIData, calcSTOCHData, calcMOMData, calcWMSRData, calcKSTData, calcFASTKData, calcMACDData, calcATRData, calcWMAData, calcDEMAData, calcTEMAData, calcHMAData, calcKAMAData, calcSARData, calcSuperTrendData, calcKeltnerData, calcDonchianData, calcIchimokuData, calcROCData, calcTRIXData, calcHVData, calcParkinsonData, calcChaikinVolData, calcVMAData, calcOBVData, calcPVTData, calcVWAPData, calcCMFData, calcMFIData, calcPivotData, calcFibData, calcStructureData, calcZonesData, calcVolumeProfileData, DEFAULT_MA_PERIODS, } from './calculators';
2
+ export const CALCULATOR_MAP = {
3
+ calcCCIData: (data, c) => calcCCIData(data, c.period),
4
+ calcMACDData: (data, c) => calcMACDData(data, c.fastPeriod, c.slowPeriod, c.signalPeriod),
5
+ calcMAData: (data, c) => {
6
+ const r = {};
7
+ for (const p of DEFAULT_MA_PERIODS) {
8
+ if (c['ma' + p])
9
+ r[p] = calcMAData(data, p);
10
+ }
11
+ return { series: r, enabledPeriods: Object.keys(r).map(Number) };
12
+ },
13
+ calcRSIData: (data, c) => {
14
+ const p = [c.period1, c.period2, c.period3];
15
+ const s = [c.showRSI1, c.showRSI2, c.showRSI3];
16
+ const r = {};
17
+ for (let i = 0; i < 3; i++) {
18
+ if (s[i])
19
+ r[p[i]] = calcRSIData(data, p[i]);
20
+ }
21
+ return { series: r, enabledPeriods: Object.keys(r).map(Number) };
22
+ },
23
+ calcTRIXData: (data, c) => calcTRIXData(data, c.period, c.signalPeriod),
24
+ calcBOLLData: (data, c) => calcBOLLData(data, c.period, c.multiplier),
25
+ calcEXPMAData: (data, c) => calcEXPMAData(data, c.fastPeriod, c.slowPeriod),
26
+ calcENEData: (data, c) => calcENEData(data, c.period, c.deviation),
27
+ calcSTOCHData: (data, c) => calcSTOCHData(data, c.n, c.m),
28
+ calcMOMData: (data, c) => calcMOMData(data, c.period),
29
+ calcWMSRData: (data, c) => calcWMSRData(data, c.period),
30
+ calcKSTData: (data, c) => calcKSTData(data, c.roc1, c.roc2, c.roc3, c.roc4, c.signalPeriod),
31
+ calcFASTKData: (data, c) => calcFASTKData(data, c.period),
32
+ calcATRData: (data, c) => calcATRData(data, c.period),
33
+ calcWMAData: (data, c) => calcWMAData(data, c.period),
34
+ calcDEMAData: (data, c) => calcDEMAData(data, c.period),
35
+ calcTEMAData: (data, c) => calcTEMAData(data, c.period),
36
+ calcHMAData: (data, c) => calcHMAData(data, c.period),
37
+ calcKAMAData: (data, c) => calcKAMAData(data, c.period, c.fastPeriod, c.slowPeriod),
38
+ calcSARData: (data, c) => calcSARData(data, c.step, c.maxStep),
39
+ calcSuperTrendData: (data, c) => calcSuperTrendData(data, c.atrPeriod, c.multiplier),
40
+ calcKeltnerData: (data, c) => calcKeltnerData(data, c.emaPeriod, c.atrPeriod, c.multiplier),
41
+ calcDonchianData: (data, c) => calcDonchianData(data, c.period),
42
+ calcIchimokuData: (data, c) => calcIchimokuData(data, c.tenkanPeriod, c.kijunPeriod, c.spanBPeriod, c.displacement),
43
+ calcROCData: (data, c) => calcROCData(data, c.period),
44
+ calcHVData: (data, c) => calcHVData(data, c.period, c.annualizationFactor),
45
+ calcParkinsonData: (data, c) => calcParkinsonData(data, c.period, c.annualizationFactor),
46
+ calcChaikinVolData: (data, c) => calcChaikinVolData(data, c.emaPeriod, c.rocPeriod),
47
+ calcVMAData: (data, c) => calcVMAData(data, c.period),
48
+ calcOBVData: (data, c) => calcOBVData(data),
49
+ calcPVTData: (data, c) => calcPVTData(data),
50
+ calcVWAPData: (data, c) => calcVWAPData(data, c.sessionResetGapMs),
51
+ calcCMFData: (data, c) => calcCMFData(data, c.period),
52
+ calcMFIData: (data, c) => calcMFIData(data, c.period),
53
+ calcPivotData: (data, c) => calcPivotData(data),
54
+ calcFibData: (data, c) => calcFibData(data, c.period),
55
+ calcStructureData: (data, c) => calcStructureData(data, c.leftWindow, c.rightWindow, c.breakoutSource),
56
+ calcZonesData: (data, c) => calcZonesData(data, c.obLookback, 5, 2, 'close'),
57
+ calcVolumeProfileData: (data, c) => calcVolumeProfileData(data, c.bins, c.lookback, c.valueAreaPercent),
58
+ };
59
+ export function createWorkerCompute(descriptor) {
60
+ return CALCULATOR_MAP[descriptor.computeKey] ?? ((_data, _config) => {
61
+ console.warn(`[IndicatorRuntime] Unknown computeKey: ${descriptor.computeKey}`);
62
+ return [];
63
+ });
64
+ }
11
65
  export class IndicatorRuntime {
12
- // 数据
13
66
  currentData = [];
14
67
  dataVersion = 0;
15
- // 配置
16
- config = this.getDefaultConfig();
17
68
  configVersion = 0;
18
- // 缓存的 series
19
- cachedSeries = {};
20
- cachedBollSeries = [];
21
- cachedExpmaSeries = [];
22
- cachedEneSeries = [];
23
- cachedRsiSeries = {};
24
- cachedCciSeries = [];
25
- cachedStochSeries = [];
26
- cachedMomSeries = [];
27
- cachedWmsrSeries = [];
28
- cachedKstSeries = [];
29
- cachedFastkSeries = [];
30
- cachedMacdSeries = [];
31
- cachedAtrSeries = [];
32
- cachedWmaSeries = [];
33
- cachedDemaSeries = [];
34
- cachedTemaSeries = [];
35
- cachedHmaSeries = [];
36
- cachedKamaSeries = [];
37
- cachedSarSeries = [];
38
- cachedSupertrendSeries = [];
39
- cachedKeltnerSeries = [];
40
- cachedDonchianSeries = [];
41
- cachedIchimokuSeries = [];
42
- cachedRocSeries = [];
43
- cachedTrixSeries = [];
44
- cachedTrixSignalSeries = [];
45
- cachedHvSeries = [];
46
- cachedParkinsonSeries = [];
47
- cachedChaikinVolSeries = [];
48
- cachedVmaSeries = [];
49
- cachedObvSeries = [];
50
- cachedPvtSeries = [];
51
- cachedVwapSeries = [];
52
- cachedCmfSeries = [];
53
- cachedMfiSeries = [];
54
- cachedPivotSeries = [];
55
- cachedFibSeries = [];
56
- cachedStructureSeries = { swings: [], events: [], trend: 'range' };
57
- cachedZonesSeries = [];
58
- cachedVolumeProfileSeries = { bins: [], poc: 0, vah: 0, val: 0, totalVolume: 0 };
59
- // 脏标记
60
- dirtyData = true;
61
- dirtyMAConfig = true;
62
- dirtyBollConfig = true;
63
- dirtyExpmaConfig = true;
64
- dirtyEneConfig = true;
65
- dirtyRsiConfig = true;
66
- dirtyCciConfig = true;
67
- dirtyStochConfig = true;
68
- dirtyMomConfig = true;
69
- dirtyWmsrConfig = true;
70
- dirtyKstConfig = true;
71
- dirtyFastkConfig = true;
72
- dirtyMacdConfig = true;
73
- dirtyAtrConfig = true;
74
- dirtyWmaConfig = true;
75
- dirtyDemaConfig = true;
76
- dirtyTemaConfig = true;
77
- dirtyHmaConfig = true;
78
- dirtyKamaConfig = true;
79
- dirtySarConfig = true;
80
- dirtySupertrendConfig = true;
81
- dirtyKeltnerConfig = true;
82
- dirtyDonchianConfig = true;
83
- dirtyIchimokuConfig = true;
84
- dirtyRocConfig = true;
85
- dirtyTrixConfig = true;
86
- dirtyHvConfig = true;
87
- dirtyParkinsonConfig = true;
88
- dirtyChaikinVolConfig = true;
89
- dirtyVmaConfig = true;
90
- dirtyObvConfig = true;
91
- dirtyPvtConfig = true;
92
- dirtyVwapConfig = true;
93
- dirtyCmfConfig = true;
94
- dirtyMfiConfig = true;
95
- dirtyPivotConfig = true;
96
- dirtyFibConfig = true;
97
- dirtyStructureConfig = true;
98
- dirtyZonesConfig = true;
99
- dirtyVolumeProfileConfig = true;
100
- getDefaultConfig() {
101
- return {
102
- ma: { ma5: true, ma10: true, ma20: true, ma30: true, ma60: true },
103
- boll: {
104
- period: 20,
105
- multiplier: 2,
106
- showUpper: true,
107
- showMiddle: true,
108
- showLower: true,
109
- showBand: true,
110
- },
111
- expma: { fastPeriod: 12, slowPeriod: 50 },
112
- ene: { period: 10, deviation: 11 },
113
- rsi: {
114
- period1: 6,
115
- period2: 12,
116
- period3: 24,
117
- showRSI1: true,
118
- showRSI2: true,
119
- showRSI3: true,
120
- },
121
- cci: { period: 14, showCCI: true },
122
- stoch: { n: 9, m: 3, showK: true, showD: true },
123
- mom: { period: 10, showMOM: true },
124
- wmsr: { period: 14, showWMSR: true },
125
- kst: {
126
- roc1: 10,
127
- roc2: 15,
128
- roc3: 20,
129
- roc4: 30,
130
- signalPeriod: 9,
131
- showKST: true,
132
- showSignal: true,
133
- },
134
- fastk: { period: 9, showFASTK: true },
135
- macd: {
136
- fastPeriod: 12,
137
- slowPeriod: 26,
138
- signalPeriod: 9,
139
- showDIF: true,
140
- showDEA: true,
141
- showBAR: true,
142
- },
143
- atr: { period: DEFAULT_ATR_PERIOD, showATR: true },
144
- wma: { period: DEFAULT_WMA_PERIOD, showWMA: true },
145
- dema: { period: DEFAULT_DEMA_PERIOD, showDEMA: true },
146
- tema: { period: DEFAULT_TEMA_PERIOD, showTEMA: true },
147
- hma: { period: DEFAULT_HMA_PERIOD, showHMA: true },
148
- kama: {
149
- period: DEFAULT_KAMA_PERIOD,
150
- fastPeriod: DEFAULT_KAMA_FAST_PERIOD,
151
- slowPeriod: DEFAULT_KAMA_SLOW_PERIOD,
152
- showKAMA: true,
153
- },
154
- sar: { step: DEFAULT_SAR_STEP, maxStep: DEFAULT_SAR_MAX_STEP, showSAR: true },
155
- supertrend: {
156
- atrPeriod: DEFAULT_SUPERTREND_ATR_PERIOD,
157
- multiplier: DEFAULT_SUPERTREND_MULTIPLIER,
158
- showSuperTrend: true,
159
- },
160
- keltner: {
161
- emaPeriod: DEFAULT_KELTNER_EMA_PERIOD,
162
- atrPeriod: DEFAULT_KELTNER_ATR_PERIOD,
163
- multiplier: DEFAULT_KELTNER_MULTIPLIER,
164
- showUpper: true,
165
- showMiddle: true,
166
- showLower: true,
167
- },
168
- donchian: {
169
- period: DEFAULT_DONCHIAN_PERIOD,
170
- showUpper: true,
171
- showMiddle: true,
172
- showLower: true,
173
- },
174
- ichimoku: {
175
- tenkanPeriod: DEFAULT_ICHIMOKU_TENKAN,
176
- kijunPeriod: DEFAULT_ICHIMOKU_KIJUN,
177
- spanBPeriod: DEFAULT_ICHIMOKU_SPAN_B,
178
- displacement: DEFAULT_ICHIMOKU_DISPLACEMENT,
179
- showTenkan: true,
180
- showKijun: true,
181
- showSpanA: true,
182
- showSpanB: true,
183
- showCloud: true,
184
- showChikou: true,
185
- },
186
- roc: { period: DEFAULT_ROC_PERIOD, showROC: true },
187
- trix: {
188
- period: DEFAULT_TRIX_PERIOD,
189
- signalPeriod: DEFAULT_TRIX_SIGNAL_PERIOD,
190
- showTRIX: true,
191
- showSignal: true,
192
- },
193
- hv: {
194
- period: DEFAULT_HV_PERIOD,
195
- annualizationFactor: DEFAULT_HV_ANNUALIZATION,
196
- showHV: true,
197
- },
198
- parkinson: {
199
- period: DEFAULT_PARKINSON_PERIOD,
200
- annualizationFactor: DEFAULT_PARKINSON_ANNUALIZATION,
201
- showParkinson: true,
202
- },
203
- chaikinVol: {
204
- emaPeriod: DEFAULT_CHAIKIN_VOL_EMA_PERIOD,
205
- rocPeriod: DEFAULT_CHAIKIN_VOL_ROC_PERIOD,
206
- showChaikinVol: true,
207
- },
208
- vma: { period: DEFAULT_VMA_PERIOD, showVMA: true },
209
- obv: { showOBV: true },
210
- pvt: { showPVT: true },
211
- vwap: { sessionResetGapMs: DEFAULT_VWAP_SESSION_GAP_MS, showVWAP: true },
212
- cmf: { period: DEFAULT_CMF_PERIOD, showCMF: true },
213
- mfi: { period: DEFAULT_MFI_PERIOD, showMFI: true },
214
- pivot: { showPP: true, showR1: true, showR2: true, showR3: false, showS1: true, showS2: true, showS3: false },
215
- fib: { period: DEFAULT_FIB_PERIOD, showLevels: true },
216
- structure: {
217
- leftWindow: DEFAULT_STRUCTURE_LEFT,
218
- rightWindow: DEFAULT_STRUCTURE_RIGHT,
219
- breakoutSource: 'close',
220
- showSwingLabels: true,
221
- showBOS: true,
222
- showCHOCH: true,
223
- showProvisional: false,
224
- },
225
- zones: {
226
- showFVG: true,
227
- showOB: true,
228
- showFilledZones: false,
229
- obLookback: DEFAULT_ZONES_OB_LOOKBACK,
230
- },
231
- volumeProfile: {
232
- bins: DEFAULT_VP_BINS,
233
- lookback: DEFAULT_VP_LOOKBACK,
234
- valueAreaPercent: DEFAULT_VP_VALUE_AREA,
235
- showPOC: true,
236
- showValueArea: true,
237
- },
238
- rsiPaneId: 'sub_RSI',
239
- cciPaneId: 'sub_CCI',
240
- stochPaneId: 'sub_STOCH',
241
- momPaneId: 'sub_MOM',
242
- wmsrPaneId: 'sub_WMSR',
243
- kstPaneId: 'sub_KST',
244
- fastkPaneId: 'sub_FASTK',
245
- macdPaneId: 'sub_MACD',
246
- atrPaneId: 'sub_ATR',
247
- wmaPaneId: 'sub_WMA',
248
- demaPaneId: 'sub_DEMA',
249
- temaPaneId: 'sub_TEMA',
250
- hmaPaneId: 'sub_HMA',
251
- kamaPaneId: 'sub_KAMA',
252
- sarPaneId: 'sub_SAR',
253
- supertrendPaneId: 'sub_SuperTrend',
254
- keltnerPaneId: 'sub_Keltner',
255
- donchianPaneId: 'sub_Donchian',
256
- ichimokuPaneId: 'sub_Ichimoku',
257
- rocPaneId: 'sub_ROC',
258
- trixPaneId: 'sub_TRIX',
259
- hvPaneId: 'sub_HV',
260
- parkinsonPaneId: 'sub_Parkinson',
261
- chaikinVolPaneId: 'sub_ChaikinVol',
262
- vmaPaneId: 'sub_VMA',
263
- obvPaneId: 'sub_OBV',
264
- pvtPaneId: 'sub_PVT',
265
- vwapPaneId: 'sub_VWAP',
266
- cmfPaneId: 'sub_CMF',
267
- mfiPaneId: 'sub_MFI',
268
- pivotPaneId: 'sub_Pivot',
269
- fibPaneId: 'sub_Fib',
270
- structurePaneId: 'sub_Structure',
271
- zonesPaneId: 'sub_Zones',
272
- volumeProfilePaneId: 'sub_VolumeProfile',
273
- };
69
+ dataDirty = true;
70
+ configMap = new Map();
71
+ seriesMap = new Map();
72
+ dirtyFlags = new Map();
73
+ descriptorMap = new Map();
74
+ constructor(descriptors = []) {
75
+ for (const d of descriptors) {
76
+ this.addDescriptor(d);
77
+ }
78
+ }
79
+ addDescriptor(d) {
80
+ const configKey = d.configKey ?? 'unknown';
81
+ if (this.descriptorMap.has(configKey))
82
+ return;
83
+ this.descriptorMap.set(configKey, d);
84
+ const def = typeof d.defaultConfig === 'function'
85
+ ? d.defaultConfig()
86
+ : d.defaultConfig;
87
+ this.configMap.set(configKey, { ...def });
88
+ this.dirtyFlags.set(configKey, true);
274
89
  }
275
- /**
276
- * 更新数据
277
- */
278
90
  setData(data, version) {
279
- if (this.dataVersion === version && !this.dirtyData)
91
+ if (this.dataVersion === version && !this.dataDirty)
280
92
  return;
281
93
  this.currentData = data;
282
94
  this.dataVersion = version;
283
- this.dirtyData = true;
95
+ this.dataDirty = true;
284
96
  }
285
- /**
286
- * 更新配置
287
- */
288
97
  shallowEqual(a, b) {
289
98
  const keysA = Object.keys(a);
290
99
  const keysB = Object.keys(b);
@@ -296,1059 +105,66 @@ export class IndicatorRuntime {
296
105
  }
297
106
  return true;
298
107
  }
299
- /**
300
- * 更新配置(仅值变更时才设置脏标记)
301
- */
302
108
  setConfig(config, version) {
303
- // 合并配置(仅值变更时才标记脏)
304
- if (config.ma !== undefined && !this.shallowEqual(config.ma, this.config.ma)) {
305
- this.config.ma = { ...this.config.ma, ...config.ma };
306
- this.dirtyMAConfig = true;
307
- }
308
- if (config.boll !== undefined && !this.shallowEqual(config.boll, this.config.boll)) {
309
- this.config.boll = { ...this.config.boll, ...config.boll };
310
- this.dirtyBollConfig = true;
311
- }
312
- if (config.expma !== undefined && !this.shallowEqual(config.expma, this.config.expma)) {
313
- this.config.expma = { ...this.config.expma, ...config.expma };
314
- this.dirtyExpmaConfig = true;
315
- }
316
- if (config.ene !== undefined && !this.shallowEqual(config.ene, this.config.ene)) {
317
- this.config.ene = { ...this.config.ene, ...config.ene };
318
- this.dirtyEneConfig = true;
319
- }
320
- if (config.rsi !== undefined && !this.shallowEqual(config.rsi, this.config.rsi)) {
321
- this.config.rsi = { ...this.config.rsi, ...config.rsi };
322
- this.dirtyRsiConfig = true;
323
- }
324
- if (config.cci !== undefined && !this.shallowEqual(config.cci, this.config.cci)) {
325
- this.config.cci = { ...this.config.cci, ...config.cci };
326
- this.dirtyCciConfig = true;
327
- }
328
- if (config.stoch !== undefined && !this.shallowEqual(config.stoch, this.config.stoch)) {
329
- this.config.stoch = { ...this.config.stoch, ...config.stoch };
330
- this.dirtyStochConfig = true;
331
- }
332
- if (config.mom !== undefined && !this.shallowEqual(config.mom, this.config.mom)) {
333
- this.config.mom = { ...this.config.mom, ...config.mom };
334
- this.dirtyMomConfig = true;
335
- }
336
- if (config.wmsr !== undefined && !this.shallowEqual(config.wmsr, this.config.wmsr)) {
337
- this.config.wmsr = { ...this.config.wmsr, ...config.wmsr };
338
- this.dirtyWmsrConfig = true;
339
- }
340
- if (config.kst !== undefined && !this.shallowEqual(config.kst, this.config.kst)) {
341
- this.config.kst = { ...this.config.kst, ...config.kst };
342
- this.dirtyKstConfig = true;
343
- }
344
- if (config.fastk !== undefined && !this.shallowEqual(config.fastk, this.config.fastk)) {
345
- this.config.fastk = { ...this.config.fastk, ...config.fastk };
346
- this.dirtyFastkConfig = true;
347
- }
348
- if (config.macd !== undefined && !this.shallowEqual(config.macd, this.config.macd)) {
349
- this.config.macd = { ...this.config.macd, ...config.macd };
350
- this.dirtyMacdConfig = true;
351
- }
352
- if (config.atr !== undefined && !this.shallowEqual(config.atr, this.config.atr)) {
353
- this.config.atr = { ...this.config.atr, ...config.atr };
354
- this.dirtyAtrConfig = true;
355
- }
356
- if (config.wma !== undefined && !this.shallowEqual(config.wma, this.config.wma)) {
357
- this.config.wma = { ...this.config.wma, ...config.wma };
358
- this.dirtyWmaConfig = true;
359
- }
360
- if (config.dema !== undefined && !this.shallowEqual(config.dema, this.config.dema)) {
361
- this.config.dema = { ...this.config.dema, ...config.dema };
362
- this.dirtyDemaConfig = true;
363
- }
364
- if (config.tema !== undefined && !this.shallowEqual(config.tema, this.config.tema)) {
365
- this.config.tema = { ...this.config.tema, ...config.tema };
366
- this.dirtyTemaConfig = true;
367
- }
368
- if (config.hma !== undefined && !this.shallowEqual(config.hma, this.config.hma)) {
369
- this.config.hma = { ...this.config.hma, ...config.hma };
370
- this.dirtyHmaConfig = true;
371
- }
372
- if (config.kama !== undefined && !this.shallowEqual(config.kama, this.config.kama)) {
373
- this.config.kama = { ...this.config.kama, ...config.kama };
374
- this.dirtyKamaConfig = true;
375
- }
376
- if (config.sar !== undefined && !this.shallowEqual(config.sar, this.config.sar)) {
377
- this.config.sar = { ...this.config.sar, ...config.sar };
378
- this.dirtySarConfig = true;
379
- }
380
- if (config.supertrend !== undefined && !this.shallowEqual(config.supertrend, this.config.supertrend)) {
381
- this.config.supertrend = { ...this.config.supertrend, ...config.supertrend };
382
- this.dirtySupertrendConfig = true;
383
- }
384
- if (config.keltner !== undefined && !this.shallowEqual(config.keltner, this.config.keltner)) {
385
- this.config.keltner = { ...this.config.keltner, ...config.keltner };
386
- this.dirtyKeltnerConfig = true;
387
- }
388
- if (config.donchian !== undefined && !this.shallowEqual(config.donchian, this.config.donchian)) {
389
- this.config.donchian = { ...this.config.donchian, ...config.donchian };
390
- this.dirtyDonchianConfig = true;
391
- }
392
- if (config.ichimoku !== undefined && !this.shallowEqual(config.ichimoku, this.config.ichimoku)) {
393
- this.config.ichimoku = { ...this.config.ichimoku, ...config.ichimoku };
394
- this.dirtyIchimokuConfig = true;
395
- }
396
- if (config.roc !== undefined && !this.shallowEqual(config.roc, this.config.roc)) {
397
- this.config.roc = { ...this.config.roc, ...config.roc };
398
- this.dirtyRocConfig = true;
399
- }
400
- if (config.trix !== undefined && !this.shallowEqual(config.trix, this.config.trix)) {
401
- this.config.trix = { ...this.config.trix, ...config.trix };
402
- this.dirtyTrixConfig = true;
403
- }
404
- if (config.hv !== undefined && !this.shallowEqual(config.hv, this.config.hv)) {
405
- this.config.hv = { ...this.config.hv, ...config.hv };
406
- this.dirtyHvConfig = true;
407
- }
408
- if (config.parkinson !== undefined && !this.shallowEqual(config.parkinson, this.config.parkinson)) {
409
- this.config.parkinson = { ...this.config.parkinson, ...config.parkinson };
410
- this.dirtyParkinsonConfig = true;
411
- }
412
- if (config.chaikinVol !== undefined && !this.shallowEqual(config.chaikinVol, this.config.chaikinVol)) {
413
- this.config.chaikinVol = { ...this.config.chaikinVol, ...config.chaikinVol };
414
- this.dirtyChaikinVolConfig = true;
415
- }
416
- if (config.vma !== undefined && !this.shallowEqual(config.vma, this.config.vma)) {
417
- this.config.vma = { ...this.config.vma, ...config.vma };
418
- this.dirtyVmaConfig = true;
419
- }
420
- if (config.obv !== undefined && !this.shallowEqual(config.obv, this.config.obv)) {
421
- this.config.obv = { ...this.config.obv, ...config.obv };
422
- this.dirtyObvConfig = true;
423
- }
424
- if (config.pvt !== undefined && !this.shallowEqual(config.pvt, this.config.pvt)) {
425
- this.config.pvt = { ...this.config.pvt, ...config.pvt };
426
- this.dirtyPvtConfig = true;
427
- }
428
- if (config.vwap !== undefined && !this.shallowEqual(config.vwap, this.config.vwap)) {
429
- this.config.vwap = { ...this.config.vwap, ...config.vwap };
430
- this.dirtyVwapConfig = true;
431
- }
432
- if (config.cmf !== undefined && !this.shallowEqual(config.cmf, this.config.cmf)) {
433
- this.config.cmf = { ...this.config.cmf, ...config.cmf };
434
- this.dirtyCmfConfig = true;
435
- }
436
- if (config.mfi !== undefined && !this.shallowEqual(config.mfi, this.config.mfi)) {
437
- this.config.mfi = { ...this.config.mfi, ...config.mfi };
438
- this.dirtyMfiConfig = true;
439
- }
440
- if (config.pivot !== undefined && !this.shallowEqual(config.pivot, this.config.pivot)) {
441
- this.config.pivot = { ...this.config.pivot, ...config.pivot };
442
- this.dirtyPivotConfig = true;
443
- }
444
- if (config.fib !== undefined && !this.shallowEqual(config.fib, this.config.fib)) {
445
- this.config.fib = { ...this.config.fib, ...config.fib };
446
- this.dirtyFibConfig = true;
447
- }
448
- if (config.structure !== undefined && !this.shallowEqual(config.structure, this.config.structure)) {
449
- this.config.structure = { ...this.config.structure, ...config.structure };
450
- this.dirtyStructureConfig = true;
451
- }
452
- if (config.zones !== undefined && !this.shallowEqual(config.zones, this.config.zones)) {
453
- this.config.zones = { ...this.config.zones, ...config.zones };
454
- this.dirtyZonesConfig = true;
455
- }
456
- if (config.volumeProfile !== undefined && !this.shallowEqual(config.volumeProfile, this.config.volumeProfile)) {
457
- this.config.volumeProfile = { ...this.config.volumeProfile, ...config.volumeProfile };
458
- this.dirtyVolumeProfileConfig = true;
109
+ for (const [key, value] of Object.entries(config)) {
110
+ if (value === undefined)
111
+ continue;
112
+ const desc = this.descriptorMap.get(key);
113
+ if (desc) {
114
+ const current = this.configMap.get(key);
115
+ if (!current || !this.shallowEqual(value, current)) {
116
+ this.configMap.set(key, { ...(current ?? {}), ...value });
117
+ this.dirtyFlags.set(key, true);
118
+ }
119
+ continue;
120
+ }
459
121
  }
460
- // pane IDs
461
- if (config.rsiPaneId !== undefined)
462
- this.config.rsiPaneId = config.rsiPaneId;
463
- if (config.cciPaneId !== undefined)
464
- this.config.cciPaneId = config.cciPaneId;
465
- if (config.stochPaneId !== undefined)
466
- this.config.stochPaneId = config.stochPaneId;
467
- if (config.momPaneId !== undefined)
468
- this.config.momPaneId = config.momPaneId;
469
- if (config.wmsrPaneId !== undefined)
470
- this.config.wmsrPaneId = config.wmsrPaneId;
471
- if (config.kstPaneId !== undefined)
472
- this.config.kstPaneId = config.kstPaneId;
473
- if (config.fastkPaneId !== undefined)
474
- this.config.fastkPaneId = config.fastkPaneId;
475
- if (config.macdPaneId !== undefined)
476
- this.config.macdPaneId = config.macdPaneId;
477
- if (config.atrPaneId !== undefined)
478
- this.config.atrPaneId = config.atrPaneId;
479
- if (config.wmaPaneId !== undefined)
480
- this.config.wmaPaneId = config.wmaPaneId;
481
- if (config.demaPaneId !== undefined)
482
- this.config.demaPaneId = config.demaPaneId;
483
- if (config.temaPaneId !== undefined)
484
- this.config.temaPaneId = config.temaPaneId;
485
- if (config.hmaPaneId !== undefined)
486
- this.config.hmaPaneId = config.hmaPaneId;
487
- if (config.kamaPaneId !== undefined)
488
- this.config.kamaPaneId = config.kamaPaneId;
489
- if (config.sarPaneId !== undefined)
490
- this.config.sarPaneId = config.sarPaneId;
491
- if (config.supertrendPaneId !== undefined)
492
- this.config.supertrendPaneId = config.supertrendPaneId;
493
- if (config.keltnerPaneId !== undefined)
494
- this.config.keltnerPaneId = config.keltnerPaneId;
495
- if (config.donchianPaneId !== undefined)
496
- this.config.donchianPaneId = config.donchianPaneId;
497
- if (config.ichimokuPaneId !== undefined)
498
- this.config.ichimokuPaneId = config.ichimokuPaneId;
499
- if (config.rocPaneId !== undefined)
500
- this.config.rocPaneId = config.rocPaneId;
501
- if (config.trixPaneId !== undefined)
502
- this.config.trixPaneId = config.trixPaneId;
503
- if (config.hvPaneId !== undefined)
504
- this.config.hvPaneId = config.hvPaneId;
505
- if (config.parkinsonPaneId !== undefined)
506
- this.config.parkinsonPaneId = config.parkinsonPaneId;
507
- if (config.chaikinVolPaneId !== undefined)
508
- this.config.chaikinVolPaneId = config.chaikinVolPaneId;
509
- if (config.vmaPaneId !== undefined)
510
- this.config.vmaPaneId = config.vmaPaneId;
511
- if (config.obvPaneId !== undefined)
512
- this.config.obvPaneId = config.obvPaneId;
513
- if (config.pvtPaneId !== undefined)
514
- this.config.pvtPaneId = config.pvtPaneId;
515
- if (config.vwapPaneId !== undefined)
516
- this.config.vwapPaneId = config.vwapPaneId;
517
- if (config.cmfPaneId !== undefined)
518
- this.config.cmfPaneId = config.cmfPaneId;
519
- if (config.mfiPaneId !== undefined)
520
- this.config.mfiPaneId = config.mfiPaneId;
521
- if (config.pivotPaneId !== undefined)
522
- this.config.pivotPaneId = config.pivotPaneId;
523
- if (config.fibPaneId !== undefined)
524
- this.config.fibPaneId = config.fibPaneId;
525
- if (config.structurePaneId !== undefined)
526
- this.config.structurePaneId = config.structurePaneId;
527
- if (config.zonesPaneId !== undefined)
528
- this.config.zonesPaneId = config.zonesPaneId;
529
- if (config.volumeProfilePaneId !== undefined)
530
- this.config.volumeProfilePaneId = config.volumeProfilePaneId;
531
122
  this.configVersion = version;
532
123
  }
533
- /**
534
- * 强制所有指标标记为脏(用于 recompute)
535
- */
536
124
  forceDirty() {
537
- this.dirtyData = true;
538
- this.dirtyMAConfig = true;
539
- this.dirtyBollConfig = true;
540
- this.dirtyExpmaConfig = true;
541
- this.dirtyEneConfig = true;
542
- this.dirtyRsiConfig = true;
543
- this.dirtyCciConfig = true;
544
- this.dirtyStochConfig = true;
545
- this.dirtyMomConfig = true;
546
- this.dirtyWmsrConfig = true;
547
- this.dirtyKstConfig = true;
548
- this.dirtyFastkConfig = true;
549
- this.dirtyMacdConfig = true;
550
- this.dirtyAtrConfig = true;
551
- this.dirtyWmaConfig = true;
552
- this.dirtyDemaConfig = true;
553
- this.dirtyTemaConfig = true;
554
- this.dirtyHmaConfig = true;
555
- this.dirtyKamaConfig = true;
556
- this.dirtySarConfig = true;
557
- this.dirtySupertrendConfig = true;
558
- this.dirtyKeltnerConfig = true;
559
- this.dirtyDonchianConfig = true;
560
- this.dirtyIchimokuConfig = true;
561
- this.dirtyRocConfig = true;
562
- this.dirtyTrixConfig = true;
563
- this.dirtyHvConfig = true;
564
- this.dirtyParkinsonConfig = true;
565
- this.dirtyChaikinVolConfig = true;
566
- this.dirtyVmaConfig = true;
567
- this.dirtyObvConfig = true;
568
- this.dirtyPvtConfig = true;
569
- this.dirtyVwapConfig = true;
570
- this.dirtyCmfConfig = true;
571
- this.dirtyMfiConfig = true;
572
- this.dirtyPivotConfig = true;
573
- this.dirtyFibConfig = true;
574
- this.dirtyStructureConfig = true;
575
- this.dirtyZonesConfig = true;
576
- this.dirtyVolumeProfileConfig = true;
125
+ this.dataDirty = true;
126
+ for (const key of this.dirtyFlags.keys()) {
127
+ this.dirtyFlags.set(key, true);
128
+ }
577
129
  }
578
- /**
579
- * 获取当前数据版本
580
- */
581
130
  getDataVersion() {
582
131
  return this.dataVersion;
583
132
  }
584
- /**
585
- * 获取当前配置版本
586
- */
587
133
  getConfigVersion() {
588
134
  return this.configVersion;
589
135
  }
590
- /**
591
- * 计算所有指标的 series(如果脏了)
592
- * 返回结果包,供主线程组装成 render states
593
- */
594
136
  computeSeries() {
595
137
  const data = this.currentData;
596
138
  const changed = [];
597
- // MA
598
- if (this.dirtyData || this.dirtyMAConfig) {
599
- this.cachedSeries = {};
600
- for (const period of DEFAULT_MA_PERIODS) {
601
- const flagKey = `ma${period}`;
602
- if (this.config.ma[flagKey]) {
603
- this.cachedSeries[period] = calcMAData(data, period);
604
- }
139
+ for (const [configKey, desc] of this.descriptorMap) {
140
+ if (this.dataDirty || this.dirtyFlags.get(configKey)) {
141
+ const config = this.configMap.get(configKey);
142
+ this.seriesMap.set(configKey, desc.compute(data, config));
143
+ changed.push(configKey);
605
144
  }
606
- changed.push('ma');
607
- }
608
- // BOLL
609
- if (this.dirtyData || this.dirtyBollConfig) {
610
- this.cachedBollSeries = calcBOLLData(data, this.config.boll.period, this.config.boll.multiplier);
611
- changed.push('boll');
612
145
  }
613
- // EXPMA
614
- if (this.dirtyData || this.dirtyExpmaConfig) {
615
- this.cachedExpmaSeries = calcEXPMAData(data, this.config.expma.fastPeriod, this.config.expma.slowPeriod);
616
- changed.push('expma');
146
+ this.dataDirty = false;
147
+ for (const key of this.dirtyFlags.keys()) {
148
+ this.dirtyFlags.set(key, false);
617
149
  }
618
- // ENE
619
- if (this.dirtyData || this.dirtyEneConfig) {
620
- this.cachedEneSeries = calcENEData(data, this.config.ene.period, this.config.ene.deviation);
621
- changed.push('ene');
622
- }
623
- // RSI
624
- if (this.dirtyData || this.dirtyRsiConfig) {
625
- this.cachedRsiSeries = {};
626
- const periods = [this.config.rsi.period1, this.config.rsi.period2, this.config.rsi.period3];
627
- const shows = [this.config.rsi.showRSI1, this.config.rsi.showRSI2, this.config.rsi.showRSI3];
628
- for (let i = 0; i < periods.length; i++) {
629
- if (shows[i]) {
630
- this.cachedRsiSeries[periods[i]] = calcRSIData(data, periods[i]);
631
- }
632
- }
633
- changed.push('rsi');
634
- }
635
- // CCI
636
- if (this.dirtyData || this.dirtyCciConfig) {
637
- if (this.config.cci.showCCI) {
638
- this.cachedCciSeries = calcCCIData(data, this.config.cci.period);
639
- }
640
- else {
641
- this.cachedCciSeries = [];
642
- }
643
- changed.push('cci');
644
- }
645
- // STOCH
646
- if (this.dirtyData || this.dirtyStochConfig) {
647
- if (this.config.stoch.showK || this.config.stoch.showD) {
648
- this.cachedStochSeries = calcSTOCHData(data, this.config.stoch.n, this.config.stoch.m);
649
- }
650
- else {
651
- this.cachedStochSeries = [];
652
- }
653
- changed.push('stoch');
654
- }
655
- // MOM
656
- if (this.dirtyData || this.dirtyMomConfig) {
657
- if (this.config.mom.showMOM) {
658
- this.cachedMomSeries = calcMOMData(data, this.config.mom.period);
659
- }
660
- else {
661
- this.cachedMomSeries = [];
662
- }
663
- changed.push('mom');
664
- }
665
- // WMSR
666
- if (this.dirtyData || this.dirtyWmsrConfig) {
667
- if (this.config.wmsr.showWMSR) {
668
- this.cachedWmsrSeries = calcWMSRData(data, this.config.wmsr.period);
669
- }
670
- else {
671
- this.cachedWmsrSeries = [];
672
- }
673
- changed.push('wmsr');
674
- }
675
- // KST
676
- if (this.dirtyData || this.dirtyKstConfig) {
677
- if (this.config.kst.showKST || this.config.kst.showSignal) {
678
- this.cachedKstSeries = calcKSTData(data, this.config.kst.roc1, this.config.kst.roc2, this.config.kst.roc3, this.config.kst.roc4, this.config.kst.signalPeriod);
679
- }
680
- else {
681
- this.cachedKstSeries = [];
682
- }
683
- changed.push('kst');
684
- }
685
- // FASTK
686
- if (this.dirtyData || this.dirtyFastkConfig) {
687
- if (this.config.fastk.showFASTK) {
688
- this.cachedFastkSeries = calcFASTKData(data, this.config.fastk.period);
689
- }
690
- else {
691
- this.cachedFastkSeries = [];
692
- }
693
- changed.push('fastk');
694
- }
695
- // MACD
696
- if (this.dirtyData || this.dirtyMacdConfig) {
697
- if (this.config.macd.showDIF || this.config.macd.showDEA || this.config.macd.showBAR) {
698
- this.cachedMacdSeries = calcMACDData(data, this.config.macd.fastPeriod, this.config.macd.slowPeriod, this.config.macd.signalPeriod);
699
- }
700
- else {
701
- this.cachedMacdSeries = [];
702
- }
703
- changed.push('macd');
704
- }
705
- // ATR
706
- if (this.dirtyData || this.dirtyAtrConfig) {
707
- if (this.config.atr.showATR) {
708
- this.cachedAtrSeries = calcATRData(data, this.config.atr.period);
150
+ const bundle = { _changed: changed };
151
+ for (const [configKey] of this.descriptorMap) {
152
+ const raw = this.seriesMap.get(configKey);
153
+ const params = { ...(this.configMap.get(configKey) ?? {}) };
154
+ const entry = {};
155
+ if (raw && typeof raw === 'object' && 'series' in raw) {
156
+ Object.assign(entry, raw);
709
157
  }
710
158
  else {
711
- this.cachedAtrSeries = [];
712
- }
713
- changed.push('atr');
714
- }
715
- // WMA
716
- if (this.dirtyData || this.dirtyWmaConfig) {
717
- if (this.config.wma.showWMA) {
718
- this.cachedWmaSeries = calcWMAData(data, this.config.wma.period);
719
- }
720
- else {
721
- this.cachedWmaSeries = [];
722
- }
723
- changed.push('wma');
724
- }
725
- // DEMA
726
- if (this.dirtyData || this.dirtyDemaConfig) {
727
- if (this.config.dema.showDEMA) {
728
- this.cachedDemaSeries = calcDEMAData(data, this.config.dema.period);
729
- }
730
- else {
731
- this.cachedDemaSeries = [];
732
- }
733
- changed.push('dema');
734
- }
735
- // TEMA
736
- if (this.dirtyData || this.dirtyTemaConfig) {
737
- if (this.config.tema.showTEMA) {
738
- this.cachedTemaSeries = calcTEMAData(data, this.config.tema.period);
739
- }
740
- else {
741
- this.cachedTemaSeries = [];
742
- }
743
- changed.push('tema');
744
- }
745
- // HMA
746
- if (this.dirtyData || this.dirtyHmaConfig) {
747
- if (this.config.hma.showHMA) {
748
- this.cachedHmaSeries = calcHMAData(data, this.config.hma.period);
749
- }
750
- else {
751
- this.cachedHmaSeries = [];
752
- }
753
- changed.push('hma');
754
- }
755
- // KAMA
756
- if (this.dirtyData || this.dirtyKamaConfig) {
757
- if (this.config.kama.showKAMA) {
758
- this.cachedKamaSeries = calcKAMAData(data, this.config.kama.period, this.config.kama.fastPeriod, this.config.kama.slowPeriod);
759
- }
760
- else {
761
- this.cachedKamaSeries = [];
762
- }
763
- changed.push('kama');
764
- }
765
- // SAR
766
- if (this.dirtyData || this.dirtySarConfig) {
767
- if (this.config.sar.showSAR) {
768
- this.cachedSarSeries = calcSARData(data, this.config.sar.step, this.config.sar.maxStep);
769
- }
770
- else {
771
- this.cachedSarSeries = [];
772
- }
773
- changed.push('sar');
774
- }
775
- // SuperTrend
776
- if (this.dirtyData || this.dirtySupertrendConfig) {
777
- if (this.config.supertrend.showSuperTrend) {
778
- this.cachedSupertrendSeries = calcSuperTrendData(data, this.config.supertrend.atrPeriod, this.config.supertrend.multiplier);
779
- }
780
- else {
781
- this.cachedSupertrendSeries = [];
782
- }
783
- changed.push('supertrend');
784
- }
785
- // Keltner
786
- if (this.dirtyData || this.dirtyKeltnerConfig) {
787
- if (this.config.keltner.showUpper || this.config.keltner.showMiddle || this.config.keltner.showLower) {
788
- this.cachedKeltnerSeries = calcKeltnerData(data, this.config.keltner.emaPeriod, this.config.keltner.atrPeriod, this.config.keltner.multiplier);
789
- }
790
- else {
791
- this.cachedKeltnerSeries = [];
792
- }
793
- changed.push('keltner');
794
- }
795
- // Donchian
796
- if (this.dirtyData || this.dirtyDonchianConfig) {
797
- if (this.config.donchian.showUpper || this.config.donchian.showMiddle || this.config.donchian.showLower) {
798
- this.cachedDonchianSeries = calcDonchianData(data, this.config.donchian.period);
799
- }
800
- else {
801
- this.cachedDonchianSeries = [];
802
- }
803
- changed.push('donchian');
804
- }
805
- // Ichimoku
806
- if (this.dirtyData || this.dirtyIchimokuConfig) {
807
- const ic = this.config.ichimoku;
808
- if (ic.showTenkan || ic.showKijun || ic.showSpanA || ic.showSpanB || ic.showCloud || ic.showChikou) {
809
- this.cachedIchimokuSeries = calcIchimokuData(data, ic.tenkanPeriod, ic.kijunPeriod, ic.spanBPeriod, ic.displacement);
810
- }
811
- else {
812
- this.cachedIchimokuSeries = [];
813
- }
814
- changed.push('ichimoku');
815
- }
816
- // ROC
817
- if (this.dirtyData || this.dirtyRocConfig) {
818
- if (this.config.roc.showROC) {
819
- this.cachedRocSeries = calcROCData(data, this.config.roc.period);
820
- }
821
- else {
822
- this.cachedRocSeries = [];
823
- }
824
- changed.push('roc');
825
- }
826
- // TRIX
827
- if (this.dirtyData || this.dirtyTrixConfig) {
828
- if (this.config.trix.showTRIX || this.config.trix.showSignal) {
829
- const result = calcTRIXData(data, this.config.trix.period, this.config.trix.signalPeriod);
830
- this.cachedTrixSeries = result.series;
831
- this.cachedTrixSignalSeries = result.signalSeries;
832
- }
833
- else {
834
- this.cachedTrixSeries = [];
835
- this.cachedTrixSignalSeries = [];
836
- }
837
- changed.push('trix');
838
- }
839
- // HV
840
- if (this.dirtyData || this.dirtyHvConfig) {
841
- if (this.config.hv.showHV) {
842
- this.cachedHvSeries = calcHVData(data, this.config.hv.period, this.config.hv.annualizationFactor);
843
- }
844
- else {
845
- this.cachedHvSeries = [];
846
- }
847
- changed.push('hv');
848
- }
849
- // Parkinson
850
- if (this.dirtyData || this.dirtyParkinsonConfig) {
851
- if (this.config.parkinson.showParkinson) {
852
- this.cachedParkinsonSeries = calcParkinsonData(data, this.config.parkinson.period, this.config.parkinson.annualizationFactor);
853
- }
854
- else {
855
- this.cachedParkinsonSeries = [];
856
- }
857
- changed.push('parkinson');
858
- }
859
- // Chaikin Volatility
860
- if (this.dirtyData || this.dirtyChaikinVolConfig) {
861
- if (this.config.chaikinVol.showChaikinVol) {
862
- this.cachedChaikinVolSeries = calcChaikinVolData(data, this.config.chaikinVol.emaPeriod, this.config.chaikinVol.rocPeriod);
863
- }
864
- else {
865
- this.cachedChaikinVolSeries = [];
866
- }
867
- changed.push('chaikinVol');
868
- }
869
- // VMA
870
- if (this.dirtyData || this.dirtyVmaConfig) {
871
- if (this.config.vma.showVMA) {
872
- this.cachedVmaSeries = calcVMAData(data, this.config.vma.period);
873
- }
874
- else {
875
- this.cachedVmaSeries = [];
876
- }
877
- changed.push('vma');
878
- }
879
- // OBV
880
- if (this.dirtyData || this.dirtyObvConfig) {
881
- if (this.config.obv.showOBV) {
882
- this.cachedObvSeries = calcOBVData(data);
883
- }
884
- else {
885
- this.cachedObvSeries = [];
886
- }
887
- changed.push('obv');
888
- }
889
- // PVT
890
- if (this.dirtyData || this.dirtyPvtConfig) {
891
- if (this.config.pvt.showPVT) {
892
- this.cachedPvtSeries = calcPVTData(data);
893
- }
894
- else {
895
- this.cachedPvtSeries = [];
896
- }
897
- changed.push('pvt');
898
- }
899
- // VWAP
900
- if (this.dirtyData || this.dirtyVwapConfig) {
901
- if (this.config.vwap.showVWAP) {
902
- this.cachedVwapSeries = calcVWAPData(data, this.config.vwap.sessionResetGapMs);
903
- }
904
- else {
905
- this.cachedVwapSeries = [];
906
- }
907
- changed.push('vwap');
908
- }
909
- // CMF
910
- if (this.dirtyData || this.dirtyCmfConfig) {
911
- if (this.config.cmf.showCMF) {
912
- this.cachedCmfSeries = calcCMFData(data, this.config.cmf.period);
913
- }
914
- else {
915
- this.cachedCmfSeries = [];
916
- }
917
- changed.push('cmf');
918
- }
919
- // MFI
920
- if (this.dirtyData || this.dirtyMfiConfig) {
921
- if (this.config.mfi.showMFI) {
922
- this.cachedMfiSeries = calcMFIData(data, this.config.mfi.period);
923
- }
924
- else {
925
- this.cachedMfiSeries = [];
926
- }
927
- changed.push('mfi');
928
- }
929
- // Pivot
930
- if (this.dirtyData || this.dirtyPivotConfig) {
931
- const p = this.config.pivot;
932
- if (p.showPP || p.showR1 || p.showR2 || p.showR3 || p.showS1 || p.showS2 || p.showS3) {
933
- this.cachedPivotSeries = calcPivotData(data);
934
- }
935
- else {
936
- this.cachedPivotSeries = [];
937
- }
938
- changed.push('pivot');
939
- }
940
- // Fibonacci
941
- if (this.dirtyData || this.dirtyFibConfig) {
942
- if (this.config.fib.showLevels) {
943
- this.cachedFibSeries = calcFibData(data, this.config.fib.period);
944
- }
945
- else {
946
- this.cachedFibSeries = [];
947
- }
948
- changed.push('fib');
949
- }
950
- // SMC Structure
951
- if (this.dirtyData || this.dirtyStructureConfig) {
952
- const s = this.config.structure;
953
- if (s.showSwingLabels || s.showBOS || s.showCHOCH) {
954
- this.cachedStructureSeries = calcStructureData(data, s.leftWindow, s.rightWindow, s.breakoutSource);
955
- }
956
- else {
957
- this.cachedStructureSeries = { swings: [], events: [], trend: 'range' };
958
- }
959
- changed.push('structure');
960
- }
961
- // SMC Zones
962
- if (this.dirtyData || this.dirtyZonesConfig) {
963
- const z = this.config.zones;
964
- if (z.showFVG || z.showOB) {
965
- this.cachedZonesSeries = calcZonesData(data, z.obLookback, this.config.structure.leftWindow, this.config.structure.rightWindow, this.config.structure.breakoutSource);
966
- }
967
- else {
968
- this.cachedZonesSeries = [];
969
- }
970
- changed.push('zones');
971
- }
972
- // Volume Profile
973
- if (this.dirtyData || this.dirtyVolumeProfileConfig) {
974
- const vp = this.config.volumeProfile;
975
- if (vp.showPOC || vp.showValueArea) {
976
- this.cachedVolumeProfileSeries = calcVolumeProfileData(data, vp.bins, vp.lookback, vp.valueAreaPercent);
977
- }
978
- else {
979
- this.cachedVolumeProfileSeries = { bins: [], poc: 0, vah: 0, val: 0, totalVolume: 0 };
159
+ entry.series = raw;
160
+ if (raw && typeof raw === 'object' && !Array.isArray(raw)) {
161
+ entry.enabledPeriods = Object.keys(raw).map(Number);
162
+ }
980
163
  }
981
- changed.push('volumeProfile');
164
+ entry.params = params;
165
+ bundle[configKey] = entry;
982
166
  }
983
- // 重置脏标记
984
- this.dirtyData = false;
985
- this.dirtyMAConfig = false;
986
- this.dirtyBollConfig = false;
987
- this.dirtyExpmaConfig = false;
988
- this.dirtyEneConfig = false;
989
- this.dirtyRsiConfig = false;
990
- this.dirtyCciConfig = false;
991
- this.dirtyStochConfig = false;
992
- this.dirtyMomConfig = false;
993
- this.dirtyWmsrConfig = false;
994
- this.dirtyKstConfig = false;
995
- this.dirtyFastkConfig = false;
996
- this.dirtyMacdConfig = false;
997
- this.dirtyAtrConfig = false;
998
- this.dirtyWmaConfig = false;
999
- this.dirtyDemaConfig = false;
1000
- this.dirtyTemaConfig = false;
1001
- this.dirtyHmaConfig = false;
1002
- this.dirtyKamaConfig = false;
1003
- this.dirtySarConfig = false;
1004
- this.dirtySupertrendConfig = false;
1005
- this.dirtyKeltnerConfig = false;
1006
- this.dirtyDonchianConfig = false;
1007
- this.dirtyIchimokuConfig = false;
1008
- this.dirtyRocConfig = false;
1009
- this.dirtyTrixConfig = false;
1010
- this.dirtyHvConfig = false;
1011
- this.dirtyParkinsonConfig = false;
1012
- this.dirtyChaikinVolConfig = false;
1013
- this.dirtyVmaConfig = false;
1014
- this.dirtyObvConfig = false;
1015
- this.dirtyPvtConfig = false;
1016
- this.dirtyVwapConfig = false;
1017
- this.dirtyCmfConfig = false;
1018
- this.dirtyMfiConfig = false;
1019
- this.dirtyPivotConfig = false;
1020
- this.dirtyFibConfig = false;
1021
- this.dirtyStructureConfig = false;
1022
- this.dirtyZonesConfig = false;
1023
- this.dirtyVolumeProfileConfig = false;
1024
- // 组装结果
1025
- return {
1026
- ma: {
1027
- series: this.cachedSeries,
1028
- enabledPeriods: Object.keys(this.cachedSeries).map(Number),
1029
- },
1030
- boll: {
1031
- series: this.cachedBollSeries,
1032
- params: { ...this.config.boll },
1033
- },
1034
- expma: {
1035
- series: this.cachedExpmaSeries,
1036
- params: { ...this.config.expma },
1037
- },
1038
- ene: {
1039
- series: this.cachedEneSeries,
1040
- params: { ...this.config.ene },
1041
- },
1042
- rsi: {
1043
- series: this.cachedRsiSeries,
1044
- enabledPeriods: Object.keys(this.cachedRsiSeries).map(Number),
1045
- params: { ...this.config.rsi },
1046
- },
1047
- cci: {
1048
- series: this.cachedCciSeries,
1049
- params: { ...this.config.cci },
1050
- },
1051
- stoch: {
1052
- series: this.cachedStochSeries,
1053
- params: { ...this.config.stoch },
1054
- },
1055
- mom: {
1056
- series: this.cachedMomSeries,
1057
- params: { ...this.config.mom },
1058
- },
1059
- wmsr: {
1060
- series: this.cachedWmsrSeries,
1061
- params: { ...this.config.wmsr },
1062
- },
1063
- kst: {
1064
- series: this.cachedKstSeries,
1065
- params: { ...this.config.kst },
1066
- },
1067
- fastk: {
1068
- series: this.cachedFastkSeries,
1069
- params: { ...this.config.fastk },
1070
- },
1071
- macd: {
1072
- series: this.cachedMacdSeries,
1073
- params: { ...this.config.macd },
1074
- },
1075
- atr: {
1076
- series: this.cachedAtrSeries,
1077
- params: { ...this.config.atr },
1078
- },
1079
- wma: {
1080
- series: this.cachedWmaSeries,
1081
- params: { ...this.config.wma },
1082
- },
1083
- dema: {
1084
- series: this.cachedDemaSeries,
1085
- params: { ...this.config.dema },
1086
- },
1087
- tema: {
1088
- series: this.cachedTemaSeries,
1089
- params: { ...this.config.tema },
1090
- },
1091
- hma: {
1092
- series: this.cachedHmaSeries,
1093
- params: { ...this.config.hma },
1094
- },
1095
- kama: {
1096
- series: this.cachedKamaSeries,
1097
- params: { ...this.config.kama },
1098
- },
1099
- sar: {
1100
- series: this.cachedSarSeries,
1101
- params: { ...this.config.sar },
1102
- },
1103
- supertrend: {
1104
- series: this.cachedSupertrendSeries,
1105
- params: { ...this.config.supertrend },
1106
- },
1107
- keltner: {
1108
- series: this.cachedKeltnerSeries,
1109
- params: { ...this.config.keltner },
1110
- },
1111
- donchian: {
1112
- series: this.cachedDonchianSeries,
1113
- params: { ...this.config.donchian },
1114
- },
1115
- ichimoku: {
1116
- series: this.cachedIchimokuSeries,
1117
- params: { ...this.config.ichimoku },
1118
- },
1119
- roc: {
1120
- series: this.cachedRocSeries,
1121
- params: { ...this.config.roc },
1122
- },
1123
- trix: {
1124
- series: this.cachedTrixSeries,
1125
- signalSeries: this.cachedTrixSignalSeries,
1126
- params: { ...this.config.trix },
1127
- },
1128
- hv: {
1129
- series: this.cachedHvSeries,
1130
- params: { ...this.config.hv },
1131
- },
1132
- parkinson: {
1133
- series: this.cachedParkinsonSeries,
1134
- params: { ...this.config.parkinson },
1135
- },
1136
- chaikinVol: {
1137
- series: this.cachedChaikinVolSeries,
1138
- params: { ...this.config.chaikinVol },
1139
- },
1140
- vma: {
1141
- series: this.cachedVmaSeries,
1142
- params: { ...this.config.vma },
1143
- },
1144
- obv: {
1145
- series: this.cachedObvSeries,
1146
- params: { ...this.config.obv },
1147
- },
1148
- pvt: {
1149
- series: this.cachedPvtSeries,
1150
- params: { ...this.config.pvt },
1151
- },
1152
- vwap: {
1153
- series: this.cachedVwapSeries,
1154
- params: { ...this.config.vwap },
1155
- },
1156
- cmf: {
1157
- series: this.cachedCmfSeries,
1158
- params: { ...this.config.cmf },
1159
- },
1160
- mfi: {
1161
- series: this.cachedMfiSeries,
1162
- params: { ...this.config.mfi },
1163
- },
1164
- pivot: {
1165
- series: this.cachedPivotSeries,
1166
- params: { ...this.config.pivot },
1167
- },
1168
- fib: {
1169
- series: this.cachedFibSeries,
1170
- params: { ...this.config.fib },
1171
- },
1172
- structure: {
1173
- series: this.cachedStructureSeries,
1174
- params: { ...this.config.structure },
1175
- },
1176
- zones: {
1177
- series: this.cachedZonesSeries,
1178
- params: { ...this.config.zones },
1179
- },
1180
- volumeProfile: {
1181
- series: this.cachedVolumeProfileSeries,
1182
- params: { ...this.config.volumeProfile },
1183
- },
1184
- _changed: changed,
1185
- };
1186
- }
1187
- /**
1188
- * 获取缓存的 series(用于 visibleRange 变更时扫描极值)
1189
- */
1190
- getCachedSeries() {
1191
- return {
1192
- _changed: [],
1193
- ma: {
1194
- series: this.cachedSeries,
1195
- enabledPeriods: Object.keys(this.cachedSeries).map(Number),
1196
- },
1197
- boll: {
1198
- series: this.cachedBollSeries,
1199
- params: { ...this.config.boll },
1200
- },
1201
- expma: {
1202
- series: this.cachedExpmaSeries,
1203
- params: { ...this.config.expma },
1204
- },
1205
- ene: {
1206
- series: this.cachedEneSeries,
1207
- params: { ...this.config.ene },
1208
- },
1209
- rsi: {
1210
- series: this.cachedRsiSeries,
1211
- enabledPeriods: Object.keys(this.cachedRsiSeries).map(Number),
1212
- params: { ...this.config.rsi },
1213
- },
1214
- cci: {
1215
- series: this.cachedCciSeries,
1216
- params: { ...this.config.cci },
1217
- },
1218
- stoch: {
1219
- series: this.cachedStochSeries,
1220
- params: { ...this.config.stoch },
1221
- },
1222
- mom: {
1223
- series: this.cachedMomSeries,
1224
- params: { ...this.config.mom },
1225
- },
1226
- wmsr: {
1227
- series: this.cachedWmsrSeries,
1228
- params: { ...this.config.wmsr },
1229
- },
1230
- kst: {
1231
- series: this.cachedKstSeries,
1232
- params: { ...this.config.kst },
1233
- },
1234
- fastk: {
1235
- series: this.cachedFastkSeries,
1236
- params: { ...this.config.fastk },
1237
- },
1238
- macd: {
1239
- series: this.cachedMacdSeries,
1240
- params: { ...this.config.macd },
1241
- },
1242
- atr: {
1243
- series: this.cachedAtrSeries,
1244
- params: { ...this.config.atr },
1245
- },
1246
- wma: {
1247
- series: this.cachedWmaSeries,
1248
- params: { ...this.config.wma },
1249
- },
1250
- dema: {
1251
- series: this.cachedDemaSeries,
1252
- params: { ...this.config.dema },
1253
- },
1254
- tema: {
1255
- series: this.cachedTemaSeries,
1256
- params: { ...this.config.tema },
1257
- },
1258
- hma: {
1259
- series: this.cachedHmaSeries,
1260
- params: { ...this.config.hma },
1261
- },
1262
- kama: {
1263
- series: this.cachedKamaSeries,
1264
- params: { ...this.config.kama },
1265
- },
1266
- sar: {
1267
- series: this.cachedSarSeries,
1268
- params: { ...this.config.sar },
1269
- },
1270
- supertrend: {
1271
- series: this.cachedSupertrendSeries,
1272
- params: { ...this.config.supertrend },
1273
- },
1274
- keltner: {
1275
- series: this.cachedKeltnerSeries,
1276
- params: { ...this.config.keltner },
1277
- },
1278
- donchian: {
1279
- series: this.cachedDonchianSeries,
1280
- params: { ...this.config.donchian },
1281
- },
1282
- ichimoku: {
1283
- series: this.cachedIchimokuSeries,
1284
- params: { ...this.config.ichimoku },
1285
- },
1286
- roc: {
1287
- series: this.cachedRocSeries,
1288
- params: { ...this.config.roc },
1289
- },
1290
- trix: {
1291
- series: this.cachedTrixSeries,
1292
- signalSeries: this.cachedTrixSignalSeries,
1293
- params: { ...this.config.trix },
1294
- },
1295
- hv: {
1296
- series: this.cachedHvSeries,
1297
- params: { ...this.config.hv },
1298
- },
1299
- parkinson: {
1300
- series: this.cachedParkinsonSeries,
1301
- params: { ...this.config.parkinson },
1302
- },
1303
- chaikinVol: {
1304
- series: this.cachedChaikinVolSeries,
1305
- params: { ...this.config.chaikinVol },
1306
- },
1307
- vma: {
1308
- series: this.cachedVmaSeries,
1309
- params: { ...this.config.vma },
1310
- },
1311
- obv: {
1312
- series: this.cachedObvSeries,
1313
- params: { ...this.config.obv },
1314
- },
1315
- pvt: {
1316
- series: this.cachedPvtSeries,
1317
- params: { ...this.config.pvt },
1318
- },
1319
- vwap: {
1320
- series: this.cachedVwapSeries,
1321
- params: { ...this.config.vwap },
1322
- },
1323
- cmf: {
1324
- series: this.cachedCmfSeries,
1325
- params: { ...this.config.cmf },
1326
- },
1327
- mfi: {
1328
- series: this.cachedMfiSeries,
1329
- params: { ...this.config.mfi },
1330
- },
1331
- pivot: {
1332
- series: this.cachedPivotSeries,
1333
- params: { ...this.config.pivot },
1334
- },
1335
- fib: {
1336
- series: this.cachedFibSeries,
1337
- params: { ...this.config.fib },
1338
- },
1339
- structure: {
1340
- series: this.cachedStructureSeries,
1341
- params: { ...this.config.structure },
1342
- },
1343
- zones: {
1344
- series: this.cachedZonesSeries,
1345
- params: { ...this.config.zones },
1346
- },
1347
- volumeProfile: {
1348
- series: this.cachedVolumeProfileSeries,
1349
- params: { ...this.config.volumeProfile },
1350
- },
1351
- };
167
+ return bundle;
1352
168
  }
1353
169
  }
1354
170
  //# sourceMappingURL=indicatorRuntime.js.map