전략편집기 수정, 보조지표 설정 수정
This commit is contained in:
@@ -39,12 +39,16 @@ public class StrategyDslTimeframeNormalizer {
|
||||
if (root == null || root.isNull()) return root;
|
||||
|
||||
if ("TIMEFRAME".equals(root.path("type").asText(""))) {
|
||||
// START 다중 분봉(candleTypes) — 편집기 저장값 유지
|
||||
if (hasMultipleCandleTypes(root)) {
|
||||
// START 다중 분봉(candleTypes) — 편집기 저장값 유지, candleType 은 배열 첫 값과 동기화
|
||||
if (hasCandleTypesArray(root)) {
|
||||
return syncTimeframePrimary(root);
|
||||
}
|
||||
String current = LiveStrategyTimeframeService.normalize(root.path("candleType").asText("1m"));
|
||||
// 편집기에서 명시한 단일 분봉(3m, 5m 등)은 조건 노드 기본 1m 추론으로 덮어쓰지 않음
|
||||
if (!"1m".equals(current)) {
|
||||
return root;
|
||||
}
|
||||
String expected = inferPrimaryCandleType(root, strategyName);
|
||||
String current = LiveStrategyTimeframeService.normalize(root.path("candleType").asText("1m"));
|
||||
if (!expected.equals(current)) {
|
||||
return copyTimeframeWithCandleType(root, expected);
|
||||
}
|
||||
@@ -197,9 +201,20 @@ public class StrategyDslTimeframeNormalizer {
|
||||
return "1m";
|
||||
}
|
||||
|
||||
private static boolean hasMultipleCandleTypes(JsonNode timeframeNode) {
|
||||
private static boolean hasCandleTypesArray(JsonNode timeframeNode) {
|
||||
JsonNode arr = timeframeNode.path("candleTypes");
|
||||
return arr.isArray() && arr.size() > 1;
|
||||
return arr.isArray() && !arr.isEmpty();
|
||||
}
|
||||
|
||||
/** candleTypes[] 가 있으면 candleType 을 첫 항목과 맞춤 (stale 1m 방지) */
|
||||
private ObjectNode syncTimeframePrimary(JsonNode tf) {
|
||||
ObjectNode copy = tf.deepCopy();
|
||||
JsonNode arr = tf.path("candleTypes");
|
||||
if (arr.isArray() && !arr.isEmpty()) {
|
||||
String primary = LiveStrategyTimeframeService.normalize(arr.get(0).asText("1m"));
|
||||
copy.put("candleType", primary);
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
private ObjectNode copyTimeframeWithCandleType(JsonNode tf, String candleType) {
|
||||
|
||||
Reference in New Issue
Block a user