【问题标题】:Do quantmod indicator calculations include the current day?quantmod 指标计算是否包括当天?
【发布时间】:2015-07-21 14:28:52
【问题描述】:

我是 quantmod 的新手,我想知道我可以添加的指标在计算中是否存在滞后。

例如,RSI 会根据过去 14 天(不含当天还是包含当天)计算 RSI?如果我想获得最后一天的 RSI,我应该将带有 lag 函数的代码包装为下面的第二行代码吗?

# The 14-period relative strength index calculated off the open
RSI_14 <- RSI(Op(Data),n=14)
# The 14-period relative strength index calculated off the prior day's open
RSI_14_lastDay <- lag(RSI(Op(Data),n=14),K=1)

【问题讨论】:

  • 仅供参考,大部分指标计算都在TTR,而不是quantmod。

标签: r quantmod


【解决方案1】:

我用SMA 进行了检查,似乎指标包括当前行(最后一个新行)作为计算的一部分,因此需要添加一个滞后函数以获得当前的最后一个周期值排。这是一个例子:

RSI_14_lastDay <- lag(RSI(Op(Data),n=14),K=1)

【讨论】:

    猜你喜欢
    • 2013-07-20
    • 2022-12-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-02
    • 2022-06-13
    • 2017-02-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多