보조지표 설정 저장 오류

This commit is contained in:
Macbook
2026-06-16 01:08:58 +09:00
parent e93164deda
commit d34a824174
9 changed files with 80 additions and 57 deletions
+11 -44
View File
@@ -9,14 +9,11 @@ import {
getIndicatorDef,
getHLineLabel,
mergePlotDefs,
normalizeObvParams,
type HLineDef,
} from './indicatorRegistry';
import { initializeIndicatorConfigForEditor } from './indicatorSettingsEditor';
import { mergeGlobalDefaultsOntoChartIndicators } from './indicatorMainConfig';
import { buildMainIndicatorConfig } from './indicatorMainConfig';
import { normalizeSmaConfig } from './smaConfig';
import { normalizeIchimokuConfig } from './ichimokuConfig';
import { buildChartIndicatorConfig } from './indicatorPaneMerge';
import type { EditorConditionState } from './strategyConditionSerde';
import { collectUiEvaluationTimeframes } from './strategyTimeframeSync';
@@ -66,7 +63,9 @@ type GetVisual = (
) => {
plots: import('./indicatorRegistry').PlotDef[];
hlines: HLineDef[];
plotVisibility?: Record<string, boolean>;
cloudColors?: import('./ichimokuConfig').IchimokuCloudColors;
bandBackground?: import('../types').HlinesBackground;
};
/** 알림·가상투자 등 전략에서 생성된 차트 지표 id (워크스페이스 ind_* 와 구분) */
@@ -205,46 +204,14 @@ function buildOneIndicator(
getVisual: GetVisual,
stableId?: string,
): IndicatorConfig | null {
const def = getIndicatorDef(ref.registryType);
if (!def) return null;
const params = getParams(ref.registryType, def.defaultParams as ParamRecord);
const { plots, hlines, cloudColors } = getVisual(ref.registryType, def.plots, def.hlines ?? []);
let cfg: IndicatorConfig = {
id: stableId ?? stableStrategyIndicatorId(ref),
type: def.type,
params: { ...params },
plots,
hlines,
...(cloudColors ? { cloudColors } : {}),
};
/**
* 모든 보조지표의 기간(period)은 반드시 지표 설정(getParams, DB 저장값)을 사용한다.
* 전략 DSL 조건의 period/leftPeriod/rightPeriod 로 덮어쓰지 않는다.
* 조건의 기간 필드는 부정확(미설정 시 1 등)할 수 있어 SMA(1)=본선 겹침 등
* 잘못된 그래프를 만든다. 설정에 저장된 값(예: OBV 신호선 9일)이 유일한 기준.
* cfg.params 는 이미 getParams(저장 설정값) 결과이므로 그대로 사용.
*/
if (ref.registryType === 'SMA') {
const mainSma = buildMainIndicatorConfig('SMA', [], getParams, getVisual as Parameters<typeof buildMainIndicatorConfig>[3]);
cfg = normalizeSmaConfig({
...cfg,
params: mainSma?.params ?? cfg.params,
plots: mainSma?.plots ?? cfg.plots,
plotVisibility: mainSma?.plotVisibility ?? cfg.plotVisibility,
});
} else if (ref.registryType === 'OBV') {
cfg = {
...cfg,
params: normalizeObvParams({ ...cfg.params }),
};
}
if (ref.registryType === 'IchimokuCloud') {
cfg = normalizeIchimokuConfig(cfg);
}
const id = stableId ?? stableStrategyIndicatorId(ref);
let cfg = buildChartIndicatorConfig(
ref.registryType,
id,
getParams,
getVisual as Parameters<typeof buildChartIndicatorConfig>[3],
);
if (!cfg) return null;
if (ref.targetValue != null) {
cfg = { ...cfg, hlines: applyTargetHlines(cfg.hlines ?? [], ref.targetValue) };