보조지표 기준값 변경시 전략편집기 연동

This commit is contained in:
Macbook
2026-05-27 09:53:19 +09:00
parent 8876dbd752
commit cd5502d302
13 changed files with 288 additions and 110 deletions
+4 -14
View File
@@ -69,27 +69,17 @@ function parseFieldPeriod(field?: string): number | null {
return Number.isFinite(n) && n > 0 ? n : null;
}
/** 조건 노드의 RSI 등 값(좌측) 기간 — 오버라이드 시 DSL, 아니면 보조지표 설정(DEF) */
/** 조건 노드의 RSI 등 값(좌측) 기간 — true=전략 전용, false/미설정=보조지표 설정(DEF) 상속 */
export function isValuePeriodOverridden(cond: ConditionDSL): boolean {
if (cond.valuePeriodOverride === true) return true;
if (cond.valuePeriodOverride === false) return false;
if (cond.period != null && cond.period > 0) return true;
if (cond.leftPeriod != null && cond.leftPeriod > 0) return true;
if (isValuePeriodFieldStored(cond.indicatorType, cond.leftField)) return true;
return false;
return cond.valuePeriodOverride === true;
}
export function isRightPeriodOverridden(cond: ConditionDSL): boolean {
if (cond.rightPeriodOverride === true) return true;
if (cond.rightPeriodOverride === false) return false;
if (cond.rightPeriod != null && cond.rightPeriod > 0) return true;
return false;
return cond.rightPeriodOverride === true;
}
export function isThresholdOverridden(cond: ConditionDSL): boolean {
if (cond.thresholdOverride === true) return true;
if (cond.thresholdOverride === false) return false;
return false;
return cond.thresholdOverride === true;
}
/** 조건 노드의 RSI 등 값(좌측) 기간 */
@@ -0,0 +1,17 @@
import type { IndicatorConfig } from '../types';
/** 설정 화면 — DB 기본값 변경 여부 비교용 */
export function indicatorDefaultsFingerprint(c: IndicatorConfig): string {
return JSON.stringify({
type: c.type,
params: c.params,
plots: c.plots,
plotVisibility: c.plotVisibility,
hlines: c.hlines,
hlinesBackground: c.hlinesBackground,
bandBackground: c.bandBackground,
cloudColors: c.cloudColors,
lastValueVisible: c.lastValueVisible,
timeframeVisibility: c.timeframeVisibility,
});
}
+5 -11
View File
@@ -39,20 +39,14 @@ function applyGlobalDefToCondition(
if (cond.composite) {
const { short, long } = getCompositeDefaultPeriods(cond.indicatorType, def as CompositePeriodDef);
if (!isValuePeriodOverridden(cond)) {
const inheritLeft = !isValuePeriodOverridden(cond);
const inheritRight = !isRightPeriodOverridden(cond);
if (inheritLeft || inheritRight) {
next = syncCompositeFields({
...next,
composite: true,
leftPeriod: short,
valuePeriodOverride: false,
});
}
if (!isRightPeriodOverridden(cond)) {
next = syncCompositeFields({
...next,
composite: true,
rightPeriod: long,
rightPeriodOverride: false,
...(inheritLeft ? { leftPeriod: short, valuePeriodOverride: false as const } : null),
...(inheritRight ? { rightPeriod: long, rightPeriodOverride: false as const } : null),
});
}
return next;
+8 -7
View File
@@ -1086,13 +1086,10 @@ export function makeNodeOptionsFromPalette(data: {
if (data.composite) {
return {
composite: true,
leftPeriod: data.shortPeriod,
rightPeriod: data.longPeriod,
leftCandleType: data.leftCandleType,
rightCandleType: data.rightCandleType,
};
}
if (data.period != null) return { period: data.period };
return undefined;
}
@@ -1106,12 +1103,16 @@ export const makeNode = (
if (type === 'operator') return { id: genId(), type: value as LogicNodeType, children: [] };
if (options?.composite) {
let condition = makeCompositeCondition(value, signalType, DEF);
if (options.leftPeriod != null || options.rightPeriod != null
|| options.leftCandleType != null || options.rightCandleType != null) {
condition = {
...condition,
valuePeriodOverride: false,
rightPeriodOverride: false,
thresholdOverride: false,
};
if (options.leftCandleType != null || options.rightCandleType != null) {
condition = syncCompositeFields({
...condition,
leftPeriod: options.leftPeriod ?? condition.leftPeriod,
rightPeriod: options.rightPeriod ?? condition.rightPeriod,
composite: true,
leftCandleType: options.leftCandleType ?? condition.leftCandleType,
rightCandleType: options.rightCandleType ?? condition.rightCandleType,
});
+11 -1
View File
@@ -116,7 +116,17 @@ export function loadPaletteItems(kind: PaletteItemKind): PaletteItem[] {
try {
const stored = parseStored(localStorage.getItem(key));
if (stored && stored.length > 0) {
return mergeMissingBuiltIns(stored.map(i => ({ ...i, kind })), kind, defaults);
return mergeMissingBuiltIns(
stored.map(i => ({
...i,
kind,
...(i.builtIn
? { period: undefined, shortPeriod: undefined, longPeriod: undefined }
: {}),
})),
kind,
defaults,
);
}
} catch { /* ignore */ }
return seedItems(kind, defaults);