fix:优化股票K线图
This commit is contained in:
@@ -8,6 +8,7 @@ import cn.hutool.http.HttpUtil;
|
|||||||
import cn.stock.market.domain.basic.entity.RetifiveStock;
|
import cn.stock.market.domain.basic.entity.RetifiveStock;
|
||||||
import cn.stock.market.dto.RetifiveStockInfo;
|
import cn.stock.market.dto.RetifiveStockInfo;
|
||||||
import cn.stock.market.dto.StockHistoryResponse;
|
import cn.stock.market.dto.StockHistoryResponse;
|
||||||
|
import cn.stock.market.utils.DateTimeUtil;
|
||||||
import cn.stock.market.utils.RefinitivUtil;
|
import cn.stock.market.utils.RefinitivUtil;
|
||||||
import com.ag.exception.SysTipsException;
|
import com.ag.exception.SysTipsException;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
@@ -25,6 +26,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@@ -268,19 +270,48 @@ public class RefinitivConsumer implements ApplicationRunner {
|
|||||||
int countback = 5;
|
int countback = 5;
|
||||||
String interval = null;
|
String interval = null;
|
||||||
String resourceEndpoint = null;
|
String resourceEndpoint = null;
|
||||||
if(StringUtils.equals("H",resolution)){
|
Date start = new Date();
|
||||||
|
if(StringUtils.equals("1m",resolution)){
|
||||||
|
start = DateTimeUtil.getDayOfMorning(start,0);
|
||||||
|
countback = 360;
|
||||||
|
interval = "PT1M";
|
||||||
|
resourceEndpoint = baseURLToday + symbol;
|
||||||
|
}else
|
||||||
|
if(StringUtils.equals("3m",resolution)){
|
||||||
|
start = DateTimeUtil.getDayOfMorning(start,0);
|
||||||
|
countback = 150;
|
||||||
|
interval = "PT3M";
|
||||||
|
resourceEndpoint = baseURLToday + symbol;
|
||||||
|
}else
|
||||||
|
if(StringUtils.equals("15m",resolution)){
|
||||||
|
start = DateTimeUtil.getDayOfMorning(start,0);
|
||||||
|
countback = 50;
|
||||||
|
interval = "PT15M";
|
||||||
|
resourceEndpoint = baseURLToday + symbol;
|
||||||
|
}else
|
||||||
|
if(StringUtils.equals("30m",resolution)){
|
||||||
|
start = DateTimeUtil.getDayOfMorning(start,0);
|
||||||
countback = 30;
|
countback = 30;
|
||||||
|
interval = "PT30M";
|
||||||
|
resourceEndpoint = baseURLToday + symbol;
|
||||||
|
}else
|
||||||
|
if(StringUtils.equals("H",resolution)){
|
||||||
|
start = DateTimeUtil.getDayOfMorning(start,0);
|
||||||
|
countback = 60;
|
||||||
interval = "PT1H";
|
interval = "PT1H";
|
||||||
resourceEndpoint = baseURLToday + symbol;
|
resourceEndpoint = baseURLToday + symbol;
|
||||||
}else if(StringUtils.equals("D",resolution)){
|
}else if(StringUtils.equals("D",resolution)){
|
||||||
|
start = DateTimeUtil.getDayOfMorning(start,-30);
|
||||||
countback = 30;
|
countback = 30;
|
||||||
interval ="P1D";
|
interval ="P1D";
|
||||||
resourceEndpoint = baseURLHistory + symbol;
|
resourceEndpoint = baseURLHistory + symbol;
|
||||||
}else if(StringUtils.equals("W",resolution)){
|
}else if(StringUtils.equals("W",resolution)){
|
||||||
|
start = DateTimeUtil.getDayOfMorning(start,-60);
|
||||||
countback = 30;
|
countback = 30;
|
||||||
interval ="P1W";
|
interval ="P1W";
|
||||||
resourceEndpoint = baseURLHistory + symbol;
|
resourceEndpoint = baseURLHistory + symbol;
|
||||||
}else if(StringUtils.equals("M",resolution)){
|
}else if(StringUtils.equals("M",resolution)){
|
||||||
|
start = DateTimeUtil.getDayOfYear(start,-1);
|
||||||
countback = 30;
|
countback = 30;
|
||||||
interval ="P1M";
|
interval ="P1M";
|
||||||
resourceEndpoint = baseURLHistory + symbol;
|
resourceEndpoint = baseURLHistory + symbol;
|
||||||
@@ -288,7 +319,7 @@ public class RefinitivConsumer implements ApplicationRunner {
|
|||||||
|
|
||||||
HttpResponse response = HttpUtil.createGet(resourceEndpoint)
|
HttpResponse response = HttpUtil.createGet(resourceEndpoint)
|
||||||
.form("eventTypes","trade,quote")
|
.form("eventTypes","trade,quote")
|
||||||
.form("start","2023-05-11T18:30:12.000000000Z")
|
.form("start",start)
|
||||||
.form("count",countback)
|
.form("count",countback)
|
||||||
.form("interval",interval)
|
.form("interval",interval)
|
||||||
.header("Authorization","Bearer " + token)
|
.header("Authorization","Bearer " + token)
|
||||||
|
|||||||
@@ -185,6 +185,31 @@ public class DateTimeUtil {
|
|||||||
return cal.getTime();
|
return cal.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取某个时间的凌晨时间
|
||||||
|
* @param time
|
||||||
|
* @param date
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Date getDayOfMorning(Date time,Integer date){
|
||||||
|
Calendar lastDate = Calendar.getInstance();
|
||||||
|
lastDate.setTime(time);
|
||||||
|
lastDate.add(Calendar.DATE,date);
|
||||||
|
lastDate.set(Calendar.HOUR_OF_DAY,0);
|
||||||
|
lastDate.set(Calendar.MINUTE,0);
|
||||||
|
lastDate.set(Calendar.SECOND,0);
|
||||||
|
lastDate.set(Calendar.MILLISECOND,0);
|
||||||
|
return lastDate.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取某个时间的前/后时间,以年为单位
|
||||||
|
public static Date getDayOfYear(Date time,Integer date){
|
||||||
|
Calendar lastDate = Calendar.getInstance();
|
||||||
|
lastDate.setTime(time);
|
||||||
|
lastDate.add(Calendar.YEAR,date);
|
||||||
|
return lastDate.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
parseToDateByMinute(10);
|
parseToDateByMinute(10);
|
||||||
|
|||||||
Reference in New Issue
Block a user