| | |
| | | import com.yami.trading.bean.item.domain.Item; |
| | | import com.yami.trading.common.constants.RedisKeys; |
| | | import com.yami.trading.common.constants.RedisLockKeyConstants; |
| | | import com.yami.trading.service.MarketOpenChecker; |
| | | import com.yami.trading.common.util.RedisUtil; |
| | | import com.yami.trading.common.util.ThreadUtils; |
| | | import com.yami.trading.service.contract.ContractApplyOrderService; |
| | | import com.yami.trading.service.contract.ContractLock; |
| | | import com.yami.trading.service.contract.ContractOrderService; |
| | | import com.yami.trading.service.data.DataService; |
| | | import com.yami.trading.service.item.ItemPreMarketService; |
| | | import com.yami.trading.service.item.ItemService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.redisson.api.RLock; |
| | |
| | | |
| | | @Autowired |
| | | private ItemService itemService; |
| | | |
| | | @Autowired(required = false) |
| | | private ItemPreMarketService itemPreMarketService; |
| | | |
| | | @Autowired |
| | | private RedissonClient redissonClient; |
| | |
| | | continue; |
| | | } |
| | | |
| | | List<Realtime> realtime_list = this.dataService.realtime(order.getSymbol()); |
| | | Realtime realtime = null; |
| | | if (realtime_list.size() > 0) { |
| | | realtime = realtime_list.get(0); |
| | | //log.info("---> ContractApplyOrderHandleJob.run symbol:{} 的 realTime 值为:{}", order.getSymbol(), realtime); |
| | | } else { |
| | | log.warn("---> ContractApplyOrderHandleJob.run symbol:{} 的 realTime 值为空", order.getSymbol()); |
| | | continue; |
| | | } |
| | | |
| | | // 休市不做撮合 |
| | | Item bySymbol = itemService.findBySymbol(order.getSymbol()); |
| | | if (bySymbol == null) { |
| | | continue; |
| | | } |
| | | boolean isOpen = MarketOpenChecker.isMarketOpenByItemCloseType(bySymbol.getOpenCloseType()); |
| | | boolean preMarketActive = itemPreMarketService != null |
| | | && itemPreMarketService.isPreMarketTradingActive(order.getSymbol()); |
| | | boolean isOpen = itemService.isOpen(order.getSymbol()); |
| | | if (!isOpen) { |
| | | //log.warn("---> ContractApplyOrderHandleJob.run symbol:{} 未open", order.getSymbol()); |
| | | continue; |
| | | } |
| | | |
| | | List<Realtime> realtime_list = this.dataService.realtime(order.getSymbol()); |
| | | Realtime realtime = null; |
| | | if (realtime_list.size() > 0) { |
| | | realtime = realtime_list.get(0); |
| | | } else { |
| | | log.warn("---> ContractApplyOrderHandleJob.run symbol:{} 的 realTime 值为空", order.getSymbol()); |
| | | continue; |
| | | } |
| | | if (preMarketActive && itemPreMarketService != null) { |
| | | Double prePrice = itemPreMarketService.getActivePreMarketPrice(order.getSymbol()); |
| | | if (prePrice != null) { |
| | | realtime.setClose(prePrice); |
| | | } |
| | | } |
| | | |
| | | if ("limit".equals(order.getOrderPriceType())) { |
| | | /** |
| | | * 限价单 |
| | | */ |
| | | if ("buy".equals(order.getDirection())) { |
| | | /** |
| | | * 买涨 |
| | | */ |
| | | if (preMarketActive) { |
| | | processSuccess = this.handle(order, realtime); |
| | | } else if ("buy".equals(order.getDirection())) { |
| | | if (BigDecimal.valueOf(realtime.getClose()).compareTo(order.getPrice()) <= 0) { |
| | | processSuccess = this.handle(order, realtime); |
| | | } |
| | | } else { |
| | | /** |
| | | * 买跌 |
| | | */ |
| | | if (BigDecimal.valueOf(realtime.getClose()).compareTo(order.getPrice()) >= 0) { |
| | | processSuccess = this.handle(order, realtime); |
| | | } |
| | | } |
| | | } else { |
| | | /** |
| | | * 非限制,直接进入市场 |
| | | */ |
| | | processSuccess = this.handle(order, realtime); |
| | | } |
| | | } catch (Exception e) { |