@363045841yyt/klinechart 0.5.6 → 0.6.0

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 (36) hide show
  1. package/README.md +6 -4
  2. package/dist/index.cjs +9 -9
  3. package/dist/index.js +1792 -1580
  4. package/dist/klinechart.css +1 -1
  5. package/dist/src/components/KLineChart.vue.d.ts +1 -1
  6. package/dist/src/config/chartSettings.d.ts +1 -0
  7. package/dist/src/core/chart.d.ts +11 -2
  8. package/dist/src/core/controller/interaction.d.ts +4 -0
  9. package/dist/src/core/indicators/bollState.d.ts +34 -0
  10. package/dist/src/core/indicators/calculators.d.ts +129 -0
  11. package/dist/src/core/indicators/cciState.d.ts +15 -0
  12. package/dist/src/core/indicators/eneState.d.ts +30 -0
  13. package/dist/src/core/indicators/expmaState.d.ts +30 -0
  14. package/dist/src/core/indicators/fastkState.d.ts +15 -0
  15. package/dist/src/core/indicators/kstState.d.ts +21 -0
  16. package/dist/src/core/indicators/maState.d.ts +26 -0
  17. package/dist/src/core/indicators/momState.d.ts +15 -0
  18. package/dist/src/core/indicators/rsiState.d.ts +39 -0
  19. package/dist/src/core/indicators/scheduler.d.ts +244 -0
  20. package/dist/src/core/indicators/stochState.d.ts +18 -0
  21. package/dist/src/core/indicators/wmsrState.d.ts +15 -0
  22. package/dist/src/core/renderers/Indicator/boll.d.ts +9 -26
  23. package/dist/src/core/renderers/Indicator/cci.d.ts +2 -19
  24. package/dist/src/core/renderers/Indicator/ene.d.ts +9 -18
  25. package/dist/src/core/renderers/Indicator/expma.d.ts +9 -17
  26. package/dist/src/core/renderers/Indicator/fastk.d.ts +2 -19
  27. package/dist/src/core/renderers/Indicator/index.d.ts +10 -10
  28. package/dist/src/core/renderers/Indicator/kst.d.ts +2 -34
  29. package/dist/src/core/renderers/Indicator/ma.d.ts +10 -10
  30. package/dist/src/core/renderers/Indicator/mainIndicatorLegend.d.ts +3 -3
  31. package/dist/src/core/renderers/Indicator/mom.d.ts +2 -19
  32. package/dist/src/core/renderers/Indicator/rsi.d.ts +3 -27
  33. package/dist/src/core/renderers/Indicator/stoch.d.ts +2 -28
  34. package/dist/src/core/renderers/Indicator/wmsr.d.ts +2 -19
  35. package/package.json +1 -1
  36. package/dist/src/utils/kline/ma.d.ts +0 -2
@@ -0,0 +1,244 @@
1
+ import { PluginHost } from '../../plugin';
2
+ import { KLineData } from '../../types/price';
3
+ import { MAFlags } from './calculators';
4
+ /**
5
+ * 可见范围
6
+ */
7
+ interface VisibleRange {
8
+ start: number;
9
+ end: number;
10
+ }
11
+ /**
12
+ * BOLL 调度器配置
13
+ */
14
+ export interface BOLLSchedulerConfig {
15
+ period: number;
16
+ multiplier: number;
17
+ showUpper: boolean;
18
+ showMiddle: boolean;
19
+ showLower: boolean;
20
+ showBand: boolean;
21
+ }
22
+ /**
23
+ * EXPMA 调度器配置
24
+ */
25
+ export interface EXPMASchedulerConfig {
26
+ fastPeriod: number;
27
+ slowPeriod: number;
28
+ }
29
+ /**
30
+ * ENE 调度器配置
31
+ */
32
+ export interface ENESchedulerConfig {
33
+ period: number;
34
+ deviation: number;
35
+ }
36
+ /**
37
+ * RSI 调度器配置
38
+ */
39
+ export interface RSISchedulerConfig {
40
+ period1: number;
41
+ period2: number;
42
+ period3: number;
43
+ showRSI1: boolean;
44
+ showRSI2: boolean;
45
+ showRSI3: boolean;
46
+ }
47
+ /**
48
+ * CCI 调度器配置
49
+ */
50
+ export interface CCISchedulerConfig {
51
+ period: number;
52
+ showCCI: boolean;
53
+ }
54
+ /**
55
+ * STOCH 调度器配置
56
+ */
57
+ export interface STOCHSchedulerConfig {
58
+ n: number;
59
+ m: number;
60
+ showK: boolean;
61
+ showD: boolean;
62
+ }
63
+ /**
64
+ * MOM 调度器配置
65
+ */
66
+ export interface MOMSchedulerConfig {
67
+ period: number;
68
+ showMOM: boolean;
69
+ }
70
+ /**
71
+ * WMSR 调度器配置
72
+ */
73
+ export interface WMSRSchedulerConfig {
74
+ period: number;
75
+ showWMSR: boolean;
76
+ }
77
+ /**
78
+ * KST 调度器配置
79
+ */
80
+ export interface KSTSchedulerConfig {
81
+ roc1: number;
82
+ roc2: number;
83
+ roc3: number;
84
+ roc4: number;
85
+ signalPeriod: number;
86
+ showKST: boolean;
87
+ showSignal: boolean;
88
+ }
89
+ /**
90
+ * FASTK 调度器配置
91
+ */
92
+ export interface FASTKSchedulerConfig {
93
+ period: number;
94
+ showFASTK: boolean;
95
+ }
96
+ /**
97
+ * 指标调度器
98
+ *
99
+ * 职责:
100
+ * 1. 维护当前图表激活的指标配置
101
+ * 2. 在数据/视口/配置变更时触发计算
102
+ * 3. 将计算结果写入 StateStore,供渲染器消费
103
+ *
104
+ * 优化策略:
105
+ * - 双脏标记(dirtyData/dirtyRange):数据变更重算 series + 极值,视口变更仅重算极值
106
+ * - cachedSeries 缓存:视口变更时复用已计算的 series,避免 O(n) 重算
107
+ */
108
+ export declare class IndicatorScheduler {
109
+ private pluginHost;
110
+ private currentData;
111
+ private maConfig;
112
+ private visibleRange;
113
+ private cachedSeries;
114
+ private bollConfig;
115
+ private cachedBollSeries;
116
+ private expmaConfig;
117
+ private cachedExpmaSeries;
118
+ private eneConfig;
119
+ private cachedEneSeries;
120
+ private rsiConfig;
121
+ private rsiPaneId;
122
+ private cachedRsiSeries;
123
+ private cciConfig;
124
+ private cciPaneId;
125
+ private cachedCciSeries;
126
+ private stochConfig;
127
+ private stochPaneId;
128
+ private cachedStochSeries;
129
+ private momConfig;
130
+ private momPaneId;
131
+ private cachedMomSeries;
132
+ private wmsrConfig;
133
+ private wmsrPaneId;
134
+ private cachedWmsrSeries;
135
+ private kstConfig;
136
+ private kstPaneId;
137
+ private cachedKstSeries;
138
+ private fastkConfig;
139
+ private fastkPaneId;
140
+ private cachedFastkSeries;
141
+ private dirtyData;
142
+ private dirtyRange;
143
+ private dirtyBollConfig;
144
+ private dirtyExpmaConfig;
145
+ private dirtyEneConfig;
146
+ private dirtyRsiConfig;
147
+ private dirtyCciConfig;
148
+ private dirtyStochConfig;
149
+ private dirtyMomConfig;
150
+ private dirtyWmsrConfig;
151
+ private dirtyKstConfig;
152
+ private dirtyFastkConfig;
153
+ /**
154
+ * 设置 PluginHost,用于读写 StateStore
155
+ */
156
+ setPluginHost(host: PluginHost): void;
157
+ /**
158
+ * 数据变更时调用
159
+ * @param data 新的 K 线数据
160
+ * @param visibleRange 当前可见范围
161
+ */
162
+ update(data: KLineData[], visibleRange: VisibleRange): void;
163
+ /**
164
+ * MA 配置变更时调用
165
+ * @param config 新的 MA 配置(哪些周期启用)
166
+ */
167
+ updateMAConfig(config: MAFlags): void;
168
+ /**
169
+ * BOLL 配置变更时调用
170
+ * @param config 新的 BOLL 配置
171
+ */
172
+ updateBOLLConfig(config: Partial<BOLLSchedulerConfig>): void;
173
+ /**
174
+ * EXPMA 配置变更时调用
175
+ * @param config 新的 EXPMA 配置
176
+ */
177
+ updateEXPMAConfig(config: Partial<EXPMASchedulerConfig>): void;
178
+ /**
179
+ * ENE 配置变更时调用
180
+ * @param config 新的 ENE 配置
181
+ */
182
+ updateENEConfig(config: Partial<ENESchedulerConfig>): void;
183
+ /**
184
+ * RSI 配置变更时调用
185
+ * @param config 新的 RSI 配置
186
+ * @param paneId RSI pane ID(可选,默认 'sub_RSI')
187
+ */
188
+ updateRSIConfig(config: Partial<RSISchedulerConfig>, paneId?: string): void;
189
+ /**
190
+ * CCI 配置变更时调用
191
+ * @param config 新的 CCI 配置
192
+ * @param paneId CCI pane ID(可选,默认 'sub_CCI')
193
+ */
194
+ updateCCIConfig(config: Partial<CCISchedulerConfig>, paneId?: string): void;
195
+ /**
196
+ * STOCH 配置变更时调用
197
+ * @param config 新的 STOCH 配置
198
+ * @param paneId STOCH pane ID(可选,默认 'sub_STOCH')
199
+ */
200
+ updateSTOCHConfig(config: Partial<STOCHSchedulerConfig>, paneId?: string): void;
201
+ /**
202
+ * MOM 配置变更时调用
203
+ * @param config 新的 MOM 配置
204
+ * @param paneId MOM pane ID(可选,默认 'sub_MOM')
205
+ */
206
+ updateMOMConfig(config: Partial<MOMSchedulerConfig>, paneId?: string): void;
207
+ /**
208
+ * WMSR 配置变更时调用
209
+ * @param config 新的 WMSR 配置
210
+ * @param paneId WMSR pane ID(可选,默认 'sub_WMSR')
211
+ */
212
+ updateWMSRConfig(config: Partial<WMSRSchedulerConfig>, paneId?: string): void;
213
+ /**
214
+ * KST 配置变更时调用
215
+ * @param config 新的 KST 配置
216
+ * @param paneId KST pane ID(可选,默认 'sub_KST')
217
+ */
218
+ updateKSTConfig(config: Partial<KSTSchedulerConfig>, paneId?: string): void;
219
+ /**
220
+ * FASTK 配置变更时调用
221
+ * @param config 新的 FASTK 配置
222
+ * @param paneId FASTK pane ID(可选,默认 'sub_FASTK')
223
+ */
224
+ updateFASTKConfig(config: Partial<FASTKSchedulerConfig>, paneId?: string): void;
225
+ /**
226
+ * 视口变更时调用
227
+ * @param visibleRange 新的可见范围
228
+ */
229
+ updateVisibleRange(visibleRange: VisibleRange): void;
230
+ /**
231
+ * 强制全部重算
232
+ */
233
+ recompute(): void;
234
+ /**
235
+ * 根据脏标记执行计算
236
+ *
237
+ * 计算流程:
238
+ * 1. 若 dirtyData 或指标配置脏标记,重算对应 series
239
+ * 2. 若任一 series 重算或 dirtyRange,重算所有指标在视口内的极值
240
+ * 3. 写入所有指标的 StateStore
241
+ */
242
+ private computeIfDirty;
243
+ }
244
+ export {};
@@ -0,0 +1,18 @@
1
+ import { BaseIndicatorState } from '../../plugin';
2
+ import { STOCHPoint } from './calculators';
3
+ export interface STOCHRenderState extends BaseIndicatorState {
4
+ timestamp: number;
5
+ series: STOCHPoint[];
6
+ params: {
7
+ n: number;
8
+ m: number;
9
+ showK: boolean;
10
+ showD: boolean;
11
+ };
12
+ valueMin: number;
13
+ valueMax: number;
14
+ visibleMin: number;
15
+ visibleMax: number;
16
+ }
17
+ export declare const createSTOCHStateKey: (paneId: string) => `indicator:${string}:${string}`;
18
+ export declare const EMPTY_STOCH_STATE: STOCHRenderState;
@@ -0,0 +1,15 @@
1
+ import { BaseIndicatorState } from '../../plugin';
2
+ export interface WMSRRenderState extends BaseIndicatorState {
3
+ timestamp: number;
4
+ series: (number | undefined)[];
5
+ params: {
6
+ period: number;
7
+ showWMSR: boolean;
8
+ };
9
+ valueMin: number;
10
+ valueMax: number;
11
+ visibleMin: number;
12
+ visibleMax: number;
13
+ }
14
+ export declare const createWMSRStateKey: (paneId: string) => `indicator:${string}:${string}`;
15
+ export declare const EMPTY_WMSR_STATE: WMSRRenderState;
@@ -1,28 +1,11 @@
1
- import { RendererPlugin } from '../../../plugin';
2
- import { KLineData } from '../../../types/price';
3
- export interface BOLLConfig {
4
- /** 周期(默认20) */
5
- period?: number;
6
- /** 标准差倍数(默认2) */
7
- multiplier?: number;
8
- /** 是否显示上轨 */
9
- showUpper?: boolean;
10
- /** 是否显示下轨 */
11
- showMiddle?: boolean;
12
- /** 是否显示下轨 */
13
- showLower?: boolean;
14
- /** 是否填充带状区域 */
15
- showBand?: boolean;
16
- }
1
+ import { RendererPluginWithHost } from '../../../plugin';
17
2
  /**
18
- * 创建 BOLL(布林带)渲染器插件
3
+ * 创建 BOLL(布林带)渲染器插件(无状态版本)
4
+ *
5
+ * 设计原则:
6
+ * 1. 不持有任何计算缓存或配置状态
7
+ * 2. 所有数据从 StateStore 读取(通过 BOLL_STATE_KEY)
8
+ * 3. 配置变更通过外部 IndicatorScheduler 处理
9
+ * 4. 纯绘制函数,无副作用
19
10
  */
20
- export declare function createBOLLRendererPlugin(initialConfig?: BOLLConfig): RendererPlugin;
21
- /**
22
- * 计算指定索引处的 BOLL 值(供图例使用)
23
- */
24
- export declare function calcBOLLAtIndex(data: KLineData[], index: number, period?: number, multiplier?: number): {
25
- upper: number;
26
- middle: number;
27
- lower: number;
28
- } | null;
11
+ export declare function createBOLLRendererPlugin(): RendererPluginWithHost;
@@ -1,33 +1,16 @@
1
- import { RendererPluginWithHost, BaseIndicatorState } from '../../../plugin';
2
- import { KLineData } from '../../../types/price';
3
- export interface CCIConfig {
4
- /** 周期(默认 14) */
5
- period?: number;
6
- /** 是否显示 CCI 线 */
7
- showCCI?: boolean;
8
- }
9
- export interface CCIRenderState extends BaseIndicatorState {
10
- valueMin: number;
11
- valueMax: number;
12
- }
1
+ import { RendererPluginWithHost, PluginHost } from '../../../plugin';
13
2
  export interface CCIRendererOptions {
14
3
  /** 目标 pane ID(默认 'sub') */
15
4
  paneId?: string;
16
- /** 初始配置 */
17
- config?: CCIConfig;
18
5
  }
19
6
  /**
20
7
  * 创建 CCI 渲染器插件
21
8
  */
22
9
  export declare function createCCIRendererPlugin(options?: CCIRendererOptions): RendererPluginWithHost;
23
- /**
24
- * 计算指定索引处的 CCI 值
25
- */
26
- export declare function calcCCIAtIndex(data: KLineData[], index: number, period: number): number | undefined;
27
10
  /**
28
11
  * 获取 CCI 标题信息(供 paneTitle 使用)
29
12
  */
30
- export declare function getCCITitleInfo(data: KLineData[], index: number, period?: number): {
13
+ export declare function getCCITitleInfo(index: number, period: number, pluginHost: PluginHost, paneId?: string): {
31
14
  name: string;
32
15
  params: number[];
33
16
  values: Array<{
@@ -1,20 +1,11 @@
1
- import { RendererPlugin } from '../../../plugin';
2
- import { KLineData } from '../../../types/price';
3
- export interface ENEConfig {
4
- /** 周期(默认10) */
5
- period?: number;
6
- /** 偏离率百分比(默认11) */
7
- deviation?: number;
8
- }
1
+ import { RendererPluginWithHost } from '../../../plugin';
9
2
  /**
10
- * 计算指定索引处的 ENE 值(供图例使用)
3
+ * 创建 ENE(轨道线)渲染器插件(无状态版本)
4
+ *
5
+ * 设计原则:
6
+ * 1. 不持有任何计算缓存或配置状态
7
+ * 2. 所有数据从 StateStore 读取(通过 ENE_STATE_KEY)
8
+ * 3. 配置变更通过外部 IndicatorScheduler 处理
9
+ * 4. 纯绘制函数,无副作用
11
10
  */
12
- export declare function calcENEAtIndex(data: KLineData[], index: number, period?: number, deviation?: number): {
13
- upper: number;
14
- middle: number;
15
- lower: number;
16
- } | null;
17
- /**
18
- * 创建 ENE(轨道线)渲染器插件
19
- */
20
- export declare function createENERendererPlugin(initialConfig?: ENEConfig): RendererPlugin;
11
+ export declare function createENERendererPlugin(): RendererPluginWithHost;
@@ -1,19 +1,11 @@
1
- import { RendererPlugin } from '../../../plugin';
2
- import { KLineData } from '../../../types/price';
3
- export interface EXPMAConfig {
4
- /** 快线周期(默认12) */
5
- fastPeriod?: number;
6
- /** 慢线周期(默认50) */
7
- slowPeriod?: number;
8
- }
1
+ import { RendererPluginWithHost } from '../../../plugin';
9
2
  /**
10
- * 计算指定索引处的 EXPMA 值(供图例使用)
3
+ * 创建 EXPMA(指数平滑移动平均线)渲染器插件(无状态版本)
4
+ *
5
+ * 设计原则:
6
+ * 1. 不持有任何计算缓存或配置状态
7
+ * 2. 所有数据从 StateStore 读取(通过 EXPMA_STATE_KEY)
8
+ * 3. 配置变更通过外部 IndicatorScheduler 处理
9
+ * 4. 纯绘制函数,无副作用
11
10
  */
12
- export declare function calcEXPMAAtIndex(data: KLineData[], index: number, fastPeriod?: number, slowPeriod?: number): {
13
- fast: number;
14
- slow: number;
15
- } | null;
16
- /**
17
- * 创建 EXPMA(指数平滑移动平均线)渲染器插件
18
- */
19
- export declare function createEXPMARendererPlugin(initialConfig?: EXPMAConfig): RendererPlugin;
11
+ export declare function createEXPMARendererPlugin(): RendererPluginWithHost;
@@ -1,33 +1,16 @@
1
- import { RendererPluginWithHost, BaseIndicatorState } from '../../../plugin';
2
- import { KLineData } from '../../../types/price';
3
- export interface FASTKConfig {
4
- /** 周期(默认 9) */
5
- period?: number;
6
- /** 是否显示 FASTK 线 */
7
- showFASTK?: boolean;
8
- }
9
- export interface FASTKRenderState extends BaseIndicatorState {
10
- valueMin: number;
11
- valueMax: number;
12
- }
1
+ import { RendererPluginWithHost, PluginHost } from '../../../plugin';
13
2
  export interface FASTKRendererOptions {
14
3
  /** 目标 pane ID(默认 'sub') */
15
4
  paneId?: string;
16
- /** 初始配置 */
17
- config?: FASTKConfig;
18
5
  }
19
6
  /**
20
7
  * 创建 FASTK 渲染器插件
21
8
  */
22
9
  export declare function createFASTKRendererPlugin(options?: FASTKRendererOptions): RendererPluginWithHost;
23
- /**
24
- * 计算指定索引处的 FASTK 值
25
- */
26
- export declare function calcFASTKAtIndex(data: KLineData[], index: number, period: number): number | undefined;
27
10
  /**
28
11
  * 获取 FASTK 标题信息(供 paneTitle 使用)
29
12
  */
30
- export declare function getFASTKTitleInfo(data: KLineData[], index: number, period?: number): {
13
+ export declare function getFASTKTitleInfo(index: number, period: number, pluginHost: PluginHost, paneId?: string): {
31
14
  name: string;
32
15
  params: number[];
33
16
  values: Array<{
@@ -1,18 +1,18 @@
1
1
  import { RendererPlugin } from '../../../plugin';
2
2
  export { createMARendererPlugin, type MAFlags } from './ma';
3
- export { createBOLLRendererPlugin, calcBOLLAtIndex, type BOLLConfig } from './boll';
4
- export { createEXPMARendererPlugin, calcEXPMAAtIndex, type EXPMAConfig } from './expma';
5
- export { createENERendererPlugin, calcENEAtIndex, type ENEConfig } from './ene';
3
+ export { createBOLLRendererPlugin } from './boll';
4
+ export { createEXPMARendererPlugin } from './expma';
5
+ export { createENERendererPlugin } from './ene';
6
6
  export { createMainIndicatorLegendRendererPlugin } from './mainIndicatorLegend';
7
7
  export { createMACDRendererPlugin, calcMACDAtIndex, type MACDConfig, type MACDRendererOptions, getMACDTitleInfo } from './macd';
8
8
  export { createMACDLegendRendererPlugin, type MACDLegendOptions } from './macdLegend';
9
- export { createRSIRendererPlugin, calcRSIAtIndex, type RSIConfig, type RSIRendererOptions, getRSITitleInfo } from './rsi';
10
- export { createCCIRendererPlugin, calcCCIAtIndex, type CCIConfig, type CCIRendererOptions, getCCITitleInfo } from './cci';
11
- export { createSTOCHRendererPlugin, calcSTOCHAtIndex, type STOCHConfig, type STOCHRendererOptions, getSTOCHTitleInfo } from './stoch';
12
- export { createMOMRendererPlugin, calcMOMAtIndex, type MOMConfig, type MOMRendererOptions, getMOMTitleInfo } from './mom';
13
- export { createWMSRRendererPlugin, calcWMSRAtIndex, type WMSRConfig, type WMSRRendererOptions, getWMSRTitleInfo } from './wmsr';
14
- export { createKSTRendererPlugin, calcKSTAtIndex, type KSTConfig, type KSTRendererOptions, getKSTTitleInfo } from './kst';
15
- export { createFASTKRendererPlugin, calcFASTKAtIndex, type FASTKConfig, type FASTKRendererOptions, getFASTKTitleInfo } from './fastk';
9
+ export { createRSIRendererPlugin, type RSIRendererOptions, getRSITitleInfo } from './rsi';
10
+ export { createCCIRendererPlugin, type CCIRendererOptions, getCCITitleInfo } from './cci';
11
+ export { createSTOCHRendererPlugin, type STOCHRendererOptions, getSTOCHTitleInfo } from './stoch';
12
+ export { createMOMRendererPlugin, type MOMRendererOptions, getMOMTitleInfo } from './mom';
13
+ export { createWMSRRendererPlugin, type WMSRRendererOptions, getWMSRTitleInfo } from './wmsr';
14
+ export { createKSTRendererPlugin, type KSTRendererOptions, getKSTTitleInfo } from './kst';
15
+ export { createFASTKRendererPlugin, type FASTKRendererOptions, getFASTKTitleInfo } from './fastk';
16
16
  /**
17
17
  * 副图指标类型
18
18
  */
@@ -1,47 +1,16 @@
1
- import { RendererPluginWithHost, BaseIndicatorState } from '../../../plugin';
2
- import { KLineData } from '../../../types/price';
3
- export interface KSTConfig {
4
- /** ROC1 周期(默认 10) */
5
- roc1?: number;
6
- /** ROC2 周期(默认 15) */
7
- roc2?: number;
8
- /** ROC3 周期(默认 20) */
9
- roc3?: number;
10
- /** ROC4 周期(默认 30) */
11
- roc4?: number;
12
- /** 信号线周期(默认 9) */
13
- signalPeriod?: number;
14
- /** 是否显示 KST 线 */
15
- showKST?: boolean;
16
- /** 是否显示信号线 */
17
- showSignal?: boolean;
18
- }
19
- interface KSTPoint {
20
- kst: number;
21
- signal: number;
22
- }
23
- export interface KSTRenderState extends BaseIndicatorState {
24
- valueMin: number;
25
- valueMax: number;
26
- }
1
+ import { RendererPluginWithHost, PluginHost } from '../../../plugin';
27
2
  export interface KSTRendererOptions {
28
3
  /** 目标 pane ID(默认 'sub') */
29
4
  paneId?: string;
30
- /** 初始配置 */
31
- config?: KSTConfig;
32
5
  }
33
6
  /**
34
7
  * 创建 KST 渲染器插件
35
8
  */
36
9
  export declare function createKSTRendererPlugin(options?: KSTRendererOptions): RendererPluginWithHost;
37
- /**
38
- * 计算指定索引处的 KST 值
39
- */
40
- export declare function calcKSTAtIndex(data: KLineData[], index: number, roc1: number, roc2: number, roc3: number, roc4: number, signalPeriod: number): KSTPoint | undefined;
41
10
  /**
42
11
  * 获取 KST 标题信息(供 paneTitle 使用)
43
12
  */
44
- export declare function getKSTTitleInfo(data: KLineData[], index: number, roc1?: number, roc2?: number, roc3?: number, roc4?: number, signalPeriod?: number): {
13
+ export declare function getKSTTitleInfo(index: number, roc1: number, roc2: number, roc3: number, roc4: number, signalPeriod: number, pluginHost: PluginHost, paneId?: string): {
45
14
  name: string;
46
15
  params: number[];
47
16
  values: Array<{
@@ -50,4 +19,3 @@ export declare function getKSTTitleInfo(data: KLineData[], index: number, roc1?:
50
19
  color: string;
51
20
  }>;
52
21
  } | null;
53
- export {};
@@ -1,12 +1,12 @@
1
- import { RendererPlugin } from '../../../plugin';
2
- export type MAFlags = {
3
- ma5?: boolean;
4
- ma10?: boolean;
5
- ma20?: boolean;
6
- ma30?: boolean;
7
- ma60?: boolean;
8
- };
1
+ import { RendererPluginWithHost } from '../../../plugin';
2
+ export type { MAFlags } from '../../indicators/calculators';
9
3
  /**
10
- * 创建 MA 均线渲染器插件
4
+ * 创建 MA 均线渲染器插件(无状态版本)
5
+ *
6
+ * 设计原则:
7
+ * 1. 不持有任何计算缓存或配置状态
8
+ * 2. 所有数据从 StateStore 读取(通过 MA_STATE_KEY)
9
+ * 3. 配置变更通过外部 IndicatorScheduler 处理,不经过本渲染器
10
+ * 4. 纯绘制函数,无副作用
11
11
  */
12
- export declare function createMARendererPlugin(showMA?: MAFlags): RendererPlugin;
12
+ export declare function createMARendererPlugin(): RendererPluginWithHost;
@@ -1,10 +1,10 @@
1
- import { RendererPlugin } from '../../../plugin';
1
+ import { RendererPluginWithHost } from '../../../plugin';
2
2
  /**
3
3
  * 创建主图指标图例渲染器插件
4
4
  *
5
5
  * 统一管理 MA、BOLL 等主图指标的图例显示,支持多行排列
6
- * 通过 setConfig 更新指标状态,不依赖事件系统
6
+ * MA 数据从 StateStore 读取(与 MA 线渲染器共享同一数据源)
7
7
  */
8
8
  export declare function createMainIndicatorLegendRendererPlugin(options: {
9
9
  yPaddingPx: number;
10
- }): RendererPlugin;
10
+ }): RendererPluginWithHost;
@@ -1,33 +1,16 @@
1
- import { RendererPluginWithHost, BaseIndicatorState } from '../../../plugin';
2
- import { KLineData } from '../../../types/price';
3
- export interface MOMConfig {
4
- /** 周期(默认 10) */
5
- period?: number;
6
- /** 是否显示 MOM 线 */
7
- showMOM?: boolean;
8
- }
9
- export interface MOMRenderState extends BaseIndicatorState {
10
- valueMin: number;
11
- valueMax: number;
12
- }
1
+ import { RendererPluginWithHost, PluginHost } from '../../../plugin';
13
2
  export interface MOMRendererOptions {
14
3
  /** 目标 pane ID(默认 'sub') */
15
4
  paneId?: string;
16
- /** 初始配置 */
17
- config?: MOMConfig;
18
5
  }
19
6
  /**
20
7
  * 创建 MOM 渲染器插件
21
8
  */
22
9
  export declare function createMOMRendererPlugin(options?: MOMRendererOptions): RendererPluginWithHost;
23
- /**
24
- * 计算指定索引处的 MOM 值
25
- */
26
- export declare function calcMOMAtIndex(data: KLineData[], index: number, period: number): number | undefined;
27
10
  /**
28
11
  * 获取 MOM 标题信息(供 paneTitle 使用)
29
12
  */
30
- export declare function getMOMTitleInfo(data: KLineData[], index: number, period?: number): {
13
+ export declare function getMOMTitleInfo(index: number, period: number, pluginHost: PluginHost, paneId?: string): {
31
14
  name: string;
32
15
  params: number[];
33
16
  values: Array<{
@@ -1,41 +1,17 @@
1
- import { RendererPluginWithHost, BaseIndicatorState } from '../../../plugin';
2
- import { KLineData } from '../../../types/price';
3
- export interface RSIConfig {
4
- /** 第一条 RSI 周期(默认 6) */
5
- period1?: number;
6
- /** 第二条 RSI 周期(默认 12) */
7
- period2?: number;
8
- /** 第三条 RSI 周期(默认 24) */
9
- period3?: number;
10
- /** 是否显示 RSI1 */
11
- showRSI1?: boolean;
12
- /** 是否显示 RSI2 */
13
- showRSI2?: boolean;
14
- /** 是否显示 RSI3 */
15
- showRSI3?: boolean;
16
- }
17
- export interface RSIRenderState extends BaseIndicatorState {
18
- valueMin: number;
19
- valueMax: number;
20
- }
1
+ import { RendererPluginWithHost, PluginHost } from '../../../plugin';
21
2
  export interface RSIRendererOptions {
22
3
  /** 目标 pane ID(默认 'sub') */
23
4
  paneId?: string;
24
- /** 初始配置 */
25
- config?: RSIConfig;
26
5
  }
27
6
  /**
28
7
  * 创建 RSI 渲染器插件
29
8
  */
30
9
  export declare function createRSIRendererPlugin(options?: RSIRendererOptions): RendererPluginWithHost;
31
- /**
32
- * 计算指定索引处的 RSI 值
33
- */
34
- export declare function calcRSIAtIndex(data: KLineData[], index: number, period: number): number | undefined;
35
10
  /**
36
11
  * 获取 RSI 标题信息(供 paneTitle 使用)
12
+ * 从 StateStore 读取已计算的 RSI 数据
37
13
  */
38
- export declare function getRSITitleInfo(data: KLineData[], index: number, period1?: number, period2?: number, period3?: number): {
14
+ export declare function getRSITitleInfo(index: number, period1: number, period2: number, period3: number, pluginHost: PluginHost, paneId?: string): {
39
15
  name: string;
40
16
  params: number[];
41
17
  values: Array<{