From d174d6963d62b3bd176f9e7ba3cf0d7f75a91b69 Mon Sep 17 00:00:00 2001 From: zainali5120 <512061637@qq.com> Date: Wed, 16 Sep 2020 16:03:22 +0800 Subject: [PATCH] 撮合交易代码提交 --- src/main/java/com/xcong/excoin/quartz/job/CoinTradeInitJob.java | 22 +++++++++++++++++++++- 1 files changed, 21 insertions(+), 1 deletions(-) diff --git a/src/main/java/com/xcong/excoin/quartz/job/CoinTradeInitJob.java b/src/main/java/com/xcong/excoin/quartz/job/CoinTradeInitJob.java index 91a81fd..9d4215c 100644 --- a/src/main/java/com/xcong/excoin/quartz/job/CoinTradeInitJob.java +++ b/src/main/java/com/xcong/excoin/quartz/job/CoinTradeInitJob.java @@ -1,10 +1,12 @@ package com.xcong.excoin.quartz.job; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.huobi.client.SubscriptionClient; import com.huobi.client.SubscriptionOptions; import com.huobi.client.model.Candlestick; import com.huobi.client.model.enums.CandlestickInterval; +import com.xcong.excoin.modules.coin.dao.OrderCoinDealDao; import com.xcong.excoin.modules.coin.dao.OrderCoinsDao; import com.xcong.excoin.modules.coin.entity.OrderCoinsEntity; import com.xcong.excoin.modules.coin.service.OrderCoinService; @@ -17,6 +19,7 @@ import com.xcong.excoin.rabbit.producer.ExchangeProducer; import com.xcong.excoin.trade.CoinTrader; import com.xcong.excoin.trade.CoinTraderFactory; +import com.xcong.excoin.trade.ExchangeTrade; import com.xcong.excoin.utils.CoinTypeConvert; import com.xcong.excoin.utils.RedisUtils; import lombok.extern.slf4j.Slf4j; @@ -30,6 +33,7 @@ import java.text.ParseException; import java.util.ArrayList; import java.util.List; +import java.util.Map; /** * 开启撮合交易 @@ -44,12 +48,14 @@ @Resource private OrderCoinsDao orderCoinsDao; + @Resource + private OrderCoinDealDao orderCoinDealDao; @Resource private CoinTraderFactory factory; @Resource - private OrderCoinService coinService; + private RedisUtils redisUtils; @Resource private MarketService marketService; @@ -98,7 +104,21 @@ processor.initializeThumb(); //processor.initializeUsdRate(); processor.setIsHalt(false); + List<ExchangeTrade> nekk = orderCoinDealDao.selectOrderCoinDealByTime("NEKK", null, null); + processor.process(nekk); + String symbolUsdt = symbol; + if(!symbol.contains("USDT")){ + symbolUsdt = symbol+"/USDT"; + } + String key = "NEW_KINE_{}"; + key = StrUtil.format(key, symbolUsdt); + Object o = redisUtils.get(key); + if(o!=null){ + Map<String, Candlestick> currentKlineMap = (Map<String, Candlestick> )o; + ((DefaultCoinProcessor) processor).setCurrentKlineMap(currentKlineMap); + } processorFactory.addProcessor(symbol, processor); + } } -- Gitblit v1.9.1