Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,16 @@ public void executeTrade(WaitingOrders waitingOrders, TradePair<Order, Order> tr
tradeService.updateOrder(sellOrder);

// 예수금 처리
// - 매도 예수금 처리
this.increaseAccountCash(sellOrder, totalTradedPrice);

// - 매수 잔여금액 반환
if (!isMarketOrder(buyOrder) && buyOrder.getPrice() > tradedPrice) { // 매도 호가보다 높은 가격에 매수를 시도한 경우, 차액 반환
log.debug("[{}] 매도 호가보다 높은 가격에 매수를 시도한 경우, 차액 반환", Thread.currentThread().threadId());
double totalRefundAmount = (buyOrder.getPrice() - tradedPrice) * tradedSize;
this.increaseAccountCash(buyOrder, totalRefundAmount);
}

// - 매도 예수금 처리
this.increaseAccountCash(sellOrder, totalTradedPrice);

// 지갑 누적계산
this.updateWalletAfterTrade(buyOrder, ticker, tradedSize, totalTradedPrice);
this.updateWalletAfterTrade(sellOrder, ticker, tradedSize, totalTradedPrice);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.cleanengine.coin.user.info.infra.WalletRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Optional;
Expand Down Expand Up @@ -38,7 +39,7 @@ public Account createNewAccount(Integer userId, double cash) {
return accountRepository.save(account);
}

@Transactional
@Transactional(isolation = Isolation.READ_COMMITTED)
public void resetBot(String ticker) {
Account sellBotAccount = accountRepository.findByUserId(SELL_ORDER_BOT_ID).orElseThrow();
sellBotAccount.setCash(0.0);
Expand Down
Loading