목록형 전략평가 수정
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user