분석결과 레포트 수정
This commit is contained in:
@@ -44,7 +44,92 @@ class ComplexStrategyDslAdapterTest {
|
||||
seedStorage(MARKET, "5m", buildSyntheticSeries("5m", 80));
|
||||
}
|
||||
|
||||
/** Logic Expression 예시와 동일 구조의 매수 조건 */
|
||||
/** OR(AND, AND) — 4개 조건을 평탄 OR로 처리하면 true가 되는 케이스에서 false여야 함 */
|
||||
@Test
|
||||
void orAndNested_doesNotFlattenChildrenToOr() throws Exception {
|
||||
JsonNode buy = MAPPER.readTree("""
|
||||
{
|
||||
"type": "OR",
|
||||
"children": [
|
||||
{
|
||||
"type": "AND",
|
||||
"children": [
|
||||
{ "type": "CONDITION", "condition": {
|
||||
"indicatorType": "MA", "conditionType": "GT",
|
||||
"leftField": "CLOSE_PRICE", "rightField": "K_999999999", "candleRange": 1
|
||||
}},
|
||||
{ "type": "CONDITION", "condition": {
|
||||
"indicatorType": "MA", "conditionType": "GT",
|
||||
"leftField": "CLOSE_PRICE", "rightField": "K_1", "candleRange": 1
|
||||
}}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "AND",
|
||||
"children": [
|
||||
{ "type": "CONDITION", "condition": {
|
||||
"indicatorType": "MA", "conditionType": "GT",
|
||||
"leftField": "CLOSE_PRICE", "rightField": "K_999999999", "candleRange": 1
|
||||
}},
|
||||
{ "type": "CONDITION", "condition": {
|
||||
"indicatorType": "MA", "conditionType": "GT",
|
||||
"leftField": "CLOSE_PRICE", "rightField": "K_1", "candleRange": 1
|
||||
}}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
""");
|
||||
|
||||
Rule rule = adapter.toRule(buy, primary1m, Map.of());
|
||||
int idx = primary1m.getEndIndex();
|
||||
// 평탄 OR(4조건)이면 close>K_1 하나만으로 true — AND 중첩이면 각 분기 false → 전체 false
|
||||
assertFalse(rule.isSatisfied(idx, null),
|
||||
"OR(AND)는 분기 내 모든 조건이 충족될 때만 true — 단일 true 자식으로는 true가 되면 안 됨");
|
||||
}
|
||||
|
||||
@Test
|
||||
void orAndNested_oneFullAndBranchSatisfies() throws Exception {
|
||||
JsonNode buy = MAPPER.readTree("""
|
||||
{
|
||||
"type": "OR",
|
||||
"children": [
|
||||
{
|
||||
"type": "AND",
|
||||
"children": [
|
||||
{ "type": "CONDITION", "condition": {
|
||||
"indicatorType": "MA", "conditionType": "GT",
|
||||
"leftField": "CLOSE_PRICE", "rightField": "K_1", "candleRange": 1
|
||||
}},
|
||||
{ "type": "CONDITION", "condition": {
|
||||
"indicatorType": "MA", "conditionType": "GT",
|
||||
"leftField": "CLOSE_PRICE", "rightField": "K_0", "candleRange": 1
|
||||
}}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "AND",
|
||||
"children": [
|
||||
{ "type": "CONDITION", "condition": {
|
||||
"indicatorType": "MA", "conditionType": "GT",
|
||||
"leftField": "CLOSE_PRICE", "rightField": "K_999999999", "candleRange": 1
|
||||
}},
|
||||
{ "type": "CONDITION", "condition": {
|
||||
"indicatorType": "MA", "conditionType": "GT",
|
||||
"leftField": "CLOSE_PRICE", "rightField": "K_1", "candleRange": 1
|
||||
}}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
""");
|
||||
|
||||
Rule rule = adapter.toRule(buy, primary1m, Map.of());
|
||||
assertTrue(rule.isSatisfied(primary1m.getEndIndex(), null),
|
||||
"OR(AND) — 한 분기의 AND가 모두 true이면 전체 true");
|
||||
}
|
||||
|
||||
/** Logic Expression 예시와 동일 구조의 매수 조건 */
|
||||
@Test
|
||||
void buyCondition_compilesAndEvaluates() throws Exception {
|
||||
JsonNode buy = MAPPER.readTree("""
|
||||
|
||||
Reference in New Issue
Block a user