getHS1DayDataFromRaw <- function(theFile,sPeriod="/"){
dat <- readBin(theFile, 'raw', n=100000000)
mat <- matrix(dat, byrow=T, ncol=32)
dt <- as.Date(as.character(apply(mat[, 1:4, drop=FALSE], 1, function(x) readBin(x,"integer",size=4) )), '%Y%m%d')
op <- apply(mat[, 5:8, drop=FALSE], 1, function(x) readBin(x,"integer",size=4)/100 )
hi <- apply(mat[, 9:12, drop=FALSE], 1, function(x) readBin(x,"integer",size=4)/100 )
lo <- apply(mat[, 13:16, drop=FALSE], 1, function(x) readBin(x,"integer",size=4)/100 )
cl <- apply(mat[, 17:20, drop=FALSE], 1, function(x) readBin(x,"integer",size=4)/100 )
am <- apply(mat[, 21:24, drop=FALSE], 1, function(x) readBin(x,"double",size=4) )
vo <- apply(mat[, 25:28, drop=FALSE], 1, function(x) readBin(x,"integer",size=4))
theData <- data.frame(dt, op, hi, lo, cl, vo, am,stringsAsFactors=FALSE)
theData <- try.xts(theData[,c(2,3,4,5,6,7)],as.POSIXct(theData[,
R 读取 通达信V5.92 日数据文件 *.day 代码
最新推荐文章于 2025-10-03 19:59:11 发布
本文介绍了一种使用R语言从通达信V5.92读取股票历史数据的方法,详细解释了如何通过自定义函数getHS1DayDataFromRaw解析原始数据文件,获取包括日期、开盘价、最高价、最低价、收盘价、成交量和成交额在内的数据,并将其转换为时间序列格式。值得注意的是,该数据为未复权的真实价格数据。

最低0.47元/天 解锁文章
5815

被折叠的 条评论
为什么被折叠?



