분석레포트 로직 수정
This commit is contained in:
@@ -237,7 +237,7 @@ public class PaperTradingService {
|
||||
// 시장가(MARKET)를 포함한 모든 주문을 현재가 기준 지정가 미체결로 생성한다.
|
||||
// 체결은 PaperOrderMatcherService 가 다음 시세 틱에서 처리한다.
|
||||
GcPaperOrder order = createPendingLimitOrder(account, app, req.getMarket(), side, orderKind,
|
||||
source, req.getStrategyId(), price, qty, false);
|
||||
source, req.getStrategyId(), price, qty, false, null, null, null);
|
||||
return PaperPlaceOrderResult.builder().order(toOrderDto(order)).build();
|
||||
}
|
||||
|
||||
@@ -261,6 +261,12 @@ public class PaperTradingService {
|
||||
|
||||
public void tryExecuteOnSignal(Long userId, String market,
|
||||
Long strategyId, String signalType, double price) {
|
||||
tryExecuteOnSignal(userId, market, strategyId, signalType, price, null, null, null);
|
||||
}
|
||||
|
||||
public void tryExecuteOnSignal(Long userId, String market,
|
||||
Long strategyId, String signalType, double price,
|
||||
String candleType, String strategyName, String executionType) {
|
||||
long uid;
|
||||
try {
|
||||
uid = TradingAccess.requireUserId(userId);
|
||||
@@ -332,7 +338,8 @@ public class PaperTradingService {
|
||||
if (qty * execPrice < minOrder) return;
|
||||
// 알림 발생 시점 현재가 기준 미체결 주문 생성 (staged=true → 체결 시 단계 진행)
|
||||
createPendingLimitOrder(account, app, market, "BUY", "market", "STRATEGY",
|
||||
strategyId, price, qty, true);
|
||||
strategyId, price, qty, true,
|
||||
candleType, strategyName, executionType);
|
||||
log.info("[Paper] STRATEGY BUY (staged) 미체결 생성 {} qty≈{} @ {}", market, qty, price);
|
||||
} else {
|
||||
double budgetPct = pct(app.getPaperAutoTradeBudgetPct(), 95);
|
||||
@@ -347,7 +354,8 @@ public class PaperTradingService {
|
||||
if (qty * execPrice < minOrder) return;
|
||||
// 알림 발생 시점 현재가 기준 미체결 주문 생성
|
||||
createPendingLimitOrder(account, app, market, "BUY", "market", "STRATEGY",
|
||||
strategyId, price, qty, false);
|
||||
strategyId, price, qty, false,
|
||||
candleType, strategyName, executionType);
|
||||
log.info("[Paper] STRATEGY BUY 미체결 생성 {} qty≈{} @ {}", market, qty, price);
|
||||
}
|
||||
} else {
|
||||
@@ -364,12 +372,14 @@ public class PaperTradingService {
|
||||
if (qty * execPrice < minOrder) return;
|
||||
// 알림 발생 시점 현재가 기준 미체결 주문 생성 (staged=true → 체결 시 단계 진행)
|
||||
createPendingLimitOrder(account, app, market, "SELL", "market", "STRATEGY",
|
||||
strategyId, price, qty, true);
|
||||
strategyId, price, qty, true,
|
||||
candleType, strategyName, executionType);
|
||||
log.info("[Paper] STRATEGY SELL (staged) 미체결 생성 {} qty={} @ {}", market, qty, price);
|
||||
} else {
|
||||
// 알림 발생 시점 현재가 기준 미체결 주문 생성
|
||||
createPendingLimitOrder(account, app, market, "SELL", "market", "STRATEGY",
|
||||
strategyId, price, avail, false);
|
||||
strategyId, price, avail, false,
|
||||
candleType, strategyName, executionType);
|
||||
log.info("[Paper] STRATEGY SELL 미체결 생성 {} qty={} @ {}", market, avail, price);
|
||||
}
|
||||
}
|
||||
@@ -440,7 +450,8 @@ public class PaperTradingService {
|
||||
double qty = order.getQuantity().doubleValue();
|
||||
executeTrade(uid, app, order.getSymbol(),
|
||||
order.getSide(), order.getOrderKind(), order.getSource(), order.getStrategyId(),
|
||||
limit, qty, null, "STRATEGY".equals(order.getSource()));
|
||||
limit, qty, null, "STRATEGY".equals(order.getSource()),
|
||||
order.getCandleType(), order.getStrategyName(), order.getExecutionType());
|
||||
|
||||
order.setStatus("FILLED");
|
||||
order.setFilledQuantity(order.getQuantity());
|
||||
@@ -532,7 +543,9 @@ public class PaperTradingService {
|
||||
private GcPaperOrder createPendingLimitOrder(GcPaperAccount account, GcAppSettings app,
|
||||
String market, String side, String orderKind,
|
||||
String source, Long strategyId,
|
||||
double limitPrice, double qty, boolean staged) {
|
||||
double limitPrice, double qty, boolean staged,
|
||||
String candleType, String strategyName,
|
||||
String executionType) {
|
||||
double feeRate = pct(app.getPaperFeeRatePct(), 0.05);
|
||||
double slip = pct(app.getPaperSlippagePct(), 0);
|
||||
double execPrice = "BUY".equals(side)
|
||||
@@ -559,6 +572,9 @@ public class PaperTradingService {
|
||||
.orderKind(orderKind)
|
||||
.source(source)
|
||||
.strategyId(strategyId)
|
||||
.candleType(candleType)
|
||||
.strategyName(strategyName)
|
||||
.executionType(executionType)
|
||||
.staged(staged)
|
||||
.build());
|
||||
}
|
||||
@@ -581,6 +597,9 @@ public class PaperTradingService {
|
||||
.orderKind(orderKind)
|
||||
.source(source)
|
||||
.strategyId(strategyId)
|
||||
.candleType(candleType)
|
||||
.strategyName(strategyName)
|
||||
.executionType(executionType)
|
||||
.staged(staged)
|
||||
.build());
|
||||
}
|
||||
@@ -611,6 +630,15 @@ public class PaperTradingService {
|
||||
String market, String side, String orderKind, String source,
|
||||
Long strategyId, double inputPrice, double inputQty,
|
||||
String koreanName, boolean autoTrade) {
|
||||
return executeTrade(userId, app, market, side, orderKind, source, strategyId,
|
||||
inputPrice, inputQty, koreanName, autoTrade, null, null, null);
|
||||
}
|
||||
|
||||
private PaperTradeDto executeTrade(long userId, GcAppSettings app,
|
||||
String market, String side, String orderKind, String source,
|
||||
Long strategyId, double inputPrice, double inputQty,
|
||||
String koreanName, boolean autoTrade,
|
||||
String candleType, String strategyName, String executionType) {
|
||||
GcPaperAccount account = getOrCreateAccount(userId, app);
|
||||
double feeRate = pct(app.getPaperFeeRatePct(), 0.05);
|
||||
double slip = pct(app.getPaperSlippagePct(), 0);
|
||||
@@ -646,6 +674,9 @@ public class PaperTradingService {
|
||||
.orderKind(orderKind)
|
||||
.source(source)
|
||||
.strategyId(strategyId)
|
||||
.candleType(candleType)
|
||||
.strategyName(strategyName)
|
||||
.executionType(executionType)
|
||||
.price(price)
|
||||
.quantity(qty)
|
||||
.grossAmount(gross)
|
||||
@@ -690,6 +721,9 @@ public class PaperTradingService {
|
||||
.orderKind(orderKind)
|
||||
.source(source)
|
||||
.strategyId(strategyId)
|
||||
.candleType(candleType)
|
||||
.strategyName(strategyName)
|
||||
.executionType(executionType)
|
||||
.price(price)
|
||||
.quantity(qty)
|
||||
.grossAmount(gross)
|
||||
@@ -791,6 +825,9 @@ public class PaperTradingService {
|
||||
.orderKind(t.getOrderKind())
|
||||
.source(t.getSource())
|
||||
.strategyId(t.getStrategyId())
|
||||
.candleType(t.getCandleType())
|
||||
.strategyName(t.getStrategyName())
|
||||
.executionType(t.getExecutionType())
|
||||
.price(t.getPrice().doubleValue())
|
||||
.quantity(t.getQuantity().doubleValue())
|
||||
.grossAmount(t.getGrossAmount().doubleValue())
|
||||
|
||||
Reference in New Issue
Block a user