목록형 전략평가 수정

This commit is contained in:
Macbook
2026-06-18 02:05:09 +09:00
parent b96fc64c91
commit bde65b6ef8
3 changed files with 51 additions and 22 deletions
+23 -17
View File
@@ -34,6 +34,7 @@ import {
normalizeStartCombineOp,
updateStartCombineOp,
updateStartCandleTypes,
updateBranchRoot,
type EditorConditionState,
} from '../utils/strategyConditionSerde';
import { migrateLogicRootForEditor } from '../utils/strategyConditionNormalize';
@@ -778,6 +779,7 @@ export default function StrategyEditorPage({
const resolved = typeof next === 'function'
? next(currentEditorStateRef.current)
: next;
currentEditorStateRef.current = resolved;
setCurrentRoot(resolved.root);
setCurrentLayout(prev => ({
...prev,
@@ -790,12 +792,12 @@ export default function StrategyEditorPage({
}, [setCurrentRoot, setCurrentLayout, scheduleStrategyPersist]);
const handleStartCandleTypesChange = useCallback((startId: string, candleTypes: string[]) => {
handleEditorStateChange(updateStartCandleTypes(currentEditorState, startId, candleTypes));
}, [handleEditorStateChange, currentEditorState]);
handleEditorStateChange(prev => updateStartCandleTypes(prev, startId, candleTypes));
}, [handleEditorStateChange]);
const handleStartCombineOpChange = useCallback((op: StartCombineOp) => {
handleEditorStateChange(updateStartCombineOp(currentEditorState, op));
}, [handleEditorStateChange, currentEditorState]);
handleEditorStateChange(prev => updateStartCombineOp(prev, op));
}, [handleEditorStateChange]);
const switchSignalTab = useCallback((tab: 'buy' | 'sell') => {
if (editorMode === 'graph') layoutFlushRef.current?.();
@@ -1328,9 +1330,9 @@ export default function StrategyEditorPage({
}, []);
const handleAddStartSection = useCallback(() => {
handleEditorStateChange(addExtraStartSection(currentEditorState));
handleEditorStateChange(prev => addExtraStartSection(prev));
bumpLayoutSeed(layoutStrategyKey, signalTab);
}, [handleEditorStateChange, currentEditorState, bumpLayoutSeed, layoutStrategyKey, signalTab]);
}, [handleEditorStateChange, bumpLayoutSeed, layoutStrategyKey, signalTab]);
const applyPalette = useCallback((type: string, value: string, _label: string, composite = false) => {
if (type === 'start') {
@@ -1338,12 +1340,15 @@ export default function StrategyEditorPage({
return;
}
const newNode = makeNode(type, value, signalTab, DEF, composite ? { composite: true } : undefined);
const root = currentRoot;
if (!root) setCurrentRoot(newNode);
else if (type === 'operator') setCurrentRoot(mergeAtRoot(root, newNode, true));
else setCurrentRoot(mergeAtRoot(root, newNode, false));
scheduleStrategyPersist();
}, [signalTab, DEF, currentRoot, setCurrentRoot, handleAddStartSection, scheduleStrategyPersist]);
handleEditorStateChange(prev => {
const root = prev.root;
if (!root) return updateBranchRoot(prev, START_NODE_ID, newNode);
if (type === 'operator') {
return updateBranchRoot(prev, START_NODE_ID, mergeAtRoot(root, newNode, true));
}
return updateBranchRoot(prev, START_NODE_ID, mergeAtRoot(root, newNode, false));
});
}, [signalTab, DEF, handleEditorStateChange, handleAddStartSection]);
const applyPaletteItem = useCallback((item: PaletteItem) => {
const stochPair = isStochOverboughtPairPaletteValue(item.value);
@@ -1361,11 +1366,12 @@ export default function StrategyEditorPage({
? buildStableStrategyTree(item.value, DEF)
: makeNode('indicator', item.value, signalTab, DEF, composite ? { composite: true } : undefined);
if (!newNode) return;
const root = currentRoot;
if (!root) setCurrentRoot(newNode);
else setCurrentRoot(mergeAtRoot(root, newNode, false));
scheduleStrategyPersist();
}, [signalTab, DEF, currentRoot, setCurrentRoot, scheduleStrategyPersist]);
handleEditorStateChange(prev => {
const root = prev.root;
if (!root) return updateBranchRoot(prev, START_NODE_ID, newNode);
return updateBranchRoot(prev, START_NODE_ID, mergeAtRoot(root, newNode, false));
});
}, [signalTab, DEF, handleEditorStateChange]);
const applySidewaysFilter = useCallback((filterId: string) => {
const newNode = buildSidewaysFilterNode(filterId, DEF, sidewaysPalette);