Murali Murali - 22 days ago 6
R Question

quantmod - Quarterly and Annual reports - Is it possible to extract past 10 historic periods?

Is there way I can extract the data for last 10 historic periods?
As of now I am getting 5 historic quarterly reports and 4 historic Annual reports via this code.

Please help me.

library(quantmod)
getFin('AAPL') # returns AAPL.f to "env"
viewFin(AAPL.f, "IS", "Q") # Quarterly Income Statement
viewFin(AAPL.f, "CF", "A") # Annual Cash Flows

Answer

You can use this, but I think the limitation is 4 years of historical data.

require(quantmod)

setwd("C:/Users/your_path_here/Desktop")

stocks <- c("AAVL",
"ACAD",
"ACHN")

# equityList <- read.csv("EquityList.csv", header = FALSE, stringsAsFactors = FALSE)
# names(equityList) <- c ("Ticker")

for (i in 1 : length(stocks)) {   
        temp<-getFinancials(stocks[i],src="google",auto.assign=FALSE)
        write.csv(temp$IS$A,paste(stocks[i],"_Income_Statement(Annual).csv",sep=""))
        write.csv(temp$BS$A,paste(stocks[i],"_Balance_Sheet(Annual).csv",sep=""))
        write.csv(temp$CF$A,paste(stocks[i],"_Cash_Flow(Annual).csv",sep=""))
}
Comments