fix: 일목균형표 구름 - 프로덕션 빌드 SpanA==SpanB 버그 수정
프로덕션 빌드에서 lightweight-charts-indicators 라이브러리가 plot3(SpanA)와 plot4(SpanB)에 동일한 값을 반환하는 버그 존재. SpanA==SpanB 시 폴리곤 면적=0으로 구름이 보이지 않음. 해결: 라이브러리의 plot3/plot4 대신 convPlot(전환선)/basePlot(기준선)과 rawBars 기반 _donchianAt()으로 SpanA/SpanB를 직접 계산 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1382,34 +1382,31 @@ export class ChartManager {
|
||||
|
||||
/** 구름 데이터 빌드: 과거(역사 데이터) + 미래 26봉 포함 */
|
||||
private _buildIchimokuCloudData(
|
||||
spanAPlot: PlotData,
|
||||
spanBPlot: PlotData,
|
||||
convPlot: PlotData,
|
||||
basePlot: PlotData,
|
||||
_spanAPlot: PlotData,
|
||||
_spanBPlot: PlotData,
|
||||
convPlot: PlotData,
|
||||
basePlot: PlotData,
|
||||
displacement: number,
|
||||
laggingPeriod: number,
|
||||
): IchimokuCloudPoint[] {
|
||||
// 과거 구름
|
||||
const bMap = new Map(
|
||||
(spanBPlot ?? []).filter(p => p.value != null && !isNaN(p.value)).map(p => [p.time, p.value])
|
||||
);
|
||||
const historical: IchimokuCloudPoint[] = (spanAPlot ?? [])
|
||||
.filter(p => p.value != null && !isNaN(p.value) && bMap.has(p.time))
|
||||
.map(p => ({ time: p.time as number, spanA: p.value, spanB: bMap.get(p.time)! }));
|
||||
// 라이브러리의 plot3/plot4(SpanA/SpanB)는 프로덕션 빌드에서
|
||||
// 동일한 값을 반환하는 버그가 있으므로, convPlot(전환선)/basePlot(기준선)과
|
||||
// rawBars 기반 _donchianAt으로 직접 재계산한다.
|
||||
const N = this.rawBars.length;
|
||||
const historical: IchimokuCloudPoint[] = [];
|
||||
|
||||
// 진단 로그: spanA/spanB 원본 값 비교
|
||||
const aValid = (spanAPlot ?? []).filter(p => p.value != null && !isNaN(p.value));
|
||||
const bValid = (spanBPlot ?? []).filter(p => p.value != null && !isNaN(p.value));
|
||||
const aLast3 = aValid.slice(-3).map(p => p.value);
|
||||
const bLast3 = bValid.slice(-3).map(p => p.value);
|
||||
const histLast3 = historical.slice(-3).map(p => ({ a: p.spanA, b: p.spanB, eq: p.spanA === p.spanB }));
|
||||
const maxHistDiff = historical.length > 0 ? Math.max(...historical.map(p => Math.abs(p.spanA - p.spanB))) : 0;
|
||||
console.log('[IchimokuCloud] BUILD RAW: spanA last3=', aLast3, 'spanB last3=', bLast3,
|
||||
'| hist last3=', JSON.stringify(histLast3), '| maxDiff=', maxHistDiff,
|
||||
'| histLen=', historical.length, 'sameRef=', spanAPlot === spanBPlot);
|
||||
for (let i = displacement - 1; i < N; i++) {
|
||||
const srcIdx = i - (displacement - 1);
|
||||
const conv = convPlot[srcIdx]?.value;
|
||||
const base = basePlot[srcIdx]?.value;
|
||||
if (conv == null || isNaN(conv) || base == null || isNaN(base)) continue;
|
||||
const spanA = (conv + base) / 2;
|
||||
const spanB = this._donchianAt(srcIdx, laggingPeriod);
|
||||
if (spanB === null) continue;
|
||||
historical.push({ time: this.rawBars[i].time, spanA, spanB });
|
||||
}
|
||||
|
||||
// 미래 구름
|
||||
const N = this.rawBars.length;
|
||||
if (N < 2) return historical;
|
||||
const interval = this.rawBars[N - 1].time - this.rawBars[N - 2].time;
|
||||
const lastTime = this.rawBars[N - 1].time;
|
||||
|
||||
Reference in New Issue
Block a user