New file |
| | |
| | | package com.xcong.excoin.quartz.job; |
| | | |
| | | 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.symbols.service.SymbolsService; |
| | | import com.xcong.excoin.rabbit.pricequeue.WebsocketPriceService; |
| | | import com.xcong.excoin.utils.CoinTypeConvert; |
| | | import com.xcong.excoin.utils.RedisUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * 最新价更新 |
| | | * |
| | | * @author wzy |
| | | * @date 2020-05-28 |
| | | **/ |
| | | @Slf4j |
| | | @Component |
| | | @ConditionalOnProperty(prefix = "app", name = "day-line", havingValue = "true") |
| | | public class DayLineDataUpdateJob { |
| | | |
| | | @Resource |
| | | private RedisUtils redisUtils; |
| | | |
| | | @Resource |
| | | private SymbolsService symbolsService; |
| | | |
| | | @Resource |
| | | private WebsocketPriceService websocketPriceService; |
| | | |
| | | @PostConstruct |
| | | public void initNewestPrice() { |
| | | log.info("#=======价格更新开启=======#"); |
| | | SubscriptionOptions subscriptionOptions = new SubscriptionOptions(); |
| | | subscriptionOptions.setConnectionDelayOnFailure(5); |
| | | subscriptionOptions.setUri("wss://api.hadax.com/ws"); |
| | | SubscriptionClient subscriptionClient = SubscriptionClient.create("", "", subscriptionOptions); |
| | | |
| | | subscriptionClient.subscribeCandlestickEvent("btcusdt,ethusdt,eosusdt,etcusdt,ltcusdt,bchusdt,xrpusdt", CandlestickInterval.DAY1, (candlestickEvent) -> { |
| | | Candlestick data = candlestickEvent.getData(); |
| | | redisUtils.set(CoinTypeConvert.convert(candlestickEvent.getSymbol()), data); |
| | | }); |
| | | |
| | | } |
| | | } |