전략평가 수정

This commit is contained in:
Macbook
2026-06-12 14:59:23 +09:00
parent c562a4eab2
commit 7579ed9de4
7 changed files with 338 additions and 5 deletions
@@ -0,0 +1,27 @@
import type { BacktestSignal } from './backendApi';
export interface BarSignalHighlight {
buy: boolean;
sell: boolean;
}
const isBuySignalType = (type: BacktestSignal['type']): boolean =>
type === 'BUY' || type === 'SHORT_EXIT';
const isSellSignalType = (type: BacktestSignal['type']): boolean =>
type === 'SELL' || type === 'SHORT_ENTRY' || type === 'PARTIAL_SELL';
/** 선택 봉 시각에 백테스트 매매 시그널이 있는지 (차트 마커와 동일 기준) */
export function resolveBarSignalHighlight(
signals: BacktestSignal[],
barTimeSec: number | null | undefined,
): BarSignalHighlight {
if (barTimeSec == null || signals.length === 0) {
return { buy: false, sell: false };
}
const atBar = signals.filter(s => s.time === barTimeSec);
return {
buy: atBar.some(s => isBuySignalType(s.type)),
sell: atBar.some(s => isSellSignalType(s.type)),
};
}