feat: retifive K线
This commit is contained in:
@@ -255,7 +255,8 @@ public class RefinitivConsumer implements ApplicationRunner {
|
||||
}
|
||||
}
|
||||
|
||||
public JSONArray getKLink(String symbol,String resolution){
|
||||
public StockHistoryResponse getKLink(String symbol,String resolution){
|
||||
StockHistoryResponse result = new StockHistoryResponse();
|
||||
String token = getToken();
|
||||
if(StringUtils.isBlank(token)){
|
||||
throw new SysTipsException("token为空");
|
||||
@@ -290,8 +291,36 @@ public class RefinitivConsumer implements ApplicationRunner {
|
||||
if(response.getStatus() != 200){
|
||||
throw new SysTipsException("获取股票K线失败");
|
||||
}
|
||||
JSONArray jsonArray = JSONArray.parseArray(response.body());
|
||||
JSONArray dateArray = JSONObject.parseObject(jsonArray.get(0).toString()).getJSONArray("data");
|
||||
List<Long> t = new ArrayList<>(); //时间
|
||||
List<Double> o = new ArrayList<>(); //开盘价
|
||||
List<Double> h = new ArrayList<>(); // 最高价
|
||||
List<Double> l = new ArrayList<>();//最低价
|
||||
List<Double> c = new ArrayList<>();//当前价
|
||||
List<Long> v = new ArrayList<>();//交易量
|
||||
for(int i = 0; i < dateArray.size(); i++){
|
||||
JSONArray date = dateArray.getJSONArray(i);
|
||||
|
||||
return JSONArray.parseArray(response.body());
|
||||
Instant instant = Instant.parse(date.get(0).toString());
|
||||
long timestampMillis = instant.toEpochMilli();
|
||||
t.add(timestampMillis);
|
||||
|
||||
o.add(Double.valueOf(date.get(3).toString()));
|
||||
|
||||
h.add(Double.valueOf(date.get(1).toString()));
|
||||
l.add(Double.valueOf(date.get(2).toString()));
|
||||
c.add(Double.valueOf(date.get(4).toString()));
|
||||
v.add(Long.valueOf(date.get(6).toString()));
|
||||
}
|
||||
result.setT(t);
|
||||
result.setO(o);
|
||||
result.setH(h);
|
||||
result.setL(l);
|
||||
result.setC(c);
|
||||
result.setV(v);
|
||||
result.setS("ok");
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getToken(){
|
||||
|
||||
Reference in New Issue
Block a user