61 lines
2.2 KiB
TypeScript
61 lines
2.2 KiB
TypeScript
/**
|
|
* 알림 미니 차트 — 메인 실시간 차트(slot0)와 동일한 지표 설정 사용
|
|
*
|
|
* strat_* + buildStrategyChartIndicators 경로는 period=1 → maLength 오염 등
|
|
* 메인 ind_* 워크스페이스 설정과 어긋난다. 워크스페이스에 동일 type 이 있으면
|
|
* ind_* 인스턴스를 그대로 쓴다 (params·plots·maLength·id 모두 동일).
|
|
*/
|
|
import type { IndicatorConfig } from '../types';
|
|
import { enrichIndicatorConfig } from './indicatorRegistry';
|
|
|
|
/**
|
|
* @param strategyIndicators mergeGlobalDefaults·ensurePaperChartOverlays 적용 후 목록
|
|
* @param workspaceIndicators slot0.indicators (메인 차트와 동일)
|
|
*/
|
|
export function resolveNotificationChartIndicators(
|
|
strategyIndicators: IndicatorConfig[],
|
|
workspaceIndicators: IndicatorConfig[],
|
|
): IndicatorConfig[] {
|
|
if (!workspaceIndicators.length) {
|
|
return strategyIndicators.map(enrichIndicatorConfig);
|
|
}
|
|
|
|
const wsByType = new Map(workspaceIndicators.map(i => [i.type, i]));
|
|
|
|
return strategyIndicators.map(stratInd => {
|
|
const ws = wsByType.get(stratInd.type);
|
|
if (!ws) return enrichIndicatorConfig(stratInd);
|
|
return enrichIndicatorConfig({
|
|
...ws,
|
|
hidden: stratInd.hidden ?? ws.hidden,
|
|
mergedWith: stratInd.mergedWith ?? ws.mergedWith,
|
|
});
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 워크스페이스에 필요한 type 이 모두 있으면 strat 빌드 없이 slot0 지표만 사용.
|
|
* (메인 ChartSlot 과 동일한 ind_* 설정·순서)
|
|
*/
|
|
export function buildNotificationChartIndicators(
|
|
withOverlays: IndicatorConfig[],
|
|
workspaceIndicators: IndicatorConfig[],
|
|
): IndicatorConfig[] {
|
|
const neededTypes = new Set(withOverlays.map(i => i.type));
|
|
|
|
if (workspaceIndicators.length > 0
|
|
&& [...neededTypes].every(t => workspaceIndicators.some(w => w.type === t))) {
|
|
const wsByType = new Map(workspaceIndicators.map(w => [w.type, w]));
|
|
return withOverlays.map(ind => {
|
|
const ws = wsByType.get(ind.type)!;
|
|
return enrichIndicatorConfig({
|
|
...ws,
|
|
hidden: ind.hidden ?? ws.hidden,
|
|
mergedWith: ind.mergedWith ?? ws.mergedWith,
|
|
});
|
|
});
|
|
}
|
|
|
|
return resolveNotificationChartIndicators(withOverlays, workspaceIndicators);
|
|
}
|