일목균형표 조건 수정
This commit is contained in:
@@ -51,6 +51,7 @@ public class LiveConditionStatusService {
|
||||
private final IndicatorSettingsService indicatorSettingsService;
|
||||
private final ObjectMapper objectMapper;
|
||||
private final DynamicSubscriptionManager subscriptionManager;
|
||||
private final StrategyDslTimeframeNormalizer timeframeNormalizer;
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public LiveConditionStatusDto evaluate(Long userId, String deviceId,
|
||||
@@ -102,7 +103,7 @@ public class LiveConditionStatusService {
|
||||
}
|
||||
|
||||
if (chartBars != null && !chartBars.isEmpty() && chartTimeframe != null && !chartTimeframe.isBlank()) {
|
||||
return evaluateOnChartBars(strategy, market, strategyId, pending, chartBars, chartTimeframe,
|
||||
return evaluateOnChartBars(strategy, market, strategyId, chartBars, chartTimeframe,
|
||||
barTimeSec, params, visual);
|
||||
}
|
||||
|
||||
@@ -215,19 +216,25 @@ public class LiveConditionStatusService {
|
||||
GcStrategy strategy,
|
||||
String market,
|
||||
long strategyId,
|
||||
List<PendingCond> pending,
|
||||
List<OhlcvBar> chartBars,
|
||||
String chartTimeframe,
|
||||
Long barTimeSec,
|
||||
Map<String, Map<String, Object>> params,
|
||||
Map<String, Map<String, Object>> visual) {
|
||||
try {
|
||||
JsonNode buyDsl = objectMapper.readTree(
|
||||
JsonNode buyDslRaw = objectMapper.readTree(
|
||||
strategy.getBuyConditionJson() != null ? strategy.getBuyConditionJson() : "null");
|
||||
JsonNode sellDsl = objectMapper.readTree(
|
||||
JsonNode sellDslRaw = objectMapper.readTree(
|
||||
strategy.getSellConditionJson() != null ? strategy.getSellConditionJson() : "null");
|
||||
|
||||
String primaryTf = OhlcvBarSeriesSupport.normalizeTf(chartTimeframe);
|
||||
JsonNode buyDsl = timeframeNormalizer.remapForChartTimeframe(buyDslRaw, primaryTf);
|
||||
JsonNode sellDsl = timeframeNormalizer.remapForChartTimeframe(sellDslRaw, primaryTf);
|
||||
|
||||
List<PendingCond> pending = new ArrayList<>();
|
||||
collectConditionsFromNode(buyDsl, "1m", "buy", pending);
|
||||
collectConditionsFromNode(sellDsl, "1m", "sell", pending);
|
||||
|
||||
BarSeries primarySeries = OhlcvBarSeriesSupport.buildSeries(chartBars, primaryTf);
|
||||
if (primarySeries.isEmpty()) {
|
||||
return empty(market, strategyId);
|
||||
@@ -322,16 +329,13 @@ public class LiveConditionStatusService {
|
||||
Long barTimeSec) {
|
||||
if (dsl == null || dsl.isNull()) return null;
|
||||
try {
|
||||
String primaryTf = extractPrimaryTimeframe(dsl);
|
||||
BarSeries series = resolveChartSeries(primaryTf, OhlcvBarSeriesSupport.normalizeTf(primaryTf),
|
||||
primarySeries, seriesOverrides, market);
|
||||
if (series == null || series.isEmpty()) return null;
|
||||
if (primarySeries == null || primarySeries.isEmpty()) return null;
|
||||
|
||||
StrategyDslToTa4jAdapter.RuleBuildContext ctx =
|
||||
new StrategyDslToTa4jAdapter.RuleBuildContext(
|
||||
series, params, visual, market, ta4jStorage, false, seriesOverrides);
|
||||
primarySeries, params, visual, market, ta4jStorage, false, seriesOverrides);
|
||||
Rule rule = adapter.toRule(dsl, ctx);
|
||||
int index = OhlcvBarSeriesSupport.resolveBarIndex(series, barTimeSec);
|
||||
int index = OhlcvBarSeriesSupport.resolveBarIndex(primarySeries, barTimeSec);
|
||||
return rule.isSatisfied(index, null);
|
||||
} catch (Exception e) {
|
||||
log.debug("[LiveCondition:chart] overall rule fail market={}: {}", market, e.getMessage());
|
||||
@@ -339,6 +343,12 @@ public class LiveConditionStatusService {
|
||||
}
|
||||
}
|
||||
|
||||
private void collectConditionsFromNode(JsonNode node, String timeframe, String side,
|
||||
List<PendingCond> out) {
|
||||
if (node == null || node.isNull()) return;
|
||||
walk(node, timeframe, side, out, new HashSet<>());
|
||||
}
|
||||
|
||||
private LiveConditionStatusDto empty(String market, long strategyId) {
|
||||
return LiveConditionStatusDto.builder()
|
||||
.market(market)
|
||||
@@ -673,12 +683,14 @@ public class LiveConditionStatusService {
|
||||
indicatorSettingsService.getAllVisual(userId, deviceId);
|
||||
|
||||
try {
|
||||
JsonNode buyDsl = objectMapper.readTree(
|
||||
JsonNode buyDslRaw = objectMapper.readTree(
|
||||
strategy.getBuyConditionJson() != null ? strategy.getBuyConditionJson() : "null");
|
||||
JsonNode sellDsl = objectMapper.readTree(
|
||||
JsonNode sellDslRaw = objectMapper.readTree(
|
||||
strategy.getSellConditionJson() != null ? strategy.getSellConditionJson() : "null");
|
||||
|
||||
String primaryTf = OhlcvBarSeriesSupport.normalizeTf(chartTimeframe);
|
||||
JsonNode buyDsl = timeframeNormalizer.remapForChartTimeframe(buyDslRaw, primaryTf);
|
||||
JsonNode sellDsl = timeframeNormalizer.remapForChartTimeframe(sellDslRaw, primaryTf);
|
||||
BarSeries primarySeries = OhlcvBarSeriesSupport.buildSeries(chartBars, primaryTf);
|
||||
if (primarySeries.isEmpty()) {
|
||||
return List.of();
|
||||
|
||||
Reference in New Issue
Block a user