bergant / xbrlus

R interface to XBRL US API
Other
21 stars 4 forks source link

Warning message: NAs introduced by coercion #5

Closed SteveBronder closed 8 years ago

SteveBronder commented 8 years ago

Hello again! Hope you are doing well. A bug in parsing or an internal change in XBRL at some point is causing a weird issue in pre-2011 calls. Take for example the company AAR CORP who submitted a 10-Q in the first quarter of 2010 and 2011, respectively. I checked to make sure they submitted for each of these quarters and they submitted on 2010-03-19 and 2011-03-22.

AAR CORP's cik is 0000001750

Here we try to collect the elements given in the toy example for XBRLUS. For 2010 it fails, but for 2011 it works.


company <- "0000001750"

elements <- xbrlBaseElement(c(
  "AssetsCurrent",
  "AssetsNoncurrent",
  "Assets",
  "LiabilitiesCurrent",
  "LiabilitiesNoncurrent",
  "Liabilities",
  "StockholdersEquity",
  "MinorityInterest",
  "StockholdersEquityIncludingPortionAttributableToNoncontrollingInterest",
  "LiabilitiesAndStockholdersEquity"
))

value<- xbrlValues(CIK =  company,#table,
                   Element = elements[,"elementName"],
                   DimReqd = FALSE,
                   Ultimus = TRUE,
                   Small = TRUE, 
                   Period = "1Q",
                   Year = 2010,
                   as_data_frame = TRUE)
Warning message:
NAs introduced by coercion

Now for 2011

value<- xbrlValues(CIK =  company,#table,
                   Element = elements[,"elementName"],
                   DimReqd = FALSE,
                   Ultimus = TRUE,
                   Small = TRUE, 
                   Period = "1Q",
                   Year = 2011,
                   as_data_frame = TRUE)

What is strange is that if you change the years to 2009 and 2012 you get the same effect. Did something change in how XBRL kept data pre-2011?

Session Info

sessionInfo()
R version 3.2.5 (2016-04-14)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.4 LTS

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] xbrlus_0.1.1.9001

loaded via a namespace (and not attached):
[1] httr_1.1.0      R6_2.1.2        rsconnect_0.4.3 tools_3.2.5     curl_0.9.7      XML_3.98-1.4 
SteveBronder commented 8 years ago

I wonder if this has something to do with the previous mismatch column bug?

3

bergant commented 8 years ago

Hello! I'm OK, thanks.

There are two problems with your API request:

  1. There is no filling 1Q for 2010 (at least not in the xbrlus database as API returns empty values). (There is yearly one though - with Period = "Y") .
  2. xbrlus package does not recognize count = 0 inside the xbrlus API response.

In the new package version i could only fix the second one and return empty data frame - instead of NA values and warnings. Thanks for finding this.

BTW, there is a way to lookup all fillings for specific company - try:

xbrlNetwork(Element = "Assets", Linkbase = "Calculation", CIK = company)

But it does not return the type of the filling.

bergant commented 8 years ago

... and there is also an option to not define a period type. From original docs:

if not provided all periods are returned.

SteveBronder commented 8 years ago

Awesome thanks!

SteveBronder commented 8 years ago

Related to this:

Can you clarify why, when I go to

https://www.sec.gov/Archives/edgar/full-index/1994/QTR2/

and search through company.idx, AAR CORP shows up as having filed a 10-Q on 1994-04-14. However when I search with xbrlNetwork() the earliest it finds is 2010. Does the XBRL API not go as far back as the entire XBRL database? Or is what I found for something else?

SteveBronder commented 8 years ago

Also for xbrlNetwork(), it seem to fail out for companies that it should not.

For example, Tranzonic Companies only filed from 1995 to 1998, but when xbrlNetwork() tries to get their filing info it returns an error

xbrlNetwork(Element = c("Liabilities"), Linkbase = "Calculation", CIK = "0000001761")
Error: HTTP error: 500
Mon, 29 Aug 2016 15:45:12
Error - Insufficient Parameters
This call returns too much data. Please revise the attributes to include at least a CIK or Accession Number.