Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get all the elements contained in the original XBRL? #4

Open
ashgreat opened this issue Feb 21, 2017 · 1 comment
Open

How to get all the elements contained in the original XBRL? #4

ashgreat opened this issue Feb 21, 2017 · 1 comment
Assignees

Comments

@ashgreat
Copy link

Is there any way we can get more detailed items that are there in the financial statements but not output from your functions? For example, I want to extract information on warranty accruals and warranty claims, which are output in the XBRL list. However, there is no way I can get them from your functions because they cover only high level financial statements.

@bergant
Copy link
Owner

bergant commented Feb 22, 2017

Yes, for now it doesn't cover other disclosures. But, it is possible to get the data from parsed XBRL directly. In the result returned by xbrlDoAll there are tables:

  • element (=XBRL concepts)
  • context (=periods, dimensions)
  • fact (=values)

We have to find concepts related to warrants and join them to context and value:

library(XBRL)
report_url <- "https://www.sec.gov/Archives/edgar/data/320193/000119312514383437/aapl-20140927.xml"

old_o <- options(stringsAsFactors = FALSE)
xbrl_data <- xbrlDoAll(report_url)
options(old_o)

library(dplyr)
library(tidyr)
  
xbrl_data$element %>% 
  filter(grepl("Warrant",elementId) & # all "Warrant" elements
           type == "xbrli:monetaryItemType") %>% 
  inner_join(xbrl_data$fact, by = "elementId") %>% 
  inner_join(xbrl_data$context, by = "contextId") %>% 
  dplyr::mutate(amount = as.numeric(fact)*10^(as.numeric(decimals))) %>% 
  select(elementId, amount, startDate, endDate, periodType) %>% 
  split(.$periodType)

# Result:

# $duration
#                                        elementId amount  startDate    endDate periodType
# 1         StandardProductWarrantyAccrualPayments   3703 2012-09-30 2013-09-28   duration
# 2         StandardProductWarrantyAccrualPayments   3760 2013-09-29 2014-09-27   duration
# 3         StandardProductWarrantyAccrualPayments   1786 2011-09-25 2012-09-29   duration
# 4 StandardProductWarrantyAccrualWarrantiesIssued   5032 2012-09-30 2013-09-28   duration
# 5 StandardProductWarrantyAccrualWarrantiesIssued   4952 2013-09-29 2014-09-27   duration
# 6 StandardProductWarrantyAccrualWarrantiesIssued   2184 2011-09-25 2012-09-29   duration
# 
# $instant
#                         elementId amount startDate    endDate periodType
# 7  StandardProductWarrantyAccrual   1240      <NA> 2011-09-24    instant
# 8  StandardProductWarrantyAccrual   1638      <NA> 2012-09-29    instant
# 9  StandardProductWarrantyAccrual   2967      <NA> 2013-09-28    instant
# 10 StandardProductWarrantyAccrual   4159      <NA> 2014-09-27    instant

@bergant bergant self-assigned this Feb 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants