README.md

xbrlr

This project primarily intends to build a universal xbrl instance reader in R. However we might add a few functions specific to national or international taxonomies eg. DK(erst), US(SEC)

Installation

Right now you can only install from the github sources:

devtools::install_github("soetang/xbrlr")

Primary functionality

Loading and initializing xbrl document

library("xbrlr")

# first download the xbrl file
uri = "https://datacvr.virk.dk/data/offentliggorelse?dl_ref=ZG9rdW1lbnRsYWdlcjovLzAzL2YxL2NhLzVlLzNmLzFkYmYtNGRmNC04ZDk2LTI1MGI2YTJlNzY1YQ"
xml_doc <- httr::GET(url = uri) %>% httr::content()

# then create the xbrl instance
xbrl_instance <- xbrl(xml_doc)

# now you can access the three tables that make up the instance
xbrl_instance$facts
xbrl_instance$units
xbrl_instance$contexts

Note that we currently dont support footnotes but gladly accepts pull requests

Turning it all into one dataframe

Here we created a function to join units and context onto the facts table

xbrl_table <- to_one_table(xbrl_instance)

Getting the data for this year only (DK and DE only)

We have build helper functions to get the facts regarding the specific period of XBRL the document for: - Danish get_this_period_dk - German get_this_period_de

Continuing the example from above:

this_year <- get_this_period_dk(xbrl_table)

Example for German XBRL

de_example <- get_example("de") %>% 
  file() %>%
  xml2::read_xml() %>%
  xbrl() %>%
  to_one_table() %>% 
  get_this_period_de()

API to danish financial statements

However in order to parse xbrl files you need to access the files first. Here we provide direct access to danish reports.

Below we collect links to all reports published today, and filter away any without xbrl

pubs_from_today <- query_api_dk(as.character(Sys.Date())) %>% 
  dplyr::filter(xml_link != "")

This project draws inspiration from XBRL-AI - xbrl for ml in python and XBRLfiles which uses the r XBRL package which is primarily aimed at SEC data. Parsing using the XBRL library fails if taxonomy files are not avaiable, in this project the goal is that parsing should only use the xbrl instance without outside dependencies.



soetang/xbrlr documentation built on May 26, 2019, 7:01 p.m.