macd 그래프 오류
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user