-
Notifications
You must be signed in to change notification settings - Fork 69
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
Outstanding shares from 10k or 10q #6
Comments
There is no special support (yet) in finstr. But, when the id of the XBRL concept is known, it is possible to extract it from the XBRL directly. The sec.gov page (interactive data) exposes the concept id when clicked on the description in the table. To extract the value from XBRL, join the element (concept) to the fact (value) and context (period, dimensions). Here is an example for the # Apple 10-K report:
doc_url <- "https://www.sec.gov/Archives/edgar/data/320193/000162828016020309/aapl-20160924.xml"
# download and parse XBRL
library(XBRL)
old_o <- options(stringsAsFactors = FALSE)
xbrl_data <- xbrlDoAll(doc_url)
options(old_o)
library(dplyr)
xbrl_data$element %>%
filter(elementId == "dei_EntityCommonStockSharesOutstanding") %>%
left_join(xbrl_data$fact, by = "elementId") %>%
left_join(xbrl_data$context, by = "contextId") %>%
mutate(value = as.numeric(fact) * 10 ^ as.numeric(decimals)) %>%
select(elementId, value, unitId, endDate)
# elementId value unitId endDate
# 1 dei_EntityCommonStockSharesOutstanding 5332313 shares 2016-10-14
|
excellent, thanks for the help. |
Thanks bergant for this excellent package working smoothly with SEC filings! I am particularly looking for debt as reported in the balance sheet and debt breakup as given in the Notes to Financial Statement. The id of the XBRL concept is known: us-gaap_LongTermDebtNoncurrent I ran into some error while running the query:
Can you pls help on this? How can I get this debt number as well as debt breakup as pasted from the footnotes Kind regards, |
First check the missing |
Thanks for pointing this. Still, I am not very much sure why I am getting an error : "Error in filter_impl(.data, quo) : Pls see my code below
This still shows me the error: Best, |
The following code xbrl_data17$element %>%
filter(elementId == "us-gaap_LongTermDebtNoncurrent") %>%
left_join(xbrl_data17$fact, by = "elementId") %>%
left_join(xbrl_data17$context, by = "contextId") %>%
mutate(value = as.numeric (fact) * 10 ^ as.numeric(decimals)) %>%
select( elementId, value, unitId, endDate) will return only values for the #> elementId value unitId endDate
#> 1 us-gaap_LongTermDebtNoncurrent 75427 usd 2016-09-24
#> 2 us-gaap_LongTermDebtNoncurrent 89864 usd 2017-07-01 For debt summary table you should find all elements from "http://www.apple.com/role/DebtSummaryOfTermDebtDetails" role, Maybe we can start like this (this will not create a final table): relations <-
finstr::xbrl_get_relations(xbrl_data17, role_id = "http://www.apple.com/role/DebtSummaryOfTermDebtDetails", lbase = "presentation")
elements <-
data.frame(
elementId = with(relations, unique(c(fromElementId, toElementId))),
stringsAsFactors = FALSE
) %>%
dplyr::left_join(xbrl_data17$element, by = c("elementId")) %>%
dplyr::left_join(relations, by = c("elementId" = "toElementId")) %>%
dplyr::left_join(xbrl_data17$label, by = c("elementId")) %>%
dplyr::filter(labelRole == "http://www.xbrl.org/2003/role/label") %>%
dplyr::transmute(elementId, parentId = fromElementId, order, type, balance, labelString)
elements_h <- finstr::get_elements_h(elements)
elements_h %>%
filter(type != "nonnum:domainItemType") %>%
left_join(xbrl_data17$fact, by = "elementId") %>%
left_join(xbrl_data17$context, by = "contextId") %>%
select(id, elementId, order, labelString, fact, unitId, startDate, endDate, type, contextId) %>%
arrange(id)
# ... |
Hi, |
Great package! Is there a way to pull outstanding shares from the qs and ks? Its usually listed on the first page of the report so I'm sure it's there, just haven't figured out how to access it.
The text was updated successfully, but these errors were encountered: