알림목록 obv 그래프 문제 최종수정

This commit is contained in:
Macbook
2026-06-10 09:57:38 +09:00
parent 490db298b6
commit 1ec22d6ea2
12 changed files with 745 additions and 162 deletions
+17 -22
View File
@@ -15,7 +15,7 @@ import {
import { initializeIndicatorConfigForEditor } from './indicatorSettingsEditor';
import { mergeGlobalDefaultsOntoChartIndicators } from './indicatorMainConfig';
import { buildMainIndicatorConfig } from './indicatorMainConfig';
import { normalizeSmaConfig, smaPeriodKey } from './smaConfig';
import { normalizeSmaConfig } from './smaConfig';
import { normalizeIchimokuConfig } from './ichimokuConfig';
import { extractVirtualConditions } from './virtualStrategyConditions';
@@ -68,6 +68,11 @@ type GetVisual = (
cloudColors?: import('./ichimokuConfig').IchimokuCloudColors;
};
/** 알림·가상투자 등 전략에서 생성된 차트 지표 id (워크스페이스 ind_* 와 구분) */
export function isStrategyChartIndicatorId(id: string): boolean {
return id.startsWith('strat_');
}
/** 전략 DSL 기준 안정 id — getVisualConfig/settingsRevision 변경 시 id 재발급 방지 */
export function stableStrategyIndicatorId(ref: IndicatorRef): string {
const parts = [ref.registryType];
@@ -192,37 +197,25 @@ function buildOneIndicator(
...(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]);
const periods = [ref.period, ref.leftPeriod, ref.rightPeriod]
.filter((p): p is number => typeof p === 'number' && p > 0);
const p = { ...cfg.params };
if (periods.length > 0) {
periods.slice(0, 11).forEach((val, i) => {
p[smaPeriodKey(i + 1)] = val;
});
}
cfg = normalizeSmaConfig({
...cfg,
params: p,
params: mainSma?.params ?? cfg.params,
plots: mainSma?.plots ?? cfg.plots,
plotVisibility: mainSma?.plotVisibility ?? cfg.plotVisibility,
});
} else if (ref.registryType === 'OBV') {
const p = normalizeObvParams({ ...cfg.params });
const signalLen = ref.rightPeriod ?? ref.period;
if (signalLen != null && signalLen > 0) {
p.maLength = signalLen;
}
cfg = {
...cfg,
params: p,
plots: mergePlotDefs(cfg.plots, def.plots),
};
} else if (ref.period != null && ref.period > 0) {
cfg = {
...cfg,
params: { ...cfg.params, length: ref.period },
params: normalizeObvParams({ ...cfg.params }),
};
}
@@ -246,6 +239,7 @@ export function buildStrategyChartIndicators(
strategy: StrategyDto | undefined,
getParams: GetParams,
getVisual: GetVisual,
workspaceIndicators?: IndicatorConfig[],
): IndicatorConfig[] {
if (!strategy) return [];
@@ -276,6 +270,7 @@ export function buildStrategyChartIndicators(
result,
getParams,
(type, defaultPlots, defaultHlines) => getVisual(type, defaultPlots ?? [], defaultHlines ?? []),
workspaceIndicators,
);
}