전략평가 오류 수정

This commit is contained in:
Macbook
2026-06-17 01:16:41 +09:00
parent f1ce499809
commit 7c3f3433e7
7 changed files with 210 additions and 27 deletions
@@ -152,10 +152,14 @@ public class StrategyDslToTa4jAdapter {
BarSeries resolveSeries(String candleType) {
String ct = LiveStrategyTimeframeService.normalize(candleType);
// 백테스트 사전 집계 시리즈 우선 검색
// 백테스트·차트 scan — 사전 집계 시리즈 우선
if (seriesOverrides != null && seriesOverrides.containsKey(ct)) {
return seriesOverrides.get(ct);
}
// 차트봉 scan/eval — Ta4jStorage(실시간 1m 등)와 OHLCV 혼합 금지 (시그널 0·차트 불일치)
if (seriesOverrides != null && !seriesOverrides.isEmpty()) {
return primarySeries;
}
if (storage != null && market != null && !market.isBlank()
&& storage.exists(market, ct)) {
return storage.getOrCreate(market, ct);
@@ -252,7 +256,7 @@ public class StrategyDslToTa4jAdapter {
}
private Rule buildTimeframeRule(JsonNode node, RuleBuildContext ctx) {
String ct = node.path("candleType").asText("1m");
String ct = resolveTimeframeCandleType(node);
BarSeries branchSeries = ctx.resolveSeries(ct);
RuleBuildContext branchCtx = ctx.withPrimary(branchSeries);
List<Rule> rules = childRules(node, branchCtx);
@@ -263,6 +267,15 @@ public class StrategyDslToTa4jAdapter {
ctx.useConfirmedOnly(), ctx.isBacktest());
}
/** TIMEFRAME 노드 — candleTypes[0] 우선, 없으면 candleType (레거시 기본 1m) */
private static String resolveTimeframeCandleType(JsonNode node) {
JsonNode types = node.path("candleTypes");
if (types.isArray() && !types.isEmpty()) {
return LiveStrategyTimeframeService.normalize(types.get(0).asText("1m"));
}
return LiveStrategyTimeframeService.normalize(node.path("candleType").asText("1m"));
}
/**
* 다른 시간봉 시리즈로 빌드된 Rule.
*