-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContinuousDownload.R
More file actions
32 lines (25 loc) · 843 Bytes
/
Copy pathContinuousDownload.R
File metadata and controls
32 lines (25 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
tickers <- read.csv("/Users/ehren/Documents/StockAnalysis/tickerSymbols.csv", header=FALSE)$V1
tickers <- as.character(tickers)
getSymbolsCont <-
function(tickers, from=NULL, to=Sys.Date(), src="yahoo") {
lookback = 60
startDate = Sys.Date() - lookback
thePath = "/Users/ehren/Documents/StockAnalysis/stockData/"
theFiles = list.files(path=thePath,pattern=".csv")
ok = FALSE
n = NROW(tickers)
i = 1
while(i <= n | !ok) {
print(tickers[i])
sym = NULL
try ( sym <- getSymbols(tickers[i], from=from, to=to, src=src,
auto.assign=FALSE))
if(!is.null(sym)) {
assign(tickers[i], sym, envir = .GlobalEnv)
i = i+1
ok=TRUE
} else {ok=FALSE}
Sys.sleep(1)
}
return(sym)
}