직접입력값 평가오류 수정

This commit is contained in:
Macbook
2026-06-18 00:15:18 +09:00
parent 9c832a3ab8
commit ea8576d756
9 changed files with 128 additions and 90 deletions
@@ -3,6 +3,7 @@ import type { ConditionDSL, LogicNode } from './strategyTypes';
import type { DefType } from './strategyEditorShared';
import { getDefaultConditionFields } from './strategyEditorShared';
import {
canonicalizeConditionThreshold,
isThresholdOverridden,
isValuePeriodOverridden,
parseThresholdField,
@@ -43,14 +44,14 @@ function migrateConditionThreshold(
if (isThresholdOverridden(cond)) {
const val = coerceTargetValue(cond.targetValue) ?? parseThresholdField(cond.rightField);
if (val != null) {
const role = inferThresholdRoleForValue(val, cond.indicatorType, def.hlThresh);
const role = inferThresholdRoleForValue(val, cond.indicatorType, {});
if (role != null) {
const { targetValue: _t, ...rest } = cond;
return migrateConditionPeriod({ ...rest, rightField: role, thresholdOverride: false });
}
}
if (cond.rightField?.startsWith('K_')) {
const role = inferThresholdSymbolFromLegacyExact(cond.rightField, cond.indicatorType, def.hlThresh);
const role = inferThresholdSymbolFromLegacyExact(cond.rightField, cond.indicatorType, {});
if (role != null) {
const { targetValue: _t, ...rest } = cond;
return migrateConditionPeriod({ ...rest, rightField: role, thresholdOverride: false });
@@ -61,8 +62,8 @@ function migrateConditionThreshold(
let rightField = cond.rightField;
if (rightField?.startsWith('K_')) {
rightField = inferThresholdSymbolFromLegacyExact(rightField, cond.indicatorType, def.hlThresh)
?? inferThresholdSymbolFromLegacy(rightField, cond.indicatorType, def.hlThresh);
rightField = inferThresholdSymbolFromLegacyExact(rightField, cond.indicatorType, {})
?? inferThresholdSymbolFromLegacy(rightField, cond.indicatorType, {});
}
if (!rightField || (!isThresholdSymbol(rightField) && !rightField.startsWith('K_'))) {
const defaults = getDefaultConditionFields(cond.indicatorType, signalType, def);
@@ -139,47 +140,7 @@ export function migrateLogicRootForEditor(
/** 저장·표시·평가 공통 — K_50 등을 HL_MID 로 접기 */
export function normalizeConditionForPersistence(cond: ConditionDSL): ConditionDSL {
let next: ConditionDSL = {
...cond,
indicatorType: cond.indicatorType?.toUpperCase?.() ?? cond.indicatorType,
};
const targetNum = coerceTargetValue(next.targetValue);
if (isThresholdOverridden(next)) {
if (targetNum != null) {
const role = inferThresholdRoleForValue(targetNum, next.indicatorType, {});
if (role != null) {
const { targetValue: _t, ...rest } = next;
next = { ...rest, rightField: role, thresholdOverride: false };
}
} else if (next.rightField?.startsWith('K_')) {
const role = inferThresholdSymbolFromLegacyExact(next.rightField, next.indicatorType, {});
if (role != null) {
const { targetValue: _t, ...rest } = next;
next = { ...rest, rightField: role, thresholdOverride: false };
}
}
}
if (!isThresholdOverridden(next)) {
if (next.rightField?.startsWith('K_')) {
next.rightField = inferThresholdSymbolFromLegacyExact(
next.rightField,
next.indicatorType,
{},
) ?? defaultInheritedThresholdField(next.indicatorType);
}
if (!isThresholdSymbol(next.rightField)) {
const role = next.indicatorType === 'DISPARITY' || next.indicatorType === 'VOLUME_OSC'
|| next.indicatorType === 'TRIX'
? THRESHOLD_HL_MID : THRESHOLD_HL_OVER;
if (parseThresholdField(next.rightField) != null || !next.rightField) {
next.rightField = role;
}
}
const { targetValue: _t, ...rest } = next;
next = { ...rest, thresholdOverride: false };
}
let next = canonicalizeConditionThreshold(cond);
if (!isValuePeriodOverridden(next)) {
const prefix = VALUE_FIELD_PREFIX[next.indicatorType];