| | |
| | | import com.yami.trading.bean.purchasing.dto.ExchangeLock; |
| | | import com.yami.trading.common.exception.YamiShopBindException; |
| | | import com.yami.trading.common.util.ThreadUtils; |
| | | import com.yami.trading.service.MarketOpenChecker; |
| | | import com.yami.trading.service.data.DataService; |
| | | import com.yami.trading.service.exchange.ExchangeApplyOrderService; |
| | | import com.yami.trading.service.item.ItemPreMarketService; |
| | | import com.yami.trading.service.item.ItemService; |
| | | import com.yami.trading.service.syspara.SysparaService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | @Autowired |
| | | ItemService itemService; |
| | | @Autowired |
| | | ItemPreMarketService itemPreMarketService; |
| | | @Autowired |
| | | SysparaService sysparaService; |
| | | |
| | | public void start() { |
| | |
| | | if (bySymbol == null) { |
| | | throw new YamiShopBindException("当前币对不存在"); |
| | | } |
| | | boolean isOpen = MarketOpenChecker.isMarketOpenByItemCloseType(bySymbol.getOpenCloseType()); |
| | | boolean isOpen = itemService.isOpen(order.getSymbol()); |
| | | if (!isOpen) { |
| | | continue; |
| | | } |
| | | Realtime realtime = this.dataService.realtime(order.getSymbol()).get(0); |
| | | Double fillPrice = realtime.getClose(); |
| | | boolean preMarketActive = itemPreMarketService != null |
| | | && itemPreMarketService.isPreMarketTradingActive(order.getSymbol()); |
| | | if (preMarketActive) { |
| | | Double prePrice = itemPreMarketService.getActivePreMarketPrice(order.getSymbol()); |
| | | if (prePrice != null) { |
| | | fillPrice = prePrice; |
| | | } |
| | | } |
| | | // 限价单 |
| | | if (ExchangeApplyOrder.ORDER_PRICE_TYPE_LIMIT.equals(order.getOrderPriceType())) { |
| | | if (ExchangeApplyOrder.OFFSET_OPEN.equals(order.getOffset())) { |
| | | if (preMarketActive) { |
| | | this.handle(order, fillPrice); |
| | | } else if (ExchangeApplyOrder.OFFSET_OPEN.equals(order.getOffset())) { |
| | | if (realtime.getClose() <= order.getPrice()) { |
| | | this.handle(order, realtime.getClose()); |
| | | } |
| | |
| | | } |
| | | // 市价单 |
| | | else { |
| | | this.handle(order, realtime.getClose()); |
| | | this.handle(order, fillPrice); |
| | | } |
| | | } |
| | | } catch (Exception e) { |