백테스팅 시간봉 문제
This commit is contained in:
@@ -17,7 +17,8 @@ import { mergeGlobalDefaultsOntoChartIndicators } from './indicatorMainConfig';
|
||||
import { buildMainIndicatorConfig } from './indicatorMainConfig';
|
||||
import { normalizeSmaConfig } from './smaConfig';
|
||||
import { normalizeIchimokuConfig } from './ichimokuConfig';
|
||||
import { extractVirtualConditions } from './virtualStrategyConditions';
|
||||
import type { EditorConditionState } from './strategyConditionSerde';
|
||||
import { collectUiEvaluationTimeframes } from './strategyTimeframeSync';
|
||||
|
||||
const DSL_TO_REGISTRY: Record<string, string> = {
|
||||
RSI: 'RSI',
|
||||
@@ -93,22 +94,33 @@ export function candleTypeToTimeframe(candleType: string): Timeframe {
|
||||
return '1m';
|
||||
}
|
||||
|
||||
export function resolveStrategyTimeframes(strategy: StrategyDto | undefined): Timeframe[] {
|
||||
if (!strategy) return ['1m'];
|
||||
const conditions = extractVirtualConditions(strategy);
|
||||
const set = new Set<Timeframe>();
|
||||
for (const row of conditions) {
|
||||
set.add(candleTypeToTimeframe(row.timeframe));
|
||||
}
|
||||
if (set.size === 0) set.add('1m');
|
||||
return [...set].sort((a, b) => {
|
||||
const order: Timeframe[] = ['1m', '3m', '5m', '10m', '15m', '30m', '1h', '4h', '1D', '1W', '1M'];
|
||||
return order.indexOf(a) - order.indexOf(b);
|
||||
});
|
||||
const TIMEFRAME_SORT_ORDER: Timeframe[] = ['1m', '3m', '5m', '10m', '15m', '30m', '1h', '4h', '1D', '1W', '1M'];
|
||||
|
||||
function sortStrategyTimeframes(tfs: Timeframe[]): Timeframe[] {
|
||||
return [...tfs].sort(
|
||||
(a, b) => TIMEFRAME_SORT_ORDER.indexOf(a) - TIMEFRAME_SORT_ORDER.indexOf(b),
|
||||
);
|
||||
}
|
||||
|
||||
export function resolveStrategyPrimaryTimeframe(strategy: StrategyDto | undefined): Timeframe {
|
||||
const tfs = resolveStrategyTimeframes(strategy);
|
||||
/** 편집기 START·flowLayout·저장 DSL에서 전략 평가 시간봉 수집 */
|
||||
export function resolveStrategyTimeframes(
|
||||
strategy: StrategyDto | undefined,
|
||||
editorState?: { buy: EditorConditionState; sell: EditorConditionState },
|
||||
): Timeframe[] {
|
||||
const candleTypes = collectUiEvaluationTimeframes(strategy?.id ?? 0, strategy ?? null, editorState);
|
||||
if (candleTypes.length === 0) return ['1m'];
|
||||
const set = new Set<Timeframe>();
|
||||
for (const ct of candleTypes) {
|
||||
set.add(candleTypeToTimeframe(ct));
|
||||
}
|
||||
return sortStrategyTimeframes([...set]);
|
||||
}
|
||||
|
||||
export function resolveStrategyPrimaryTimeframe(
|
||||
strategy: StrategyDto | undefined,
|
||||
editorState?: { buy: EditorConditionState; sell: EditorConditionState },
|
||||
): Timeframe {
|
||||
const tfs = resolveStrategyTimeframes(strategy, editorState);
|
||||
return tfs[0] ?? '1m';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user