Skip to main content

Creates and updates a database for indexes of ESEF filings and SEC XBRL filings and filers (only filings metadata NOT filings contents)

Project description

test publish-pypi

XBRL Reports Indexes (xri)

xri creates and updates a database for indexes of ESEF filings and SEC XBRL filings and filers (only filings metadata NOT filings contents). SEC XBRL filings index is based on data extracted from SEC Monthly RSS Feeds for XBRL filings, ESEF XBRL filings index is based on data extracted from filings.xbrl.org.

This package is useful for easily collecting and organizing up to date information about XBRL filings available on SEC, including latest filings (updated every 10 minutes during working hours), and the same for ESEF filings. Data can be stored in sqlite, postgres or mysql databases (sqlite recommended).

A downloadable sqlite example database is available on google drive here, contains filings data until 2022-09-14.

Installation

pip install xbrl-reports-index

From source

Clone repo, then build and install locally or install editable:

# editable
pip install -e .
# build
python -m build
pip install dist/*.whl

Usage

Command line

For options and help:

$ xri-db-tasks -h
# initialize sqlite database update data (requires internet connection)
$ xri-db-task <database-name> --initialize-database --update-sec --update-sec

Initializing the database and loading data may take a long time for SEC information, but subsequent updates should take less than a minute. when using postgres or mysql, database must be created on the server first and connection information should be provided as follows:

$ xri-db-task database_name,product,user,password,host,port,timeout --initialize-database --update-sec --update-sec

product: sqlite (default), postgres or mysql.

To search filings:

$ xri-db-tasks <db connection params> --search-filings sec --form-type 10-q --added-date-from 2022-08-10 --added-date-to 2022-08-10 --sec-industry-tree 70 --limit-result 1000 --output-file search.rss
2022-09-14 03:48:32,220 [rss-db.initialize-db] Verified/Initialized 
2022-09-14 03:48:33,269 [rss-db.info] Created search.rss for 186 filings.

The above command returns SEC filings for forms 10-K and 10-Q filed between 2022-08-10 and 2022-08-12 inclusive, result is saved as an rss file similar to SEC rss feed, this file can be used by arelle for further processing.

Python script

This package uses SQLAlchemy as an ORM. Usage is as follows:

from xbrlreportsindexes.core.index_db import XbrlIndexDB
from sqlalchemy.orm import Session

# create a db object
db = XbrlIndexDB('scratches/xdb_test.db')

# create a query object
qry = db.search_filings(
        filing_system='sec',
        publication_date_from='2022-08-10',
        publication_date_to='2022-08-12',
        form_type='10-q',
        industry_code_tree='70',
        limit=1000,
)

# execute query and print out count
with Session(db.engine) as session:
    result = qry.with_session(session)
    print(result.count())

Result:

>>> 186

Or we can go directly to the industry table:

# import SEC model
from xbrlreportsindexes.model import SEC

session = Session(db.engine)
# filter for industry 70
industry = session.query(
    SEC.SecIndustry).filter(
        SEC.SecIndustry.industry_classification=='SEC',
        SEC.SecIndustry.industry_code==70,
        ).first()
print(industry.industry_description)

industry name

>>> 'Services'
# get filings of that industry
filings = industry.all_industry_tree_filings(session)

# filter filings
filings.filter(
    SEC.SecFiling.pub_date >= '2022-08-10',
    SEC.SecFiling.pub_date < '2022-08-13',
    SEC.SecFiling.form_type.like('%10-Q%'),
    ).count()

result of count

>>> 186

All other tools from SQLAlchemy can be used to query and analyze the data, for example, here is the to 5 forms by count of filings for August 2022:

from sqlalchemy import func, desc

form_type = SEC.SecFiling.form_type

filings_august_qry = session.query(
    form_type, func.count(form_type).label('count_forms')).group_by(
        form_type).order_by(desc('count_forms')).limit(5)

for f in filings_august_qry:
    print(f[0], '->', f'{f[1]:,}', 'forms')
8-K -> 8,193 forms
10-Q -> 5,343 forms
8-K/A -> 198 forms
485BPOS -> 173 forms
10-K -> 167 forms

Data update

A cron job can be setup to collect information about new filing from SEC site every 10 minutes during working hours as follows:

*/10 6-22 * * 1-5 xri-db-task <db connection parameters> --update-sec # note timezone differences

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xbrl-reports-indexes-0.94.tar.gz (3.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xbrl_reports_indexes-0.94-py3-none-any.whl (3.4 MB view details)

Uploaded Python 3

File details

Details for the file xbrl-reports-indexes-0.94.tar.gz.

File metadata

  • Download URL: xbrl-reports-indexes-0.94.tar.gz
  • Upload date:
  • Size: 3.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.15

File hashes

Hashes for xbrl-reports-indexes-0.94.tar.gz
Algorithm Hash digest
SHA256 0c088b687103eb8266496fc7b2f0ed3ee66f05262de4e5941163011fda406f55
MD5 05ebd8f656029cea1e09510e648c82f3
BLAKE2b-256 a6108cd24c6b702745521b142c93613c8fcbe335658908c0920b4fb127a9eae1

See more details on using hashes here.

File details

Details for the file xbrl_reports_indexes-0.94-py3-none-any.whl.

File metadata

File hashes

Hashes for xbrl_reports_indexes-0.94-py3-none-any.whl
Algorithm Hash digest
SHA256 be1ce9df2789c1d0f49dd122facd401d21c5b5dc4abc797e2881320c2a175bae
MD5 42d5a9939999c1050056f776e4c0cabf
BLAKE2b-256 08a42bc6db50e3a15186ddcfa3e5ac5f73b67f43a4e09a13b8a4eaa631d7238d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page