Skip to main content

🐋 equities

Overview:

equities allows for easy access to the SEC's XBRL Financial Statement Dataset
Parsed data is stored locally and served to the user in pandas dataframes
The Dataset:

https://www.sec.gov/dera/data/financial-statement-data-sets.html

Install:

pip3 install equities

Donate:

Consider donating bitcoin to fund the future development of this project.

bitcoin wallet address: 3LU5MEaAXRJoCo6vx67g1Jj7qDFRKhMs5t

TUTORIAL:

The library consists of two central objects, Universe and Company.

Universe:

Building the Universe

We begin by initializing our universe and downloading our sec data packages.

from equities import Universe
u = Universe()

Essential Methods

To get the number of companies in the universe call: len(u)

To get a dataframe of XBRL metadata from of all companies in the universe call:

u.properties()

"CIK" numbers are the sec's official unique identifier for public companies. To get a full list of the cik numbers call:

u.ciks()

Accessing Companies

Universe objects are indexable by "CIK" integers. As an example, to access the first company in the universe call:

first_cik = universe.ciks()[0]
u[first_cik] # This returns an Company object.

Company:

A Company object should be thought of as an abstract representation of a real company. Every company must have an associated Universe of origin.

from equities import Company

Accessing the Financial Statements

Consider the first Company in our universe, universe[u.ciks()[0]]. It is a Company object.

c = u[u.ciks()[0]]

Dataframes of the company's financial statements over the universe in question is given by:

c.income()      # income statement dataframe

c.balance()     # Balancesheet dataframe

c.cash()        # Cash Flow Statement dataframe

c.equity()      # Consolidated Equity dataframe

Additional Company Details

To get the XBRL metadata for a given company as a pandas series call:

c.properties()

Example

I really want to demonstrate the beauty of this dataset since this is often difficult when looking at thousands of numeric datatables. Let's take a very naive peek by plotting various statements as a kind of stacked timeseries.

The following is a start to finish example of how one might plot the financial statements of the first three companies in the universe.

To perform this experiment, run the following:

from equities import test
test()

Here is the code that this function executes:

import pandas as pd
from equities import Universe, Company
import matplotlib.pyplot as plt

u = Universe()
u.build()

k,f,s = 'bar',(20,10),True
for cik in u.ciks()[:3]:

    u[cik].income().T.plot(
        kind=k,
        figsize=f,
        stacked=s)

    u[cik].cash().T.plot(
        kind=k,
        figsize=f,
        stacked=s)

    u[cik].balance().T.plot(
        kind=k,
        figsize=f,
        stacked=s)

plt.show()

Metadata

Release files for enigma-12312 2.1.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for enigma-12312 2.1.10
File Size Uploaded Provenance Actions
enigma-12312-2.1.10.tar.gz 4.3 kB Without provenance Details for enigma-12312-2.1.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for enigma-12312 2.1.10
File Interpreter ABI Platform Actions
enigma_12312-2.1.10-py3-none-any.whl Python 3 none any Details for enigma_12312-2.1.10-py3-none-any.whl

Total release size: 9.3 kB

Release files / enigma-12312-2.1.10.tar.gz

Download URL enigma-12312-2.1.10.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ee71f26c0e53ef0db8b978aaa8ed7b74c0539b4bf553949b3031d0caac13a101
BLAKE2b-256 checksum
How to use checksums
875348c9c76f8a9dfab8ad065f6e488d27db382b908be1634e8b98a8f0f753a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/50.3.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.5

Release files / enigma_12312-2.1.10-py3-none-any.whl

Download URL enigma_12312-2.1.10-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20bc250892dcaba93059f95161be9a59d45c8ce217ab6cac5b026bbe35937335
BLAKE2b-256 checksum
How to use checksums
4a28c35571cab0ca348824d8ea3be29cdf2e46ae164fdcc5f836de3ce7a20611
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/50.3.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.5

Security for enigma-12312 2.1.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.1.10 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page