1

I want to be able to generate tables that show select financial statement line items and financial statement ratios (e.g., revene, OpEx, EBITDA, enterprise value). I'm trying to get getFin to accept a list of tickers.

library(quantmod)
library(xts)

ticker <- c("MS", "GS", "CS")
ticker1 <- getSymbols(ticker)
getFin(ticker1) #env.class

income<-viewFin(ticker1, "IS","A") # annual income statement
balancesheet<-viewFin(ticker1,"BS","A") # annual balance sheet

However, getFin is only recognizing the MS ticker as MS.f, so GS.f and CS.f do not get added to the environment. This also prevents income and balancesheet to be added to the environment.

Let me know how this can be fix. Thanks for the help.

Ari
  • 13
  • 3
  • hi hi, if you print out the code in getFin, you will see Symbol <- strsplit(Symbol, ";")[[1]]. that means that Symbol should be passed in as a single string with each symbol separated by ";"; try using this instead getFin(paste(ticker1,collapse=";")) – chinsoon12 Apr 14 '16 at 01:08

1 Answers1

0

Load the data into an environment you create, rather than the global environment. Then use eapply to loop over all objects in the environment and call viewFin on each.

e <- new.env()
getFin(paste0(ticker,collapse=";"), env=e)
income <- eapply(e, viewFin, type="IS", period="A")
balancesheet <- eapply(e, viewFin, type="BS", period="A")

income and balancesheet will be lists of the relevant statements for each of the objects specified by ticker.

Joshua Ulrich
  • 173,410
  • 32
  • 338
  • 418