투자관리 화면 수정

This commit is contained in:
Macbook
2026-05-31 17:02:39 +09:00
parent 78f00dbaa5
commit d6c2f3e451
8 changed files with 251 additions and 13 deletions
+2 -1
View File
@@ -113,8 +113,9 @@ export function areIchimokuSpanLinesVisible(config: IndicatorConfig): boolean {
);
}
/** 구름 영역을 그릴 수 있는지 (선행스팬 + 상승/하락 구름 중 하나 이상 on) */
/** 구름 영역을 그릴 수 있는지 (지표 표시 on + 선행스팬 + 구름 색상 설정) */
export function isIchimokuCloudVisible(config: IndicatorConfig): boolean {
if (config.hidden === true) return false;
if (!areIchimokuSpanLinesVisible(config)) return false;
const colors = resolveIchimokuCloudColors(config.cloudColors);
return colors.bullishVisible !== false || colors.bearishVisible !== false;
@@ -0,0 +1,69 @@
import type { IndicatorConfig } from '../types';
/** 투자관리 차트 탭 — 캔들 오버레이 표시/숨김 (저장 없음, 화면 세션만) */
export type PaperOverlayToggleKey = 'ma' | 'ichimoku' | 'bollinger';
export type PaperOverlayVisibility = Record<PaperOverlayToggleKey, boolean>;
export const DEFAULT_PAPER_OVERLAY_VISIBILITY: PaperOverlayVisibility = {
ma: true,
ichimoku: true,
bollinger: true,
};
const MA_TYPES = new Set(['SMA', 'EMA']);
export const PAPER_OVERLAY_TOGGLE_ORDER: PaperOverlayToggleKey[] = [
'ma',
'ichimoku',
'bollinger',
];
export const PAPER_OVERLAY_LABELS: Record<PaperOverlayToggleKey, string> = {
ma: '이동평균선',
ichimoku: '일목균형표',
bollinger: '볼린저 밴드',
};
/** 우측 툴바 표시 설정 그룹 메뉴 헤더 */
export const PAPER_OVERLAY_MENU_TITLE = '표시 설정';
export function paperOverlayKeyForType(type: string): PaperOverlayToggleKey | null {
if (MA_TYPES.has(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', 'bollinger'];
export function listPaperOverlayToggleItems(
indicators: IndicatorConfig[],
visibility: PaperOverlayVisibility,
): Array<{ key: PaperOverlayToggleKey; label: string; visible: boolean }> {
const present = new Set<PaperOverlayToggleKey>(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],
}));
}
@@ -248,6 +248,41 @@ export function buildStrategyChartIndicators(
return result;
}
const MA_OVERLAY_TYPES = new Set(['SMA', 'EMA']);
/**
* 투자관리 차트 탭 — 캔들 영역에 이동평균(SMA)·볼린저밴드를 기본 포함
* (전략 조건에 없어도 표시 설정 메뉴로 표시/숨김 가능)
*/
export function ensurePaperChartOverlays(
indicators: IndicatorConfig[],
getParams: GetParams,
getVisual: GetVisual,
): IndicatorConfig[] {
const hasMa = indicators.some(i => MA_OVERLAY_TYPES.has(i.type));
const hasBb = indicators.some(i => i.type === 'BollingerBands');
const prepend: IndicatorConfig[] = [];
if (!hasMa) {
const sma = buildOneIndicator(
{ dslType: 'MA', registryType: 'SMA' },
getParams,
getVisual,
);
if (sma) prepend.push(sma);
}
if (!hasBb) {
const bb = buildOneIndicator(
{ dslType: 'BOLLINGER', registryType: 'BollingerBands' },
getParams,
getVisual,
);
if (bb) prepend.push(bb);
}
if (prepend.length === 0) return indicators;
return [...prepend, ...indicators];
}
/** 가상투자 차트 — 전략 지표 + 기본 일목균형표 */
export function buildVirtualTradingChartIndicators(
strategy: StrategyDto | undefined,