전략 시간봉 오류 수정
This commit is contained in:
@@ -311,7 +311,7 @@ function parseMultiStartWrapper(dsl: LogicNode): EditorConditionState | null {
|
||||
children.forEach((tf, index) => {
|
||||
const candleTypes = readTimeframeCandleTypes(tf as LogicNode);
|
||||
const candleType = candleTypes[0];
|
||||
const branchRoot = tf.children?.[0] ?? null;
|
||||
const branchRoot = syncSubtreeCandleTypes(tf.children?.[0] ?? null, candleType);
|
||||
if (index === 0) {
|
||||
startMeta[START_NODE_ID] = { candleTypes, candleType };
|
||||
primaryRoot = branchRoot;
|
||||
@@ -341,10 +341,11 @@ export function decodeConditionForEditor(dsl: LogicNode | null): EditorCondition
|
||||
|
||||
if (dsl.type === 'TIMEFRAME') {
|
||||
const candleTypes = readTimeframeCandleTypes(dsl);
|
||||
const primary = candleTypes[0];
|
||||
return {
|
||||
root: dsl.children?.[0] ?? null,
|
||||
root: syncSubtreeCandleTypes(dsl.children?.[0] ?? null, primary),
|
||||
startMeta: {
|
||||
[START_NODE_ID]: { candleTypes, candleType: candleTypes[0] },
|
||||
[START_NODE_ID]: { candleTypes, candleType: primary },
|
||||
},
|
||||
extraStartIds: [],
|
||||
extraRoots: {},
|
||||
@@ -354,7 +355,7 @@ export function decodeConditionForEditor(dsl: LogicNode | null): EditorCondition
|
||||
|
||||
const inferred = inferPrimaryCandleFromTree(dsl);
|
||||
return {
|
||||
root: dsl,
|
||||
root: syncSubtreeCandleTypes(dsl, inferred),
|
||||
startMeta: {
|
||||
[START_NODE_ID]: { candleTypes: [inferred], candleType: inferred },
|
||||
},
|
||||
@@ -429,8 +430,21 @@ export function collectDslBranches(dsl: LogicNode | null): ConditionBranch[] {
|
||||
return collectEditorBranches(decodeConditionForEditor(dsl));
|
||||
}
|
||||
|
||||
/** DB가 1m 기본값만 갖고 편집기 localStorage에 다른 분봉이 있을 때 localStorage 우선 */
|
||||
function pickMergedStartCandleTypes(decoded: string[], stored?: string[]): string[] {
|
||||
const fromDb = normalizeCandleTypesList(decoded);
|
||||
const fromStored = stored?.length ? normalizeCandleTypesList(stored) : [];
|
||||
const dbIsLegacyDefault = fromDb.length === 1 && fromDb[0] === '1m';
|
||||
const storedDiffers = fromStored.length > 0
|
||||
&& (fromStored.length !== fromDb.length || fromStored.some((ct, i) => ct !== fromDb[i]));
|
||||
if (storedDiffers && (dbIsLegacyDefault || fromDb.length === 0)) {
|
||||
return fromStored;
|
||||
}
|
||||
return fromDb;
|
||||
}
|
||||
|
||||
/**
|
||||
* 전략 로드 시 startMeta 병합 — DB DSL에서 복원한 시간봉이 localStorage보다 우선.
|
||||
* 전략 로드 시 startMeta 병합 — DB가 1m 기본값만 있고 localStorage에 다른 분봉이 있으면 localStorage 우선.
|
||||
*/
|
||||
export function mergeStartMetaForLoad(
|
||||
decoded: Record<string, StartNodeMeta>,
|
||||
@@ -441,7 +455,10 @@ export function mergeStartMetaForLoad(
|
||||
...stored,
|
||||
};
|
||||
for (const [startId, meta] of Object.entries(decoded)) {
|
||||
const types = getStartCandleTypes(meta);
|
||||
const types = pickMergedStartCandleTypes(
|
||||
getStartCandleTypes(meta),
|
||||
stored?.[startId] ? getStartCandleTypes(stored[startId]) : undefined,
|
||||
);
|
||||
merged[startId] = { candleTypes: types, candleType: types[0] };
|
||||
}
|
||||
return merged;
|
||||
|
||||
Reference in New Issue
Block a user