package com.yami.trading.huobi.task;
|
|
|
import com.yami.trading.bean.item.domain.Item;
|
import com.yami.trading.huobi.hobi.internal.XueQiuDataServiceImpl;
|
import com.yami.trading.service.MarketOpenChecker;
|
import com.yami.trading.huobi.hobi.internal.SpiderService;
|
import com.yami.trading.huobi.hobi.internal.TWDataServiceImpl;
|
import com.yami.trading.service.item.ItemService;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.context.annotation.Lazy;
|
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.stereotype.Component;
|
|
import java.util.ArrayList;
|
import java.util.stream.Collectors;
|
|
/**
|
* @哪吒出海 股票市场深度数据
|
*/
|
@Component
|
@Lazy(value = false)
|
@Slf4j
|
public class AStockTradeListTask {
|
@Autowired
|
private DepthPushJob depthPushJob;
|
@Autowired
|
private ItemService itemService;
|
//@Autowired
|
//private SpiderService spiderService;
|
|
@Autowired
|
private XueQiuDataServiceImpl xueQiuDataService;
|
|
@Autowired
|
private TWDataServiceImpl twDataService;
|
private volatile boolean isAStockInit = false;
|
private volatile boolean isUsStockInit = false;
|
|
private volatile boolean isTwStockInit = false;
|
|
/**
|
* 雪球接口频繁 暂时取消市场深度数据 【后续优化成模拟数据自动生成】
|
* @throws 哪吒出海
|
*/
|
//@Scheduled(cron = "*/5 * * * * ?")
|
public void sendTask() throws InterruptedException {
|
if(!isAStockInit){
|
fetchAStock();
|
isAStockInit = true;
|
}
|
if(MarketOpenChecker.isMarketOpenByItemCloseType(Item.A_STOCKS)){
|
fetchAStock();
|
}
|
|
if(!isUsStockInit){
|
fetchUs();
|
|
isUsStockInit = true;
|
}
|
if(MarketOpenChecker.isMarketOpenByItemCloseType(Item.US_STOCKS)){
|
fetchUs();
|
|
}
|
|
if(!isTwStockInit){
|
//fetchTW();
|
|
isTwStockInit = true;
|
}
|
if(MarketOpenChecker.isMarketOpenByItemCloseType(Item.TW_STOCKS)){
|
//fetchTW();
|
|
}
|
|
}
|
|
private void fetchAStock() {
|
//接口目前只能单个获取
|
//String remarks = new ArrayList<>(itemService.list()).stream().filter(t->t.isActive() && Item.A_STOCKS.equalsIgnoreCase(t.getOpenCloseType())).map(Item::getRemarks).collect(Collectors.joining(","));
|
//xueQiuDataService.tradeList(remarks, false);
|
itemService.list().stream().filter(t->Item.A_STOCKS.equalsIgnoreCase(t.getOpenCloseType())).map(Item::getSymbol).forEach(symbols->{
|
xueQiuDataService.tradeList(symbols, false);
|
});
|
}
|
|
private void fetchUs() {
|
//接口目前只能单个获取
|
//String remarks = new ArrayList<>(itemService.list()).stream().filter(t->t.isActive() && Item.US_STOCKS.equalsIgnoreCase(t.getOpenCloseType())).map(Item::getRemarks).collect(Collectors.joining(","));
|
//xueQiuDataService.tradeList(remarks, true);
|
itemService.findByType(Item.US_STOCKS).stream().map(Item::getSymbol).forEach(usSymbols->{
|
xueQiuDataService.tradeList(usSymbols, true);
|
});
|
}
|
private void fetchTW() {
|
String remarks = new ArrayList<>(itemService.list()).stream().filter(t->t.isActive() && Item.TW_STOCKS.equalsIgnoreCase(t.getOpenCloseType())).map(Item::getRemarks).collect(Collectors.joining(","));
|
xueQiuDataService.tradeList(remarks, true);
|
}
|
|
}
|