전략평가 수정
This commit is contained in:
@@ -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)),
|
||||
};
|
||||
}
|
||||
@@ -51,6 +51,8 @@ export async function fetchEvaluationSnapshotAtBar(
|
||||
rows: baseRows.map(r => normalizeConditionRow({ ...r, currentValue: null, satisfied: null })),
|
||||
updatedAt: Date.now(),
|
||||
matchRate: 0,
|
||||
overallEntryMet: null,
|
||||
overallExitMet: null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -62,5 +64,7 @@ export async function fetchEvaluationSnapshotAtBar(
|
||||
rows,
|
||||
updatedAt: status.updatedAt || Date.now(),
|
||||
matchRate: coerceFiniteNumber(status.matchRate) ?? 0,
|
||||
overallEntryMet: status.overallEntryMet ?? null,
|
||||
overallExitMet: status.overallExitMet ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user