@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
|
@@ -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, KAMASchedulerConfig } from '../../indicators/scheduler'
|
|
9
|
+
import { calcKAMAData } from '../../indicators/calculators'
|
|
9
10
|
|
|
10
11
|
const KAMA_COLOR = '#0ea5e9'
|
|
11
12
|
|
|
@@ -126,17 +127,17 @@ export function createKAMARendererPlugin(options: KAMARendererOptions = {}): Ren
|
|
|
126
127
|
category: 'main',
|
|
127
128
|
stateKey: createKAMAStateKey,
|
|
128
129
|
defaultPaneId: 'main',
|
|
129
|
-
paneIdField: 'kamaPaneId',
|
|
130
130
|
allowMainPane: true,
|
|
131
131
|
mainPane: { rendererName: 'kama_main', toActiveConfig: (params, active) => ({ ...params, showKAMA: active }) },
|
|
132
132
|
visibleState: { compose: createSparseVisibleStateComposer('kama', EMPTY_KAMA_STATE) },
|
|
133
133
|
scale: { indicatorKey: 'kama', label: 'KAMA', decimals: 2 },
|
|
134
134
|
updateConfig: (scheduler, params, paneId) => {
|
|
135
|
-
(scheduler as IndicatorScheduler).
|
|
135
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('kama', params, paneId)
|
|
136
136
|
},
|
|
137
137
|
applyResult: (host, state, paneId) => {
|
|
138
138
|
host.setSharedState(createKAMAStateKey(paneId), state as any, 'indicator_scheduler')
|
|
139
139
|
},
|
|
140
|
+
runtime: { configKey:'kama', defaultConfig:{period:10,fastPeriod:2,slowPeriod:30,showKAMA:true}, computeKey:'calcKAMAData', compute:(data,c)=>calcKAMAData(data,c.period,c.fastPeriod,c.slowPeriod) },
|
|
140
141
|
})
|
|
141
142
|
class KAMADefinition {
|
|
142
143
|
static rendererFactory = createKAMARendererPlugin
|
|
@@ -5,6 +5,7 @@ import { createKeltnerStateKey, EMPTY_KELTNER_STATE } from '../../indicators/kel
|
|
|
5
5
|
import { Indicator } from '../../indicators/indicatorDefinitionRegistry'
|
|
6
6
|
import { resolveStateKey } from '../../indicators/indicatorMetadata'
|
|
7
7
|
import type { IndicatorScheduler, KeltnerSchedulerConfig } from '../../indicators/scheduler'
|
|
8
|
+
import { calcKeltnerData } from '../../indicators/calculators'
|
|
8
9
|
import { createBandVisibleStateComposer } from '../../indicators/visibleStateComposers'
|
|
9
10
|
|
|
10
11
|
const KELTNER_UPPER_COLOR = '#7c3aed'
|
|
@@ -128,17 +129,17 @@ function drawLine(ctx: CanvasRenderingContext2D, pts: Point[], color: string): v
|
|
|
128
129
|
category: 'main',
|
|
129
130
|
stateKey: createKeltnerStateKey,
|
|
130
131
|
defaultPaneId: 'main',
|
|
131
|
-
paneIdField: 'keltnerPaneId',
|
|
132
132
|
allowMainPane: true,
|
|
133
133
|
mainPane: { rendererName: 'keltner_main', toActiveConfig: (params, active) => ({ ...params, showUpper: active, showMiddle: active, showLower: active }) },
|
|
134
134
|
scale: { indicatorKey: 'keltner', label: 'Keltner', decimals: 2 },
|
|
135
135
|
visibleState: { compose: createBandVisibleStateComposer('keltner', EMPTY_KELTNER_STATE, 'lower', 'upper') },
|
|
136
136
|
updateConfig: (scheduler, params, paneId) => {
|
|
137
|
-
(scheduler as IndicatorScheduler).
|
|
137
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('keltner', params, paneId)
|
|
138
138
|
},
|
|
139
139
|
applyResult: (host, state, paneId) => {
|
|
140
140
|
host.setSharedState(createKeltnerStateKey(paneId), state as any, 'indicator_scheduler')
|
|
141
141
|
},
|
|
142
|
+
runtime: { configKey:'keltner', defaultConfig:{emaPeriod:20,atrPeriod:10,multiplier:2,showUpper:true,showMiddle:true,showLower:true}, computeKey:'calcKeltnerData', compute:(data,c)=>calcKeltnerData(data,c.emaPeriod,c.atrPeriod,c.multiplier) },
|
|
142
143
|
})
|
|
143
144
|
class KeltnerDefinition {
|
|
144
145
|
static rendererFactory = createKeltnerRendererPlugin
|
|
@@ -9,6 +9,7 @@ import { Indicator } from '../../indicators/indicatorDefinitionRegistry'
|
|
|
9
9
|
import { resolveStateKey } from '../../indicators/indicatorMetadata'
|
|
10
10
|
import type { IndicatorScheduler, KSTSchedulerConfig } from '../../indicators/scheduler'
|
|
11
11
|
import { createKstScaleRendererPlugin } from './scale/kst_scale'
|
|
12
|
+
import { calcKSTData } from '../../indicators/calculators'
|
|
12
13
|
|
|
13
14
|
type LinePoint = { x: number; y: number }
|
|
14
15
|
|
|
@@ -208,7 +209,7 @@ const { ctx, pane, range, scrollLeft, dpr, kLineCenters, lineWebGLSurface } = co
|
|
|
208
209
|
},
|
|
209
210
|
|
|
210
211
|
setConfig() {
|
|
211
|
-
// no-op: 配置通过 scheduler.
|
|
212
|
+
// no-op: 配置通过 scheduler.updateIndicatorConfig() 更新
|
|
212
213
|
},
|
|
213
214
|
}
|
|
214
215
|
}
|
|
@@ -296,15 +297,15 @@ export function getKSTTitleInfo(
|
|
|
296
297
|
category: 'oscillator',
|
|
297
298
|
stateKey: createKSTStateKey,
|
|
298
299
|
defaultPaneId: 'sub_KST',
|
|
299
|
-
paneIdField: 'kstPaneId',
|
|
300
300
|
scaleRendererFactory: createKstScaleRendererPlugin,
|
|
301
301
|
updateConfig: (scheduler, params, paneId) => {
|
|
302
|
-
(scheduler as IndicatorScheduler).
|
|
302
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('kst', params, paneId)
|
|
303
303
|
},
|
|
304
304
|
visibleState: { compose: createPaddedPointVisibleStateComposer('kst', EMPTY_KST_STATE, ['kst', 'signal'] as const) },
|
|
305
305
|
applyResult: (host, state, paneId) => {
|
|
306
306
|
host.setSharedState(createKSTStateKey(paneId), state as any, 'indicator_scheduler')
|
|
307
307
|
},
|
|
308
|
+
runtime: { configKey:'kst', defaultConfig:{roc1:10,roc2:15,roc3:20,roc4:30,signalPeriod:9,showKST:true,showSignal:true}, computeKey:'calcKSTData', compute:(data,c)=>calcKSTData(data,c.roc1,c.roc2,c.roc3,c.roc4,c.signalPeriod) },
|
|
308
309
|
})
|
|
309
310
|
class KSTIndicatorDefinition {
|
|
310
311
|
static rendererFactory = createKSTRendererPlugin
|
|
@@ -5,7 +5,7 @@ import { Indicator } from '../../indicators/indicatorDefinitionRegistry'
|
|
|
5
5
|
import { resolveStateKey } from '../../indicators/indicatorMetadata'
|
|
6
6
|
import type { IndicatorPriceRangeComputer, IndicatorRenderStateComposer } from '../../indicators/indicatorMetadata'
|
|
7
7
|
import type { IndicatorScheduler } from '../../indicators/scheduler'
|
|
8
|
-
import type
|
|
8
|
+
import { calcMAData, type MAFlags } from '../../indicators/calculators'
|
|
9
9
|
import { alignToPhysicalPixelCenter } from '../../draw/pixelAlign'
|
|
10
10
|
import { resolveThemeColors } from '../../../tokens'
|
|
11
11
|
|
|
@@ -112,7 +112,7 @@ function getMAStateKey(host: PluginHost | null): string | null {
|
|
|
112
112
|
composeRenderState: composeMARenderState,
|
|
113
113
|
},
|
|
114
114
|
updateConfig: (scheduler, params) => {
|
|
115
|
-
(scheduler as IndicatorScheduler).
|
|
115
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('ma', params)
|
|
116
116
|
},
|
|
117
117
|
semantic: {
|
|
118
118
|
apply: (chart, indicator) => {
|
|
@@ -128,6 +128,7 @@ function getMAStateKey(host: PluginHost | null): string | null {
|
|
|
128
128
|
applyResult: (host, state, _paneId) => {
|
|
129
129
|
host.setSharedState(MA_STATE_KEY, state as any, 'ma_scheduler')
|
|
130
130
|
},
|
|
131
|
+
runtime: { configKey:'ma', defaultConfig:{ma5:true,ma10:true,ma20:true,ma30:true,ma60:true}, computeKey:'calcMAData', compute:(data,c)=>{const p=[5,10,20,30,60];const r:Record<number,(number|undefined)[]>={};for(const o of p){if((c as any)['ma'+o])r[o]=calcMAData(data,o)}return r} },
|
|
131
132
|
})
|
|
132
133
|
class MADefinition {
|
|
133
134
|
static rendererFactory = createMARendererPlugin
|
|
@@ -345,25 +345,25 @@ function drawMacdBarsWithCanvas2D(
|
|
|
345
345
|
ctx.fillStyle = barUpColor
|
|
346
346
|
for (let i = 0; i < barUpCount; i++) {
|
|
347
347
|
const off = i * 4
|
|
348
|
-
ctx.fillRect(barUpBuf[off]
|
|
348
|
+
ctx.fillRect(barUpBuf[off]!, barUpBuf[off + 1]!, barUpBuf[off + 2]!, barUpBuf[off + 3]!)
|
|
349
349
|
}
|
|
350
350
|
|
|
351
351
|
ctx.fillStyle = barUpLightColor
|
|
352
352
|
for (let i = 0; i < barUpLightCount; i++) {
|
|
353
353
|
const off = i * 4
|
|
354
|
-
ctx.fillRect(barUpLightBuf[off]
|
|
354
|
+
ctx.fillRect(barUpLightBuf[off]!, barUpLightBuf[off + 1]!, barUpLightBuf[off + 2]!, barUpLightBuf[off + 3]!)
|
|
355
355
|
}
|
|
356
356
|
|
|
357
357
|
ctx.fillStyle = barDownColor
|
|
358
358
|
for (let i = 0; i < barDownCount; i++) {
|
|
359
359
|
const off = i * 4
|
|
360
|
-
ctx.fillRect(barDownBuf[off]
|
|
360
|
+
ctx.fillRect(barDownBuf[off]!, barDownBuf[off + 1]!, barDownBuf[off + 2]!, barDownBuf[off + 3]!)
|
|
361
361
|
}
|
|
362
362
|
|
|
363
363
|
ctx.fillStyle = barDownLightColor
|
|
364
364
|
for (let i = 0; i < barDownLightCount; i++) {
|
|
365
365
|
const off = i * 4
|
|
366
|
-
ctx.fillRect(barDownLightBuf[off]
|
|
366
|
+
ctx.fillRect(barDownLightBuf[off]!, barDownLightBuf[off + 1]!, barDownLightBuf[off + 2]!, barDownLightBuf[off + 3]!)
|
|
367
367
|
}
|
|
368
368
|
|
|
369
369
|
ctx.restore()
|
|
@@ -471,15 +471,15 @@ export function getMACDTitleInfo(
|
|
|
471
471
|
category: 'oscillator',
|
|
472
472
|
stateKey: createMACDStateKey,
|
|
473
473
|
defaultPaneId: 'sub_MACD',
|
|
474
|
-
paneIdField: 'macdPaneId',
|
|
475
474
|
scaleRendererFactory: createMacdScaleRendererPlugin,
|
|
476
475
|
visibleState: { compose: createMACDVisibleStateComposer('macd', EMPTY_MACD_STATE) },
|
|
477
476
|
updateConfig: (scheduler, params, paneId) => {
|
|
478
|
-
(scheduler as IndicatorScheduler).
|
|
479
|
-
},
|
|
480
|
-
applyResult: (host, state, paneId) => {
|
|
481
|
-
host.setSharedState(createMACDStateKey(paneId), state as any, 'indicator_scheduler')
|
|
477
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('macd', params, paneId)
|
|
482
478
|
},
|
|
479
|
+
applyResult: (host, state, paneId) => {
|
|
480
|
+
host.setSharedState(createMACDStateKey(paneId), state as any, 'indicator_scheduler')
|
|
481
|
+
},
|
|
482
|
+
runtime: { configKey:'macd', defaultConfig:{fastPeriod:12,slowPeriod:26,signalPeriod:9,showDIF:true,showDEA:true,showBAR:true}, computeKey:'calcMACDData', compute:(data,c)=>calcMACDData(data,c.fastPeriod,c.slowPeriod,c.signalPeriod) },
|
|
483
483
|
})
|
|
484
484
|
class MACDIndicatorDefinition {
|
|
485
485
|
static rendererFactory = createMACDRendererPlugin
|
|
@@ -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, MFISchedulerConfig } from '../../indicators/scheduler'
|
|
9
|
+
import { calcMFIData } from '../../indicators/calculators'
|
|
9
10
|
|
|
10
11
|
const MFI_COLOR = '#fb923c'
|
|
11
12
|
|
|
@@ -133,15 +134,20 @@ export function createMFIRendererPlugin(options: { paneId?: string } = {}): Rend
|
|
|
133
134
|
category: 'volume',
|
|
134
135
|
stateKey: createMFIStateKey,
|
|
135
136
|
defaultPaneId: 'sub_MFI',
|
|
136
|
-
paneIdField: 'mfiPaneId',
|
|
137
137
|
visibleState: { compose: createFixedRangeSparseVisibleStateComposer('mfi', EMPTY_MFI_STATE) },
|
|
138
138
|
scale: { indicatorKey: 'mfi', label: 'MFI', decimals: 2 },
|
|
139
139
|
updateConfig: (scheduler, params, paneId) => {
|
|
140
|
-
(scheduler as IndicatorScheduler).
|
|
140
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('mfi', params, paneId)
|
|
141
141
|
},
|
|
142
142
|
applyResult: (host, state, paneId) => {
|
|
143
143
|
host.setSharedState(createMFIStateKey(paneId), state as any, 'indicator_scheduler')
|
|
144
144
|
},
|
|
145
|
+
runtime: {
|
|
146
|
+
configKey: 'mfi',
|
|
147
|
+
defaultConfig: { period: 14, showMFI: true },
|
|
148
|
+
computeKey: 'calcMFIData',
|
|
149
|
+
compute: (data, c) => calcMFIData(data, c.period),
|
|
150
|
+
},
|
|
145
151
|
})
|
|
146
152
|
class MFIIndicatorDefinition {
|
|
147
153
|
static rendererFactory = createMFIRendererPlugin
|
|
@@ -10,6 +10,7 @@ import { Indicator } from '../../indicators/indicatorDefinitionRegistry'
|
|
|
10
10
|
import { resolveStateKey } from '../../indicators/indicatorMetadata'
|
|
11
11
|
import type { IndicatorScheduler, MOMSchedulerConfig } from '../../indicators/scheduler'
|
|
12
12
|
import { createMomScaleRendererPlugin } from './scale/mom_scale'
|
|
13
|
+
import { calcMOMData } from '../../indicators/calculators'
|
|
13
14
|
|
|
14
15
|
type LinePoint = { x: number; y: number }
|
|
15
16
|
|
|
@@ -239,7 +240,7 @@ const { ctx, pane, range, scrollLeft, dpr, kLineCenters, lineWebGLSurface } = co
|
|
|
239
240
|
},
|
|
240
241
|
|
|
241
242
|
setConfig() {
|
|
242
|
-
// no-op: 配置通过 scheduler.
|
|
243
|
+
// no-op: 配置通过 scheduler.updateIndicatorConfig() 更新
|
|
243
244
|
},
|
|
244
245
|
}
|
|
245
246
|
}
|
|
@@ -305,15 +306,20 @@ export function getMOMTitleInfo(
|
|
|
305
306
|
category: 'oscillator',
|
|
306
307
|
stateKey: createMOMStateKey,
|
|
307
308
|
defaultPaneId: 'sub_MOM',
|
|
308
|
-
paneIdField: 'momPaneId',
|
|
309
309
|
scaleRendererFactory: createMomScaleRendererPlugin,
|
|
310
310
|
updateConfig: (scheduler, params, paneId) => {
|
|
311
|
-
(scheduler as IndicatorScheduler).
|
|
311
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('mom', params, paneId)
|
|
312
312
|
},
|
|
313
313
|
visibleState: { compose: createPaddedSparseVisibleStateComposer('mom', EMPTY_MOM_STATE) },
|
|
314
314
|
applyResult: (host, state, paneId) => {
|
|
315
315
|
host.setSharedState(createMOMStateKey(paneId), state as any, 'indicator_scheduler')
|
|
316
316
|
},
|
|
317
|
+
runtime: {
|
|
318
|
+
configKey: 'mom',
|
|
319
|
+
defaultConfig: { period: 10, showMOM: true },
|
|
320
|
+
computeKey: 'calcMOMData',
|
|
321
|
+
compute: (data, c) => calcMOMData(data, c.period),
|
|
322
|
+
},
|
|
317
323
|
})
|
|
318
324
|
class MOMIndicatorDefinition {
|
|
319
325
|
static rendererFactory = createMOMRendererPlugin
|
|
@@ -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, OBVSchedulerConfig } from '../../indicators/scheduler'
|
|
9
|
+
import { calcOBVData } from '../../indicators/calculators'
|
|
9
10
|
|
|
10
11
|
const OBV_COLOR = '#16a34a'
|
|
11
12
|
|
|
@@ -114,15 +115,20 @@ export function createOBVRendererPlugin(options: { paneId?: string } = {}): Rend
|
|
|
114
115
|
category: 'volume',
|
|
115
116
|
stateKey: createOBVStateKey,
|
|
116
117
|
defaultPaneId: 'sub_OBV',
|
|
117
|
-
paneIdField: 'obvPaneId',
|
|
118
118
|
visibleState: { compose: createSparseVisibleStateComposer('obv', EMPTY_OBV_STATE) },
|
|
119
119
|
scale: { indicatorKey: 'obv', label: 'OBV', decimals: 0 },
|
|
120
120
|
updateConfig: (scheduler, params, paneId) => {
|
|
121
|
-
(scheduler as IndicatorScheduler).
|
|
121
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('obv', params, paneId)
|
|
122
122
|
},
|
|
123
123
|
applyResult: (host, state, paneId) => {
|
|
124
124
|
host.setSharedState(createOBVStateKey(paneId), state as any, 'indicator_scheduler')
|
|
125
125
|
},
|
|
126
|
+
runtime: {
|
|
127
|
+
configKey: 'obv',
|
|
128
|
+
defaultConfig: { showOBV: true },
|
|
129
|
+
computeKey: 'calcOBVData',
|
|
130
|
+
compute: (data, c) => calcOBVData(data),
|
|
131
|
+
},
|
|
126
132
|
})
|
|
127
133
|
class OBVIndicatorDefinition {
|
|
128
134
|
static rendererFactory = createOBVRendererPlugin
|
|
@@ -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, ParkinsonSchedulerConfig } from '../../indicators/scheduler'
|
|
10
|
+
import { calcParkinsonData } from '../../indicators/calculators'
|
|
10
11
|
|
|
11
12
|
const PARKINSON_COLOR = '#0891b2'
|
|
12
13
|
|
|
@@ -116,15 +117,15 @@ export function createParkinsonRendererPlugin(options: { paneId?: string } = {})
|
|
|
116
117
|
category: 'oscillator',
|
|
117
118
|
stateKey: createParkinsonStateKey,
|
|
118
119
|
defaultPaneId: 'sub_Parkinson',
|
|
119
|
-
paneIdField: 'parkinsonPaneId',
|
|
120
120
|
scale: { indicatorKey: 'parkinson', label: 'Parkinson', decimals: 2 },
|
|
121
121
|
updateConfig: (scheduler, params, paneId) => {
|
|
122
|
-
(scheduler as IndicatorScheduler).
|
|
122
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('parkinson', params, paneId)
|
|
123
123
|
},
|
|
124
124
|
visibleState: { compose: createNonNegativeSparseVisibleStateComposer('parkinson', EMPTY_PARKINSON_STATE) },
|
|
125
125
|
applyResult: (host, state, paneId) => {
|
|
126
126
|
host.setSharedState(createParkinsonStateKey(paneId), state as any, 'indicator_scheduler')
|
|
127
127
|
},
|
|
128
|
+
runtime: { configKey:'parkinson', defaultConfig:{period:20,annualizationFactor:252,showParkinson:true}, computeKey:'calcParkinsonData', compute:(data,c)=>calcParkinsonData(data,c.period,c.annualizationFactor) },
|
|
128
129
|
})
|
|
129
130
|
class ParkinsonIndicatorDefinition {
|
|
130
131
|
static rendererFactory = createParkinsonRendererPlugin
|
|
@@ -6,6 +6,7 @@ import { Indicator } from '../../indicators/indicatorDefinitionRegistry'
|
|
|
6
6
|
import { resolveStateKey } from '../../indicators/indicatorMetadata'
|
|
7
7
|
import type { IndicatorScheduler, PivotSchedulerConfig } from '../../indicators/scheduler'
|
|
8
8
|
import { createExactRangePointVisibleStateComposer } from '../../indicators/visibleStateComposers'
|
|
9
|
+
import { calcPivotData } from '../../indicators/calculators'
|
|
9
10
|
|
|
10
11
|
const PP_COLOR = '#94a3b8'
|
|
11
12
|
const R_COLOR = '#dc2626'
|
|
@@ -121,17 +122,17 @@ function drawStep(ctx: CanvasRenderingContext2D, pts: Point[], color: string): v
|
|
|
121
122
|
category: 'main',
|
|
122
123
|
stateKey: createPivotStateKey,
|
|
123
124
|
defaultPaneId: 'main',
|
|
124
|
-
paneIdField: 'pivotPaneId',
|
|
125
125
|
allowMainPane: true,
|
|
126
126
|
mainPane: { rendererName: 'pivot_main', toActiveConfig: (params, active) => ({ ...params, showPP: active, showR1: active, showR2: active, showR3: active, showS1: active, showS2: active, showS3: active }) },
|
|
127
127
|
scale: { indicatorKey: 'pivot', label: 'Pivot', decimals: 2 },
|
|
128
128
|
visibleState: { compose: createExactRangePointVisibleStateComposer('pivot', EMPTY_PIVOT_STATE, ['pp', 'r1', 'r2', 'r3', 's1', 's2', 's3']) },
|
|
129
129
|
updateConfig: (scheduler, params, paneId) => {
|
|
130
|
-
(scheduler as IndicatorScheduler).
|
|
130
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('pivot', params, paneId)
|
|
131
131
|
},
|
|
132
132
|
applyResult: (host, state, paneId) => {
|
|
133
133
|
host.setSharedState(createPivotStateKey(paneId), state as any, 'indicator_scheduler')
|
|
134
134
|
},
|
|
135
|
+
runtime: { configKey:'pivot', defaultConfig:{showPP:true,showR1:true,showR2:true,showR3:true,showS1:true,showS2:true,showS3:true}, computeKey:'calcPivotData', compute:(data,c)=>calcPivotData(data) },
|
|
135
136
|
})
|
|
136
137
|
class PivotDefinition {
|
|
137
138
|
static rendererFactory = createPivotRendererPlugin
|
|
@@ -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, PVTSchedulerConfig } from '../../indicators/scheduler'
|
|
9
|
+
import { calcPVTData } from '../../indicators/calculators'
|
|
9
10
|
|
|
10
11
|
const PVT_COLOR = '#a855f7'
|
|
11
12
|
|
|
@@ -114,15 +115,20 @@ export function createPVTRendererPlugin(options: { paneId?: string } = {}): Rend
|
|
|
114
115
|
category: 'volume',
|
|
115
116
|
stateKey: createPVTStateKey,
|
|
116
117
|
defaultPaneId: 'sub_PVT',
|
|
117
|
-
paneIdField: 'pvtPaneId',
|
|
118
118
|
visibleState: { compose: createSparseVisibleStateComposer('pvt', EMPTY_PVT_STATE) },
|
|
119
119
|
scale: { indicatorKey: 'pvt', label: 'PVT', decimals: 0 },
|
|
120
120
|
updateConfig: (scheduler, params, paneId) => {
|
|
121
|
-
(scheduler as IndicatorScheduler).
|
|
121
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('pvt', params, paneId)
|
|
122
122
|
},
|
|
123
123
|
applyResult: (host, state, paneId) => {
|
|
124
124
|
host.setSharedState(createPVTStateKey(paneId), state as any, 'indicator_scheduler')
|
|
125
125
|
},
|
|
126
|
+
runtime: {
|
|
127
|
+
configKey: 'pvt',
|
|
128
|
+
defaultConfig: { showPVT: true },
|
|
129
|
+
computeKey: 'calcPVTData',
|
|
130
|
+
compute: (data, c) => calcPVTData(data),
|
|
131
|
+
},
|
|
126
132
|
})
|
|
127
133
|
class PVTIndicatorDefinition {
|
|
128
134
|
static rendererFactory = createPVTRendererPlugin
|
|
@@ -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, ROCSchedulerConfig } from '../../indicators/scheduler'
|
|
9
|
+
import { calcROCData } from '../../indicators/calculators'
|
|
9
10
|
|
|
10
11
|
const ROC_COLOR = '#0ea5e9'
|
|
11
12
|
|
|
@@ -134,15 +135,20 @@ export function createROCRendererPlugin(options: ROCRendererOptions = {}): Rende
|
|
|
134
135
|
category: 'oscillator',
|
|
135
136
|
stateKey: createROCStateKey,
|
|
136
137
|
defaultPaneId: 'sub_ROC',
|
|
137
|
-
paneIdField: 'rocPaneId',
|
|
138
138
|
visibleState: { compose: createSparseVisibleStateComposer('roc', EMPTY_ROC_STATE) },
|
|
139
139
|
scale: { indicatorKey: 'roc', label: 'ROC', decimals: 2 },
|
|
140
140
|
updateConfig: (scheduler, params, paneId) => {
|
|
141
|
-
(scheduler as IndicatorScheduler).
|
|
141
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('roc', params, paneId)
|
|
142
142
|
},
|
|
143
143
|
applyResult: (host, state, paneId) => {
|
|
144
144
|
host.setSharedState(createROCStateKey(paneId), state as any, 'indicator_scheduler')
|
|
145
145
|
},
|
|
146
|
+
runtime: {
|
|
147
|
+
configKey: 'roc',
|
|
148
|
+
defaultConfig: { period: 12, showROC: true },
|
|
149
|
+
computeKey: 'calcROCData',
|
|
150
|
+
compute: (data, c) => calcROCData(data, c.period),
|
|
151
|
+
},
|
|
146
152
|
})
|
|
147
153
|
class ROCIndicatorDefinition {
|
|
148
154
|
static rendererFactory = createROCRendererPlugin
|
|
@@ -9,6 +9,7 @@ import { createFixedRangeRecordVisibleStateComposer } from '../../indicators/vis
|
|
|
9
9
|
import { resolveStateKey } from '../../indicators/indicatorMetadata'
|
|
10
10
|
import type { IndicatorScheduler, RSISchedulerConfig } from '../../indicators/scheduler'
|
|
11
11
|
import { createRsiScaleRendererPlugin } from './scale/rsi_scale'
|
|
12
|
+
import { calcRSIData } from '../../indicators/calculators'
|
|
12
13
|
|
|
13
14
|
type LinePoint = { x: number; y: number }
|
|
14
15
|
|
|
@@ -287,7 +288,7 @@ const { ctx, pane, range, scrollLeft, dpr, kLineCenters, lineWebGLSurface } = co
|
|
|
287
288
|
},
|
|
288
289
|
|
|
289
290
|
setConfig(_newConfig: Record<string, unknown>) {
|
|
290
|
-
// 无状态渲染器:配置变更请使用 chart.getIndicatorScheduler().
|
|
291
|
+
// 无状态渲染器:配置变更请使用 chart.getIndicatorScheduler().updateIndicatorConfig()
|
|
291
292
|
},
|
|
292
293
|
}
|
|
293
294
|
}
|
|
@@ -389,15 +390,15 @@ export function getRSITitleInfo(
|
|
|
389
390
|
category: 'oscillator',
|
|
390
391
|
stateKey: createRSIStateKey,
|
|
391
392
|
defaultPaneId: 'sub_RSI',
|
|
392
|
-
paneIdField: 'rsiPaneId',
|
|
393
393
|
visibleState: { compose: createFixedRangeRecordVisibleStateComposer('rsi', EMPTY_RSI_STATE) },
|
|
394
394
|
scaleRendererFactory: createRsiScaleRendererPlugin,
|
|
395
395
|
updateConfig: (scheduler, params, paneId) => {
|
|
396
|
-
(scheduler as IndicatorScheduler).
|
|
396
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('rsi', params, paneId)
|
|
397
397
|
},
|
|
398
398
|
applyResult: (host, state, paneId) => {
|
|
399
399
|
host.setSharedState(createRSIStateKey(paneId), state as any, 'indicator_scheduler')
|
|
400
400
|
},
|
|
401
|
+
runtime: { configKey:'rsi', defaultConfig:{period1:6,period2:12,period3:24,showRSI1:true,showRSI2:true,showRSI3:true}, computeKey:'calcRSIData', compute:(data,c)=>{const p=[c.period1,c.period2,c.period3];const s=[c.showRSI1,c.showRSI2,c.showRSI3];const r:Record<number,(number|undefined)[]>={};for(let i=0;i<3;i++){if(s[i])r[p[i]]=calcRSIData(data,p[i])}return r} },
|
|
401
402
|
})
|
|
402
403
|
class RSIIndicatorDefinition {
|
|
403
404
|
static rendererFactory = createRSIRendererPlugin
|
|
@@ -5,6 +5,7 @@ import { createSARStateKey, EMPTY_SAR_STATE } from '../../indicators/sarState'
|
|
|
5
5
|
import { Indicator } from '../../indicators/indicatorDefinitionRegistry'
|
|
6
6
|
import { resolveStateKey } from '../../indicators/indicatorMetadata'
|
|
7
7
|
import type { IndicatorScheduler, SARSchedulerConfig } from '../../indicators/scheduler'
|
|
8
|
+
import { calcSARData } from '../../indicators/calculators'
|
|
8
9
|
import { createValuePointVisibleStateComposer } from '../../indicators/visibleStateComposers'
|
|
9
10
|
|
|
10
11
|
const SAR_UP_COLOR = '#22c55e'
|
|
@@ -103,17 +104,17 @@ export function createSARRendererPlugin(options: SARRendererOptions = {}): Rende
|
|
|
103
104
|
category: 'main',
|
|
104
105
|
stateKey: createSARStateKey,
|
|
105
106
|
defaultPaneId: 'main',
|
|
106
|
-
paneIdField: 'sarPaneId',
|
|
107
107
|
allowMainPane: true,
|
|
108
108
|
mainPane: { rendererName: 'sar_main', toActiveConfig: (params, active) => ({ ...params, showSAR: active }) },
|
|
109
109
|
scale: { indicatorKey: 'sar', label: 'SAR', decimals: 4 },
|
|
110
110
|
visibleState: { compose: createValuePointVisibleStateComposer('sar', EMPTY_SAR_STATE, ['value']) },
|
|
111
111
|
updateConfig: (scheduler, params, paneId) => {
|
|
112
|
-
(scheduler as IndicatorScheduler).
|
|
112
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('sar', params, paneId)
|
|
113
113
|
},
|
|
114
114
|
applyResult: (host, state, paneId) => {
|
|
115
115
|
host.setSharedState(createSARStateKey(paneId), state as any, 'indicator_scheduler')
|
|
116
116
|
},
|
|
117
|
+
runtime: { configKey:'sar', defaultConfig:{step:0.02,maxStep:0.2,showSAR:true}, computeKey:'calcSARData', compute:(data,c)=>calcSARData(data,c.step,c.maxStep) },
|
|
117
118
|
})
|
|
118
119
|
class SARDefinition {
|
|
119
120
|
static rendererFactory = createSARRendererPlugin
|
|
@@ -9,6 +9,7 @@ import { createFixedRangePointVisibleStateComposer } from '../../indicators/visi
|
|
|
9
9
|
import { resolveStateKey } from '../../indicators/indicatorMetadata'
|
|
10
10
|
import type { IndicatorScheduler, STOCHSchedulerConfig } from '../../indicators/scheduler'
|
|
11
11
|
import { createStochScaleRendererPlugin } from './scale/stoch_scale'
|
|
12
|
+
import { calcSTOCHData } from '../../indicators/calculators'
|
|
12
13
|
|
|
13
14
|
type LinePoint = { x: number; y: number }
|
|
14
15
|
|
|
@@ -267,7 +268,7 @@ const { ctx, pane, range, scrollLeft, dpr, kLineCenters, lineWebGLSurface } = co
|
|
|
267
268
|
},
|
|
268
269
|
|
|
269
270
|
setConfig() {
|
|
270
|
-
// no-op: 配置通过 scheduler.
|
|
271
|
+
// no-op: 配置通过 scheduler.updateIndicatorConfig() 更新
|
|
271
272
|
},
|
|
272
273
|
}
|
|
273
274
|
}
|
|
@@ -352,15 +353,15 @@ export function getSTOCHTitleInfo(
|
|
|
352
353
|
category: 'oscillator',
|
|
353
354
|
stateKey: createSTOCHStateKey,
|
|
354
355
|
defaultPaneId: 'sub_STOCH',
|
|
355
|
-
paneIdField: 'stochPaneId',
|
|
356
356
|
visibleState: { compose: createFixedRangePointVisibleStateComposer('stoch', EMPTY_STOCH_STATE, ['k', 'd'] as const) },
|
|
357
357
|
scaleRendererFactory: createStochScaleRendererPlugin,
|
|
358
358
|
updateConfig: (scheduler, params, paneId) => {
|
|
359
|
-
(scheduler as IndicatorScheduler).
|
|
359
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('stoch', params, paneId)
|
|
360
360
|
},
|
|
361
361
|
applyResult: (host, state, paneId) => {
|
|
362
362
|
host.setSharedState(createSTOCHStateKey(paneId), state as any, 'indicator_scheduler')
|
|
363
363
|
},
|
|
364
|
+
runtime: { configKey:'stoch', defaultConfig:{n:9,m:3,showK:true,showD:true}, computeKey:'calcSTOCHData', compute:(data,c)=>calcSTOCHData(data,c.n,c.m) },
|
|
364
365
|
})
|
|
365
366
|
class STOCHIndicatorDefinition {
|
|
366
367
|
static rendererFactory = createSTOCHRendererPlugin
|
|
@@ -7,6 +7,7 @@ import { Indicator } from '../../indicators/indicatorDefinitionRegistry'
|
|
|
7
7
|
import { createFixedUnitVisibleStateComposer } from '../../indicators/visibleStateComposers'
|
|
8
8
|
import { resolveStateKey } from '../../indicators/indicatorMetadata'
|
|
9
9
|
import type { IndicatorScheduler, StructureSchedulerConfig } from '../../indicators/scheduler'
|
|
10
|
+
import { calcStructureData } from '../../indicators/calculators'
|
|
10
11
|
|
|
11
12
|
const LABEL_FONT = '11px sans-serif'
|
|
12
13
|
|
|
@@ -116,17 +117,17 @@ export function createStructureRendererPlugin(options: { paneId?: string } = {})
|
|
|
116
117
|
category: 'sub',
|
|
117
118
|
stateKey: createStructureStateKey,
|
|
118
119
|
defaultPaneId: 'sub_Structure',
|
|
119
|
-
paneIdField: 'structurePaneId',
|
|
120
120
|
allowMainPane: true,
|
|
121
121
|
mainPane: { rendererName: 'structure_main', toActiveConfig: (params, active) => ({ ...params, showSwingLabels: active, showBOS: active, showCHOCH: active }) },
|
|
122
122
|
scale: { indicatorKey: 'structure', label: 'Structure', decimals: 2 },
|
|
123
123
|
visibleState: { compose: createFixedUnitVisibleStateComposer('structure', EMPTY_STRUCTURE_STATE) },
|
|
124
124
|
updateConfig: (scheduler, params, paneId) => {
|
|
125
|
-
(scheduler as IndicatorScheduler).
|
|
125
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('structure', params, paneId)
|
|
126
126
|
},
|
|
127
127
|
applyResult: (host, state, paneId) => {
|
|
128
128
|
host.setSharedState(createStructureStateKey(paneId), state as any, 'indicator_scheduler')
|
|
129
129
|
},
|
|
130
|
+
runtime: { configKey:'structure', defaultConfig:{leftWindow:5,rightWindow:2,breakoutSource:'close',showSwingLabels:true,showBOS:true,showCHOCH:true,showProvisional:true}, computeKey:'calcStructureData', compute:(data,c)=>calcStructureData(data,c.leftWindow,c.rightWindow,c.breakoutSource) },
|
|
130
131
|
})
|
|
131
132
|
class StructureIndicatorDefinition {
|
|
132
133
|
static rendererFactory = createStructureRendererPlugin
|
|
@@ -5,6 +5,7 @@ import { createSuperTrendStateKey, EMPTY_SUPERTREND_STATE } from '../../indicato
|
|
|
5
5
|
import { Indicator } from '../../indicators/indicatorDefinitionRegistry'
|
|
6
6
|
import { resolveStateKey } from '../../indicators/indicatorMetadata'
|
|
7
7
|
import type { IndicatorScheduler, SuperTrendSchedulerConfig } from '../../indicators/scheduler'
|
|
8
|
+
import { calcSuperTrendData } from '../../indicators/calculators'
|
|
8
9
|
import { createValuePointVisibleStateComposer } from '../../indicators/visibleStateComposers'
|
|
9
10
|
|
|
10
11
|
const ST_UP_COLOR = '#22c55e'
|
|
@@ -105,17 +106,17 @@ export function createSuperTrendRendererPlugin(options: SuperTrendRendererOption
|
|
|
105
106
|
category: 'oscillator',
|
|
106
107
|
stateKey: createSuperTrendStateKey,
|
|
107
108
|
defaultPaneId: 'sub_SuperTrend',
|
|
108
|
-
paneIdField: 'supertrendPaneId',
|
|
109
109
|
allowMainPane: true,
|
|
110
110
|
mainPane: { rendererName: 'supertrend_main', toActiveConfig: (params, active) => ({ ...params, showSuperTrend: active }) },
|
|
111
111
|
scale: { indicatorKey: 'supertrend', label: 'SuperTrend', decimals: 2 },
|
|
112
112
|
visibleState: { compose: createValuePointVisibleStateComposer('supertrend', EMPTY_SUPERTREND_STATE, ['value']) },
|
|
113
113
|
updateConfig: (scheduler, params, paneId) => {
|
|
114
|
-
(scheduler as IndicatorScheduler).
|
|
114
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('supertrend', params, paneId)
|
|
115
115
|
},
|
|
116
116
|
applyResult: (host, state, paneId) => {
|
|
117
117
|
host.setSharedState(createSuperTrendStateKey(paneId), state as any, 'indicator_scheduler')
|
|
118
118
|
},
|
|
119
|
+
runtime: { configKey:'supertrend', defaultConfig:{atrPeriod:10,multiplier:3,showSuperTrend:true}, computeKey:'calcSuperTrendData', compute:(data,c)=>calcSuperTrendData(data,c.atrPeriod,c.multiplier) },
|
|
119
120
|
})
|
|
120
121
|
class SuperTrendIndicatorDefinition {
|
|
121
122
|
static rendererFactory = createSuperTrendRendererPlugin
|
|
@@ -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, TEMASchedulerConfig } from '../../indicators/scheduler'
|
|
9
|
+
import { calcTEMAData } from '../../indicators/calculators'
|
|
9
10
|
|
|
10
11
|
const TEMA_COLOR = '#d946ef'
|
|
11
12
|
|
|
@@ -126,17 +127,17 @@ export function createTEMARendererPlugin(options: TEMARendererOptions = {}): Ren
|
|
|
126
127
|
category: 'main',
|
|
127
128
|
stateKey: createTEMAStateKey,
|
|
128
129
|
defaultPaneId: 'main',
|
|
129
|
-
paneIdField: 'temaPaneId',
|
|
130
130
|
allowMainPane: true,
|
|
131
131
|
mainPane: { rendererName: 'tema_main', toActiveConfig: (params, active) => ({ ...params, showTEMA: active }) },
|
|
132
132
|
visibleState: { compose: createSparseVisibleStateComposer('tema', EMPTY_TEMA_STATE) },
|
|
133
133
|
scale: { indicatorKey: 'tema', label: 'TEMA', decimals: 2 },
|
|
134
134
|
updateConfig: (scheduler, params, paneId) => {
|
|
135
|
-
(scheduler as IndicatorScheduler).
|
|
135
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('tema', params, paneId)
|
|
136
136
|
},
|
|
137
137
|
applyResult: (host, state, paneId) => {
|
|
138
138
|
host.setSharedState(createTEMAStateKey(paneId), state as any, 'indicator_scheduler')
|
|
139
139
|
},
|
|
140
|
+
runtime: { configKey:'tema', defaultConfig:{period:14,showTEMA:true}, computeKey:'calcTEMAData', compute:(data,c)=>calcTEMAData(data,c.period) },
|
|
140
141
|
})
|
|
141
142
|
class TEMADefinition {
|
|
142
143
|
static rendererFactory = createTEMARendererPlugin
|
|
@@ -7,6 +7,7 @@ import { createDualSparseVisibleStateComposer } from '../../indicators/visibleSt
|
|
|
7
7
|
import { Indicator } from '../../indicators/indicatorDefinitionRegistry'
|
|
8
8
|
import { resolveStateKey } from '../../indicators/indicatorMetadata'
|
|
9
9
|
import type { IndicatorScheduler, TRIXSchedulerConfig } from '../../indicators/scheduler'
|
|
10
|
+
import { calcTRIXData } from '../../indicators/calculators'
|
|
10
11
|
|
|
11
12
|
const TRIX_COLOR = '#e11d48'
|
|
12
13
|
const SIGNAL_COLOR = '#f59e0b'
|
|
@@ -150,15 +151,15 @@ function drawLine(ctx: CanvasRenderingContext2D, pts: Point[], color: string): v
|
|
|
150
151
|
category: 'oscillator',
|
|
151
152
|
stateKey: createTRIXStateKey,
|
|
152
153
|
defaultPaneId: 'sub_TRIX',
|
|
153
|
-
paneIdField: 'trixPaneId',
|
|
154
154
|
scale: { indicatorKey: 'trix', label: 'TRIX', decimals: 6 },
|
|
155
155
|
updateConfig: (scheduler, params, paneId) => {
|
|
156
|
-
(scheduler as IndicatorScheduler).
|
|
156
|
+
(scheduler as IndicatorScheduler).updateIndicatorConfig('trix', params, paneId)
|
|
157
157
|
},
|
|
158
158
|
visibleState: { compose: createDualSparseVisibleStateComposer('trix', EMPTY_TRIX_STATE) },
|
|
159
159
|
applyResult: (host, state, paneId) => {
|
|
160
160
|
host.setSharedState(createTRIXStateKey(paneId), state as any, 'indicator_scheduler')
|
|
161
161
|
},
|
|
162
|
+
runtime: { configKey:'trix', defaultConfig:{period:15,signalPeriod:9,showTRIX:true,showSignal:true}, computeKey:'calcTRIXData', compute:(data,c)=>calcTRIXData(data,c.period,c.signalPeriod) },
|
|
162
163
|
})
|
|
163
164
|
class TRIXIndicatorDefinition {
|
|
164
165
|
static rendererFactory = createTRIXRendererPlugin
|