Skip to content

soetang/xbrlr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

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 only)

We have build helper functions to get the facts relating to the period of XBRL the document:

  • Danish get_this_period_dk

Continuing the example from above:

this_year <- get_this_period_dk(xbrl_table)

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.

About

XBRL in R

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages