xts对象上的Spotvol计算不断产生POSIX和设置错误错误

问题描述 投票:0回答:1

我正在尝试通过使用高频软件包中的spotvol函数来计算大型股票数据集的每日实现/历史波动率。由于某些原因,我不断收到POSIX(时间戳)错误,并且尝试了许多不同的方法将样本转换为xts对象。

数据集样本:

2015-01-02 10:00:00  80.15
2015-01-02 11:00:00  81.00
2015-01-02 12:00:00  80.50
2015-01-02 13:00:00  80.40
2015-01-02 14:00:00  80.15
2015-01-02 15:00:00  81.00
2015-01-02 16:00:00  80.50
2015-01-05 10:00:00  80.40
2015-01-05 11:00:00  80.95
2015-01-05 12:00:00  81.05
2015-01-05 13:00:00  80.85
2015-01-05 14:00:00  80.50
2015-01-05 15:00:00  80.40
2015-01-05 16:00:00  80.95

我用来转换为xts对象的代码如下:

vol_df2 <- vol_df1 %>%
  mutate(time_stamp = as.POSIXct(time_stamp, format = "%Y-%m-%d %H:%M:%S"))

vol_df3 <- as.xts(vol_df2, order.by = vol_df2$time_stamp, tz = "", unique = F)

用于尝试根据1小时时间段]计算每日Spotvol的代码如下:注意:我的实际数据具有很高的频率,因此,我提供了2天中每小时的汇总数据。

  spotvol(vol_df3, method = "detper", on = "hours", k = 1,
          marketopen = "10:00:00", marketclose = "16:00:00")

我得到的错误如下:

Error in as.POSIXlt.character(x, tz, ...): 
character string is not in a standard unambiguous format
  do not know how to convert 'time' to class “POSIXct”
In addition: Warning messages:
1: All formats failed to parse. No formats found. 
2: All formats failed to parse. No formats found. 
3: In min.default(numeric(0), na.rm = FALSE) :
  no non-missing arguments to min; returning Inf
4: In max.default(numeric(0), na.rm = FALSE) :
  no non-missing arguments to max; returning -Inf
5: All formats failed to parse. No formats found.

Error in set(x, j = name, value = value) : 
Supplied 1054304 items to be assigned to 1054377 items of column
'PRICE'. If you wish to 'recycle' the RHS please use rep() to make this
intent clear to readers of your code.

到目前为止,我所做的研究没有得到任何结果,因为我仅遵循有关转换时间戳记以及转换为xts对象的说明。当我运行Linux系统时,遇到了以下问题:https://github.com/Rdatatable/data.table/issues/1619

我也尝试过使用data.table方法,这也会产生与POSIX时间戳的明确格式有关的错误。

就像我在Spotvol的命令中缺少参数一样,但是,我无法确定是否存在可以从此处的文档更改的默认值:https://www.rdocumentation.org/packages/highfrequency/versions/0.6.3/topics/spotvol

编辑:我现在收到的唯一错误是列表中关于设置错误的最后一个错误...当我在fill=TRUE功能的fill=FALSE部分中将aggregatePrice更改为spotvol时spotvol似乎想计算一下,但仍会引发Error in set错误。

在此方面的任何帮助将不胜感激。干杯:)

我正在尝试通过使用高频软件包中的spotvol函数来计算大型股票数据集的每日实现/历史波动率。由于某些原因,我一直在获取POSIX(...

r timestamp time-series xts
1个回答
0
投票

问题出在这行代码中:

© www.soinside.com 2019 - 2024. All rights reserved.