@363045841yyt/klinechart-core 0.7.11 → 0.7.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine/indicators/indicator.worker.js +32 -4
- package/dist/engine/indicators/indicator.worker.js.map +1 -1
- package/dist/engine/indicators/indicatorDefinitionRegistry.d.ts +3 -2
- package/dist/engine/indicators/indicatorDefinitionRegistry.d.ts.map +1 -1
- package/dist/engine/indicators/indicatorDefinitionRegistry.js.map +1 -1
- package/dist/engine/indicators/indicatorMetadata.d.ts +27 -1
- package/dist/engine/indicators/indicatorMetadata.d.ts.map +1 -1
- package/dist/engine/indicators/indicatorMetadata.js.map +1 -1
- package/dist/engine/indicators/indicatorRuntime.d.ts +12 -117
- package/dist/engine/indicators/indicatorRuntime.d.ts.map +1 -1
- package/dist/engine/indicators/indicatorRuntime.js +123 -1308
- package/dist/engine/indicators/indicatorRuntime.js.map +1 -1
- package/dist/engine/indicators/scheduler.d.ts +3 -142
- package/dist/engine/indicators/scheduler.d.ts.map +1 -1
- package/dist/engine/indicators/scheduler.js +59 -431
- package/dist/engine/indicators/scheduler.js.map +1 -1
- package/dist/engine/indicators/stateComposer.d.ts.map +1 -1
- package/dist/engine/indicators/stateComposer.js +15 -47
- package/dist/engine/indicators/stateComposer.js.map +1 -1
- package/dist/engine/indicators/workerProtocol.d.ts +12 -36
- package/dist/engine/indicators/workerProtocol.d.ts.map +1 -1
- package/dist/engine/indicators/workerProtocol.js.map +1 -1
- package/dist/engine/renderers/Indicator/atr.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/atr.js +9 -3
- package/dist/engine/renderers/Indicator/atr.js.map +1 -1
- package/dist/engine/renderers/Indicator/boll.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/boll.js +4 -2
- package/dist/engine/renderers/Indicator/boll.js.map +1 -1
- package/dist/engine/renderers/Indicator/cci.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/cci.js +9 -3
- package/dist/engine/renderers/Indicator/cci.js.map +1 -1
- package/dist/engine/renderers/Indicator/chaikinVol.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/chaikinVol.js +8 -2
- package/dist/engine/renderers/Indicator/chaikinVol.js.map +1 -1
- package/dist/engine/renderers/Indicator/cmf.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/cmf.js +8 -2
- package/dist/engine/renderers/Indicator/cmf.js.map +1 -1
- package/dist/engine/renderers/Indicator/dema.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/dema.js +3 -2
- package/dist/engine/renderers/Indicator/dema.js.map +1 -1
- package/dist/engine/renderers/Indicator/donchian.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/donchian.js +3 -2
- package/dist/engine/renderers/Indicator/donchian.js.map +1 -1
- package/dist/engine/renderers/Indicator/ene.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/ene.js +5 -3
- package/dist/engine/renderers/Indicator/ene.js.map +1 -1
- package/dist/engine/renderers/Indicator/expma.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/expma.js +3 -1
- package/dist/engine/renderers/Indicator/expma.js.map +1 -1
- package/dist/engine/renderers/Indicator/fastk.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/fastk.js +9 -3
- package/dist/engine/renderers/Indicator/fastk.js.map +1 -1
- package/dist/engine/renderers/Indicator/fib.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/fib.js +3 -2
- package/dist/engine/renderers/Indicator/fib.js.map +1 -1
- package/dist/engine/renderers/Indicator/hma.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/hma.js +3 -2
- package/dist/engine/renderers/Indicator/hma.js.map +1 -1
- package/dist/engine/renderers/Indicator/hv.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/hv.js +3 -2
- package/dist/engine/renderers/Indicator/hv.js.map +1 -1
- package/dist/engine/renderers/Indicator/ichimoku.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/ichimoku.js +3 -2
- package/dist/engine/renderers/Indicator/ichimoku.js.map +1 -1
- package/dist/engine/renderers/Indicator/kama.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/kama.js +3 -2
- package/dist/engine/renderers/Indicator/kama.js.map +1 -1
- package/dist/engine/renderers/Indicator/keltner.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/keltner.js +3 -2
- package/dist/engine/renderers/Indicator/keltner.js.map +1 -1
- package/dist/engine/renderers/Indicator/kst.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/kst.js +4 -3
- package/dist/engine/renderers/Indicator/kst.js.map +1 -1
- package/dist/engine/renderers/Indicator/ma.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/ma.js +6 -1
- package/dist/engine/renderers/Indicator/ma.js.map +1 -1
- package/dist/engine/renderers/Indicator/macd.js +2 -2
- package/dist/engine/renderers/Indicator/macd.js.map +1 -1
- package/dist/engine/renderers/Indicator/mfi.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/mfi.js +8 -2
- package/dist/engine/renderers/Indicator/mfi.js.map +1 -1
- package/dist/engine/renderers/Indicator/mom.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/mom.js +9 -3
- package/dist/engine/renderers/Indicator/mom.js.map +1 -1
- package/dist/engine/renderers/Indicator/obv.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/obv.js +8 -2
- package/dist/engine/renderers/Indicator/obv.js.map +1 -1
- package/dist/engine/renderers/Indicator/parkinson.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/parkinson.js +3 -2
- package/dist/engine/renderers/Indicator/parkinson.js.map +1 -1
- package/dist/engine/renderers/Indicator/pivot.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/pivot.js +3 -2
- package/dist/engine/renderers/Indicator/pivot.js.map +1 -1
- package/dist/engine/renderers/Indicator/pvt.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/pvt.js +8 -2
- package/dist/engine/renderers/Indicator/pvt.js.map +1 -1
- package/dist/engine/renderers/Indicator/roc.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/roc.js +8 -2
- package/dist/engine/renderers/Indicator/roc.js.map +1 -1
- package/dist/engine/renderers/Indicator/rsi.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/rsi.js +7 -3
- package/dist/engine/renderers/Indicator/rsi.js.map +1 -1
- package/dist/engine/renderers/Indicator/sar.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/sar.js +3 -2
- package/dist/engine/renderers/Indicator/sar.js.map +1 -1
- package/dist/engine/renderers/Indicator/stoch.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/stoch.js +4 -3
- package/dist/engine/renderers/Indicator/stoch.js.map +1 -1
- package/dist/engine/renderers/Indicator/structure.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/structure.js +3 -2
- package/dist/engine/renderers/Indicator/structure.js.map +1 -1
- package/dist/engine/renderers/Indicator/supertrend.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/supertrend.js +3 -2
- package/dist/engine/renderers/Indicator/supertrend.js.map +1 -1
- package/dist/engine/renderers/Indicator/tema.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/tema.js +3 -2
- package/dist/engine/renderers/Indicator/tema.js.map +1 -1
- package/dist/engine/renderers/Indicator/trix.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/trix.js +3 -2
- package/dist/engine/renderers/Indicator/trix.js.map +1 -1
- package/dist/engine/renderers/Indicator/vma.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/vma.js +8 -2
- package/dist/engine/renderers/Indicator/vma.js.map +1 -1
- package/dist/engine/renderers/Indicator/volumeProfile.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/volumeProfile.js +3 -2
- package/dist/engine/renderers/Indicator/volumeProfile.js.map +1 -1
- package/dist/engine/renderers/Indicator/vwap.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/vwap.js +8 -2
- package/dist/engine/renderers/Indicator/vwap.js.map +1 -1
- package/dist/engine/renderers/Indicator/wma.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/wma.js +3 -2
- package/dist/engine/renderers/Indicator/wma.js.map +1 -1
- package/dist/engine/renderers/Indicator/wmsr.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/wmsr.js +9 -3
- package/dist/engine/renderers/Indicator/wmsr.js.map +1 -1
- package/dist/engine/renderers/Indicator/zones.d.ts.map +1 -1
- package/dist/engine/renderers/Indicator/zones.js +3 -2
- package/dist/engine/renderers/Indicator/zones.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -2
- package/src/engine/indicators/__tests__/registerBuiltins.test.ts +14 -22
- package/src/engine/indicators/__tests__/scheduler.test.ts +14 -14
- package/src/engine/indicators/__tests__/stateComposer.test.ts +7 -4
- package/src/engine/indicators/indicator.worker.ts +36 -4
- package/src/engine/indicators/indicatorDefinitionRegistry.ts +3 -1
- package/src/engine/indicators/indicatorMetadata.ts +29 -1
- package/src/engine/indicators/indicatorRuntime.ts +120 -1447
- package/src/engine/indicators/scheduler.ts +57 -485
- package/src/engine/indicators/stateComposer.ts +16 -60
- package/src/engine/indicators/workerProtocol.ts +14 -36
- package/src/engine/renderers/Indicator/atr.ts +9 -3
- package/src/engine/renderers/Indicator/boll.ts +4 -2
- package/src/engine/renderers/Indicator/cci.ts +9 -3
- package/src/engine/renderers/Indicator/chaikinVol.ts +8 -2
- package/src/engine/renderers/Indicator/cmf.ts +8 -2
- package/src/engine/renderers/Indicator/dema.ts +3 -2
- package/src/engine/renderers/Indicator/donchian.ts +3 -2
- package/src/engine/renderers/Indicator/ene.ts +5 -3
- package/src/engine/renderers/Indicator/expma.ts +3 -1
- package/src/engine/renderers/Indicator/fastk.ts +9 -3
- package/src/engine/renderers/Indicator/fib.ts +3 -2
- package/src/engine/renderers/Indicator/hma.ts +3 -2
- package/src/engine/renderers/Indicator/hv.ts +3 -2
- package/src/engine/renderers/Indicator/ichimoku.ts +3 -2
- package/src/engine/renderers/Indicator/kama.ts +3 -2
- package/src/engine/renderers/Indicator/keltner.ts +3 -2
- package/src/engine/renderers/Indicator/kst.ts +4 -3
- package/src/engine/renderers/Indicator/ma.ts +3 -2
- package/src/engine/renderers/Indicator/macd.ts +9 -9
- package/src/engine/renderers/Indicator/mfi.ts +8 -2
- package/src/engine/renderers/Indicator/mom.ts +9 -3
- package/src/engine/renderers/Indicator/obv.ts +8 -2
- package/src/engine/renderers/Indicator/parkinson.ts +3 -2
- package/src/engine/renderers/Indicator/pivot.ts +3 -2
- package/src/engine/renderers/Indicator/pvt.ts +8 -2
- package/src/engine/renderers/Indicator/roc.ts +8 -2
- package/src/engine/renderers/Indicator/rsi.ts +4 -3
- package/src/engine/renderers/Indicator/sar.ts +3 -2
- package/src/engine/renderers/Indicator/stoch.ts +4 -3
- package/src/engine/renderers/Indicator/structure.ts +3 -2
- package/src/engine/renderers/Indicator/supertrend.ts +3 -2
- package/src/engine/renderers/Indicator/tema.ts +3 -2
- package/src/engine/renderers/Indicator/trix.ts +3 -2
- package/src/engine/renderers/Indicator/vma.ts +8 -2
- package/src/engine/renderers/Indicator/volumeProfile.ts +3 -2
- package/src/engine/renderers/Indicator/vwap.ts +8 -2
- package/src/engine/renderers/Indicator/wma.ts +3 -2
- package/src/engine/renderers/Indicator/wmsr.ts +9 -3
- package/src/engine/renderers/Indicator/zones.ts +3 -2
- package/src/version.ts +1 -1
|
@@ -70,6 +70,7 @@ import type { ZonesRenderState } from './zonesState'
|
|
|
70
70
|
import type { VolumeProfileRenderState } from './volumeProfileState'
|
|
71
71
|
import type { IndicatorSeriesBundle } from './workerProtocol'
|
|
72
72
|
import type { IndicatorMetadata } from './indicatorMetadata'
|
|
73
|
+
import { getRegisteredIndicatorDefinitions } from './indicatorDefinitionRegistry'
|
|
73
74
|
|
|
74
75
|
/**
|
|
75
76
|
* 可见范围
|
|
@@ -166,56 +167,13 @@ type MainRenderStateIndicatorId = keyof MainRenderStates
|
|
|
166
167
|
|
|
167
168
|
type ComposedRenderStates = VisibleSubIndicatorStates & MainRenderStates
|
|
168
169
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
'kama',
|
|
177
|
-
'roc',
|
|
178
|
-
'chaikinVol',
|
|
179
|
-
'obv',
|
|
180
|
-
'pvt',
|
|
181
|
-
'vwap',
|
|
182
|
-
'rsi',
|
|
183
|
-
'stoch',
|
|
184
|
-
'fastk',
|
|
185
|
-
'mfi',
|
|
186
|
-
'wmsr',
|
|
187
|
-
'cmf',
|
|
188
|
-
'atr',
|
|
189
|
-
'hv',
|
|
190
|
-
'kst',
|
|
191
|
-
'mom',
|
|
192
|
-
'parkinson',
|
|
193
|
-
'trix',
|
|
194
|
-
'vma',
|
|
195
|
-
'macd',
|
|
196
|
-
'sar',
|
|
197
|
-
'supertrend',
|
|
198
|
-
'keltner',
|
|
199
|
-
'donchian',
|
|
200
|
-
'ichimoku',
|
|
201
|
-
'pivot',
|
|
202
|
-
'fib',
|
|
203
|
-
'structure',
|
|
204
|
-
'zones',
|
|
205
|
-
'volumeProfile',
|
|
206
|
-
] as const satisfies readonly (keyof VisibleSubIndicatorStates)[]
|
|
207
|
-
|
|
208
|
-
type _MissingVisibleStateId = Exclude<
|
|
209
|
-
keyof VisibleSubIndicatorStates,
|
|
210
|
-
typeof METADATA_VISIBLE_STATE_INDICATOR_IDS[number]
|
|
211
|
-
>
|
|
212
|
-
type _ExtraVisibleStateId = Exclude<
|
|
213
|
-
typeof METADATA_VISIBLE_STATE_INDICATOR_IDS[number],
|
|
214
|
-
keyof VisibleSubIndicatorStates
|
|
215
|
-
>
|
|
216
|
-
type AssertNever<T extends never> = T
|
|
217
|
-
type _AssertNoMissingId = AssertNever<_MissingVisibleStateId>
|
|
218
|
-
type _AssertNoExtraId = AssertNever<_ExtraVisibleStateId>
|
|
170
|
+
function getVisibleStateIndicatorIds(): (keyof VisibleSubIndicatorStates)[] {
|
|
171
|
+
return getRegisteredIndicatorDefinitions()
|
|
172
|
+
.filter((d): d is IndicatorMetadata & { visibleState: NonNullable<IndicatorMetadata['visibleState']> } =>
|
|
173
|
+
!!d.visibleState?.compose
|
|
174
|
+
)
|
|
175
|
+
.map(d => d.name as keyof VisibleSubIndicatorStates)
|
|
176
|
+
}
|
|
219
177
|
|
|
220
178
|
/**
|
|
221
179
|
* 仅计算副图指标的 visible-only states
|
|
@@ -230,7 +188,7 @@ export function composeVisibleSubIndicatorStates(
|
|
|
230
188
|
): VisibleSubIndicatorStates {
|
|
231
189
|
const states: Partial<VisibleSubIndicatorStates> = {}
|
|
232
190
|
|
|
233
|
-
for (const indicatorId of
|
|
191
|
+
for (const indicatorId of getVisibleStateIndicatorIds()) {
|
|
234
192
|
states[indicatorId] = composeRequiredMetadataVisibleState(
|
|
235
193
|
indicatorId, bundle, visibleRange, timestamp, activeMask, getIndicatorMetadata,
|
|
236
194
|
) as never
|
|
@@ -290,15 +248,13 @@ function composeMainRenderStates(
|
|
|
290
248
|
): MainRenderStates {
|
|
291
249
|
const states: Partial<Record<MainRenderStateIndicatorId, unknown>> = {}
|
|
292
250
|
|
|
293
|
-
for (const
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
const
|
|
298
|
-
if (!
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
states[indicatorId] = composeRenderState(bundle, visibleRange, timestamp)
|
|
251
|
+
for (const def of getRegisteredIndicatorDefinitions()) {
|
|
252
|
+
if (!def.mainPane?.composeRenderState) continue
|
|
253
|
+
const indicatorId = def.name as MainRenderStateIndicatorId
|
|
254
|
+
const meta = getIndicatorMetadata(indicatorId)
|
|
255
|
+
const compose = meta?.mainPane?.composeRenderState ?? def.mainPane.composeRenderState
|
|
256
|
+
if (!compose) continue
|
|
257
|
+
states[indicatorId] = compose(bundle, visibleRange, timestamp)
|
|
302
258
|
}
|
|
303
259
|
|
|
304
260
|
return states as MainRenderStates
|
|
@@ -277,9 +277,22 @@ export interface VolumeProfileSchedulerConfig {
|
|
|
277
277
|
// Worker 请求类型
|
|
278
278
|
// ============================================================================
|
|
279
279
|
|
|
280
|
+
export interface SerializedRuntimeDescriptor {
|
|
281
|
+
configKey: string
|
|
282
|
+
paneIdKey?: string
|
|
283
|
+
defaultConfig: unknown
|
|
284
|
+
computeKey: string
|
|
285
|
+
}
|
|
286
|
+
|
|
280
287
|
export interface InitRequest {
|
|
281
288
|
type: 'init'
|
|
282
289
|
protocolVersion: number
|
|
290
|
+
descriptors?: SerializedRuntimeDescriptor[]
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export interface AddDescriptorRequest {
|
|
294
|
+
type: 'addDescriptor'
|
|
295
|
+
descriptor: SerializedRuntimeDescriptor
|
|
283
296
|
}
|
|
284
297
|
|
|
285
298
|
export interface SetDataRequest {
|
|
@@ -308,6 +321,7 @@ export interface DisposeRequest {
|
|
|
308
321
|
|
|
309
322
|
export type IndicatorWorkerRequest =
|
|
310
323
|
| InitRequest
|
|
324
|
+
| AddDescriptorRequest
|
|
311
325
|
| SetDataRequest
|
|
312
326
|
| SetConfigRequest
|
|
313
327
|
| ComputeSeriesRequest
|
|
@@ -390,42 +404,6 @@ export interface IndicatorConfigSnapshot {
|
|
|
390
404
|
structure: StructureSchedulerConfig
|
|
391
405
|
zones: ZonesSchedulerConfig
|
|
392
406
|
volumeProfile: VolumeProfileSchedulerConfig
|
|
393
|
-
// pane IDs for sub-indicators
|
|
394
|
-
rsiPaneId: string
|
|
395
|
-
cciPaneId: string
|
|
396
|
-
stochPaneId: string
|
|
397
|
-
momPaneId: string
|
|
398
|
-
wmsrPaneId: string
|
|
399
|
-
kstPaneId: string
|
|
400
|
-
fastkPaneId: string
|
|
401
|
-
macdPaneId: string
|
|
402
|
-
atrPaneId: string
|
|
403
|
-
wmaPaneId: string
|
|
404
|
-
demaPaneId: string
|
|
405
|
-
temaPaneId: string
|
|
406
|
-
hmaPaneId: string
|
|
407
|
-
kamaPaneId: string
|
|
408
|
-
sarPaneId: string
|
|
409
|
-
supertrendPaneId: string
|
|
410
|
-
keltnerPaneId: string
|
|
411
|
-
donchianPaneId: string
|
|
412
|
-
ichimokuPaneId: string
|
|
413
|
-
rocPaneId: string
|
|
414
|
-
trixPaneId: string
|
|
415
|
-
hvPaneId: string
|
|
416
|
-
parkinsonPaneId: string
|
|
417
|
-
chaikinVolPaneId: string
|
|
418
|
-
vmaPaneId: string
|
|
419
|
-
obvPaneId: string
|
|
420
|
-
pvtPaneId: string
|
|
421
|
-
vwapPaneId: string
|
|
422
|
-
cmfPaneId: string
|
|
423
|
-
mfiPaneId: string
|
|
424
|
-
pivotPaneId: string
|
|
425
|
-
fibPaneId: string
|
|
426
|
-
structurePaneId: string
|
|
427
|
-
zonesPaneId: string
|
|
428
|
-
volumeProfilePaneId: string
|
|
429
407
|
}
|
|
430
408
|
|
|
431
409
|
// ============================================================================
|
|
@@ -9,6 +9,7 @@ import { Indicator } from '../../indicators/indicatorDefinitionRegistry'
|
|
|
9
9
|
import { resolveStateKey } from '../../indicators/indicatorMetadata'
|
|
10
10
|
import type { IndicatorScheduler, ATRSchedulerConfig } from '../../indicators/scheduler'
|
|
11
11
|
import { createAtrScaleRendererPlugin } from './scale/atr_scale'
|
|
12
|
+
import { calcATRData } from '../../indicators/calculators'
|
|
12
13
|
|
|
13
14
|
type LinePoint = { x: number; y: number }
|
|
14
15
|
|
|
@@ -176,7 +177,7 @@ export function createATRRendererPlugin(options: ATRRendererOptions = {}): Rende
|
|
|
176
177
|
},
|
|
177
178
|
|
|
178
179
|
setConfig() {
|
|
179
|
-
// no-op: 配置通过 scheduler.
|
|
180
|
+
// no-op: 配置通过 scheduler.updateIndicatorConfig() 更新
|
|
180
181
|
},
|
|
181
182
|
}
|
|
182
183
|
}
|
|
@@ -234,15 +235,20 @@ export function getATRTitleInfo(
|
|
|
234
235
|
category: 'oscillator',
|
|
235
236
|
stateKey: createATRStateKey,
|
|
236
237
|
defaultPaneId: 'sub_ATR',
|
|
237
|
-
paneIdField: 'atrPaneId',
|
|
238
238
|
scaleRendererFactory: createAtrScaleRendererPlugin,
|
|
239
239
|
updateConfig: (scheduler, params, paneId) => {
|
|
240
|
-
(scheduler as IndicatorScheduler).
|
|
240
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('atr', params, paneId)
|
|
241
241
|
},
|
|
242
242
|
visibleState: { compose: createNonNegativeSparseVisibleStateComposer('atr', EMPTY_ATR_STATE) },
|
|
243
243
|
applyResult: (host, state, paneId) => {
|
|
244
244
|
host.setSharedState(createATRStateKey(paneId), state as any, 'indicator_scheduler')
|
|
245
245
|
},
|
|
246
|
+
runtime: {
|
|
247
|
+
configKey: 'atr',
|
|
248
|
+
defaultConfig: { period: 14, showATR: true },
|
|
249
|
+
computeKey: 'calcATRData',
|
|
250
|
+
compute: (data, c) => calcATRData(data, c.period),
|
|
251
|
+
},
|
|
246
252
|
})
|
|
247
253
|
class ATRIndicatorDefinition {
|
|
248
254
|
static rendererFactory = createATRRendererPlugin
|
|
@@ -8,6 +8,7 @@ import { Indicator } from '../../indicators/indicatorDefinitionRegistry'
|
|
|
8
8
|
import { resolveStateKey } from '../../indicators/indicatorMetadata'
|
|
9
9
|
import type { IndicatorPriceRangeComputer, IndicatorRenderStateComposer } from '../../indicators/indicatorMetadata'
|
|
10
10
|
import type { BOLLSchedulerConfig, IndicatorScheduler } from '../../indicators/scheduler'
|
|
11
|
+
import { calcBOLLData } from '../../indicators/calculators'
|
|
11
12
|
|
|
12
13
|
type LinePoint = { x: number; y: number }
|
|
13
14
|
|
|
@@ -169,7 +170,7 @@ const composeBOLLRenderState: IndicatorRenderStateComposer = (bundle, range, tim
|
|
|
169
170
|
composeRenderState: composeBOLLRenderState,
|
|
170
171
|
},
|
|
171
172
|
updateConfig: (scheduler, params) => {
|
|
172
|
-
(scheduler as IndicatorScheduler).
|
|
173
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('boll', params)
|
|
173
174
|
},
|
|
174
175
|
semantic: {
|
|
175
176
|
apply: (chart, indicator) => {
|
|
@@ -183,6 +184,7 @@ const composeBOLLRenderState: IndicatorRenderStateComposer = (bundle, range, tim
|
|
|
183
184
|
applyResult: (host, state, _paneId) => {
|
|
184
185
|
host.setSharedState(BOLL_STATE_KEY, state as any, 'indicator_scheduler')
|
|
185
186
|
},
|
|
187
|
+
runtime: { configKey:'boll', defaultConfig:{period:20,multiplier:2,showUpper:true,showMiddle:true,showLower:true,showBand:true}, computeKey:'calcBOLLData', compute:(data,c)=>calcBOLLData(data,c.period,c.multiplier) },
|
|
186
188
|
})
|
|
187
189
|
class BOLLDefinition {
|
|
188
190
|
static rendererFactory = createBOLLRendererPlugin
|
|
@@ -363,7 +365,7 @@ export function createBOLLRendererPlugin(): RendererPluginWithHost {
|
|
|
363
365
|
},
|
|
364
366
|
|
|
365
367
|
setConfig(_newConfig: Record<string, unknown>) {
|
|
366
|
-
// 外部控制器应调用 chart.getIndicatorScheduler().
|
|
368
|
+
// 外部控制器应调用 chart.getIndicatorScheduler().updateIndicatorConfig()
|
|
367
369
|
},
|
|
368
370
|
}
|
|
369
371
|
}
|
|
@@ -8,6 +8,7 @@ import { Indicator } from '../../indicators/indicatorDefinitionRegistry'
|
|
|
8
8
|
import { resolveStateKey } from '../../indicators/indicatorMetadata'
|
|
9
9
|
import type { IndicatorScheduler, CCISchedulerConfig } from '../../indicators/scheduler'
|
|
10
10
|
import { createCciScaleRendererPlugin } from './scale/cci_scale'
|
|
11
|
+
import { calcCCIData } from '../../indicators/calculators'
|
|
11
12
|
|
|
12
13
|
type LinePoint = { x: number; y: number }
|
|
13
14
|
|
|
@@ -202,7 +203,7 @@ const { ctx, pane, range, scrollLeft, dpr, kLineCenters, lineWebGLSurface } = co
|
|
|
202
203
|
},
|
|
203
204
|
|
|
204
205
|
setConfig() {
|
|
205
|
-
// no-op: 配置通过 scheduler.
|
|
206
|
+
// no-op: 配置通过 scheduler.updateIndicatorConfig() 更新
|
|
206
207
|
},
|
|
207
208
|
}
|
|
208
209
|
}
|
|
@@ -268,15 +269,20 @@ export function getCCITitleInfo(
|
|
|
268
269
|
category: 'oscillator',
|
|
269
270
|
stateKey: createCCIStateKey,
|
|
270
271
|
defaultPaneId: 'sub_CCI',
|
|
271
|
-
paneIdField: 'cciPaneId',
|
|
272
272
|
scaleRendererFactory: createCciScaleRendererPlugin,
|
|
273
273
|
visibleState: { compose: createCCIVisibleStateComposer('cci', EMPTY_CCI_STATE) },
|
|
274
274
|
updateConfig: (scheduler, params, paneId) => {
|
|
275
|
-
(scheduler as IndicatorScheduler).
|
|
275
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('cci', params, paneId)
|
|
276
276
|
},
|
|
277
277
|
applyResult: (host, state, paneId) => {
|
|
278
278
|
host.setSharedState(createCCIStateKey(paneId), state as any, 'indicator_scheduler')
|
|
279
279
|
},
|
|
280
|
+
runtime: {
|
|
281
|
+
configKey: 'cci',
|
|
282
|
+
defaultConfig: { period: 14, showCCI: true },
|
|
283
|
+
computeKey: 'calcCCIData',
|
|
284
|
+
compute: (data, c) => calcCCIData(data, c.period),
|
|
285
|
+
},
|
|
280
286
|
})
|
|
281
287
|
class CCIIndicatorDefinition {
|
|
282
288
|
static rendererFactory = createCCIRendererPlugin
|
|
@@ -6,6 +6,7 @@ import { Indicator } from '../../indicators/indicatorDefinitionRegistry'
|
|
|
6
6
|
import { resolveStateKey } from '../../indicators/indicatorMetadata'
|
|
7
7
|
import { createSparseVisibleStateComposer } from '../../indicators/visibleStateComposers'
|
|
8
8
|
import type { IndicatorScheduler, ChaikinVolSchedulerConfig } from '../../indicators/scheduler'
|
|
9
|
+
import { calcChaikinVolData } from '../../indicators/calculators'
|
|
9
10
|
|
|
10
11
|
const CHAIKIN_VOL_COLOR = '#f59e0b'
|
|
11
12
|
|
|
@@ -129,15 +130,20 @@ export function createChaikinVolRendererPlugin(options: { paneId?: string } = {}
|
|
|
129
130
|
category: 'oscillator',
|
|
130
131
|
stateKey: createChaikinVolStateKey,
|
|
131
132
|
defaultPaneId: 'sub_ChaikinVol',
|
|
132
|
-
paneIdField: 'chaikinVolPaneId',
|
|
133
133
|
visibleState: { compose: createSparseVisibleStateComposer('chaikinVol', EMPTY_CHAIKIN_VOL_STATE) },
|
|
134
134
|
scale: { indicatorKey: 'chaikinVol', label: 'ChaikinVol', decimals: 2 },
|
|
135
135
|
updateConfig: (scheduler, params, paneId) => {
|
|
136
|
-
(scheduler as IndicatorScheduler).
|
|
136
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('chaikinVol', params, paneId)
|
|
137
137
|
},
|
|
138
138
|
applyResult: (host, state, paneId) => {
|
|
139
139
|
host.setSharedState(createChaikinVolStateKey(paneId), state as any, 'indicator_scheduler')
|
|
140
140
|
},
|
|
141
|
+
runtime: {
|
|
142
|
+
configKey: 'chaikinVol',
|
|
143
|
+
defaultConfig: { emaPeriod: 10, rocPeriod: 10, showChaikinVol: true },
|
|
144
|
+
computeKey: 'calcChaikinVolData',
|
|
145
|
+
compute: (data, c) => calcChaikinVolData(data, c.emaPeriod, c.rocPeriod),
|
|
146
|
+
},
|
|
141
147
|
})
|
|
142
148
|
class ChaikinVolIndicatorDefinition {
|
|
143
149
|
static rendererFactory = createChaikinVolRendererPlugin
|
|
@@ -6,6 +6,7 @@ import { Indicator } from '../../indicators/indicatorDefinitionRegistry'
|
|
|
6
6
|
import { createFixedRangeSparseVisibleStateComposer } from '../../indicators/visibleStateComposers'
|
|
7
7
|
import { resolveStateKey } from '../../indicators/indicatorMetadata'
|
|
8
8
|
import type { IndicatorScheduler, CMFSchedulerConfig } from '../../indicators/scheduler'
|
|
9
|
+
import { calcCMFData } from '../../indicators/calculators'
|
|
9
10
|
|
|
10
11
|
const CMF_COLOR = '#06b6d4'
|
|
11
12
|
|
|
@@ -128,15 +129,20 @@ export function createCMFRendererPlugin(options: { paneId?: string } = {}): Rend
|
|
|
128
129
|
category: 'volume',
|
|
129
130
|
stateKey: createCMFStateKey,
|
|
130
131
|
defaultPaneId: 'sub_CMF',
|
|
131
|
-
paneIdField: 'cmfPaneId',
|
|
132
132
|
visibleState: { compose: createFixedRangeSparseVisibleStateComposer('cmf', EMPTY_CMF_STATE) },
|
|
133
133
|
scale: { indicatorKey: 'cmf', label: 'CMF', decimals: 4 },
|
|
134
134
|
updateConfig: (scheduler, params, paneId) => {
|
|
135
|
-
(scheduler as IndicatorScheduler).
|
|
135
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('cmf', params, paneId)
|
|
136
136
|
},
|
|
137
137
|
applyResult: (host, state, paneId) => {
|
|
138
138
|
host.setSharedState(createCMFStateKey(paneId), state as any, 'indicator_scheduler')
|
|
139
139
|
},
|
|
140
|
+
runtime: {
|
|
141
|
+
configKey: 'cmf',
|
|
142
|
+
defaultConfig: { period: 20, showCMF: true },
|
|
143
|
+
computeKey: 'calcCMFData',
|
|
144
|
+
compute: (data, c) => calcCMFData(data, c.period),
|
|
145
|
+
},
|
|
140
146
|
})
|
|
141
147
|
class CMFIndicatorDefinition {
|
|
142
148
|
static rendererFactory = createCMFRendererPlugin
|
|
@@ -6,6 +6,7 @@ import { Indicator } from '../../indicators/indicatorDefinitionRegistry'
|
|
|
6
6
|
import { resolveStateKey } from '../../indicators/indicatorMetadata'
|
|
7
7
|
import { createSparseVisibleStateComposer } from '../../indicators/visibleStateComposers'
|
|
8
8
|
import type { IndicatorScheduler, DEMASchedulerConfig } from '../../indicators/scheduler'
|
|
9
|
+
import { calcDEMAData } from '../../indicators/calculators'
|
|
9
10
|
|
|
10
11
|
const DEMA_COLOR = '#6366f1'
|
|
11
12
|
|
|
@@ -126,17 +127,17 @@ export function createDEMARendererPlugin(options: DEMARendererOptions = {}): Ren
|
|
|
126
127
|
category: 'main',
|
|
127
128
|
stateKey: createDEMAStateKey,
|
|
128
129
|
defaultPaneId: 'main',
|
|
129
|
-
paneIdField: 'demaPaneId',
|
|
130
130
|
allowMainPane: true,
|
|
131
131
|
mainPane: { rendererName: 'dema_main', toActiveConfig: (params, active) => ({ ...params, showDEMA: active }) },
|
|
132
132
|
visibleState: { compose: createSparseVisibleStateComposer('dema', EMPTY_DEMA_STATE) },
|
|
133
133
|
scale: { indicatorKey: 'dema', label: 'DEMA', decimals: 2 },
|
|
134
134
|
updateConfig: (scheduler, params, paneId) => {
|
|
135
|
-
(scheduler as IndicatorScheduler).
|
|
135
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('dema', params, paneId)
|
|
136
136
|
},
|
|
137
137
|
applyResult: (host, state, paneId) => {
|
|
138
138
|
host.setSharedState(createDEMAStateKey(paneId), state as any, 'indicator_scheduler')
|
|
139
139
|
},
|
|
140
|
+
runtime: { configKey:'dema', defaultConfig:{period:14,showDEMA:true}, computeKey:'calcDEMAData', compute:(data,c)=>calcDEMAData(data,c.period) },
|
|
140
141
|
})
|
|
141
142
|
class DEMADefinition {
|
|
142
143
|
static rendererFactory = createDEMARendererPlugin
|
|
@@ -5,6 +5,7 @@ import { createDonchianStateKey, EMPTY_DONCHIAN_STATE } from '../../indicators/d
|
|
|
5
5
|
import { Indicator } from '../../indicators/indicatorDefinitionRegistry'
|
|
6
6
|
import { resolveStateKey } from '../../indicators/indicatorMetadata'
|
|
7
7
|
import type { IndicatorScheduler, DonchianSchedulerConfig } from '../../indicators/scheduler'
|
|
8
|
+
import { calcDonchianData } from '../../indicators/calculators'
|
|
8
9
|
import { createBandVisibleStateComposer } from '../../indicators/visibleStateComposers'
|
|
9
10
|
|
|
10
11
|
const DONCHIAN_UPPER_COLOR = '#0891b2'
|
|
@@ -128,17 +129,17 @@ function drawLine(ctx: CanvasRenderingContext2D, pts: Point[], color: string): v
|
|
|
128
129
|
category: 'main',
|
|
129
130
|
stateKey: createDonchianStateKey,
|
|
130
131
|
defaultPaneId: 'main',
|
|
131
|
-
paneIdField: 'donchianPaneId',
|
|
132
132
|
allowMainPane: true,
|
|
133
133
|
mainPane: { rendererName: 'donchian_main', toActiveConfig: (params, active) => ({ ...params, showUpper: active, showMiddle: active, showLower: active }) },
|
|
134
134
|
scale: { indicatorKey: 'donchian', label: 'Donchian', decimals: 2 },
|
|
135
135
|
visibleState: { compose: createBandVisibleStateComposer('donchian', EMPTY_DONCHIAN_STATE, 'lower', 'upper') },
|
|
136
136
|
updateConfig: (scheduler, params, paneId) => {
|
|
137
|
-
(scheduler as IndicatorScheduler).
|
|
137
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('donchian', params, paneId)
|
|
138
138
|
},
|
|
139
139
|
applyResult: (host, state, paneId) => {
|
|
140
140
|
host.setSharedState(createDonchianStateKey(paneId), state as any, 'indicator_scheduler')
|
|
141
141
|
},
|
|
142
|
+
runtime: { configKey:'donchian', defaultConfig:{period:20,showUpper:true,showMiddle:true,showLower:true}, computeKey:'calcDonchianData', compute:(data,c)=>calcDonchianData(data,c.period) },
|
|
142
143
|
})
|
|
143
144
|
class DonchianDefinition {
|
|
144
145
|
static rendererFactory = createDonchianRendererPlugin
|
|
@@ -8,6 +8,7 @@ import { Indicator } from '../../indicators/indicatorDefinitionRegistry'
|
|
|
8
8
|
import { resolveStateKey } from '../../indicators/indicatorMetadata'
|
|
9
9
|
import type { IndicatorPriceRangeComputer, IndicatorRenderStateComposer } from '../../indicators/indicatorMetadata'
|
|
10
10
|
import type { ENESchedulerConfig, IndicatorScheduler } from '../../indicators/scheduler'
|
|
11
|
+
import { calcENEData } from '../../indicators/calculators'
|
|
11
12
|
|
|
12
13
|
type LinePoint = { x: number; y: number }
|
|
13
14
|
|
|
@@ -279,11 +280,11 @@ export function createENERendererPlugin(): RendererPluginWithHost {
|
|
|
279
280
|
* 设置配置(兼容性接口,无实际操作)
|
|
280
281
|
*
|
|
281
282
|
* 重要:本渲染器为无状态设计,不持有配置。
|
|
282
|
-
* 配置变更应通过外部控制器调用 IndicatorScheduler.
|
|
283
|
+
* 配置变更应通过外部控制器调用 IndicatorScheduler.updateIndicatorConfig() 完成。
|
|
283
284
|
*/
|
|
284
285
|
setConfig(_newConfig: Record<string, unknown>) {
|
|
285
286
|
// 无状态渲染器不存储配置
|
|
286
|
-
// 外部控制器应调用 chart.getIndicatorScheduler().
|
|
287
|
+
// 外部控制器应调用 chart.getIndicatorScheduler().updateIndicatorConfig()
|
|
287
288
|
},
|
|
288
289
|
}
|
|
289
290
|
}
|
|
@@ -301,7 +302,7 @@ export function createENERendererPlugin(): RendererPluginWithHost {
|
|
|
301
302
|
composeRenderState: composeENERenderState,
|
|
302
303
|
},
|
|
303
304
|
updateConfig: (scheduler, params) => {
|
|
304
|
-
(scheduler as IndicatorScheduler).
|
|
305
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('ene', params)
|
|
305
306
|
},
|
|
306
307
|
semantic: {
|
|
307
308
|
apply: (chart, indicator) => {
|
|
@@ -315,6 +316,7 @@ export function createENERendererPlugin(): RendererPluginWithHost {
|
|
|
315
316
|
applyResult: (host, state, _paneId) => {
|
|
316
317
|
host.setSharedState(ENE_STATE_KEY, state as any, 'indicator_scheduler')
|
|
317
318
|
},
|
|
319
|
+
runtime: { configKey:'ene', defaultConfig:{period:10,deviation:11}, computeKey:'calcENEData', compute:(data,c)=>calcENEData(data,c.period,c.deviation) },
|
|
318
320
|
})
|
|
319
321
|
class ENEDefinition {
|
|
320
322
|
static rendererFactory = createENERendererPlugin
|
|
@@ -8,6 +8,7 @@ import { Indicator } from '../../indicators/indicatorDefinitionRegistry'
|
|
|
8
8
|
import { resolveStateKey } from '../../indicators/indicatorMetadata'
|
|
9
9
|
import type { IndicatorPriceRangeComputer, IndicatorRenderStateComposer } from '../../indicators/indicatorMetadata'
|
|
10
10
|
import type { EXPMASchedulerConfig, IndicatorScheduler } from '../../indicators/scheduler'
|
|
11
|
+
import { calcEXPMAData } from '../../indicators/calculators'
|
|
11
12
|
|
|
12
13
|
type LinePoint = { x: number; y: number }
|
|
13
14
|
|
|
@@ -227,7 +228,7 @@ export function createEXPMARendererPlugin(): RendererPluginWithHost {
|
|
|
227
228
|
composeRenderState: composeEXPMARenderState,
|
|
228
229
|
},
|
|
229
230
|
updateConfig: (scheduler, params) => {
|
|
230
|
-
(scheduler as IndicatorScheduler).
|
|
231
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('expma', params)
|
|
231
232
|
},
|
|
232
233
|
semantic: {
|
|
233
234
|
apply: (chart, indicator) => {
|
|
@@ -241,6 +242,7 @@ export function createEXPMARendererPlugin(): RendererPluginWithHost {
|
|
|
241
242
|
applyResult: (host, state, _paneId) => {
|
|
242
243
|
host.setSharedState(EXPMA_STATE_KEY, state as any, 'indicator_scheduler')
|
|
243
244
|
},
|
|
245
|
+
runtime: { configKey:'expma', defaultConfig:{fastPeriod:12,slowPeriod:50}, computeKey:'calcEXPMAData', compute:(data,c)=>calcEXPMAData(data,c.fastPeriod,c.slowPeriod) },
|
|
244
246
|
})
|
|
245
247
|
class EXPMADefinition {
|
|
246
248
|
static rendererFactory = createEXPMARendererPlugin
|
|
@@ -9,6 +9,7 @@ import { createFixedRangeSparseVisibleStateComposer } from '../../indicators/vis
|
|
|
9
9
|
import { resolveStateKey } from '../../indicators/indicatorMetadata'
|
|
10
10
|
import type { IndicatorScheduler, FASTKSchedulerConfig } from '../../indicators/scheduler'
|
|
11
11
|
import { createFastkScaleRendererPlugin } from './scale/fastk_scale'
|
|
12
|
+
import { calcFASTKData } from '../../indicators/calculators'
|
|
12
13
|
|
|
13
14
|
type LinePoint = { x: number; y: number }
|
|
14
15
|
|
|
@@ -243,7 +244,7 @@ const { ctx, pane, range, scrollLeft, dpr, kLineCenters, lineWebGLSurface } = co
|
|
|
243
244
|
},
|
|
244
245
|
|
|
245
246
|
setConfig() {
|
|
246
|
-
// no-op: 配置通过 scheduler.
|
|
247
|
+
// no-op: 配置通过 scheduler.updateIndicatorConfig() 更新
|
|
247
248
|
},
|
|
248
249
|
}
|
|
249
250
|
}
|
|
@@ -309,15 +310,20 @@ export function getFASTKTitleInfo(
|
|
|
309
310
|
category: 'oscillator',
|
|
310
311
|
stateKey: createFASTKStateKey,
|
|
311
312
|
defaultPaneId: 'sub_FASTK',
|
|
312
|
-
paneIdField: 'fastkPaneId',
|
|
313
313
|
visibleState: { compose: createFixedRangeSparseVisibleStateComposer('fastk', EMPTY_FASTK_STATE) },
|
|
314
314
|
scaleRendererFactory: createFastkScaleRendererPlugin,
|
|
315
315
|
updateConfig: (scheduler, params, paneId) => {
|
|
316
|
-
(scheduler as IndicatorScheduler).
|
|
316
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('fastk', params, paneId)
|
|
317
317
|
},
|
|
318
318
|
applyResult: (host, state, paneId) => {
|
|
319
319
|
host.setSharedState(createFASTKStateKey(paneId), state as any, 'indicator_scheduler')
|
|
320
320
|
},
|
|
321
|
+
runtime: {
|
|
322
|
+
configKey: 'fastk',
|
|
323
|
+
defaultConfig: { period: 9, showFASTK: true },
|
|
324
|
+
computeKey: 'calcFASTKData',
|
|
325
|
+
compute: (data, c) => calcFASTKData(data, c.period),
|
|
326
|
+
},
|
|
321
327
|
})
|
|
322
328
|
class FASTKIndicatorDefinition {
|
|
323
329
|
static rendererFactory = createFASTKRendererPlugin
|
|
@@ -6,6 +6,7 @@ import { Indicator } from '../../indicators/indicatorDefinitionRegistry'
|
|
|
6
6
|
import { resolveStateKey } from '../../indicators/indicatorMetadata'
|
|
7
7
|
import type { IndicatorScheduler, FibSchedulerConfig } from '../../indicators/scheduler'
|
|
8
8
|
import { createExactRangePointVisibleStateComposer } from '../../indicators/visibleStateComposers'
|
|
9
|
+
import { calcFibData } from '../../indicators/calculators'
|
|
9
10
|
|
|
10
11
|
const FIB_COLORS = {
|
|
11
12
|
high: '#94a3b8',
|
|
@@ -131,17 +132,17 @@ function drawLine(ctx: CanvasRenderingContext2D, pts: Point[], color: string): v
|
|
|
131
132
|
category: 'main',
|
|
132
133
|
stateKey: createFibStateKey,
|
|
133
134
|
defaultPaneId: 'main',
|
|
134
|
-
paneIdField: 'fibPaneId',
|
|
135
135
|
allowMainPane: true,
|
|
136
136
|
mainPane: { rendererName: 'fib_main', toActiveConfig: (params, active) => ({ ...params, showLevels: active }) },
|
|
137
137
|
scale: { indicatorKey: 'fib', label: 'Fib', decimals: 4 },
|
|
138
138
|
visibleState: { compose: createExactRangePointVisibleStateComposer('fib', EMPTY_FIB_STATE, ['low', 'high']) },
|
|
139
139
|
updateConfig: (scheduler, params, paneId) => {
|
|
140
|
-
(scheduler as IndicatorScheduler).
|
|
140
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('fib', params, paneId)
|
|
141
141
|
},
|
|
142
142
|
applyResult: (host, state, paneId) => {
|
|
143
143
|
host.setSharedState(createFibStateKey(paneId), state as any, 'indicator_scheduler')
|
|
144
144
|
},
|
|
145
|
+
runtime: { configKey:'fib', defaultConfig:{period:50,showLevels:true}, computeKey:'calcFibData', compute:(data,c)=>calcFibData(data,c.period) },
|
|
145
146
|
})
|
|
146
147
|
class FibDefinition {
|
|
147
148
|
static rendererFactory = createFibRendererPlugin
|
|
@@ -6,6 +6,7 @@ import { Indicator } from '../../indicators/indicatorDefinitionRegistry'
|
|
|
6
6
|
import { resolveStateKey } from '../../indicators/indicatorMetadata'
|
|
7
7
|
import { createSparseVisibleStateComposer } from '../../indicators/visibleStateComposers'
|
|
8
8
|
import type { IndicatorScheduler, HMASchedulerConfig } from '../../indicators/scheduler'
|
|
9
|
+
import { calcHMAData } from '../../indicators/calculators'
|
|
9
10
|
|
|
10
11
|
const HMA_COLOR = '#f43f5e'
|
|
11
12
|
|
|
@@ -126,17 +127,17 @@ export function createHMARendererPlugin(options: HMARendererOptions = {}): Rende
|
|
|
126
127
|
category: 'main',
|
|
127
128
|
stateKey: createHMAStateKey,
|
|
128
129
|
defaultPaneId: 'main',
|
|
129
|
-
paneIdField: 'hmaPaneId',
|
|
130
130
|
allowMainPane: true,
|
|
131
131
|
mainPane: { rendererName: 'hma_main', toActiveConfig: (params, active) => ({ ...params, showHMA: active }) },
|
|
132
132
|
visibleState: { compose: createSparseVisibleStateComposer('hma', EMPTY_HMA_STATE) },
|
|
133
133
|
scale: { indicatorKey: 'hma', label: 'HMA', decimals: 2 },
|
|
134
134
|
updateConfig: (scheduler, params, paneId) => {
|
|
135
|
-
(scheduler as IndicatorScheduler).
|
|
135
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('hma', params, paneId)
|
|
136
136
|
},
|
|
137
137
|
applyResult: (host, state, paneId) => {
|
|
138
138
|
host.setSharedState(createHMAStateKey(paneId), state as any, 'indicator_scheduler')
|
|
139
139
|
},
|
|
140
|
+
runtime: { configKey:'hma', defaultConfig:{period:14,showHMA:true}, computeKey:'calcHMAData', compute:(data,c)=>calcHMAData(data,c.period) },
|
|
140
141
|
})
|
|
141
142
|
class HMADefinition {
|
|
142
143
|
static rendererFactory = createHMARendererPlugin
|
|
@@ -7,6 +7,7 @@ import { createNonNegativeSparseVisibleStateComposer } from '../../indicators/vi
|
|
|
7
7
|
import { Indicator } from '../../indicators/indicatorDefinitionRegistry'
|
|
8
8
|
import { resolveStateKey } from '../../indicators/indicatorMetadata'
|
|
9
9
|
import type { IndicatorScheduler, HVSchedulerConfig } from '../../indicators/scheduler'
|
|
10
|
+
import { calcHVData } from '../../indicators/calculators'
|
|
10
11
|
|
|
11
12
|
const HV_COLOR = '#7c3aed'
|
|
12
13
|
|
|
@@ -116,15 +117,15 @@ export function createHVRendererPlugin(options: { paneId?: string } = {}): Rende
|
|
|
116
117
|
category: 'oscillator',
|
|
117
118
|
stateKey: createHVStateKey,
|
|
118
119
|
defaultPaneId: 'sub_HV',
|
|
119
|
-
paneIdField: 'hvPaneId',
|
|
120
120
|
scale: { indicatorKey: 'hv', label: 'HV', decimals: 2 },
|
|
121
121
|
updateConfig: (scheduler, params, paneId) => {
|
|
122
|
-
(scheduler as IndicatorScheduler).
|
|
122
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('hv', params, paneId)
|
|
123
123
|
},
|
|
124
124
|
visibleState: { compose: createNonNegativeSparseVisibleStateComposer('hv', EMPTY_HV_STATE) },
|
|
125
125
|
applyResult: (host, state, paneId) => {
|
|
126
126
|
host.setSharedState(createHVStateKey(paneId), state as any, 'indicator_scheduler')
|
|
127
127
|
},
|
|
128
|
+
runtime: { configKey:'hv', defaultConfig:{period:20,annualizationFactor:252,showHV:true}, computeKey:'calcHVData', compute:(data,c)=>calcHVData(data,c.period,c.annualizationFactor) },
|
|
128
129
|
})
|
|
129
130
|
class HVIndicatorDefinition {
|
|
130
131
|
static rendererFactory = createHVRendererPlugin
|
|
@@ -5,6 +5,7 @@ import { createIchimokuStateKey, EMPTY_ICHIMOKU_STATE } from '../../indicators/i
|
|
|
5
5
|
import { Indicator } from '../../indicators/indicatorDefinitionRegistry'
|
|
6
6
|
import { resolveStateKey } from '../../indicators/indicatorMetadata'
|
|
7
7
|
import type { IndicatorScheduler, IchimokuSchedulerConfig } from '../../indicators/scheduler'
|
|
8
|
+
import { calcIchimokuData } from '../../indicators/calculators'
|
|
8
9
|
import { createValuePointVisibleStateComposer } from '../../indicators/visibleStateComposers'
|
|
9
10
|
|
|
10
11
|
const TENKAN_COLOR = '#dc2626'
|
|
@@ -172,17 +173,17 @@ function fillCloud(
|
|
|
172
173
|
category: 'main',
|
|
173
174
|
stateKey: createIchimokuStateKey,
|
|
174
175
|
defaultPaneId: 'main',
|
|
175
|
-
paneIdField: 'ichimokuPaneId',
|
|
176
176
|
allowMainPane: true,
|
|
177
177
|
mainPane: { rendererName: 'ichimoku_main', toActiveConfig: (params, active) => ({ ...params, showTenkan: active, showKijun: active, showSpanA: active, showSpanB: active, showChikou: active, showCloud: active }) },
|
|
178
178
|
scale: { indicatorKey: 'ichimoku', label: 'Ichimoku', decimals: 2 },
|
|
179
179
|
visibleState: { compose: createValuePointVisibleStateComposer('ichimoku', EMPTY_ICHIMOKU_STATE, ['tenkan', 'kijun', 'spanA', 'spanB', 'chikou']) },
|
|
180
180
|
updateConfig: (scheduler, params, paneId) => {
|
|
181
|
-
(scheduler as IndicatorScheduler).
|
|
181
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('ichimoku', params, paneId)
|
|
182
182
|
},
|
|
183
183
|
applyResult: (host, state, paneId) => {
|
|
184
184
|
host.setSharedState(createIchimokuStateKey(paneId), state as any, 'indicator_scheduler')
|
|
185
185
|
},
|
|
186
|
+
runtime: { configKey:'ichimoku', defaultConfig:{tenkanPeriod:9,kijunPeriod:26,spanBPeriod:52,displacement:26,showTenkan:true,showKijun:true,showSpanA:true,showSpanB:true,showCloud:true,showChikou:true}, computeKey:'calcIchimokuData', compute:(data,c)=>calcIchimokuData(data,c.tenkanPeriod,c.kijunPeriod,c.spanBPeriod,c.displacement) },
|
|
186
187
|
})
|
|
187
188
|
class IchimokuDefinition {
|
|
188
189
|
static rendererFactory = createIchimokuRendererPlugin
|