import type { IndicatorConfig } from '../types'; /** 투자관리 차트 탭 — 캔들 오버레이 표시/숨김 (저장 없음, 화면 세션만) */ export type PaperOverlayToggleKey = 'ma' | 'ichimoku' | 'bollinger'; export type PaperOverlayVisibility = Record; export const DEFAULT_PAPER_OVERLAY_VISIBILITY: PaperOverlayVisibility = { ma: true, ichimoku: true, bollinger: true, }; import { isMovingAverageOverlayType } from './chartOverlayVisibility'; export const PAPER_OVERLAY_TOGGLE_ORDER: PaperOverlayToggleKey[] = [ 'ma', 'ichimoku', 'bollinger', ]; export const PAPER_OVERLAY_LABELS: Record = { ma: '이동평균선', ichimoku: '일목균형표', bollinger: '볼린저 밴드', }; /** 우측 툴바 표시 설정 그룹 메뉴 헤더 */ export const PAPER_OVERLAY_MENU_TITLE = '표시 설정'; export function paperOverlayKeyForType(type: string): PaperOverlayToggleKey | null { if (isMovingAverageOverlayType(type)) return 'ma'; if (type === 'IchimokuCloud') return 'ichimoku'; if (type === 'BollingerBands') return 'bollinger'; return null; } export function applyPaperOverlayVisibility( indicators: IndicatorConfig[], visibility: PaperOverlayVisibility, ): IndicatorConfig[] { return indicators.map(ind => { const key = paperOverlayKeyForType(ind.type); if (!key) return ind; const visible = visibility[key]; return { ...ind, hidden: !visible }; }); } /** 캔들 오버레이 토글 — 전략·지표 유무와 무관하게 항상 노출 */ const PAPER_OVERLAY_ALWAYS_MENU: PaperOverlayToggleKey[] = ['ma', 'ichimoku', 'bollinger']; /** ChartManager.setChartOverlayVisibility 용 */ export function paperOverlayVisibilityToChart( visibility: PaperOverlayVisibility, ): import('./chartOverlayVisibility').ChartOverlayVisibility { return { ma: visibility.ma, bollinger: visibility.bollinger, ichimoku: visibility.ichimoku, candle: true }; } export function listPaperOverlayToggleItems( indicators: IndicatorConfig[], visibility: PaperOverlayVisibility, ): Array<{ key: PaperOverlayToggleKey; label: string; visible: boolean }> { const present = new Set(PAPER_OVERLAY_ALWAYS_MENU); for (const ind of indicators) { const key = paperOverlayKeyForType(ind.type); if (key) present.add(key); } return PAPER_OVERLAY_TOGGLE_ORDER .filter(key => present.has(key)) .map(key => ({ key, label: PAPER_OVERLAY_LABELS[key], visible: visibility[key], })); }