전략시간봉 오류 재수정

This commit is contained in:
Macbook
2026-05-28 02:09:38 +09:00
parent 5f9b20d907
commit 9137864f48
8 changed files with 215 additions and 90 deletions
@@ -170,40 +170,49 @@ public class BarBuilder {
*/
private void evaluateStrategyOnBarClose(String market, String candleType, int maturedIndex,
Bar signalBar) {
String closeSignal = liveStrategyEvaluator.evaluateCandleClose(market, candleType, maturedIndex);
String signalExecType = "CANDLE_CLOSE";
List<GcLiveStrategySettings> activeSettings = liveSettingsRepo.findActiveByMarket(market).stream()
.filter(s -> Boolean.TRUE.equals(s.getIsLiveCheck()) && s.getStrategyId() != null)
.toList();
if (activeSettings.isEmpty()) return;
if ("NONE".equals(closeSignal)) {
closeSignal = liveStrategyEvaluator.evaluateRealtimeAtClose(market, candleType, maturedIndex);
signalExecType = "REALTIME_TICK";
}
long candleTimeEpoch = signalBar.getEndTime().getEpochSecond()
- signalBar.getTimePeriod().getSeconds();
if ("BUY".equals(closeSignal) || "SELL".equals(closeSignal)) {
publishStrategySignal(market, candleType, signalBar, closeSignal);
}
for (GcLiveStrategySettings s : activeSettings) {
if (!conditionTimeframes.usesTimeframe(s.getStrategyId(), candleType)) continue;
if (!"BUY".equals(closeSignal) && !"SELL".equals(closeSignal)) return;
String closeSignal = "NONE";
String signalExecType = null;
try {
final String execType = signalExecType;
GcLiveStrategySettings activeSetting = liveSettingsRepo.findActiveByMarket(market)
.stream().filter(s -> Boolean.TRUE.equals(s.getIsLiveCheck())
&& execType.equals(s.getExecutionType())).findFirst().orElse(null);
long candleTimeEpoch = signalBar.getEndTime().getEpochSecond()
- signalBar.getTimePeriod().getSeconds();
String devId = activeSetting != null ? activeSetting.getDeviceId() : null;
Long uid = activeSetting != null ? activeSetting.getUserId() : null;
Long stratId = activeSetting != null ? activeSetting.getStrategyId() : null;
tradeSignalService.save(
devId, uid, market, stratId, null,
closeSignal, signalBar.getClosePrice().doubleValue(),
candleTimeEpoch, candleType, execType);
if (devId != null) {
orderExecutionQueue.submitSignal(devId, uid, market, stratId, closeSignal,
signalBar.getClosePrice().doubleValue());
if ("CANDLE_CLOSE".equals(s.getExecutionType())) {
closeSignal = liveStrategyEvaluator.evaluateSettingOnCandleClose(
s, market, candleType, maturedIndex);
signalExecType = "CANDLE_CLOSE";
} else if ("REALTIME_TICK".equals(s.getExecutionType())) {
closeSignal = liveStrategyEvaluator.evaluateSettingRealtimeAtClose(
s, market, candleType, maturedIndex);
signalExecType = "REALTIME_TICK";
}
if (!"BUY".equals(closeSignal) && !"SELL".equals(closeSignal)) continue;
publishStrategySignal(market, candleType, signalBar, closeSignal);
try {
tradeSignalService.save(
s.getDeviceId(), s.getUserId(),
market, s.getStrategyId(), null,
closeSignal, signalBar.getClosePrice().doubleValue(),
candleTimeEpoch, candleType, signalExecType);
if (s.getDeviceId() != null) {
orderExecutionQueue.submitSignal(
s.getDeviceId(), s.getUserId(), market,
s.getStrategyId(), closeSignal,
signalBar.getClosePrice().doubleValue());
}
} catch (Exception e) {
log.warn("[BarBuilder] 시그널 처리 실패 ({}/{} strategyId={}): {}",
market, candleType, s.getStrategyId(), e.getMessage());
}
} catch (Exception e) {
log.warn("[BarBuilder] 시그널 처리 실패 ({}/{}): {}", market, candleType, e.getMessage());
}
}