전략편집기 수정

This commit is contained in:
Macbook
2026-05-25 17:56:25 +09:00
parent aac6454724
commit 02d14e4b2b
39 changed files with 1974 additions and 288 deletions
@@ -8,16 +8,19 @@ import {
normalizeStartCombineOp,
type EditorConditionState,
} from './strategyConditionSerde';
import {
compositeDisplayName,
normalizeCompositeCondition,
} from './compositeIndicators';
import { normalizeCompositeCondition } from './compositeIndicators';
import {
getFieldOpts,
resolveFieldOptionValue,
type DefType,
} from './strategyEditorShared';
import { parseThresholdField } from './conditionPeriods';
import {
getCompositeFieldOpts,
getCompositeLeftCandleType,
getCompositeRightCandleType,
parseThresholdField,
} from './conditionPeriods';
import { formatStrategyCandleLabel } from './strategyStartNodes';
import { formatStartCandleLabel } from './strategyStartNodes';
export interface StrategyDescriptionInput {
@@ -66,7 +69,13 @@ function fieldLabel(
def: DefType,
signalType: 'buy' | 'sell',
cond?: ReturnType<typeof normalizeCompositeCondition>,
slot?: 1 | 2,
): string {
if (cond?.composite && field && slot) {
const compositeOpts = getCompositeFieldOpts(indicatorType, slot, def, cond);
const hit = compositeOpts.find(o => o.value === field);
if (hit) return hit.label;
}
const opts = getFieldOpts(indicatorType, signalType, def, cond);
const resolved = resolveFieldOptionValue(indicatorType, field);
const hit = opts.find(o => o.value === resolved);
@@ -128,21 +137,19 @@ function describeCondition(
const ct = cond.conditionType;
if (cond.composite && cond.leftPeriod && cond.rightPeriod) {
const name = compositeDisplayName(ind).split(' + ')[0] ?? ind;
const short = `${name} ${cond.leftPeriod}기간`;
const long = `${name} ${cond.rightPeriod}기간`;
switch (ct) {
case 'GT': return `${short} 값이 ${long} 값보다 큰 경우`;
case 'LT': return `${short} 값이 ${long} 값보다 작은 경우`;
case 'GTE': return `${short} 값이 ${long} 값 이상인 경우`;
case 'LTE': return `${short} 값이 ${long} 값 이하인 경우`;
case 'CROSS_UP': return `${short} 값이 ${long} 값을 상향 돌파하는 경우`;
case 'CROSS_DOWN': return `${short} 값이 ${long} 값을 하향 돌파하는 경우`;
default: {
const label = CONDITION_LABEL[ct] ?? ct;
return `${short}과(와) ${long}을(를) 비교할 때 「${label}」 조건이 성립하는 경우`;
}
}
const left = fieldLabel(ind, cond.leftField, def, signalType, cond, 1);
const right = fieldLabel(ind, cond.rightField, def, signalType, cond, 2);
const lCt = formatStrategyCandleLabel(getCompositeLeftCandleType(cond));
const rCt = formatStrategyCandleLabel(getCompositeRightCandleType(cond));
const tfNote = lCt !== rCt
? ` (${lCt} 봉의 ${left}과(와) ${rCt} 봉의 ${right} 비교)`
: ` (${lCt} 봉)`;
const base = describeConditionType(ct, left, right, {
compareValue: cond.compareValue,
slopePeriod: cond.slopePeriod,
holdDays: cond.holdDays,
});
return base + tfNote;
}
const left = fieldLabel(ind, cond.leftField, def, signalType, cond);