导入股票价格技术分析的最佳方法是什么?
What is the best way to import technical analysis of stock prices?
这是我的数据框:
每一行都有不同的日期。如果我想为股票价格导入 RSI,最好的方法是什么?
数据框的原始数据为:
mdate edate tickers adjusted1 adjusted2 adjusted3 close1 close2 close3 high1 high2 high3 low1 low2 low3 open1 open2 open3 volume1 volume2 volume3
2015-10-30 2015-11-04 TK 29.12 29.08 29.59 32.13 32.09 32.65 32.38 32.43 32.95 31.1 31.52 32.1 31.62 31.81 32.18 487000 715900 846100
2015-11-02 2015-11-05 TGP 20.42 20.57 21.08 24.84 25.02 25.64 25.09 25.31 25.81 24.14 24.4 24.9 25.09 24.8 25.05 208500 120800 270900
2015-11-03 2015-11-06 DNR 3.54 3.7 3.91 3.54 3.7 3.91 3.6 3.8 4.07 3.25 3.46 3.76 3.42 3.5 3.8 10959500 10429800 13534400
评论太长,所以这里有一个可能的例子import/analysis
library(quantmod)
library(magrittr)
library(TTR)
names = c("AAPL","AMZN","ANF") ## amazon, aaple, abb & Fitc -- tickers
my_portfolio = names
stocks <- lapply(my_portfolio,function(x){
tryCatch(
{
w = getSymbols(x,auto.assign = F,warnings = F)
message(x," Collected!")
Sys.sleep(0.05)
return(w)
},
error= function(cond)return(data.frame())
)
})
names(stocks) <- my_portfolio
### analysis
stock = stocks$AAPL
# AAPL.Open AAPL.High AAPL.Low AAPL.Close AAPL.Volume AAPL.Adjusted
# 2007-01-03 12.32714 12.36857 11.70000 11.97143 309579900 10.36364
# 2007-01-04 12.00714 12.27857 11.97429 12.23714 211815100 10.59366
# 2007-01-05 12.25286 12.31428 12.05714 12.15000 208685400 10.51822
# 2007-01-08 12.28000 12.36143 12.18286 12.21000 199276700 10.57016
# 2007-01-09 12.35000 13.28286 12.16429 13.22429 837324600 11.44823
# 2007-01-10 13.53571 13.97143 13.35000 13.85714 738220000 11.99609
rsi_ind = RSI(price = stock$AAPL.Close)
macd_ind = MACD(x = stock$AAPL.Close)
## so on
这是我的数据框:
每一行都有不同的日期。如果我想为股票价格导入 RSI,最好的方法是什么?
数据框的原始数据为:
mdate edate tickers adjusted1 adjusted2 adjusted3 close1 close2 close3 high1 high2 high3 low1 low2 low3 open1 open2 open3 volume1 volume2 volume3
2015-10-30 2015-11-04 TK 29.12 29.08 29.59 32.13 32.09 32.65 32.38 32.43 32.95 31.1 31.52 32.1 31.62 31.81 32.18 487000 715900 846100
2015-11-02 2015-11-05 TGP 20.42 20.57 21.08 24.84 25.02 25.64 25.09 25.31 25.81 24.14 24.4 24.9 25.09 24.8 25.05 208500 120800 270900
2015-11-03 2015-11-06 DNR 3.54 3.7 3.91 3.54 3.7 3.91 3.6 3.8 4.07 3.25 3.46 3.76 3.42 3.5 3.8 10959500 10429800 13534400
评论太长,所以这里有一个可能的例子import/analysis
library(quantmod)
library(magrittr)
library(TTR)
names = c("AAPL","AMZN","ANF") ## amazon, aaple, abb & Fitc -- tickers
my_portfolio = names
stocks <- lapply(my_portfolio,function(x){
tryCatch(
{
w = getSymbols(x,auto.assign = F,warnings = F)
message(x," Collected!")
Sys.sleep(0.05)
return(w)
},
error= function(cond)return(data.frame())
)
})
names(stocks) <- my_portfolio
### analysis
stock = stocks$AAPL
# AAPL.Open AAPL.High AAPL.Low AAPL.Close AAPL.Volume AAPL.Adjusted
# 2007-01-03 12.32714 12.36857 11.70000 11.97143 309579900 10.36364
# 2007-01-04 12.00714 12.27857 11.97429 12.23714 211815100 10.59366
# 2007-01-05 12.25286 12.31428 12.05714 12.15000 208685400 10.51822
# 2007-01-08 12.28000 12.36143 12.18286 12.21000 199276700 10.57016
# 2007-01-09 12.35000 13.28286 12.16429 13.22429 837324600 11.44823
# 2007-01-10 13.53571 13.97143 13.35000 13.85714 738220000 11.99609
rsi_ind = RSI(price = stock$AAPL.Close)
macd_ind = MACD(x = stock$AAPL.Close)
## so on