knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

{tidysec}

The goal of {tidysec} is to facilitate working with filings provided by the American Securities and Exchange Commission. Currently the package only supports 13F-filings. The package works with the quarterly master file.

Installation

You can install the development version of {tidysec} from Github with:

devtools::install_github("balthasars/tidysec")

Retrieve and parse a 13F-filing

Use get_13f() for that purpose. This function returns the filings as a tibble with a nested data frame column.

library(tidysec)
library(magrittr)
cik_blackrock <- "1364742"
br_2015 <- get_13f(cik = cik_blackrock, year = 2015, amendments = FALSE)
br_2015

To work with the filing(s), use tidyr::unnest():

br_2015 %>% 
  tidyr::unnest(filing)

Amendments to 13F filings (13F-HR/A) cannot be parsed yet. However, you can still get the link to their .txt file by setting link_only = TRUE and amendments = TRUE:

cik_blackrock <- "1364742"
get_13f(cik = cik_blackrock, year = 2015, link_only = TRUE, amendments = TRUE)

Get a list of all SEC filings by a company

Let's say you wanted a list of all of Credit Suisse AG's 2020 company filings.

cik_credit_suisse <- "824468"
cs_2019 <- get_list_of_filings(
  cik = cik_credit_suisse, 
  year = 2020, 
  filing_type = "all"
  )
cs_2019

Other Resources to Work with SEC Data

R packages

The following packages may also be helpful to you if you're looking to work with anything else than 13F filings (I haven't tested them though):

APIs

If you just want easy acess to filings, check out finance APIs that offer 13F filings:



balthasars/tidysec documentation built on Dec. 19, 2021, 6:41 a.m.