Files
goldenChart/frontend/src/utils/tradeExecutionMode.ts
T
2026-06-23 00:12:23 +09:00

39 lines
1.3 KiB
TypeScript

import type { BacktestSettingsDto } from './backendApi';
export type TradeExecutionMode = 'SCAN_SIGNALS' | 'BACKTEST_ENGINE';
export const TRADE_EXECUTION_MODE_OPTIONS: {
value: TradeExecutionMode;
label: string;
desc: string;
}[] = [
{
value: 'BACKTEST_ENGINE',
label: '백테스트 엔진 (슬리피지·리스크 반영)',
desc: '슬리피지, 손절/익절, 진입/청산가 기준. 실제 수익률 분석에 가깝습니다.',
},
{
value: 'SCAN_SIGNALS',
label: '조건 스캔 (현재가·DSL 충족)',
desc: '차트 마커·조건 패널과 동일. 시그널 시점 현재가 기준 체결.',
},
];
export function normalizeTradeExecutionMode(
value?: string | null,
): TradeExecutionMode {
return value === 'SCAN_SIGNALS' ? 'SCAN_SIGNALS' : 'BACKTEST_ENGINE';
}
export function isScanSignalsExecutionMode(
settings?: Pick<BacktestSettingsDto, 'tradeExecutionMode'> | null,
): boolean {
return normalizeTradeExecutionMode(settings?.tradeExecutionMode) === 'SCAN_SIGNALS';
}
export function tradeExecutionModeLabel(mode?: string | null): string {
const normalized = normalizeTradeExecutionMode(mode);
return TRADE_EXECUTION_MODE_OPTIONS.find(o => o.value === normalized)?.label
?? TRADE_EXECUTION_MODE_OPTIONS[0].label;
}