以下是我开始的代码:
library(quantmod)
library(timetk)
library(dplyr)
library(tibble)
library(tidyr)
mdate <- "2019-05-01"
edate <- "2019-05-03"
tickers <- c("MMM","C", "AAPL")
for(ticker in tickers)
Open_Raw <- cbind(Open_Raw, getSymbols(ticker, from = mdate, to = edate, auto.assign = F)[,1])
timetk::tk_tbl(Open_Raw)
Open_Raw <- timetk::tk_tbl(Open_Raw)[, -1]
colnames(Open_Raw) = tickers
## Open Price
Open_Raw <- NULL
for(ticker in tickers)
Open_Raw <- cbind(Open_Raw, getSymbols(ticker, from = mdate, to = edate, auto.assign = F)[,1])
Topen_Raw <- t(Open_Raw)
## High Price
High_Raw <- NULL
for(ticker in tickers)
High_Raw <- cbind(High_Raw, getSymbols(ticker, from = mdate, to = edate, auto.assign = F)[,2])
Thigh_Raw <- t(High_Raw)
## Low Price
Low_Raw <- NULL
for(ticker in tickers)
Low_Raw <- cbind(Low_Raw, getSymbols(ticker, from = mdate, to = edate, auto.assign = F)[,2])
Tlow_Raw <- t(Low_Raw)
## write in the same way for Close, Adjusted and Volume, and;
##Cbind Open and High
Open_High <- cbind(Topen_Raw, Thigh_Raw)
##Cbind Open_High and Low_Raw
Open_to_Low <- cbind(Open_High, Tlow_Raw)
如您所见,前两列是开盘价,第三和第四列是最高价。我可以用这些代码得到我想要的输出,但是当我尝试导入数千个股票数据时会出现错误,所以我不能使用这些。如果可能的话,我想在数据集(开盘价、最高价、最低价、收盘价、调整价和成交量)之间留出一个空间
我能做些什么来做到这一点?