具有用于 HFT 的无间隔时间间隔的 xts 的 R 索引(跟进显示时间索引提示)

发布于 2024-11-18 23:21:40 字数 1007 浏览 4 评论 0原文

Joshua,

我希望您不会发现这是一种外行方法,但是当我尝试实现您的提示如何在我的 xts 对象上仅显示某些时间索引时,我总是得到空白数字。

> dput(x)
structure(c("BHP", "BHP", "BHP", "BHP", "BHP", "BHP", "N", "N", 
"N", "N", "N", "N", "44560", "44560.0313951103", "44551.6606603345", 
"44560", "44560", "44560", "39844", "1072460", "405128", "4911", 
"2782", "1632", "44570", "44573.2273632603", "44579.8960524827", 
"44577.1033732318", "44579.9904979095", "44574.9768058317", "80", 
"13054", "88410", "13785", "5262", "1509", "12", "12", "12", 
"12", "12", "12"), .indexCLASS = structure("timeDate", package = "timeDate"),
.indexTZ = "", class = c("xts", "zoo"), index = structure(c(1306922412,
1306922414, 1306922415, 1306922416, 1306922417, 1306922418), tzone = "",
tclass = structure("timeDate", package = "timeDate")), .Dim = 6:7, .Dimnames = 
list(NULL, c("SYMBOL", "EX", "BID", "BIDSIZ", "OFR", "OFRSIZ","MODE")))
> x["T10:00:14/T10:00:17"]
     SYMBOL EX BID BIDSIZ OFR OFRSIZ MODE

因此,尽管这些值显然存在,但我没有得到任何值,我错过了什么?

Joshua,

I hope you do not find this to be a layman approach but when I tried to implement your hint how to display only certain time index on my xts object i always get blank figures.

> dput(x)
structure(c("BHP", "BHP", "BHP", "BHP", "BHP", "BHP", "N", "N", 
"N", "N", "N", "N", "44560", "44560.0313951103", "44551.6606603345", 
"44560", "44560", "44560", "39844", "1072460", "405128", "4911", 
"2782", "1632", "44570", "44573.2273632603", "44579.8960524827", 
"44577.1033732318", "44579.9904979095", "44574.9768058317", "80", 
"13054", "88410", "13785", "5262", "1509", "12", "12", "12", 
"12", "12", "12"), .indexCLASS = structure("timeDate", package = "timeDate"),
.indexTZ = "", class = c("xts", "zoo"), index = structure(c(1306922412,
1306922414, 1306922415, 1306922416, 1306922417, 1306922418), tzone = "",
tclass = structure("timeDate", package = "timeDate")), .Dim = 6:7, .Dimnames = 
list(NULL, c("SYMBOL", "EX", "BID", "BIDSIZ", "OFR", "OFRSIZ","MODE")))
> x["T10:00:14/T10:00:17"]
     SYMBOL EX BID BIDSIZ OFR OFRSIZ MODE

So I get no values though the values are clearly there, what am I missing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

音盲 2024-11-25 23:21:40

您没有说明如何创建 xts 对象,但我认为这是 xts 创建对象方式的一个小错误 - 它没有从 timeDate 对象中添加 TZ。

尝试:

 indexTZ(x) <- "GMT"

 x['20110601 10:00:14/20110601 10:00:17']
                SYMBOL EX  BID                BIDSIZ    OFR               
 2011-06-01 10:00:14 "BHP"  "N" "44560.0313951103" "1072460" "44573.2273632603"
 2011-06-01 10:00:15 "BHP"  "N" "44551.6606603345" "405128"  "44579.8960524827"
 2011-06-01 10:00:16 "BHP"  "N" "44560"            "4911"    "44577.1033732318"
 2011-06-01 10:00:17 "BHP"  "N" "44560"            "2782"    "44579.9904979095"
                OFRSIZ  MODE
 2011-06-01 10:00:14 "13054" "12"
 2011-06-01 10:00:15 "88410" "12"
 2011-06-01 10:00:16 "13785" "12"
 2011-06-01 10:00:17 "5262"  "12"

HTH
Jeff

w.rt 这个错误 - 我会调查并修补。谢谢。

You don't say how you are creating the xts object, but I think it is a small bug in how xts is creating the object - it is not adding in the TZ from the timeDate object.

Try:

 indexTZ(x) <- "GMT"

 x['20110601 10:00:14/20110601 10:00:17']
                SYMBOL EX  BID                BIDSIZ    OFR               
 2011-06-01 10:00:14 "BHP"  "N" "44560.0313951103" "1072460" "44573.2273632603"
 2011-06-01 10:00:15 "BHP"  "N" "44551.6606603345" "405128"  "44579.8960524827"
 2011-06-01 10:00:16 "BHP"  "N" "44560"            "4911"    "44577.1033732318"
 2011-06-01 10:00:17 "BHP"  "N" "44560"            "2782"    "44579.9904979095"
                OFRSIZ  MODE
 2011-06-01 10:00:14 "13054" "12"
 2011-06-01 10:00:15 "88410" "12"
 2011-06-01 10:00:16 "13785" "12"
 2011-06-01 10:00:17 "5262"  "12"

HTH
Jeff

w.r.t. the bug - I'll look into and patch. Thanks.

烟酒忠诚 2024-11-25 23:21:40
> x[ with(as.POSIXlt(index(x)), ( sec >= 14)) & with(as.POSIXlt(index(x)), ( sec <= 16) ), ]

                    SYMBOL EX  BID                BIDSIZ    OFR               
2011-06-01 10:00:14 "BHP"  "N" "44560.0313951103" "1072460" "44573.2273632603"
2011-06-01 10:00:15 "BHP"  "N" "44551.6606603345" "405128"  "44579.8960524827"
2011-06-01 10:00:16 "BHP"  "N" "44560"            "4911"    "44577.1033732318"
                    OFRSIZ  MODE
2011-06-01 10:00:14 "13054" "12"
2011-06-01 10:00:15 "88410" "12"
2011-06-01 10:00:16 "13785" "12"

当在秒级规范中使用时,我无法使 ?"[.xts" 中描述的形式正常工作,但我看到 Jeff R 已经到达现场并证明了 indexTZ(x) < ;- “GMT” 机动(我查看的许多帮助页面中都没有引用,但这是必要的。

> x[ with(as.POSIXlt(index(x)), ( sec >= 14)) & with(as.POSIXlt(index(x)), ( sec <= 16) ), ]

                    SYMBOL EX  BID                BIDSIZ    OFR               
2011-06-01 10:00:14 "BHP"  "N" "44560.0313951103" "1072460" "44573.2273632603"
2011-06-01 10:00:15 "BHP"  "N" "44551.6606603345" "405128"  "44579.8960524827"
2011-06-01 10:00:16 "BHP"  "N" "44560"            "4911"    "44577.1033732318"
                    OFRSIZ  MODE
2011-06-01 10:00:14 "13054" "12"
2011-06-01 10:00:15 "88410" "12"
2011-06-01 10:00:16 "13785" "12"

I could not get the form described in ?"[.xts" to work when being used at the seconds-level of specification, but I see that Jeff R has arrived on the scene and demonstrated that the indexTZ(x) <- "GMT" maneuver (not referenced from any of many the help pages I looked at, is necessary.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文