평가로직 오류 수정
This commit is contained in:
+10
-5
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* 전략 조건 DSL — K_50 등 직접입력 스냅샷을 hline 역할(HL_MID 등)로 정규화.
|
||||
@@ -37,11 +38,15 @@ public final class StrategyConditionThresholdNormalizer {
|
||||
}
|
||||
|
||||
private static void normalizeCondition(ObjectNode cond) {
|
||||
normalizeThresholdField(cond, "rightField");
|
||||
normalizeThresholdField(cond, "leftField");
|
||||
String indType = cond.path("indicatorType").asText("").toUpperCase(Locale.ROOT);
|
||||
if (!indType.isBlank()) {
|
||||
cond.put("indicatorType", indType);
|
||||
}
|
||||
normalizeThresholdField(cond, "rightField", indType);
|
||||
normalizeThresholdField(cond, "leftField", indType);
|
||||
}
|
||||
|
||||
private static void normalizeThresholdField(ObjectNode cond, String fieldKey) {
|
||||
private static void normalizeThresholdField(ObjectNode cond, String fieldKey, String indType) {
|
||||
String field = cond.path(fieldKey).asText("");
|
||||
if (field.isBlank()) return;
|
||||
|
||||
@@ -49,7 +54,7 @@ public final class StrategyConditionThresholdNormalizer {
|
||||
Double value = readThresholdValue(cond, field);
|
||||
|
||||
if (override || field.startsWith("K_")) {
|
||||
String role = inferRoleForValue(cond.path("indicatorType").asText(""), value, field);
|
||||
String role = inferRoleForValue(indType, value, field);
|
||||
if (role != null) {
|
||||
cond.put(fieldKey, role);
|
||||
cond.remove("targetValue");
|
||||
@@ -59,7 +64,7 @@ public final class StrategyConditionThresholdNormalizer {
|
||||
}
|
||||
|
||||
if (!override && field.startsWith("K_")) {
|
||||
String role = inferRoleForValue(cond.path("indicatorType").asText(""), value, field);
|
||||
String role = inferRoleForValue(indType, value, field);
|
||||
if (role != null) {
|
||||
cond.put(fieldKey, role);
|
||||
cond.remove("targetValue");
|
||||
|
||||
@@ -152,10 +152,14 @@ public class StrategyService {
|
||||
dto.setCreatedAt(e.getCreatedAt());
|
||||
dto.setUpdatedAt(e.getUpdatedAt());
|
||||
try {
|
||||
if (e.getBuyConditionJson() != null)
|
||||
dto.setBuyCondition(objectMapper.readTree(e.getBuyConditionJson()));
|
||||
if (e.getSellConditionJson() != null)
|
||||
dto.setSellCondition(objectMapper.readTree(e.getSellConditionJson()));
|
||||
if (e.getBuyConditionJson() != null) {
|
||||
JsonNode buy = objectMapper.readTree(e.getBuyConditionJson());
|
||||
dto.setBuyCondition(StrategyConditionThresholdNormalizer.normalizeTree(buy));
|
||||
}
|
||||
if (e.getSellConditionJson() != null) {
|
||||
JsonNode sell = objectMapper.readTree(e.getSellConditionJson());
|
||||
dto.setSellCondition(StrategyConditionThresholdNormalizer.normalizeTree(sell));
|
||||
}
|
||||
if (e.getFlowLayoutJson() != null && !e.getFlowLayoutJson().isBlank())
|
||||
dto.setFlowLayout(objectMapper.readTree(e.getFlowLayoutJson()));
|
||||
} catch (Exception ex) {
|
||||
|
||||
Reference in New Issue
Block a user