【问题标题】:RSI is different in R vs Yahoo Finance/TradingViewRSI 与 Yahoo Finance/TradingView 不同
【发布时间】:2021-09-01 20:00:34
【问题描述】:

在 R 中计算的 RSI 与我在 Yahoo-Finance 中看到的不同。 Yahoo-Finance 文档说它使用SMAclose。我在 R 中做了同样的事情,但值不匹配。我不确定该信任哪一个。我尝试了关闭和调整关闭​​。

library(quantmod)
getSymbols("AAPL", from = '2021-05-01', to = '2021-06-16')

price <- Cl(AAPL)   #Close Price
RSI(price, SMA, n = 5)

RSI(5, Close)的R输出:

雅虎财经:

AdjClose <- Ad(AAPL) # Adjusted close
RSI(AdjClose, SMA, n = 5)

【问题讨论】:

    标签: r quantmod yahoo-finance tidyquant ttr


    【解决方案1】:

    RSI 计算使用 EMA,而不是 SMA。不知道你从哪里得到雅虎的描述,但如果它说它使用 sma,那是不正确的。 rsi的上下计算是典型的ema计算。大多数软件包/软件都使用 Wilder 平滑,但也有少数没有。默认情况下,quantmod 在 RSI 计算中使用 Wilder 平滑。但如果您在 RSI 函数中指定 EMA 而没有 wilder = TRUE,则不会进行平滑处理。

    要获得与 yahoo 相同的数据,您需要使用 quantmond (TTR) 的基本 RSI 函数。

    tail(RSI(price, n = 5))
                    rsi
    2021-06-08 63.28863
    2021-06-09 66.53765
    2021-06-10 51.60627
    2021-06-11 63.91243
    2021-06-14 79.97755
    2021-06-15 69.58576
    

    或者如果您想填写所有详细信息:

    tail(RSI(price, EMA, n = 5, wilder = TRUE))
    
                    rsi
    2021-06-08 63.28863
    2021-06-09 66.53765
    2021-06-10 51.60627
    2021-06-11 63.91243
    2021-06-14 79.97755
    2021-06-15 69.58576
    

    【讨论】:

      猜你喜欢
      • 2021-04-05
      • 2022-01-23
      • 1970-01-01
      • 1970-01-01
      • 2021-08-01
      • 1970-01-01
      • 2020-07-23
      • 2017-09-06
      • 1970-01-01
      相关资源
      最近更新 更多