Skip to main content

equities aims to democratize access to public company financial data.

Project description

🐋 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()

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

Project details


Release history Release notifications | RSS feed

This version

2.2.4

Download files

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

Source Distribution

equities-2.2.4.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

equities-2.2.4-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file equities-2.2.4.tar.gz.

File metadata

  • Download URL: equities-2.2.4.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.1

File hashes

Hashes for equities-2.2.4.tar.gz
Algorithm Hash digest
SHA256 8931cdfe4aadc697b69b9eb9bc0b7de287c6900fffa6fa25efbbc33cecbdbcae
MD5 2b78097975a752babc4f3a9b5c39e5fe
BLAKE2b-256 d7181396bac52274e8b50236cdedc41d47858c9c26613c60c2ae324867fac3a9

See more details on using hashes here.

File details

Details for the file equities-2.2.4-py3-none-any.whl.

File metadata

  • Download URL: equities-2.2.4-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.1

File hashes

Hashes for equities-2.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0b69ce90cf02ecd3642bc62ed73b8031d4bade1bb0aad70636697de06cb43304
MD5 e07a4e9b70e02576b43c928f2d69f66e
BLAKE2b-256 719e883c225bc56ab94bc02ecb863d834d3f3ef5971c99c7e07f0ea6194b0af2

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