백테스팅 워밍업데이터 적용

This commit is contained in:
Macbook
2026-06-12 01:41:34 +09:00
parent 0d338fffe4
commit 74b0ea4ab6
12 changed files with 335 additions and 52 deletions
+16
View File
@@ -1,6 +1,7 @@
import type { ChartType, Timeframe } from '../types';
import type { BacktestResultRecord } from './backendApi';
import { formatUpbitKrwPrice } from './safeFormat';
import { INDICATOR_WARMUP } from './upbitApi';
export function toUpbitMarket(symbol: string): string {
return symbol.startsWith('KRW-') ? symbol : `KRW-${symbol}`;
@@ -40,6 +41,21 @@ export function resolveBacktestRecordExecTimeframe(record: BacktestResultRecord)
return '1m';
}
/** 백테스트 결과 차트 로드 봉 수 — 평가 구간 + 지표 워밍업 (차트 SMA와 백테스트 엔진 정렬) */
export function resolveBacktestChartBarCount(record: BacktestResultRecord): number {
const evalCount = record.barCount > 0 ? record.barCount : 200;
let warmup = INDICATOR_WARMUP;
if (record.executionSnapshotJson) {
try {
const snap = JSON.parse(record.executionSnapshotJson) as { warmupBarCount?: number };
if (typeof snap.warmupBarCount === 'number' && snap.warmupBarCount > 0) {
warmup = snap.warmupBarCount;
}
} catch { /* ignore */ }
}
return evalCount + warmup;
}
const CHART_TYPE_KO: Record<ChartType, string> = {
candlestick: '캔들스틱',
bar: '바',