1

XTS の period.apply() で TTR インジケーター関数を直接使用できないようです。私が間違っていることを理解するのを手伝ってください。

> require(TTR)
> require(quantmod)
> require(xts)
> data(sample_matrix)

> period.apply(sample_matrix, endpoints(sample_matrix,"weeks"), RSI)

Error in EMA(c(NA, 0.190714286249097, 0.190459011271606, 0, 0, 0, NA,  : 
  Invalid 'n'

私もas.xts(sample_matrix)最初に試してみましたが、役に立ちません。

4

1 に答える 1

1

質問へのコメントに基づいて、次のようなものが必要だと思います。

> RSI(Cl(to.period(sample_matrix, "weeks", 2)),4)
               [,1]
2007-01-07       NA
2007-01-21       NA
2007-02-04       NA
2007-02-18       NA
2007-03-04 58.42659
2007-03-18 40.25955
2007-04-01 27.12793
2007-04-15 50.26745
2007-04-29 38.97652
2007-05-13 22.03943
2007-05-27 28.75952
2007-06-10 22.21261
2007-06-24 21.58207
2007-06-30 41.69338
于 2011-03-30T19:25:07.130 に答える