전략편집기 목록방식 오류 수정
This commit is contained in:
@@ -236,7 +236,18 @@ public class StrategyDslToTa4jAdapter {
|
||||
public Double readConditionFieldValue(JsonNode cond, BarSeries series,
|
||||
Map<String, Map<String, Object>> params,
|
||||
int index, boolean leftSide) {
|
||||
if (cond == null || cond.isNull() || series == null || index < 0) return null;
|
||||
RuleBuildContext ctx = new RuleBuildContext(series, params != null ? params : Map.of(),
|
||||
Map.of(), null, null, false, Map.of());
|
||||
return readConditionFieldValue(cond, ctx, index, leftSide);
|
||||
}
|
||||
|
||||
/** scan·진단 — Rule 빌드와 동일 RuleBuildContext 사용 */
|
||||
public Double readConditionFieldValue(JsonNode cond, RuleBuildContext ctx,
|
||||
int index, boolean leftSide) {
|
||||
if (cond == null || cond.isNull() || ctx == null || ctx.primarySeries() == null || index < 0) {
|
||||
return null;
|
||||
}
|
||||
BarSeries series = ctx.primarySeries();
|
||||
if (index >= series.getBarCount()) return null;
|
||||
|
||||
String field = leftSide
|
||||
@@ -251,13 +262,11 @@ public class StrategyDslToTa4jAdapter {
|
||||
int sidePeriod = leftSide ? leftPeriod : rightPeriod;
|
||||
|
||||
String registryKey = toRegistryKey(indType);
|
||||
Map<String, Object> indParams = params != null
|
||||
? params.getOrDefault(registryKey, Map.of())
|
||||
Map<String, Object> indParams = ctx.indicatorParams() != null
|
||||
? ctx.indicatorParams().getOrDefault(registryKey, Map.of())
|
||||
: Map.of();
|
||||
|
||||
try {
|
||||
RuleBuildContext ctx = new RuleBuildContext(series, params != null ? params : Map.of(),
|
||||
Map.of(), null, null, false, Map.of());
|
||||
Indicator<Num> ind = resolveField(field, indType, indParams, series, condPeriod, sidePeriod, cond, ctx);
|
||||
Num v = ind.getValue(index);
|
||||
return v != null ? v.doubleValue() : null;
|
||||
@@ -762,6 +771,11 @@ public class StrategyDslToTa4jAdapter {
|
||||
if (field == null || field.isBlank() || field.equals("NONE")) {
|
||||
return new ConstantIndicator<>(s, s.numFactory().numOf(0));
|
||||
}
|
||||
// K_* 직접입력 — 상수 임계값 (HL_*·지표 필드 해석보다 우선)
|
||||
if (field.startsWith("K_")) {
|
||||
Indicator<Num> kConst = resolveDirectKConstant(field, indType, cond, ctx, s);
|
||||
if (kConst != null) return kConst;
|
||||
}
|
||||
return switch (field) {
|
||||
case "CLOSE_PRICE" -> new ClosePriceIndicator(s);
|
||||
case "OPEN_PRICE" -> new OpenPriceIndicator(s);
|
||||
@@ -792,6 +806,20 @@ public class StrategyDslToTa4jAdapter {
|
||||
new RuleBuildContext(s, Map.of(), Map.of(), null, null, false, Map.of()));
|
||||
}
|
||||
|
||||
/** K_55 등 직접입력 임계 — ConstantIndicator 또는 null(폴백) */
|
||||
private Indicator<Num> resolveDirectKConstant(String field, String indType,
|
||||
JsonNode cond, RuleBuildContext ctx,
|
||||
BarSeries s) {
|
||||
Double val = IndicatorHlineResolver.resolveThresholdField(
|
||||
cond, field, indType, ctx != null ? ctx.indicatorVisual() : Map.of());
|
||||
if (val == null) {
|
||||
double parsed = resolveConstantField(field);
|
||||
if (!Double.isNaN(parsed)) val = parsed;
|
||||
}
|
||||
if (val == null) return null;
|
||||
return new ConstantIndicator<>(s, s.numFactory().numOf(val));
|
||||
}
|
||||
|
||||
private double resolveConstantField(String field) {
|
||||
// K_ 접두사: 프론트엔드가 hline 실제값으로 생성한 상수 필드
|
||||
// 예) K_60 → 60, K_-100 → -100, K_0 → 0
|
||||
|
||||
Reference in New Issue
Block a user