전략편집기 수정, 보조지표 설정 수정
This commit is contained in:
+24
@@ -55,6 +55,30 @@ class StrategyConditionTimeframeServiceTest {
|
||||
assertFalse(service.usesTimeframe(1L, "1m"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void collectForStrategy_reads3mAnd5mWithout1m() {
|
||||
GcStrategy onlyUpper = new GcStrategy();
|
||||
onlyUpper.setId(4L);
|
||||
onlyUpper.setBuyConditionJson("""
|
||||
{
|
||||
"type": "TIMEFRAME",
|
||||
"candleType": "3m",
|
||||
"candleTypes": ["3m", "5m"],
|
||||
"children": [{
|
||||
"type": "CONDITION",
|
||||
"condition": { "indicatorType": "RSI", "period": 14 }
|
||||
}]
|
||||
}
|
||||
""");
|
||||
when(strategyRepo.findById(4L)).thenReturn(Optional.of(onlyUpper));
|
||||
|
||||
Set<String> tfs = service.collectForStrategy(4L);
|
||||
assertEquals(Set.of("3m", "5m"), tfs);
|
||||
assertFalse(service.usesTimeframe(4L, "1m"));
|
||||
assertTrue(service.usesTimeframe(4L, "3m"));
|
||||
assertTrue(service.usesTimeframe(4L, "5m"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void collectForStrategy_readsMultipleCandleTypesFromTimeframeNode() {
|
||||
GcStrategy multi = new GcStrategy();
|
||||
|
||||
@@ -11,6 +11,44 @@ class StrategyDslTimeframeNormalizerTest {
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
private final StrategyDslTimeframeNormalizer normalizer = new StrategyDslTimeframeNormalizer(objectMapper);
|
||||
|
||||
@Test
|
||||
void normalize_preserves3mAnd5mWithout1m() throws Exception {
|
||||
String json = """
|
||||
{
|
||||
"type": "TIMEFRAME",
|
||||
"candleType": "1m",
|
||||
"candleTypes": ["3m", "5m"],
|
||||
"children": [{
|
||||
"type": "CONDITION",
|
||||
"condition": { "indicatorType": "RSI", "period": 14 }
|
||||
}]
|
||||
}
|
||||
""";
|
||||
String normalized = normalizer.normalizeJson(json, "테스트");
|
||||
JsonNode root = objectMapper.readTree(normalized);
|
||||
assertEquals(2, root.path("candleTypes").size());
|
||||
assertEquals("3m", root.path("candleTypes").get(0).asText());
|
||||
assertEquals("5m", root.path("candleTypes").get(1).asText());
|
||||
assertEquals("3m", root.path("candleType").asText());
|
||||
}
|
||||
|
||||
@Test
|
||||
void normalize_preservesSingleExplicit3m() throws Exception {
|
||||
String json = """
|
||||
{
|
||||
"type": "TIMEFRAME",
|
||||
"candleType": "3m",
|
||||
"children": [{
|
||||
"type": "CONDITION",
|
||||
"condition": { "indicatorType": "RSI", "period": 14 }
|
||||
}]
|
||||
}
|
||||
""";
|
||||
String normalized = normalizer.normalizeJson(json, "테스트");
|
||||
JsonNode root = objectMapper.readTree(normalized);
|
||||
assertEquals("3m", root.path("candleType").asText());
|
||||
}
|
||||
|
||||
@Test
|
||||
void normalize_preservesMultiCandleTypesOnSave() throws Exception {
|
||||
String json = """
|
||||
|
||||
Reference in New Issue
Block a user