fix:修改指数信息
This commit is contained in:
@@ -945,8 +945,10 @@ public class StockService {
|
|||||||
market.setName("BSESENSEX指数");
|
market.setName("BSESENSEX指数");
|
||||||
vo1.setIndexVo(market);
|
vo1.setIndexVo(market);
|
||||||
|
|
||||||
String type = "min";
|
String period = "P1D";
|
||||||
List<JSONObject> list = InvestingApis.of().kline(StockCode.of(stockCode), type);
|
String interval = "PT1H";
|
||||||
|
String type = "day";
|
||||||
|
List<JSONObject> list = InvestingApis.of().kIndex(stockCode,period,interval, type);
|
||||||
if(list == null || list.size() == 0){
|
if(list == null || list.size() == 0){
|
||||||
type = "day";
|
type = "day";
|
||||||
list = InvestingApis.of().kline(StockCode.of(stockCode), type);
|
list = InvestingApis.of().kline(StockCode.of(stockCode), type);
|
||||||
@@ -963,8 +965,10 @@ public class StockService {
|
|||||||
market.setName("NIFTY50指数");
|
market.setName("NIFTY50指数");
|
||||||
vo2.setIndexVo(market);
|
vo2.setIndexVo(market);
|
||||||
|
|
||||||
String type = "min";
|
String period = "P1D";
|
||||||
List<JSONObject> list = InvestingApis.of().kline(StockCode.of(stockCode), type);
|
String interval = "PT1H";
|
||||||
|
String type = "day";
|
||||||
|
List<JSONObject> list = InvestingApis.of().kIndex(stockCode,period,interval, type);
|
||||||
if(list == null || list.size() == 0){
|
if(list == null || list.size() == 0){
|
||||||
type = "day";
|
type = "day";
|
||||||
list = InvestingApis.of().kline(StockCode.of(stockCode), type);
|
list = InvestingApis.of().kline(StockCode.of(stockCode), type);
|
||||||
|
|||||||
@@ -153,7 +153,6 @@ public class InvestingApis {
|
|||||||
"Time": "1698055197",
|
"Time": "1698055197",
|
||||||
"Url": "/equities/aditya-birla",
|
"Url": "/equities/aditya-birla",
|
||||||
"Volume": 3693615
|
"Volume": 3693615
|
||||||
* @param httpClient
|
|
||||||
* @param currPage
|
* @param currPage
|
||||||
* @param pageSize
|
* @param pageSize
|
||||||
* @return
|
* @return
|
||||||
@@ -252,6 +251,34 @@ public class InvestingApis {
|
|||||||
.collect(Collectors.toList())
|
.collect(Collectors.toList())
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
public List<JSONObject> kIndex(String code,String period, String interval,String type) throws IOException {
|
||||||
|
if(code == null) {
|
||||||
|
throw new RuntimeException("找不到股票信息");
|
||||||
|
}
|
||||||
|
Date nowDate = new Date();
|
||||||
|
JSONObject json = InvestingInvokerApis.of().__IndiaIndex(code, period,interval);
|
||||||
|
return json
|
||||||
|
.getJSONArray("data")
|
||||||
|
.stream()
|
||||||
|
.map(val -> {
|
||||||
|
JSONArray _ar = (JSONArray) val;
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
item.put("date", _ar.get(0));
|
||||||
|
item.put("open", _ar.get(1));
|
||||||
|
item.put("high", _ar.get(2));
|
||||||
|
item.put("low", _ar.get(3));
|
||||||
|
item.put("close", _ar.get(4));
|
||||||
|
item.put("volume", _ar.get(5));
|
||||||
|
return item;
|
||||||
|
}).filter(val -> {
|
||||||
|
if("min".equalsIgnoreCase(type)) {
|
||||||
|
return DateUtil.isSameDay(nowDate, new Date(val.getLong("date")));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList())
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
public static InvestingApis of() {
|
public static InvestingApis of() {
|
||||||
return new InvestingApis();
|
return new InvestingApis();
|
||||||
|
|||||||
@@ -202,6 +202,15 @@ public class InvestingInvokerApis {
|
|||||||
return JSON.parseObject(body);
|
return JSON.parseObject(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JSONObject __IndiaIndex(String code,String period, String interval)throws IOException {
|
||||||
|
String tmpl = "https://api.investing.com/api/financialdata/{}/historical/chart/?period={}&interval={}&pointscount=160";
|
||||||
|
String url = StrFormatter.format(tmpl, code, period, interval);
|
||||||
|
Builder builder = builderGet(url);
|
||||||
|
|
||||||
|
String body = httpClient().newCall(builder.build()).execute().body().string();
|
||||||
|
return JSON.parseObject(body);
|
||||||
|
}
|
||||||
|
|
||||||
public static InvestingInvokerApis of() {
|
public static InvestingInvokerApis of() {
|
||||||
return new InvestingInvokerApis();
|
return new InvestingInvokerApis();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,4 +71,10 @@ public class BtodayStockPO {
|
|||||||
/**
|
/**
|
||||||
* 上次更新时间 */
|
* 上次更新时间 */
|
||||||
Date lastUpdateTime;
|
Date lastUpdateTime;
|
||||||
|
|
||||||
|
/** 是否锁定 0否 1是 */
|
||||||
|
Integer isLock;
|
||||||
|
|
||||||
|
/** 是否展示 0是 1否 */
|
||||||
|
Integer isShow;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,6 +257,8 @@ public class Scraper {
|
|||||||
btodayStock.setSelfUrl(url);
|
btodayStock.setSelfUrl(url);
|
||||||
btodayStock.setUrl(detailUrl);
|
btodayStock.setUrl(detailUrl);
|
||||||
btodayStock.setLastUpdateTime(new Date());
|
btodayStock.setLastUpdateTime(new Date());
|
||||||
|
btodayStock.setIsLock(0);
|
||||||
|
btodayStock.setIsShow(0);
|
||||||
btodayStockRepo.save(btodayStock);
|
btodayStockRepo.save(btodayStock);
|
||||||
|
|
||||||
/* if (webInfo != null) {
|
/* if (webInfo != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user