1분봉 오류 수정
This commit is contained in:
+41
@@ -276,6 +276,47 @@ class StrategyConditionTimeframeServiceTest {
|
||||
assertTrue(service.usesTimeframe(7L, "3m"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void collectForStrategy_flowLayoutStale1mRemovedWhenConditionsAreUpperOnly() {
|
||||
GcStrategy strategy = new GcStrategy();
|
||||
strategy.setId(8L);
|
||||
strategy.setName("CCI 3분 5분 10분 15분 1시간");
|
||||
strategy.setFlowLayoutJson("""
|
||||
{
|
||||
"buy": {
|
||||
"startMeta": {
|
||||
"start-0": {
|
||||
"candleTypes": ["1m", "3m", "5m", "10m", "15m", "1h"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""");
|
||||
strategy.setBuyConditionJson("""
|
||||
{
|
||||
"type": "TIMEFRAME",
|
||||
"candleType": "3m",
|
||||
"candleTypes": ["3m", "5m", "10m", "15m", "1h"],
|
||||
"children": [{
|
||||
"type": "AND",
|
||||
"children": [
|
||||
{ "type": "CONDITION", "condition": { "indicatorType": "CCI", "leftCandleType": "3m" } },
|
||||
{ "type": "CONDITION", "condition": { "indicatorType": "CCI", "leftCandleType": "5m" } }
|
||||
]
|
||||
}]
|
||||
}
|
||||
""");
|
||||
when(strategyRepo.findById(8L)).thenReturn(Optional.of(strategy));
|
||||
when(dslNormalizer.alignSellStartTimeframeToBuy(org.mockito.ArgumentMatchers.any(), org.mockito.ArgumentMatchers.any()))
|
||||
.thenAnswer(inv -> inv.getArgument(1));
|
||||
when(dslNormalizer.normalizeJson(org.mockito.ArgumentMatchers.anyString(), org.mockito.ArgumentMatchers.any()))
|
||||
.thenAnswer(inv -> inv.getArgument(0));
|
||||
|
||||
Set<String> tfs = service.collectForStrategy(8L);
|
||||
assertEquals(Set.of("3m", "5m", "10m", "15m", "1h"), tfs);
|
||||
assertFalse(service.usesTimeframe(8L, "1m"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void collectForStrategy_legacyTreeDefaultsTo1m() {
|
||||
GcStrategy legacy = new GcStrategy();
|
||||
|
||||
@@ -186,6 +186,29 @@ class StrategyDslTimeframeNormalizerTest {
|
||||
assertEquals("15m", root.path("candleType").asText());
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveStartCandleTypes_dropsStale1mWhenAllConditionsDefaultTo1m() throws Exception {
|
||||
String json = """
|
||||
{
|
||||
"type": "TIMEFRAME",
|
||||
"candleType": "1m",
|
||||
"candleTypes": ["1m", "3m", "5m", "10m", "15m", "1h"],
|
||||
"children": [{
|
||||
"type": "AND",
|
||||
"children": [
|
||||
{ "type": "CONDITION", "condition": { "indicatorType": "CCI", "leftCandleType": "1m" } },
|
||||
{ "type": "CONDITION", "condition": { "indicatorType": "CCI", "leftCandleType": "1m" } },
|
||||
{ "type": "CONDITION", "condition": { "indicatorType": "CCI", "leftCandleType": "1m" } }
|
||||
]
|
||||
}]
|
||||
}
|
||||
""";
|
||||
JsonNode root = objectMapper.readTree(json);
|
||||
assertEquals(
|
||||
Set.of("3m", "5m", "10m", "15m", "1h"),
|
||||
StrategyDslTimeframeNormalizer.resolveStartCandleTypes(root));
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveStartCandleTypes_dropsStale1mWhenConditionsUseMultipleUpperTfs() throws Exception {
|
||||
String json = """
|
||||
|
||||
Reference in New Issue
Block a user