전략시간봉 오류 재수정
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ public class LiveStrategyScheduler {
|
||||
BarSeries series = ta4jStorage.getOrCreate(market, candleType);
|
||||
if (series.isEmpty()) return;
|
||||
|
||||
String signal = evaluator.evaluateRealtimeTick(market, candleType);
|
||||
String signal = evaluator.evaluateSettingRealtimeTick(s, market, candleType);
|
||||
if ("BUY".equals(signal) || "SELL".equals(signal)) {
|
||||
// 현재 진행 중인 캔들 정보 조회
|
||||
org.ta4j.core.Bar lastBar = series.getLastBar();
|
||||
|
||||
Reference in New Issue
Block a user