import type { IndicatorConfig } from '../types'; import { getIndicatorDef } from './indicatorRegistry'; /** 실시간 차트 — 캔들 pane 오버레이 표시/숨김 (세션만, DB 미저장) */ export type ChartOverlayToggleKey = 'ma' | 'bollinger' | 'ichimoku' | 'candle'; export type ChartOverlayVisibility = Record; export const DEFAULT_CHART_OVERLAY_VISIBILITY: ChartOverlayVisibility = { ma: true, bollinger: true, ichimoku: true, candle: true, }; export const CHART_OVERLAY_TOGGLE_ORDER: ChartOverlayToggleKey[] = [ 'ma', 'bollinger', 'ichimoku', 'candle', ]; export const CHART_OVERLAY_LABELS: Record = { ma: '이동평균선', bollinger: '볼린저 밴드', ichimoku: '일목균형표', candle: '캔들차트', }; /** 캔들 pane 오버레이 이동평균 그룹 (SMA·EMA·WMA·HMA 등 Moving Averages 카테고리) */ export function isMovingAverageOverlayType(type: string): boolean { const def = getIndicatorDef(type); return def?.category === 'Moving Averages' && def.overlay === true; } export function chartOverlayKeyForType(type: string): ChartOverlayToggleKey | null { if (isMovingAverageOverlayType(type)) return 'ma'; if (type === 'IchimokuCloud') return 'ichimoku'; if (type === 'BollingerBands') return 'bollinger'; return null; } /** * 오버레이 그룹 + 지표 자체 hidden 을 반영한 표시용 config (entry.config 는 변경하지 않음). * ChartManager 는 _chartOverlayVisibility 로 직접 제어 — 이 헬퍼는 UI/필터용. */ export function effectiveConfigForOverlay( config: IndicatorConfig, visibility: ChartOverlayVisibility, ): IndicatorConfig { const key = chartOverlayKeyForType(config.type); if (!key) return config; if (config.hidden === true) return config; if (!visibility[key]) return { ...config, hidden: true }; return config; } export function listChartOverlayToggleItems( visibility: ChartOverlayVisibility, ): Array<{ key: ChartOverlayToggleKey; label: string; visible: boolean }> { return CHART_OVERLAY_TOGGLE_ORDER.map(key => ({ key, label: CHART_OVERLAY_LABELS[key], visible: visibility[key], })); }