quantmod 指标计算是否包括当天?
Do quantmod indicator calculations include the current day?
我是 quantmod 的新手,我想知道我可以添加的指标在计算中是否有滞后。
例如,RSI
会根据过去 14 天计算 RSI(不含当前日期或包含当前日期)吗?如果我想获得最后一天的 RSI,我是否应该将带有滞后函数的代码包装在下面的第二行代码中?
# 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)
我用 SMA
检查过,指标似乎包括当前行(最后一个新行)作为计算的一部分,因此需要添加滞后函数以获得最后一个周期当前行的值。这是一个例子:
RSI_14_lastDay <- lag(RSI(Op(Data),n=14),K=1)
我是 quantmod 的新手,我想知道我可以添加的指标在计算中是否有滞后。
例如,RSI
会根据过去 14 天计算 RSI(不含当前日期或包含当前日期)吗?如果我想获得最后一天的 RSI,我是否应该将带有滞后函数的代码包装在下面的第二行代码中?
# 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)
我用 SMA
检查过,指标似乎包括当前行(最后一个新行)作为计算的一部分,因此需要添加滞后函数以获得最后一个周期当前行的值。这是一个例子:
RSI_14_lastDay <- lag(RSI(Op(Data),n=14),K=1)