전략평가 화면 전략템플릿 목록탭 적용

This commit is contained in:
Macbook
2026-06-24 01:25:28 +09:00
parent 1ab5cef020
commit 0544971fd8
7 changed files with 495 additions and 55 deletions
@@ -58,6 +58,11 @@ import {
import type { PlotDef, HLineDef } from '../utils/indicatorRegistry';
import type { IndicatorVisualConfig } from './useIndicatorSettings';
import type { PaletteItem } from '../utils/strategyPaletteStorage';
import type { TemplatePaletteRow } from '../components/strategyEditor/TemplatePaletteTab';
import {
buildTemplateEvaluationPayload,
suggestTemplateEvaluationStrategyName,
} from '../utils/strategyEvaluationTemplateApply';
const AUTOSAVE_MS = 400;
@@ -478,6 +483,38 @@ export function useStrategyEvaluationEditor({
});
}, [def, handleEditorStateChange]);
const applyTemplateForEvaluation = useCallback(async (row: TemplatePaletteRow): Promise<StrategyDto | null> => {
const payload = buildTemplateEvaluationPayload(row, def);
if (!payload) {
showSaveToast('템플릿을 적용할 수 없습니다');
return null;
}
setBuyEditorState(payload.buy);
setSellEditorState(payload.sell);
setBuyOrphans(payload.buyOrphans);
setSellOrphans(payload.sellOrphans);
setFlowLayout(payload.flowLayout);
setSignalTab(payload.preferredTab);
loadedStrategyIdRef.current = null;
buyEditorStateRef.current = payload.buy;
sellEditorStateRef.current = payload.sell;
buyOrphansRef.current = payload.buyOrphans;
sellOrphansRef.current = payload.sellOrphans;
flowLayoutRef.current = payload.flowLayout;
const existingNames = new Set(strategiesRef.current.map(s => s.name.trim()));
const name = suggestTemplateEvaluationStrategyName(row.label, existingNames);
return flushPersist({
asNew: true,
name,
description: payload.strategyDescription,
silent: false,
});
}, [def, flushPersist, showSaveToast]);
const switchSignalTab = useCallback((tab: 'buy' | 'sell') => {
if (tab === signalTab) return;
void flushPersist();
@@ -497,6 +534,7 @@ export function useStrategyEvaluationEditor({
applyPalette,
applyPaletteItem,
applySidewaysFilter,
applyTemplateForEvaluation,
saving,
saveNow,
openSaveDialog,