@363045841yyt/klinechart 0.6.10 → 0.7.1

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 (77) hide show
  1. package/dist/favicon.ico +0 -0
  2. package/dist/index.cjs +5 -5
  3. package/dist/index.js +20330 -8582
  4. package/dist/klinechart.css +1 -1
  5. package/dist/mock-stock-data.json +1 -0
  6. package/dist/src/components/IndicatorSelector.vue.d.ts +0 -1
  7. package/dist/src/components/KLineChart.vue.d.ts +1 -1
  8. package/dist/src/config/chartSettings.d.ts +6 -0
  9. package/dist/src/core/chart.d.ts +208 -11
  10. package/dist/src/core/draw/pixelAlign.d.ts +7 -7
  11. package/dist/src/core/drawing/plugin.d.ts +19 -0
  12. package/dist/src/core/indicators/calculators.d.ts +129 -0
  13. package/dist/src/core/indicators/chaikinVolState.d.ts +18 -0
  14. package/dist/src/core/indicators/cmfState.d.ts +16 -0
  15. package/dist/src/core/indicators/fibState.d.ts +26 -0
  16. package/dist/src/core/indicators/hvState.d.ts +18 -0
  17. package/dist/src/core/indicators/ichimokuState.d.ts +44 -0
  18. package/dist/src/core/indicators/indicatorDefinitionRegistry.d.ts +30 -0
  19. package/dist/src/core/indicators/indicatorMetadata.d.ts +81 -0
  20. package/dist/src/core/indicators/indicatorRegistry.d.ts +57 -0
  21. package/dist/src/core/indicators/indicatorRuntime.d.ts +35 -0
  22. package/dist/src/core/indicators/mfiState.d.ts +16 -0
  23. package/dist/src/core/indicators/obvState.d.ts +14 -0
  24. package/dist/src/core/indicators/parkinsonState.d.ts +18 -0
  25. package/dist/src/core/indicators/pivotState.d.ts +29 -0
  26. package/dist/src/core/indicators/pvtState.d.ts +14 -0
  27. package/dist/src/core/indicators/rocState.d.ts +16 -0
  28. package/dist/src/core/indicators/rsiState.d.ts +4 -0
  29. package/dist/src/core/indicators/scheduler.d.ts +82 -3
  30. package/dist/src/core/indicators/stateComposer.d.ts +51 -0
  31. package/dist/src/core/indicators/structureState.d.ts +43 -0
  32. package/dist/src/core/indicators/trixState.d.ts +20 -0
  33. package/dist/src/core/indicators/vmaState.d.ts +16 -0
  34. package/dist/src/core/indicators/volumeProfileState.d.ts +34 -0
  35. package/dist/src/core/indicators/vwapState.d.ts +16 -0
  36. package/dist/src/core/indicators/workerProtocol.d.ts +198 -1
  37. package/dist/src/core/indicators/zonesState.d.ts +26 -0
  38. package/dist/src/core/renderers/Indicator/cci.d.ts +2 -1
  39. package/dist/src/core/renderers/Indicator/chaikinVol.d.ts +4 -0
  40. package/dist/src/core/renderers/Indicator/cmf.d.ts +4 -0
  41. package/dist/src/core/renderers/Indicator/ene.d.ts +0 -8
  42. package/dist/src/core/renderers/Indicator/fastk.d.ts +2 -1
  43. package/dist/src/core/renderers/Indicator/fib.d.ts +4 -0
  44. package/dist/src/core/renderers/Indicator/hv.d.ts +4 -0
  45. package/dist/src/core/renderers/Indicator/ichimoku.d.ts +5 -0
  46. package/dist/src/core/renderers/Indicator/index.d.ts +27 -1
  47. package/dist/src/core/renderers/Indicator/kst.d.ts +2 -1
  48. package/dist/src/core/renderers/Indicator/macd.d.ts +2 -1
  49. package/dist/src/core/renderers/Indicator/mfi.d.ts +4 -0
  50. package/dist/src/core/renderers/Indicator/mom.d.ts +2 -1
  51. package/dist/src/core/renderers/Indicator/obv.d.ts +4 -0
  52. package/dist/src/core/renderers/Indicator/parkinson.d.ts +4 -0
  53. package/dist/src/core/renderers/Indicator/pivot.d.ts +4 -0
  54. package/dist/src/core/renderers/Indicator/pvt.d.ts +4 -0
  55. package/dist/src/core/renderers/Indicator/roc.d.ts +5 -0
  56. package/dist/src/core/renderers/Indicator/rsi.d.ts +3 -2
  57. package/dist/src/core/renderers/Indicator/scale/indicator_scale.d.ts +4 -1
  58. package/dist/src/core/renderers/Indicator/stoch.d.ts +2 -1
  59. package/dist/src/core/renderers/Indicator/structure.d.ts +4 -0
  60. package/dist/src/core/renderers/Indicator/subPaneConfig.d.ts +2 -2
  61. package/dist/src/core/renderers/Indicator/trix.d.ts +5 -0
  62. package/dist/src/core/renderers/Indicator/vma.d.ts +4 -0
  63. package/dist/src/core/renderers/Indicator/volumeProfile.d.ts +4 -0
  64. package/dist/src/core/renderers/Indicator/vwap.d.ts +4 -0
  65. package/dist/src/core/renderers/Indicator/wmsr.d.ts +2 -1
  66. package/dist/src/core/renderers/Indicator/zones.d.ts +4 -0
  67. package/dist/src/core/renderers/candle.d.ts +2 -1
  68. package/dist/src/core/theme/colors.d.ts +207 -228
  69. package/dist/src/plugin/PluginHost.d.ts +3 -0
  70. package/dist/src/plugin/types.d.ts +6 -0
  71. package/dist/src/semantic/types.d.ts +59 -0
  72. package/dist/src/utils/kLineDraw/MA.d.ts +5 -10
  73. package/dist/src/utils/kLineDraw/axis.d.ts +7 -7
  74. package/dist/src/utils/kLineDraw/grid.d.ts +2 -2
  75. package/dist/src/utils/kLineDraw/kLine.d.ts +1 -1
  76. package/dist/src/utils/kline/format.d.ts +4 -7
  77. package/package.json +111 -103
@@ -0,0 +1,30 @@
1
+ import { IndicatorMetadata, IndicatorCategory, StateKey, RendererFactory } from './indicatorMetadata';
2
+ import { PluginHost } from '../../plugin';
3
+ export interface IndicatorDefinitionConfig {
4
+ name: string;
5
+ displayName: string;
6
+ category: IndicatorCategory;
7
+ stateKey: StateKey;
8
+ defaultPaneId: string;
9
+ paneIdField?: keyof import('./workerProtocol').IndicatorConfigSnapshot;
10
+ allowMainPane?: boolean;
11
+ applyResult?: (host: PluginHost, state: unknown, paneId: string) => void;
12
+ }
13
+ type IndicatorDefinitionClass = {
14
+ new (...args: never[]): unknown;
15
+ rendererFactory?: RendererFactory;
16
+ };
17
+ /**
18
+ * 标准类装饰器:在模块加载时收集指标定义
19
+ *
20
+ * 使用方式:
21
+ * @Indicator({ name: 'ma', ... })
22
+ * class MADefinition {
23
+ * static rendererFactory = createMARendererPlugin
24
+ * }
25
+ */
26
+ export declare function Indicator(config: IndicatorDefinitionConfig): <T extends IndicatorDefinitionClass>(value: T, context: ClassDecoratorContext<T>) => T;
27
+ export declare function getRegisteredIndicatorDefinitions(): readonly IndicatorMetadata[];
28
+ export declare function getRegisteredIndicatorDefinition(name: string): IndicatorMetadata | undefined;
29
+ export declare function clearRegisteredIndicatorDefinitionsForTest(): void;
30
+ export {};
@@ -0,0 +1,81 @@
1
+ import { PluginHost, RendererPluginWithHost } from '../../plugin';
2
+ import { IndicatorConfigSnapshot } from './workerProtocol';
3
+ /**
4
+ * 指标分类:主图/副图
5
+ */
6
+ export type IndicatorCategory = 'main' | 'sub' | 'oscillator' | 'volume';
7
+ /**
8
+ * State key 生成器类型
9
+ * - 主图指标:常量字符串
10
+ * - 副图指标:函数,接收 paneId 返回 key
11
+ */
12
+ export type StateKey = string | ((paneId: string) => string);
13
+ /**
14
+ * 渲染器工厂函数
15
+ */
16
+ export type RendererFactory = () => RendererPluginWithHost;
17
+ /**
18
+ * 指标元数据接口
19
+ */
20
+ export interface IndicatorMetadata<T = unknown> {
21
+ /**
22
+ * 指标唯一标识
23
+ * 如:'ma', 'boll', 'rsi', 'customIndicator'
24
+ */
25
+ name: string;
26
+ /**
27
+ * 显示名称(用于日志和调试)
28
+ */
29
+ displayName: string;
30
+ /**
31
+ * 分类:主图/副图
32
+ */
33
+ category: IndicatorCategory;
34
+ /**
35
+ * StateStore key
36
+ * - 主图指标:常量字符串(如 'indicator:ma:main')
37
+ * - 副图指标:函数 (paneId) => string
38
+ */
39
+ stateKey: StateKey;
40
+ /**
41
+ * 在 configSnapshot 中的 paneId 字段名
42
+ * 用于从配置中获取当前 pane ID
43
+ */
44
+ paneIdField?: keyof IndicatorConfigSnapshot;
45
+ /**
46
+ * 渲染器工厂函数
47
+ * 调用时创建该指标的渲染器实例
48
+ */
49
+ rendererFactory: RendererFactory;
50
+ /**
51
+ * 默认 pane ID
52
+ * - 主图指标:'main'
53
+ * - 副图指标:如 'sub_RSI'
54
+ */
55
+ defaultPaneId: string;
56
+ /**
57
+ * 是否启用(可选条件判断)
58
+ * 用于副图指标根据配置决定是否参与计算
59
+ */
60
+ isEnabled?: (config: IndicatorConfigSnapshot) => boolean;
61
+ /**
62
+ * 将指标计算结果写入 StateStore
63
+ * @param host - PluginHost
64
+ * @param state - 计算结果(由 composeRenderStates 或 composeVisibleSubIndicatorStates 产出)
65
+ * @param paneId - 目标 pane ID(从 configSnapshot 读取)
66
+ */
67
+ applyResult?: (host: PluginHost, state: unknown, paneId: string) => void;
68
+ /**
69
+ * 是否允许在主图显示(部分副图指标可切换至主图)
70
+ * - true:指标可放置在主图(如 WMA/SAR/Pivot 等叠加类指标)
71
+ * - false/undefined:仅限副图显示
72
+ */
73
+ allowMainPane?: boolean;
74
+ }
75
+ /**
76
+ * 提取 stateKey 对应的实际 key 值
77
+ * @param stateKey - 可以是字符串或函数
78
+ * @param paneId - pane ID(副图指标需要)
79
+ * @returns 实际的 state key 字符串
80
+ */
81
+ export declare function resolveStateKey(stateKey: StateKey, paneId?: string): string;
@@ -0,0 +1,57 @@
1
+ import { IndicatorMetadata } from './indicatorMetadata';
2
+ /**
3
+ * IndicatorRegistry - 指标注册表
4
+ *
5
+ * 管理所有已注册指标的元数据
6
+ * 支持运行时动态注册/注销指标
7
+ */
8
+ export declare class IndicatorRegistry {
9
+ private indicators;
10
+ /**
11
+ * 注册指标
12
+ * @param meta - 指标元数据
13
+ * @throws 如果 name 为空或元数据无效
14
+ */
15
+ register<T>(meta: IndicatorMetadata<T>): void;
16
+ /**
17
+ * 注销指标
18
+ * @param name - 指标名称
19
+ * @returns 是否成功注销
20
+ */
21
+ unregister(name: string): boolean;
22
+ /**
23
+ * 获取指定指标的元数据
24
+ * @param name - 指标名称
25
+ * @returns 元数据或 undefined
26
+ */
27
+ get(name: string): IndicatorMetadata | undefined;
28
+ /**
29
+ * 检查指标是否已注册
30
+ * @param name - 指标名称
31
+ */
32
+ has(name: string): boolean;
33
+ /**
34
+ * 获取所有已注册指标
35
+ */
36
+ getAll(): readonly IndicatorMetadata[];
37
+ /**
38
+ * 获取主图指标
39
+ */
40
+ getMainIndicators(): readonly IndicatorMetadata[];
41
+ /**
42
+ * 获取副图指标
43
+ */
44
+ getSubIndicators(): readonly IndicatorMetadata[];
45
+ /**
46
+ * 获取指标名称列表
47
+ */
48
+ getNames(): string[];
49
+ /**
50
+ * 清空所有注册指标
51
+ */
52
+ clear(): void;
53
+ /**
54
+ * 获取已注册指标数量
55
+ */
56
+ get size(): number;
57
+ }
@@ -31,6 +31,24 @@ export declare class IndicatorRuntime {
31
31
  private cachedSupertrendSeries;
32
32
  private cachedKeltnerSeries;
33
33
  private cachedDonchianSeries;
34
+ private cachedIchimokuSeries;
35
+ private cachedRocSeries;
36
+ private cachedTrixSeries;
37
+ private cachedTrixSignalSeries;
38
+ private cachedHvSeries;
39
+ private cachedParkinsonSeries;
40
+ private cachedChaikinVolSeries;
41
+ private cachedVmaSeries;
42
+ private cachedObvSeries;
43
+ private cachedPvtSeries;
44
+ private cachedVwapSeries;
45
+ private cachedCmfSeries;
46
+ private cachedMfiSeries;
47
+ private cachedPivotSeries;
48
+ private cachedFibSeries;
49
+ private cachedStructureSeries;
50
+ private cachedZonesSeries;
51
+ private cachedVolumeProfileSeries;
34
52
  private dirtyData;
35
53
  private dirtyMAConfig;
36
54
  private dirtyBollConfig;
@@ -54,6 +72,23 @@ export declare class IndicatorRuntime {
54
72
  private dirtySupertrendConfig;
55
73
  private dirtyKeltnerConfig;
56
74
  private dirtyDonchianConfig;
75
+ private dirtyIchimokuConfig;
76
+ private dirtyRocConfig;
77
+ private dirtyTrixConfig;
78
+ private dirtyHvConfig;
79
+ private dirtyParkinsonConfig;
80
+ private dirtyChaikinVolConfig;
81
+ private dirtyVmaConfig;
82
+ private dirtyObvConfig;
83
+ private dirtyPvtConfig;
84
+ private dirtyVwapConfig;
85
+ private dirtyCmfConfig;
86
+ private dirtyMfiConfig;
87
+ private dirtyPivotConfig;
88
+ private dirtyFibConfig;
89
+ private dirtyStructureConfig;
90
+ private dirtyZonesConfig;
91
+ private dirtyVolumeProfileConfig;
57
92
  private getDefaultConfig;
58
93
  /**
59
94
  * 更新数据
@@ -0,0 +1,16 @@
1
+ import { BaseIndicatorState } from '../../plugin';
2
+ export interface MFIRenderState extends BaseIndicatorState {
3
+ timestamp: number;
4
+ series: (number | undefined)[];
5
+ params: {
6
+ period: number;
7
+ showMFI: boolean;
8
+ };
9
+ valueMin: number;
10
+ valueMax: number;
11
+ visibleMin: number;
12
+ visibleMax: number;
13
+ }
14
+ export declare const createMFIStateKey: (paneId: string) => `indicator:${string}:${string}`;
15
+ export declare const DEFAULT_MFI_PERIOD = 14;
16
+ export declare const EMPTY_MFI_STATE: MFIRenderState;
@@ -0,0 +1,14 @@
1
+ import { BaseIndicatorState } from '../../plugin';
2
+ export interface OBVRenderState extends BaseIndicatorState {
3
+ timestamp: number;
4
+ series: (number | undefined)[];
5
+ params: {
6
+ showOBV: boolean;
7
+ };
8
+ valueMin: number;
9
+ valueMax: number;
10
+ visibleMin: number;
11
+ visibleMax: number;
12
+ }
13
+ export declare const createOBVStateKey: (paneId: string) => `indicator:${string}:${string}`;
14
+ export declare const EMPTY_OBV_STATE: OBVRenderState;
@@ -0,0 +1,18 @@
1
+ import { BaseIndicatorState } from '../../plugin';
2
+ export interface ParkinsonRenderState extends BaseIndicatorState {
3
+ timestamp: number;
4
+ series: (number | undefined)[];
5
+ params: {
6
+ period: number;
7
+ annualizationFactor: number;
8
+ showParkinson: boolean;
9
+ };
10
+ valueMin: number;
11
+ valueMax: number;
12
+ visibleMin: number;
13
+ visibleMax: number;
14
+ }
15
+ export declare const createParkinsonStateKey: (paneId: string) => `indicator:${string}:${string}`;
16
+ export declare const DEFAULT_PARKINSON_PERIOD = 20;
17
+ export declare const DEFAULT_PARKINSON_ANNUALIZATION = 252;
18
+ export declare const EMPTY_PARKINSON_STATE: ParkinsonRenderState;
@@ -0,0 +1,29 @@
1
+ import { BaseIndicatorState } from '../../plugin';
2
+ export interface PivotPoint {
3
+ pp: number;
4
+ r1: number;
5
+ r2: number;
6
+ r3: number;
7
+ s1: number;
8
+ s2: number;
9
+ s3: number;
10
+ }
11
+ export interface PivotRenderState extends BaseIndicatorState {
12
+ timestamp: number;
13
+ series: (PivotPoint | undefined)[];
14
+ params: {
15
+ showPP: boolean;
16
+ showR1: boolean;
17
+ showR2: boolean;
18
+ showR3: boolean;
19
+ showS1: boolean;
20
+ showS2: boolean;
21
+ showS3: boolean;
22
+ };
23
+ valueMin: number;
24
+ valueMax: number;
25
+ visibleMin: number;
26
+ visibleMax: number;
27
+ }
28
+ export declare const createPivotStateKey: (paneId: string) => `indicator:${string}:${string}`;
29
+ export declare const EMPTY_PIVOT_STATE: PivotRenderState;
@@ -0,0 +1,14 @@
1
+ import { BaseIndicatorState } from '../../plugin';
2
+ export interface PVTRenderState extends BaseIndicatorState {
3
+ timestamp: number;
4
+ series: (number | undefined)[];
5
+ params: {
6
+ showPVT: boolean;
7
+ };
8
+ valueMin: number;
9
+ valueMax: number;
10
+ visibleMin: number;
11
+ visibleMax: number;
12
+ }
13
+ export declare const createPVTStateKey: (paneId: string) => `indicator:${string}:${string}`;
14
+ export declare const EMPTY_PVT_STATE: PVTRenderState;
@@ -0,0 +1,16 @@
1
+ import { BaseIndicatorState } from '../../plugin';
2
+ export interface ROCRenderState extends BaseIndicatorState {
3
+ timestamp: number;
4
+ series: (number | undefined)[];
5
+ params: {
6
+ period: number;
7
+ showROC: boolean;
8
+ };
9
+ valueMin: number;
10
+ valueMax: number;
11
+ visibleMin: number;
12
+ visibleMax: number;
13
+ }
14
+ export declare const createROCStateKey: (paneId: string) => `indicator:${string}:${string}`;
15
+ export declare const DEFAULT_ROC_PERIOD = 12;
16
+ export declare const EMPTY_ROC_STATE: ROCRenderState;
@@ -27,6 +27,10 @@ export interface RSIRenderState extends BaseIndicatorState {
27
27
  /** 视口内所有 RSI 线的最大值 */
28
28
  visibleMax: number;
29
29
  }
30
+ /**
31
+ * RSI 状态的基础 StateStore 键名
32
+ */
33
+ export declare const RSI_STATE_KEY = "indicator:rsi";
30
34
  /**
31
35
  * 创建 RSI 状态的 StateStore 键名
32
36
  * 格式:indicator:rsi:{paneId}
@@ -1,7 +1,8 @@
1
1
  import { PluginHost } from '../../plugin';
2
2
  import { KLineData } from '../../types/price';
3
- import { BOLLSchedulerConfig, EXPMASchedulerConfig, ENESchedulerConfig, RSISchedulerConfig, CCISchedulerConfig, STOCHSchedulerConfig, MOMSchedulerConfig, WMSRSchedulerConfig, KSTSchedulerConfig, FASTKSchedulerConfig, MACDSchedulerConfig, ATRSchedulerConfig, WMASchedulerConfig, DEMASchedulerConfig, TEMASchedulerConfig, HMASchedulerConfig, KAMASchedulerConfig, SARSchedulerConfig, SuperTrendSchedulerConfig, KeltnerSchedulerConfig, DonchianSchedulerConfig } from './workerProtocol';
3
+ import { BOLLSchedulerConfig, EXPMASchedulerConfig, ENESchedulerConfig, RSISchedulerConfig, CCISchedulerConfig, STOCHSchedulerConfig, MOMSchedulerConfig, WMSRSchedulerConfig, KSTSchedulerConfig, FASTKSchedulerConfig, MACDSchedulerConfig, ATRSchedulerConfig, WMASchedulerConfig, DEMASchedulerConfig, TEMASchedulerConfig, HMASchedulerConfig, KAMASchedulerConfig, SARSchedulerConfig, SuperTrendSchedulerConfig, KeltnerSchedulerConfig, DonchianSchedulerConfig, IchimokuSchedulerConfig, ROCSchedulerConfig, TRIXSchedulerConfig, HVSchedulerConfig, ParkinsonSchedulerConfig, ChaikinVolSchedulerConfig, VMASchedulerConfig, OBVSchedulerConfig, PVTSchedulerConfig, VWAPSchedulerConfig, CMFSchedulerConfig, MFISchedulerConfig, PivotSchedulerConfig, FibSchedulerConfig, StructureSchedulerConfig, ZonesSchedulerConfig, VolumeProfileSchedulerConfig } from './workerProtocol';
4
4
  import { MAFlags } from './calculators';
5
+ import { IndicatorMetadata } from './indicatorMetadata';
5
6
  /**
6
7
  * 可见范围
7
8
  */
@@ -9,7 +10,7 @@ interface VisibleRange {
9
10
  start: number;
10
11
  end: number;
11
12
  }
12
- export type { BOLLSchedulerConfig, EXPMASchedulerConfig, ENESchedulerConfig, RSISchedulerConfig, CCISchedulerConfig, STOCHSchedulerConfig, MOMSchedulerConfig, WMSRSchedulerConfig, KSTSchedulerConfig, FASTKSchedulerConfig, MACDSchedulerConfig, ATRSchedulerConfig, WMASchedulerConfig, DEMASchedulerConfig, TEMASchedulerConfig, HMASchedulerConfig, KAMASchedulerConfig, SARSchedulerConfig, SuperTrendSchedulerConfig, KeltnerSchedulerConfig, DonchianSchedulerConfig, };
13
+ export type { BOLLSchedulerConfig, EXPMASchedulerConfig, ENESchedulerConfig, RSISchedulerConfig, CCISchedulerConfig, STOCHSchedulerConfig, MOMSchedulerConfig, WMSRSchedulerConfig, KSTSchedulerConfig, FASTKSchedulerConfig, MACDSchedulerConfig, ATRSchedulerConfig, WMASchedulerConfig, DEMASchedulerConfig, TEMASchedulerConfig, HMASchedulerConfig, KAMASchedulerConfig, SARSchedulerConfig, SuperTrendSchedulerConfig, KeltnerSchedulerConfig, DonchianSchedulerConfig, IchimokuSchedulerConfig, ROCSchedulerConfig, TRIXSchedulerConfig, HVSchedulerConfig, ParkinsonSchedulerConfig, ChaikinVolSchedulerConfig, VMASchedulerConfig, OBVSchedulerConfig, PVTSchedulerConfig, VWAPSchedulerConfig, CMFSchedulerConfig, MFISchedulerConfig, PivotSchedulerConfig, FibSchedulerConfig, StructureSchedulerConfig, ZonesSchedulerConfig, VolumeProfileSchedulerConfig, } from './workerProtocol';
13
14
  /**
14
15
  * IndicatorScheduler - 主线程 facade
15
16
  */
@@ -32,7 +33,24 @@ export declare class IndicatorScheduler {
32
33
  private invalidateCallback;
33
34
  /** 从 Chart 获取活跃副图 paneId 列表的回调 */
34
35
  private getActiveSubPaneIds;
36
+ private registry;
35
37
  constructor();
38
+ /**
39
+ * 注册新指标(支持动态扩展)
40
+ */
41
+ registerIndicator<T>(meta: IndicatorMetadata<T>): void;
42
+ /**
43
+ * 注销指标
44
+ */
45
+ unregisterIndicator(name: string): boolean;
46
+ /**
47
+ * 获取指标元数据(供渲染器查询)
48
+ */
49
+ getIndicatorMetadata(name: string): IndicatorMetadata | undefined;
50
+ /**
51
+ * 获取所有已注册指标
52
+ */
53
+ getAllIndicators(): readonly IndicatorMetadata[];
36
54
  /**
37
55
  * 设置 PluginHost
38
56
  */
@@ -61,10 +79,17 @@ export declare class IndicatorScheduler {
61
79
  private terminateWorker;
62
80
  private handleWorkerMessage;
63
81
  private handleSeriesResult;
82
+ /**
83
+ * 检查 state 中的 visibleMin/visibleMax 是否为 Infinity,如果是则输出 warning
84
+ */
85
+ private checkVisibleExtremes;
86
+ /** 遍历注册表中的所有指标,通过 applyResult 回调写入 StateStore */
64
87
  private applyResults;
88
+ /** 仅副图:重算可见范围极值并回调 applyResult(视口变更时同步更新,不走 Worker) */
65
89
  private updateVisibleStatesOnly;
90
+ /** 遍历注册表,标记当前可见副图,仅这些指标参与计算 */
66
91
  private buildActiveSubIndicatorMask;
67
- /** 仅保留活跃副图的配置,后端只算这些 */
92
+ /** 遍历注册表,禁用非活跃副图指标的 show* 字段,后端只算活跃指标 */
68
93
  private buildActiveConfig;
69
94
  /**
70
95
  * 数据变更时调用
@@ -162,6 +187,60 @@ export declare class IndicatorScheduler {
162
187
  * Donchian 配置变更
163
188
  */
164
189
  updateDonchianConfig(config: Partial<DonchianSchedulerConfig>, paneId?: string): void;
190
+ /**
191
+ * Ichimoku 配置变更
192
+ */
193
+ updateIchimokuConfig(config: Partial<IchimokuSchedulerConfig>, paneId?: string): void;
194
+ /**
195
+ * ROC 配置变更
196
+ */
197
+ updateROCConfig(config: Partial<ROCSchedulerConfig>, paneId?: string): void;
198
+ /**
199
+ * TRIX 配置变更
200
+ */
201
+ updateTRIXConfig(config: Partial<TRIXSchedulerConfig>, paneId?: string): void;
202
+ /**
203
+ * HV 配置变更
204
+ */
205
+ updateHVConfig(config: Partial<HVSchedulerConfig>, paneId?: string): void;
206
+ /**
207
+ * Parkinson 配置变更
208
+ */
209
+ updateParkinsonConfig(config: Partial<ParkinsonSchedulerConfig>, paneId?: string): void;
210
+ /**
211
+ * ChaikinVol 配置变更
212
+ */
213
+ updateChaikinVolConfig(config: Partial<ChaikinVolSchedulerConfig>, paneId?: string): void;
214
+ /**
215
+ * VMA 配置变更
216
+ */
217
+ updateVMAConfig(config: Partial<VMASchedulerConfig>, paneId?: string): void;
218
+ /**
219
+ * OBV 配置变更
220
+ */
221
+ updateOBVConfig(config: Partial<OBVSchedulerConfig>, paneId?: string): void;
222
+ /**
223
+ * PVT 配置变更
224
+ */
225
+ updatePVTConfig(config: Partial<PVTSchedulerConfig>, paneId?: string): void;
226
+ /**
227
+ * VWAP 配置变更
228
+ */
229
+ updateVWAPConfig(config: Partial<VWAPSchedulerConfig>, paneId?: string): void;
230
+ /** CMF 配置变更 */
231
+ updateCMFConfig(config: Partial<CMFSchedulerConfig>, paneId?: string): void;
232
+ /** MFI 配置变更 */
233
+ updateMFIConfig(config: Partial<MFISchedulerConfig>, paneId?: string): void;
234
+ /** Pivot 配置变更 */
235
+ updatePivotConfig(config: Partial<PivotSchedulerConfig>, paneId?: string): void;
236
+ /** Fib 配置变更 */
237
+ updateFibConfig(config: Partial<FibSchedulerConfig>, paneId?: string): void;
238
+ /** Structure 配置变更 */
239
+ updateStructureConfig(config: Partial<StructureSchedulerConfig>, paneId?: string): void;
240
+ /** Zones 配置变更 */
241
+ updateZonesConfig(config: Partial<ZonesSchedulerConfig>, paneId?: string): void;
242
+ /** Volume Profile 配置变更 */
243
+ updateVolumeProfileConfig(config: Partial<VolumeProfileSchedulerConfig>, paneId?: string): void;
165
244
  /**
166
245
  * 设置当前激活的主图指标
167
246
  */
@@ -20,6 +20,23 @@ import { SARRenderState } from './sarState';
20
20
  import { SuperTrendRenderState } from './supertrendState';
21
21
  import { KeltnerRenderState } from './keltnerState';
22
22
  import { DonchianRenderState } from './donchianState';
23
+ import { IchimokuRenderState } from './ichimokuState';
24
+ import { ROCRenderState } from './rocState';
25
+ import { TRIXRenderState } from './trixState';
26
+ import { HVRenderState } from './hvState';
27
+ import { ParkinsonRenderState } from './parkinsonState';
28
+ import { ChaikinVolRenderState } from './chaikinVolState';
29
+ import { VMARenderState } from './vmaState';
30
+ import { OBVRenderState } from './obvState';
31
+ import { PVTRenderState } from './pvtState';
32
+ import { VWAPRenderState } from './vwapState';
33
+ import { CMFRenderState } from './cmfState';
34
+ import { MFIRenderState } from './mfiState';
35
+ import { PivotRenderState } from './pivotState';
36
+ import { FibRenderState } from './fibState';
37
+ import { StructureRenderState } from './structureState';
38
+ import { ZonesRenderState } from './zonesState';
39
+ import { VolumeProfileRenderState } from './volumeProfileState';
23
40
  import { IndicatorSeriesBundle } from './workerProtocol';
24
41
  /**
25
42
  * 可见范围
@@ -47,6 +64,23 @@ type VisibleSubIndicatorStates = {
47
64
  supertrend: SuperTrendRenderState;
48
65
  keltner: KeltnerRenderState;
49
66
  donchian: DonchianRenderState;
67
+ ichimoku: IchimokuRenderState;
68
+ roc: ROCRenderState;
69
+ trix: TRIXRenderState;
70
+ hv: HVRenderState;
71
+ parkinson: ParkinsonRenderState;
72
+ chaikinVol: ChaikinVolRenderState;
73
+ vma: VMARenderState;
74
+ obv: OBVRenderState;
75
+ pvt: PVTRenderState;
76
+ vwap: VWAPRenderState;
77
+ cmf: CMFRenderState;
78
+ mfi: MFIRenderState;
79
+ pivot: PivotRenderState;
80
+ fib: FibRenderState;
81
+ structure: StructureRenderState;
82
+ zones: ZonesRenderState;
83
+ volumeProfile: VolumeProfileRenderState;
50
84
  };
51
85
  type VisibleSubIndicatorMask = {
52
86
  rsi?: boolean;
@@ -67,6 +101,23 @@ type VisibleSubIndicatorMask = {
67
101
  supertrend?: boolean;
68
102
  keltner?: boolean;
69
103
  donchian?: boolean;
104
+ ichimoku?: boolean;
105
+ roc?: boolean;
106
+ trix?: boolean;
107
+ hv?: boolean;
108
+ parkinson?: boolean;
109
+ chaikinVol?: boolean;
110
+ vma?: boolean;
111
+ obv?: boolean;
112
+ pvt?: boolean;
113
+ vwap?: boolean;
114
+ cmf?: boolean;
115
+ mfi?: boolean;
116
+ pivot?: boolean;
117
+ fib?: boolean;
118
+ structure?: boolean;
119
+ zones?: boolean;
120
+ volumeProfile?: boolean;
70
121
  };
71
122
  type ComposedRenderStates = VisibleSubIndicatorStates & {
72
123
  ma: MARenderState;
@@ -0,0 +1,43 @@
1
+ import { BaseIndicatorState } from '../../plugin';
2
+ export interface SwingPoint {
3
+ index: number;
4
+ price: number;
5
+ kind: 'high' | 'low';
6
+ label: 'HH' | 'HL' | 'LH' | 'LL';
7
+ confirmed: boolean;
8
+ }
9
+ export type StructureEventKind = 'BOS' | 'CHOCH';
10
+ export interface StructureEvent {
11
+ kind: StructureEventKind;
12
+ index: number;
13
+ triggerPrice: number;
14
+ brokenLevel: number;
15
+ brokenSwingIndex: number;
16
+ direction: 'up' | 'down';
17
+ }
18
+ export interface StructureSnapshot {
19
+ swings: SwingPoint[];
20
+ events: StructureEvent[];
21
+ trend: 'up' | 'down' | 'range';
22
+ }
23
+ export interface StructureRenderState extends BaseIndicatorState {
24
+ timestamp: number;
25
+ series: StructureSnapshot;
26
+ params: {
27
+ leftWindow: number;
28
+ rightWindow: number;
29
+ breakoutSource: 'close' | 'wick';
30
+ showSwingLabels: boolean;
31
+ showBOS: boolean;
32
+ showCHOCH: boolean;
33
+ showProvisional: boolean;
34
+ };
35
+ valueMin: number;
36
+ valueMax: number;
37
+ visibleMin: number;
38
+ visibleMax: number;
39
+ }
40
+ export declare const createStructureStateKey: (paneId: string) => `indicator:${string}:${string}`;
41
+ export declare const DEFAULT_STRUCTURE_LEFT = 2;
42
+ export declare const DEFAULT_STRUCTURE_RIGHT = 2;
43
+ export declare const EMPTY_STRUCTURE_STATE: StructureRenderState;
@@ -0,0 +1,20 @@
1
+ import { BaseIndicatorState } from '../../plugin';
2
+ export interface TRIXRenderState extends BaseIndicatorState {
3
+ timestamp: number;
4
+ series: (number | undefined)[];
5
+ params: {
6
+ period: number;
7
+ signalPeriod: number;
8
+ showTRIX: boolean;
9
+ showSignal: boolean;
10
+ };
11
+ signalSeries: (number | undefined)[];
12
+ valueMin: number;
13
+ valueMax: number;
14
+ visibleMin: number;
15
+ visibleMax: number;
16
+ }
17
+ export declare const createTRIXStateKey: (paneId: string) => `indicator:${string}:${string}`;
18
+ export declare const DEFAULT_TRIX_PERIOD = 15;
19
+ export declare const DEFAULT_TRIX_SIGNAL_PERIOD = 9;
20
+ export declare const EMPTY_TRIX_STATE: TRIXRenderState;
@@ -0,0 +1,16 @@
1
+ import { BaseIndicatorState } from '../../plugin';
2
+ export interface VMARenderState extends BaseIndicatorState {
3
+ timestamp: number;
4
+ series: (number | undefined)[];
5
+ params: {
6
+ period: number;
7
+ showVMA: boolean;
8
+ };
9
+ valueMin: number;
10
+ valueMax: number;
11
+ visibleMin: number;
12
+ visibleMax: number;
13
+ }
14
+ export declare const createVMAStateKey: (paneId: string) => `indicator:${string}:${string}`;
15
+ export declare const DEFAULT_VMA_PERIOD = 5;
16
+ export declare const EMPTY_VMA_STATE: VMARenderState;
@@ -0,0 +1,34 @@
1
+ import { BaseIndicatorState } from '../../plugin';
2
+ export interface VolumeProfileBin {
3
+ priceLow: number;
4
+ priceHigh: number;
5
+ volume: number;
6
+ }
7
+ export interface VolumeProfileResult {
8
+ bins: VolumeProfileBin[];
9
+ poc: number;
10
+ vah: number;
11
+ val: number;
12
+ totalVolume: number;
13
+ }
14
+ export interface VolumeProfileRenderState extends BaseIndicatorState {
15
+ timestamp: number;
16
+ series: VolumeProfileResult;
17
+ params: {
18
+ bins: number;
19
+ lookback: number;
20
+ valueAreaPercent: number;
21
+ showPOC: boolean;
22
+ showValueArea: boolean;
23
+ };
24
+ valueMin: number;
25
+ valueMax: number;
26
+ visibleMin: number;
27
+ visibleMax: number;
28
+ }
29
+ export declare const createVolumeProfileStateKey: (paneId: string) => `indicator:${string}:${string}`;
30
+ export declare const DEFAULT_VP_BINS = 24;
31
+ export declare const DEFAULT_VP_LOOKBACK = 0;
32
+ export declare const DEFAULT_VP_VALUE_AREA = 0.7;
33
+ export declare const EMPTY_VP_RESULT: VolumeProfileResult;
34
+ export declare const EMPTY_VOLUME_PROFILE_STATE: VolumeProfileRenderState;
@@ -0,0 +1,16 @@
1
+ import { BaseIndicatorState } from '../../plugin';
2
+ export interface VWAPRenderState extends BaseIndicatorState {
3
+ timestamp: number;
4
+ series: (number | undefined)[];
5
+ params: {
6
+ sessionResetGapMs: number;
7
+ showVWAP: boolean;
8
+ };
9
+ valueMin: number;
10
+ valueMax: number;
11
+ visibleMin: number;
12
+ visibleMax: number;
13
+ }
14
+ export declare const createVWAPStateKey: (paneId: string) => `indicator:${string}:${string}`;
15
+ export declare const DEFAULT_VWAP_SESSION_GAP_MS = 0;
16
+ export declare const EMPTY_VWAP_STATE: VWAPRenderState;