3

I would love to analyze balance sheets and income statements using R. I have come across package finstr.

There is an example of downloading AAPL stock data using this link accessing the XBRL data.

I would like to ask, how do I actually find out the link to the company I want? For example TSLA. I thought that it would be enough just to change the ticker and the date in the URL, obviously it does not work that way. I have been struggling for days to actually find that out, searching through SEC.

Basically I would like to get to a point, where I would be able to generate a link to any company in R (in case I want to write a loop in order to download financial statements data for al the listed companies).

Phil
  • 7,287
  • 3
  • 36
  • 66
jnpll
  • 31
  • 2
  • Does this help? [https://stackoverflow.com/questions/16635860/](https://stackoverflow.com/questions/16635860/) – Ian Campbell Mar 24 '20 at 21:25
  • Hi, not really, the post seems old and I guess the links have changed. I am not able to create the same kind of urls I would need. – jnpll Mar 25 '20 at 06:43
  • There is also the package finreportr, but that has some issues of its own. Not all stock tickers work as expected. It seems all XBRL packages have some issues nowadays due to changes on the sec side. It would seem that all of the packages need help in supporting them :-( – phiver Mar 25 '20 at 12:48
  • Yes I know I tried that package, but it fails to download the latest financial statements. :( – jnpll Mar 25 '20 at 13:18

2 Answers2

1

The URL in your link is https://www.sec.gov/Archives/edgar/data/320193/000119312514383437/aapl-20140927.xml. The first set of numbers - 320193, in your example - represents the Central Index Key (CIK) for the company with the leading zeros removed. The CIK for APPL is 0000320193, which matches the first set of numbers in that URL. You'd need the CIK for the company in which you're interested to build that URL. If you go to https://www.sec.gov/Archives/edgar/data/320193/, for example, you'll see all of the folders available for AAPL - the company with the CIK of 0000320193, remembering to remove leading zeros when constructing that URL.

If you're looking for the CIK for a company, you can also find it through a URL. Perhaps you can start by navigating to https://www.sec.gov/cgi-bin/browse-edgar?CIK=[StockSymbol]&action=getcompany&owner=exclude to get the CIK and other information. For your example, go to https://www.sec.gov/cgi-bin/browse-edgar?CIK=TSLA&action=getcompany&owner=exclude. You may be able to find more information at that initial search page.

JeffFerguson
  • 2,952
  • 19
  • 28
  • Thanks for your answer. I found out that when you go to e.g. 10K filing detail of a company, there is link for something called "XBRL INSTANCE DOCUMENT" next to which you can get the link, the one that you also mention (I chose DAL company): https://www.sec.gov/Archives/edgar/data/27904/000002790420000004/0000027904-20-000004-index.htm However some of this links contain data with invalid links inside, because I get error messages. Now I am thinking about finding somewhere a database of all the CIKs in order to be able to create a loop. I wonder how yahoo finance gets its data correctly. – jnpll Mar 28 '20 at 05:55
1

SEC provides high level explanations for accessing EDGAR Data. https://www.sec.gov/os/accessing-edgar-data

To match company names to CIK, https://www.sec.gov/Archives/edgar/cik-lookup-data.txt or https://www.sec.gov/files/company_tickers_exchange.json

With the CIK, https://www.sec.gov/edgar/sec-api-documentation . "Each entity's current filing history is available at the following URL:" https://data.sec.gov/submissions/CIK##########.json.

I used these .json files in the last month to find 10-K URL for a list of 2,000 ticker symbols. I used R. The coding was not without challenges for my intermediate level R skills.

bradicus
  • 11
  • 3