가상투자 로직 변경

This commit is contained in:
Macbook
2026-05-31 05:29:17 +09:00
parent 6da4821d9d
commit 85d7fea457
9 changed files with 39 additions and 182 deletions
@@ -263,12 +263,26 @@ public class PaperTradingService {
GcAppSettings app = appSettingsService.getEntity(userId, deviceId);
if (!Boolean.TRUE.equals(app.getPaperTradingEnabled())) return;
if (!Boolean.TRUE.equals(app.getPaperAutoTradeEnabled())) return;
boolean marketActive = liveSettingsRepo.findActiveByMarket(market).stream()
.anyMatch(s -> Boolean.TRUE.equals(s.getIsLiveCheck()));
List<GcLiveStrategySettings> liveForMarket = liveSettingsRepo.findActiveByMarket(market).stream()
.filter(s -> Boolean.TRUE.equals(s.getIsLiveCheck()))
.toList();
boolean marketActive = !liveForMarket.isEmpty();
if (!Boolean.TRUE.equals(app.getLiveStrategyCheck()) && !marketActive) return;
try {
GcPaperAccount account = getOrCreateAccount(userId, deviceId, app);
String positionMode = liveForMarket.stream()
.map(GcLiveStrategySettings::getPositionMode)
.filter(m -> m != null && !m.isBlank())
.findFirst()
.orElse("LONG_ONLY");
if ("LONG_ONLY".equals(positionMode)) {
GcPaperPosition posNow = positionRepo.findByAccountIdAndSymbol(account.getId(), market)
.orElse(null);
double held = posNow != null ? posNow.getQuantity().doubleValue() : 0;
if ("BUY".equals(signalType) && held > 0) return;
if ("SELL".equals(signalType) && held <= 0) return;
}
double feeRate = pct(app.getPaperFeeRatePct(), 0.05);
double slip = pct(app.getPaperSlippagePct(), 0);
double minOrder = app.getPaperMinOrderKrw() != null