보조지표 직접입력 오류 수정

This commit is contained in:
Macbook
2026-06-17 23:28:17 +09:00
parent 5236a6cd46
commit 3130de113b
5 changed files with 68 additions and 23 deletions
+24 -16
View File
@@ -82,6 +82,15 @@ function parseFieldPeriod(field?: string): number | null {
return Number.isFinite(n) && n > 0 ? n : null;
}
/** 조건 DSL에서 Ta4j 평가용 기간 — period 필드·leftField 접미사 */
export function resolveConditionDslPeriod(c: ConditionDSL): number | undefined {
if (c.period != null && c.period > 0) return c.period;
const fromLeft = parseFieldPeriod(c.leftField);
if (fromLeft) return fromLeft;
if (c.composite && c.leftPeriod != null && c.leftPeriod > 0) return c.leftPeriod;
return undefined;
}
/** 조건 노드의 RSI 등 값(좌측) 기간 — true=전략 전용, false/미설정=보조지표 설정(DEF) 상속 */
export function isValuePeriodOverridden(cond: ConditionDSL): boolean {
return cond.valuePeriodOverride === true;
@@ -271,7 +280,7 @@ export function activateDirectThresholdInput(
?? getChartReferenceThreshold(cond, side, inheritedField, def)
?? parseThresholdField(side === 'right' ? cond.rightField : cond.leftField);
if (value == null || !Number.isFinite(value)) return cond;
return setConditionThreshold(cond, side, value, def, { directInput: true });
return setConditionThreshold(cond, side, value, def);
}
export function setConditionThreshold(
@@ -302,22 +311,21 @@ export function setConditionThreshold(
? getChartReferenceThreshold(cond, side, inheritedField, def)
: null;
if (!options?.directInput) {
const matchedRole = def
? inferThresholdRoleForValue(value, cond.indicatorType, def.hlThresh)
: null;
if (matchedRole != null) {
const { targetValue: _t, ...rest } = cond;
return { ...rest, [fieldKey]: matchedRole, thresholdOverride: false };
}
// 30/50/70 등 hline 역할과 정확히 일치하면 직접입력·프리셋 모두 HL_* 로 통일 (평가 일치)
const matchedRole = def
? inferThresholdRoleForValue(value, cond.indicatorType, def.hlThresh)
: null;
if (matchedRole != null) {
const { targetValue: _t, ...rest } = cond;
return { ...rest, [fieldKey]: matchedRole, thresholdOverride: false };
}
if (chartRef != null && Math.abs(chartRef - value) < 0.0001) {
const role = isThresholdSymbol(inheritedField)
? inheritedField
: (side === 'right' ? THRESHOLD_HL_OVER : inheritedField);
const { targetValue: _t, ...rest } = cond;
return { ...rest, [fieldKey]: role, thresholdOverride: false };
}
if (!options?.directInput && chartRef != null && Math.abs(chartRef - value) < 0.0001) {
const role = isThresholdSymbol(inheritedField)
? inheritedField
: (side === 'right' ? THRESHOLD_HL_OVER : inheritedField);
const { targetValue: _t, ...rest } = cond;
return { ...rest, [fieldKey]: role, thresholdOverride: false };
}
return {