macd 그래프 오류

This commit is contained in:
Macbook
2026-06-16 01:23:59 +09:00
parent d34a824174
commit ea13347be8
2 changed files with 68 additions and 39 deletions
+21 -2
View File
@@ -88,6 +88,10 @@ function resolveMergedHLinePrice(
savedPrice: number,
defPrice: number,
): number {
// MACD·TRIX 등 registry 기본 중앙선이 0인 지표: 잘못 저장된 종가급 값(69872 등) 교정
if (roleLabel === '중앙선' && defPrice === 0) {
return 0;
}
if (roleLabel === '중앙선' && savedPrice === 0 && defPrice !== 0) {
return defPrice;
}
@@ -205,7 +209,7 @@ export function normalizeHLines(
const hasUnder = withFixedLabels.some(h => getLabel(h) === '침체선');
if (hasOver && hasCenter && hasUnder) {
return withFixedLabels.sort((a, b) => b.price - a.price);
return clampZeroCenterHLines(withFixedLabels, defaults).sort((a, b) => b.price - a.price);
}
const result = [...withFixedLabels];
@@ -245,7 +249,22 @@ export function normalizeHLines(
});
}
return result.sort((a, b) => b.price - a.price);
return clampZeroCenterHLines(result, defaults).sort((a, b) => b.price - a.price);
}
/** registry 기본 중앙선이 0인 지표에서 잘못 저장된 중앙선 가격을 0으로 고정 */
function clampZeroCenterHLines(hlines: HLineDef[], defaults?: HLineDef[]): HLineDef[] {
const defPrices = (defaults ?? []).map(d => d.price);
const defCenter = (defaults ?? []).find(
d => (d.label ?? getHLineLabel(d.price, defPrices)) === '중앙선',
);
if (defCenter?.price !== 0) return hlines;
const prices = hlines.map(h => h.price);
return hlines.map(h => {
const lbl = h.label ?? getHLineLabel(h.price, prices);
return lbl === '중앙선' ? { ...h, price: 0 } : h;
});
}
export interface IndicatorDef {