백테스트 전략이름, 이동평균선 그래프 오류 수정
This commit is contained in:
@@ -2,6 +2,7 @@ import type { IndicatorConfig } from '../types';
|
||||
import { enrichIndicatorConfig, getIndicatorDef } from './indicatorRegistry';
|
||||
import { normalizeSmaConfig, createDefaultSmaPlotVisibility } from './smaConfig';
|
||||
import { normalizeIchimokuConfig } from './ichimokuConfig';
|
||||
import { buildMainIndicatorConfig } from './indicatorMainConfig';
|
||||
import type { PlotDef, HLineDef } from './indicatorRegistry';
|
||||
import type { IchimokuCloudColors } from './ichimokuConfig';
|
||||
|
||||
@@ -195,6 +196,13 @@ export function buildChartIndicatorConfig(
|
||||
};
|
||||
|
||||
if (type === 'SMA') {
|
||||
const mainSma = buildMainIndicatorConfig(type, [], getParams, getVisualConfig);
|
||||
if (mainSma?.plotVisibility) {
|
||||
cfg.plotVisibility = mainSma.plotVisibility;
|
||||
}
|
||||
if (mainSma?.plots?.length) {
|
||||
cfg.plots = mainSma.plots;
|
||||
}
|
||||
cfg = normalizeSmaConfig({
|
||||
...cfg,
|
||||
plotVisibility: cfg.plotVisibility ?? createDefaultSmaPlotVisibility(),
|
||||
|
||||
@@ -32,12 +32,15 @@ function sourceLabel(source: string): string {
|
||||
}
|
||||
|
||||
function resolveStrategyLabel(
|
||||
t: PaperTradeDto,
|
||||
trades: PaperTradeDto[],
|
||||
strategyNames: Record<number, string>,
|
||||
): string {
|
||||
if (t.strategyName) return t.strategyName;
|
||||
if (t.strategyId != null) {
|
||||
return strategyNames[t.strategyId] ?? `전략 #${t.strategyId}`;
|
||||
for (const t of trades) {
|
||||
if (t.strategyName?.trim()) return t.strategyName.trim();
|
||||
}
|
||||
const first = trades[0];
|
||||
if (first?.strategyId != null) {
|
||||
return strategyNames[first.strategyId] ?? `전략 #${first.strategyId}`;
|
||||
}
|
||||
return '수동 매매';
|
||||
}
|
||||
@@ -83,7 +86,7 @@ export function buildLiveExecutionItems(
|
||||
return {
|
||||
id: key,
|
||||
symbol: first.symbol,
|
||||
strategyLabel: resolveStrategyLabel(first, strategyNames),
|
||||
strategyLabel: resolveStrategyLabel(sorted, strategyNames),
|
||||
sourceLabel: sourceLabel(first.source),
|
||||
timeframe: first.candleType ?? 'unknown',
|
||||
executionType: first.executionType ?? undefined,
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* 전략 ID → 이름 해석 (목록에 없거나 삭제된 전략 포함)
|
||||
*/
|
||||
import { loadStrategyForNotification, type StrategyDto } from './backendApi';
|
||||
|
||||
/** 전략 목록 + 누락 ID별 단건 조회로 이름 맵 보강 */
|
||||
export async function enrichStrategyNameMap(
|
||||
base: Record<number, string>,
|
||||
ids: Iterable<number | null | undefined>,
|
||||
): Promise<Record<number, string>> {
|
||||
const out = { ...base };
|
||||
const missing = [...new Set(
|
||||
[...ids]
|
||||
.map(id => (id != null && id > 0 ? Math.trunc(id) : null))
|
||||
.filter((id): id is number => id != null && !out[id]),
|
||||
)];
|
||||
if (!missing.length) return out;
|
||||
|
||||
await Promise.all(missing.map(async id => {
|
||||
try {
|
||||
const s = await loadStrategyForNotification(id);
|
||||
if (s?.name?.trim()) out[id] = s.name.trim();
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}));
|
||||
return out;
|
||||
}
|
||||
|
||||
export function strategyNamesFromList(list: StrategyDto[]): Record<number, string> {
|
||||
const out: Record<number, string> = {};
|
||||
for (const s of list) {
|
||||
if (s.id != null && s.id > 0 && s.name?.trim()) {
|
||||
out[s.id] = s.name.trim();
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -10,7 +10,8 @@ import {
|
||||
getHLineLabel,
|
||||
type HLineDef,
|
||||
} from './indicatorRegistry';
|
||||
import { createDefaultSmaPlotVisibility, normalizeSmaConfig, smaPeriodKey } from './smaConfig';
|
||||
import { buildMainIndicatorConfig } from './indicatorMainConfig';
|
||||
import { normalizeSmaConfig, smaPeriodKey } from './smaConfig';
|
||||
import { normalizeIchimokuConfig } from './ichimokuConfig';
|
||||
import { extractVirtualConditions } from './virtualStrategyConditions';
|
||||
|
||||
@@ -183,18 +184,20 @@ function buildOneIndicator(
|
||||
};
|
||||
|
||||
if (ref.registryType === 'SMA') {
|
||||
const mainSma = buildMainIndicatorConfig('SMA', [], getParams, getVisual as Parameters<typeof buildMainIndicatorConfig>[3]);
|
||||
const periods = [ref.period, ref.leftPeriod, ref.rightPeriod]
|
||||
.filter((p): p is number => typeof p === 'number' && p > 0);
|
||||
const p = { ...cfg.params };
|
||||
if (periods.length > 0) {
|
||||
const p = { ...cfg.params };
|
||||
periods.slice(0, 11).forEach((val, i) => {
|
||||
p[smaPeriodKey(i + 1)] = val;
|
||||
});
|
||||
cfg = { ...cfg, params: p };
|
||||
}
|
||||
cfg = normalizeSmaConfig({
|
||||
...cfg,
|
||||
plotVisibility: cfg.plotVisibility ?? createDefaultSmaPlotVisibility(),
|
||||
params: p,
|
||||
plots: mainSma?.plots ?? cfg.plots,
|
||||
plotVisibility: mainSma?.plotVisibility ?? cfg.plotVisibility,
|
||||
});
|
||||
} else if (ref.period != null && ref.period > 0) {
|
||||
cfg = {
|
||||
|
||||
Reference in New Issue
Block a user