직접입력 평가로직 오류

This commit is contained in:
Macbook
2026-06-17 22:10:43 +09:00
parent 3c269db6b7
commit 40cae91d8d
6 changed files with 253 additions and 10 deletions
@@ -11,6 +11,7 @@ import {
} from './conditionPeriods';
import {
defaultInheritedThresholdField,
inferThresholdRoleForValue,
inferThresholdSymbolFromLegacy,
isThresholdFieldOrSymbol,
isThresholdSymbol,
@@ -95,13 +96,33 @@ export function migrateLogicRootForEditor(
return repairPriceExtremePairForest(migrated.root, migrated.orphans);
}
/** 저장 직전 — 상속 모드는 숫자 스냅샷·targetValue 제거 */
/** 저장 직전 — 상속 모드는 숫자 스냅샷·targetValue 제거, 직접입력은 hline 역할로 등가 정규화 */
export function normalizeConditionForPersistence(cond: ConditionDSL): ConditionDSL {
let next: ConditionDSL = { ...cond };
if (isThresholdOverridden(next)) {
if (next.targetValue != null && Number.isFinite(next.targetValue)) {
const role = inferThresholdRoleForValue(next.targetValue, next.indicatorType, {});
if (role != null) {
const { targetValue: _t, ...rest } = next;
next = { ...rest, rightField: role, thresholdOverride: false };
}
} else if (next.rightField?.startsWith('K_')) {
const role = inferThresholdSymbolFromLegacy(next.rightField, next.indicatorType, {});
if (role && isThresholdSymbol(role)) {
const { targetValue: _t, ...rest } = next;
next = { ...rest, rightField: role, thresholdOverride: false };
}
}
}
if (!isThresholdOverridden(next)) {
if (next.rightField?.startsWith('K_')) {
next.rightField = defaultInheritedThresholdField(next.indicatorType);
next.rightField = inferThresholdSymbolFromLegacy(
next.rightField,
next.indicatorType,
{},
) ?? defaultInheritedThresholdField(next.indicatorType);
}
if (!isThresholdSymbol(next.rightField)) {
const role = next.indicatorType === 'DISPARITY' || next.indicatorType === 'VOLUME_OSC'