File was renamed from src/main/java/com/xcong/excoin/quartz/job/KLineDataJob.java |
| | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | 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.huobi.client.model.enums.MBPLevelEnums; |
| | | import com.huobi.client.model.event.PriceDepthEvent; |
| | | import com.xcong.excoin.netty.server.TcpServer; |
| | | import com.xcong.excoin.netty.server.WebSocketServer; |
| | | import com.xcong.excoin.netty.common.NettyTools; |
| | | import com.xcong.excoin.netty.common.ServerChannelManager; |
| | | import com.xcong.excoin.utils.CoinTypeConvert; |
| | | import com.xcong.excoin.utils.RedisUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * 火币实时数据获取 |
| | | * |
| | | * @author wzy |
| | | * @date 2021-02-23 |
| | | **/ |
| | | @Slf4j |
| | | @Component |
| | | public class KLineDataJob { |
| | | public class HuoBiDataUpdateJob { |
| | | @Autowired |
| | | private SubscriptionClient subscriptionClient; |
| | | |
| | | // @PostConstruct |
| | | @Resource |
| | | private RedisUtils redisUtils; |
| | | |
| | | @PostConstruct |
| | | public void data() throws Exception { |
| | | log.info("=================="); |
| | | subscriptionClient.subscribeCandlestickEvent("btcusdt,ethusdt,eosusdt,etcusdt,ltcusdt,bchusdt,xrpusdt", CandlestickInterval.DAY1, (candlestickEvent) -> { |
| | | Candlestick data = candlestickEvent.getData(); |
| | | }); |
| | | |
| | | // subscriptionClient.subscribePriceDepthEvent("btcusdt", priceDepthEvent -> { |
| | | // log.info("bids:{}", JSONObject.toJSONString(priceDepthEvent.getData().getBids())); |
| | | // log.info("asks:{}", JSONObject.toJSONString(priceDepthEvent.getData().getAsks())); |
| | | // }); |
| | | |
| | | log.info("========火币数据获取=========="); |
| | | subscriptionClient.subscribeCandlestickEvent("btcusdt,ethusdt,eosusdt,etcusdt,ltcusdt,bchusdt,xrpusdt", CandlestickInterval.MIN1, (candlestickEvent) -> { |
| | | Candlestick data = candlestickEvent.getData(); |
| | | }); |
| | |
| | | |
| | | subscriptionClient.subscribeCandlestickEvent("btcusdt,ethusdt,eosusdt,etcusdt,ltcusdt,bchusdt,xrpusdt", CandlestickInterval.DAY1, (candlestickEvent) -> { |
| | | Candlestick data = candlestickEvent.getData(); |
| | | redisUtils.set(CoinTypeConvert.convert(candlestickEvent.getSymbol()), data); |
| | | }); |
| | | |
| | | subscriptionClient.subscribeCandlestickEvent("btcusdt,ethusdt,eosusdt,etcusdt,ltcusdt,bchusdt,xrpusdt", CandlestickInterval.WEEK1, (candlestickEvent) -> { |
| | | Candlestick data = candlestickEvent.getData(); |
| | | }); |
| | | |
| | | // 最新价处理 |
| | | subscriptionClient.subscribeTradeEvent("btcusdt,ethusdt,xrpusdt,ltcusdt,bchusdt,eosusdt,etcusdt", tradeEvent -> { |
| | | ServerChannelManager.getTcpGroup().writeAndFlush(NettyTools.textBytes(JSONObject.toJSONString(tradeEvent))); |
| | | }); |
| | | |
| | | subscriptionClient.subscribePriceDepthEvent("btcusdt,ethusdt,xrpusdt,ltcusdt,bchusdt,eosusdt,etcusdt", priceDepthEvent -> { |
| | | }); |
| | | } |
| | | } |