obv 수정

This commit is contained in:
Macbook
2026-06-09 22:30:19 +09:00
parent 7b4fc1f811
commit 420050dfb7
4 changed files with 31 additions and 7 deletions
@@ -68,10 +68,14 @@ type GetVisual = (
cloudColors?: import('./ichimokuConfig').IchimokuCloudColors;
};
let _idSeq = 0;
function newIndId(): string {
_idSeq += 1;
return `vstrat_${_idSeq}_${Date.now()}`;
/** 전략 DSL 기준 안정 id — getVisualConfig/settingsRevision 변경 시 id 재발급 방지 */
export function stableStrategyIndicatorId(ref: IndicatorRef): string {
const parts = [ref.registryType];
if (ref.period != null) parts.push(`p${ref.period}`);
if (ref.leftPeriod != null) parts.push(`l${ref.leftPeriod}`);
if (ref.rightPeriod != null) parts.push(`r${ref.rightPeriod}`);
if (ref.targetValue != null) parts.push(`t${ref.targetValue}`);
return `strat_${parts.join('_')}`;
}
export function candleTypeToTimeframe(candleType: string): Timeframe {
@@ -171,6 +175,7 @@ function buildOneIndicator(
ref: IndicatorRef,
getParams: GetParams,
getVisual: GetVisual,
stableId?: string,
): IndicatorConfig | null {
const def = getIndicatorDef(ref.registryType);
if (!def) return null;
@@ -179,7 +184,7 @@ function buildOneIndicator(
const { plots, hlines, cloudColors } = getVisual(ref.registryType, def.plots, def.hlines ?? []);
let cfg: IndicatorConfig = {
id: newIndId(),
id: stableId ?? stableStrategyIndicatorId(ref),
type: def.type,
params: { ...params },
plots,
@@ -295,6 +300,7 @@ export function ensurePaperChartOverlays(
{ dslType: 'MA', registryType: 'SMA' },
getParams,
getVisual,
'strat_overlay_SMA',
);
if (sma) prepend.push(sma);
}
@@ -303,6 +309,7 @@ export function ensurePaperChartOverlays(
{ dslType: 'ICHIMOKU', registryType: 'IchimokuCloud' },
getParams,
getVisual,
'strat_overlay_IchimokuCloud',
);
if (ichimoku) prepend.push(ichimoku);
}
@@ -311,6 +318,7 @@ export function ensurePaperChartOverlays(
{ dslType: 'BOLLINGER', registryType: 'BollingerBands' },
getParams,
getVisual,
'strat_overlay_BollingerBands',
);
if (bb) prepend.push(bb);
}