Refinitiv未开盘时,将当前价设为昨日收盘价
This commit is contained in:
@@ -5,6 +5,7 @@ import com.google.common.collect.Lists;
|
|||||||
import com.thomsonreuters.ema.access.DataType;
|
import com.thomsonreuters.ema.access.DataType;
|
||||||
import com.thomsonreuters.ema.access.FieldEntry;
|
import com.thomsonreuters.ema.access.FieldEntry;
|
||||||
import com.thomsonreuters.ema.access.FieldList;
|
import com.thomsonreuters.ema.access.FieldList;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
|
|
||||||
@@ -20,6 +21,7 @@ import java.util.List;
|
|||||||
* @author jnerh
|
* @author jnerh
|
||||||
* @since 2024/04/11 10:20
|
* @since 2024/04/11 10:20
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class RefinitivUtil {
|
public class RefinitivUtil {
|
||||||
|
|
||||||
public static RetifiveStockInfo decodeData(FieldList fieldList, String name) {
|
public static RetifiveStockInfo decodeData(FieldList fieldList, String name) {
|
||||||
@@ -135,7 +137,7 @@ public class RefinitivUtil {
|
|||||||
.week52HighPrice(week52High).week52LowPrice(week52Low).stockType(stockType)
|
.week52HighPrice(week52High).week52LowPrice(week52Low).stockType(stockType)
|
||||||
.change(changeValue)
|
.change(changeValue)
|
||||||
.build();
|
.build();
|
||||||
return handleBlandData(retifiveStockInfo);
|
return handleData(retifiveStockInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -170,8 +172,7 @@ public class RefinitivUtil {
|
|||||||
String volume = "";//实时交易数量
|
String volume = "";//实时交易数量
|
||||||
String stockType = "";
|
String stockType = "";
|
||||||
String changeValue = "";
|
String changeValue = "";
|
||||||
while (iter.hasNext())
|
while (iter.hasNext()) {
|
||||||
{
|
|
||||||
fieldEntry = iter.next();
|
fieldEntry = iter.next();
|
||||||
// System.out.println("Fid: " + fieldEntry.fieldId() + " Name: " + fieldEntry.name() +" Unit: "+DataType.asString(fieldEntry.loadType()) + " value: " + fieldEntry.load());
|
// System.out.println("Fid: " + fieldEntry.fieldId() + " Name: " + fieldEntry.name() +" Unit: "+DataType.asString(fieldEntry.loadType()) + " value: " + fieldEntry.load());
|
||||||
if (fieldEntry.name().equals("DSPLY_NAME")) {
|
if (fieldEntry.name().equals("DSPLY_NAME")) {
|
||||||
@@ -265,10 +266,10 @@ public class RefinitivUtil {
|
|||||||
.volume(volume).week52HighPrice(week52High).week52LowPrice(week52Low).stockType(stockType).change(changeValue)
|
.volume(volume).week52HighPrice(week52High).week52LowPrice(week52Low).stockType(stockType).change(changeValue)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
return handleBlandData(retifiveStockInfo);
|
return handleData(retifiveStockInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static RetifiveStockInfo handleBlandData(RetifiveStockInfo retifiveStockInfo) {
|
private static RetifiveStockInfo handleData(RetifiveStockInfo retifiveStockInfo) {
|
||||||
Field[] fields = retifiveStockInfo.getClass().getDeclaredFields();
|
Field[] fields = retifiveStockInfo.getClass().getDeclaredFields();
|
||||||
Arrays.stream(fields).forEach(field -> {
|
Arrays.stream(fields).forEach(field -> {
|
||||||
ReflectionUtils.makeAccessible(field);
|
ReflectionUtils.makeAccessible(field);
|
||||||
@@ -279,10 +280,28 @@ public class RefinitivUtil {
|
|||||||
field.set(retifiveStockInfo, objStr.replace("(blank data)", ""));
|
field.set(retifiveStockInfo, objStr.replace("(blank data)", ""));
|
||||||
}
|
}
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
throw new RuntimeException(e);
|
log.error("Refinitiv数据源处理数据出错,", e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 未开盘时,将当前价设为昨日收盘价
|
||||||
|
try {
|
||||||
|
Field statusField = retifiveStockInfo.getClass().getDeclaredField("status");
|
||||||
|
ReflectionUtils.makeAccessible(statusField);
|
||||||
|
Object obj = statusField.get(retifiveStockInfo);
|
||||||
|
if (obj instanceof String) {
|
||||||
|
String objStr = (String) obj;
|
||||||
|
if (StringUtils.equals(objStr, "1")) {
|
||||||
|
Field lastPriceField = retifiveStockInfo.getClass().getDeclaredField("lastPrice");
|
||||||
|
Field previousPriceField = retifiveStockInfo.getClass().getDeclaredField("previousPrice");
|
||||||
|
ReflectionUtils.makeAccessible(previousPriceField);
|
||||||
|
ReflectionUtils.makeAccessible(lastPriceField);
|
||||||
|
lastPriceField.set(retifiveStockInfo, previousPriceField.get(retifiveStockInfo));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Refinitiv数据源获取status出错,", e);
|
||||||
|
}
|
||||||
return retifiveStockInfo;
|
return retifiveStockInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user