전략 시간봉 오류 수정
This commit is contained in:
@@ -24,6 +24,7 @@ import { findLogicNode, getIndicatorPeriodLabel } from '../utils/strategyFlowLay
|
||||
import {
|
||||
decodeConditionForEditor,
|
||||
encodeConditionForSave,
|
||||
mergeStartMetaForLoad,
|
||||
addExtraStartSection,
|
||||
hasMultipleStartSections,
|
||||
normalizeStartCombineOp,
|
||||
@@ -500,7 +501,7 @@ export default function StrategyEditorPage({ theme }: Props) {
|
||||
setBuyLayout({
|
||||
positions: stored?.buy.positions ?? {},
|
||||
edgeHandles: stored?.buy.edgeHandles ?? {},
|
||||
startMeta: stored?.buy.startMeta ?? buyDecoded.startMeta,
|
||||
startMeta: mergeStartMetaForLoad(buyDecoded.startMeta, stored?.buy.startMeta),
|
||||
extraStartIds: stored?.buy.extraStartIds?.length ? stored.buy.extraStartIds : buyDecoded.extraStartIds,
|
||||
extraRoots: stored?.buy.extraRoots && Object.keys(stored.buy.extraRoots).length
|
||||
? stored.buy.extraRoots
|
||||
@@ -510,7 +511,7 @@ export default function StrategyEditorPage({ theme }: Props) {
|
||||
setSellLayout({
|
||||
positions: stored?.sell.positions ?? {},
|
||||
edgeHandles: stored?.sell.edgeHandles ?? {},
|
||||
startMeta: stored?.sell.startMeta ?? sellDecoded.startMeta,
|
||||
startMeta: mergeStartMetaForLoad(sellDecoded.startMeta, stored?.sell.startMeta),
|
||||
extraStartIds: stored?.sell.extraStartIds?.length ? stored.sell.extraStartIds : sellDecoded.extraStartIds,
|
||||
extraRoots: stored?.sell.extraRoots && Object.keys(stored.sell.extraRoots).length
|
||||
? stored.sell.extraRoots
|
||||
@@ -538,6 +539,7 @@ export default function StrategyEditorPage({ theme }: Props) {
|
||||
return;
|
||||
}
|
||||
setSaveNameError(false);
|
||||
if (editorMode === 'graph') layoutFlushRef.current?.();
|
||||
const encodedBuy = encodeConditionForSave(buyEditorState);
|
||||
const encodedSell = encodeConditionForSave(sellEditorState);
|
||||
if (!encodedBuy && !encodedSell) { showSnack('조건을 최소 1개 추가하세요', false); return; }
|
||||
|
||||
@@ -161,7 +161,6 @@ export function encodeConditionForSave(state: EditorConditionState): LogicNode |
|
||||
if (branches.length === 0) return null;
|
||||
if (branches.length === 1) {
|
||||
const { candleType, root } = branches[0];
|
||||
if (normalizeStartCandleType(candleType) === DEFAULT_START_CANDLE) return root;
|
||||
return wrapTimeframe(candleType, root);
|
||||
}
|
||||
|
||||
@@ -257,3 +256,20 @@ export function collectEditorBranches(state: EditorConditionState): ConditionBra
|
||||
export function collectDslBranches(dsl: LogicNode | null): ConditionBranch[] {
|
||||
return collectEditorBranches(decodeConditionForEditor(dsl));
|
||||
}
|
||||
|
||||
/**
|
||||
* 전략 로드 시 startMeta 병합 — DB DSL에서 복원한 시간봉이 localStorage보다 우선.
|
||||
*/
|
||||
export function mergeStartMetaForLoad(
|
||||
decoded: Record<string, StartNodeMeta>,
|
||||
stored?: Record<string, StartNodeMeta> | null,
|
||||
): Record<string, StartNodeMeta> {
|
||||
const merged: Record<string, StartNodeMeta> = {
|
||||
...defaultStartMeta(),
|
||||
...stored,
|
||||
};
|
||||
for (const [startId, meta] of Object.entries(decoded)) {
|
||||
merged[startId] = { candleType: normalizeStartCandleType(meta.candleType) };
|
||||
}
|
||||
return merged;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user