일목균형표 수정

This commit is contained in:
Macbook
2026-05-27 23:36:48 +09:00
parent 9cee6387c3
commit 8cc0d1c88c
73 changed files with 2256 additions and 334 deletions
@@ -82,9 +82,17 @@ public class StrategyTriggerBranchEvaluator {
String type = node.path("type").asText("");
if ("TIMEFRAME".equals(type)) {
String ct = LiveStrategyTimeframeService.normalize(node.path("candleType").asText("1m"));
List<String> types = readTimeframeCandleTypes(node);
JsonNode sub = firstChild(node);
return new BranchScope("SINGLE", List.of(new BranchDef(ct, sub)));
if (types.size() <= 1) {
String ct = types.isEmpty() ? "1m" : types.get(0);
return new BranchScope("SINGLE", List.of(new BranchDef(ct, sub)));
}
List<BranchDef> branches = new ArrayList<>();
for (String ct : types) {
branches.add(new BranchDef(ct, sub));
}
return new BranchScope("OR", branches);
}
if ("AND".equals(type) || "OR".equals(type)) {
@@ -92,9 +100,10 @@ public class StrategyTriggerBranchEvaluator {
if (children.isArray() && !children.isEmpty() && allTimeframeChildren(children)) {
List<BranchDef> branches = new ArrayList<>();
for (JsonNode child : children) {
String ct = LiveStrategyTimeframeService.normalize(
child.path("candleType").asText("1m"));
branches.add(new BranchDef(ct, firstChild(child)));
JsonNode sub = firstChild(child);
for (String ct : readTimeframeCandleTypes(child)) {
branches.add(new BranchDef(ct, sub));
}
}
return new BranchScope(type, branches);
}
@@ -102,9 +111,18 @@ public class StrategyTriggerBranchEvaluator {
JsonNode wrapped = findTimeframeWrapper(node);
if (wrapped != null) {
String ct = LiveStrategyTimeframeService.normalize(wrapped.path("candleType").asText("1m"));
List<String> types = readTimeframeCandleTypes(wrapped);
JsonNode sub = firstChild(wrapped);
return new BranchScope("SINGLE", List.of(new BranchDef(ct, sub != null && !sub.isNull() ? sub : node)));
JsonNode subtree = sub != null && !sub.isNull() ? sub : node;
if (types.size() <= 1) {
String ct = types.isEmpty() ? "1m" : types.get(0);
return new BranchScope("SINGLE", List.of(new BranchDef(ct, subtree)));
}
List<BranchDef> branches = new ArrayList<>();
for (String ct : types) {
branches.add(new BranchDef(ct, subtree));
}
return new BranchScope("OR", branches);
}
String inferred = StrategyDslTimeframeNormalizer.inferPrimaryCandleType(node);
@@ -143,6 +161,21 @@ public class StrategyTriggerBranchEvaluator {
return true;
}
/** START 다중 분봉 — 각 마감봉마다 동일 조건 트리를 독립 평가 */
private static List<String> readTimeframeCandleTypes(JsonNode timeframeNode) {
JsonNode arr = timeframeNode.path("candleTypes");
if (arr.isArray() && !arr.isEmpty()) {
List<String> list = new ArrayList<>();
for (JsonNode t : arr) {
String ct = LiveStrategyTimeframeService.normalize(t.asText(""));
if (!ct.isBlank() && !list.contains(ct)) list.add(ct);
}
if (!list.isEmpty()) return list;
}
return List.of(LiveStrategyTimeframeService.normalize(
timeframeNode.path("candleType").asText("1m")));
}
private final class TriggerBranchRule implements Rule {
private final BranchScope scope;
private final String market;