복합지표 전략 추가
This commit is contained in:
@@ -30,6 +30,18 @@ import {
|
||||
} from '../../utils/strategyEditorShared';
|
||||
import { buildSidewaysFilterNode } from '../../utils/sidewaysFilterPaletteStorage';
|
||||
import { setStochPairSecondary } from '../../utils/stochOverboughtPair';
|
||||
import {
|
||||
setPriceExtremePairFilterLevel,
|
||||
type PriceExtremeFilterLevel,
|
||||
} from '../../utils/priceExtremeBreakoutPair';
|
||||
import {
|
||||
setInflection33PairFilterLevel,
|
||||
type Inflection33FilterLevel,
|
||||
} from '../../utils/inflection33Strategy';
|
||||
import {
|
||||
setStableStrategyPairFilterLevel,
|
||||
type StableStrategyFilterLevel,
|
||||
} from '../../utils/stableStrategyPairs';
|
||||
import {
|
||||
START_NODE_ID,
|
||||
applyEdgeHandles,
|
||||
@@ -700,7 +712,22 @@ function StrategyEditorCanvasInner({
|
||||
const handleChangeLogicGateType = useCallback((id: string, gateType: 'AND' | 'OR') => {
|
||||
const patchGate = (n: LogicNode) => (
|
||||
n.type === 'AND' || n.type === 'OR'
|
||||
? { ...n, type: gateType, stochPair: gateType === 'OR' ? n.stochPair : undefined }
|
||||
? {
|
||||
...n,
|
||||
type: gateType,
|
||||
stochPair: gateType === 'OR' ? n.stochPair : undefined,
|
||||
priceExtremePair: gateType === 'AND' ? n.priceExtremePair : undefined,
|
||||
inflection33Pair: n.inflection33Pair?.mode === 'buy'
|
||||
? (gateType === 'AND' ? n.inflection33Pair : undefined)
|
||||
: n.inflection33Pair?.mode === 'sell'
|
||||
? (gateType === 'OR' ? n.inflection33Pair : undefined)
|
||||
: undefined,
|
||||
stableStrategyPair: n.stableStrategyPair?.mode === 'buy'
|
||||
? (gateType === 'AND' ? n.stableStrategyPair : undefined)
|
||||
: n.stableStrategyPair?.mode === 'sell'
|
||||
? (gateType === 'OR' ? n.stableStrategyPair : undefined)
|
||||
: undefined,
|
||||
}
|
||||
: n
|
||||
);
|
||||
if (isOrphanNode(orphans, id)) {
|
||||
@@ -747,10 +774,76 @@ function StrategyEditorCanvasInner({
|
||||
}
|
||||
}, [root, extraRoots, orphans, def, onChange, onOrphansChange, onExtraRootsChange]);
|
||||
|
||||
const handleUpdatePriceExtremeFilterLevel = useCallback((id: string, filterLevel: PriceExtremeFilterLevel) => {
|
||||
const patchPair = (n: LogicNode) => setPriceExtremePairFilterLevel(n, filterLevel, def);
|
||||
if (isOrphanNode(orphans, id)) {
|
||||
onOrphansChange(orphans.map(o => (o.id === id ? patchPair(o) : o)));
|
||||
return;
|
||||
}
|
||||
if (root && findNodeInTree(root, id)) {
|
||||
onChange(updateNode(root, id, patchPair));
|
||||
return;
|
||||
}
|
||||
for (const [sid, branch] of Object.entries(extraRoots)) {
|
||||
if (branch && findNodeInTree(branch, id)) {
|
||||
onExtraRootsChange?.({
|
||||
...extraRoots,
|
||||
[sid]: updateNode(branch, id, patchPair),
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}, [root, extraRoots, orphans, def, onChange, onOrphansChange, onExtraRootsChange]);
|
||||
|
||||
const handleUpdateInflection33FilterLevel = useCallback((id: string, filterLevel: Inflection33FilterLevel) => {
|
||||
const patchPair = (n: LogicNode) => setInflection33PairFilterLevel(n, filterLevel, def);
|
||||
if (isOrphanNode(orphans, id)) {
|
||||
onOrphansChange(orphans.map(o => (o.id === id ? patchPair(o) : o)));
|
||||
return;
|
||||
}
|
||||
if (root && findNodeInTree(root, id)) {
|
||||
onChange(updateNode(root, id, patchPair));
|
||||
return;
|
||||
}
|
||||
for (const [sid, branch] of Object.entries(extraRoots)) {
|
||||
if (branch && findNodeInTree(branch, id)) {
|
||||
onExtraRootsChange?.({
|
||||
...extraRoots,
|
||||
[sid]: updateNode(branch, id, patchPair),
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}, [root, extraRoots, orphans, def, onChange, onOrphansChange, onExtraRootsChange]);
|
||||
|
||||
const handleUpdateStableStrategyFilterLevel = useCallback((id: string, filterLevel: StableStrategyFilterLevel) => {
|
||||
const patchPair = (n: LogicNode) => setStableStrategyPairFilterLevel(n, filterLevel, def);
|
||||
if (isOrphanNode(orphans, id)) {
|
||||
onOrphansChange(orphans.map(o => (o.id === id ? patchPair(o) : o)));
|
||||
return;
|
||||
}
|
||||
if (root && findNodeInTree(root, id)) {
|
||||
onChange(updateNode(root, id, patchPair));
|
||||
return;
|
||||
}
|
||||
for (const [sid, branch] of Object.entries(extraRoots)) {
|
||||
if (branch && findNodeInTree(branch, id)) {
|
||||
onExtraRootsChange?.({
|
||||
...extraRoots,
|
||||
[sid]: updateNode(branch, id, patchPair),
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}, [root, extraRoots, orphans, def, onChange, onOrphansChange, onExtraRootsChange]);
|
||||
|
||||
const flowCallbacks = useMemo(() => ({
|
||||
onDelete: handleDelete,
|
||||
onUpdateCondition: handleUpdateCondition,
|
||||
onUpdateStochPairSecondary: handleUpdateStochPairSecondary,
|
||||
onUpdatePriceExtremeFilterLevel: handleUpdatePriceExtremeFilterLevel,
|
||||
onUpdateInflection33FilterLevel: handleUpdateInflection33FilterLevel,
|
||||
onUpdateStableStrategyFilterLevel: handleUpdateStableStrategyFilterLevel,
|
||||
onChangeLogicGateType: handleChangeLogicGateType,
|
||||
onDropTarget: handleDropTarget,
|
||||
onDragOverTarget: handleDragOverTarget,
|
||||
@@ -758,7 +851,7 @@ function StrategyEditorCanvasInner({
|
||||
onStartCandleTypesChange: handleStartCandleTypesChange,
|
||||
onDeleteStart: handleDeleteStart,
|
||||
}), [
|
||||
handleDelete, handleUpdateCondition, handleUpdateStochPairSecondary, handleChangeLogicGateType,
|
||||
handleDelete, handleUpdateCondition, handleUpdateStochPairSecondary, handleUpdatePriceExtremeFilterLevel, handleUpdateInflection33FilterLevel, handleUpdateStableStrategyFilterLevel, handleChangeLogicGateType,
|
||||
handleDropTarget, handleDragOverTarget, handleDragLeaveTarget,
|
||||
handleStartCandleTypesChange, handleDeleteStart,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user