• Stars
    star
    221
  • Rank 178,644 (Top 4 %)
  • Language
    Python
  • License
    GNU General Publi...
  • Created about 7 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A small library to access files from SEC's edgar

EDGAR

A small library to access files from SEC's edgar.

Installation

pip install edgar

Example

To get a company's latest 5 10-Ks, run

from edgar import Company
company = Company("Oracle Corp", "0001341439")
tree = company.get_all_filings(filing_type = "10-K")
docs = Company.get_documents(tree, no_of_documents=5)

or

from edgar import Company, TXTML

company = Company("INTERNATIONAL BUSINESS MACHINES CORP", "0000051143")
doc = company.get_10K()
text = TXTML.parse_full_10K(doc)

To get all companies and find a specific one, run

from edgar import Edgar
edgar = Edgar()
possible_companies = edgar.find_company_name("Cisco System")

To avoid pull of all company data from sec.gov on Edgar initialization, pass in a local path to the data

from edgar import Edgar
edgar = Edgar("/path/to/cik-lookup-data.txt")
possible_companies = edgar.find_company_name("Cisco System")

To get XBRL data, run

from edgar import Company, XBRL, XBRLElement

company = Company("Oracle Corp", "0001341439")
results = company.get_data_files_from_10K("EX-101.INS", isxml=True)
xbrl = XBRL(results[0])
XBRLElement(xbrl.relevant_children_parsed[15]).to_dict() // returns a dictionary of name, value, and schemaRef

API

Company

Company(name, cik, timeout=10)
  • name (company name)
  • cik (company CIK number)
  • timeout (optional) (default: 10)

Methods

get_filings_url(self, filing_type="", prior_to="", ownership="include", no_of_entries=100) -> str

Returns a url to fetch filings data

  • filing_type: The type of document you want. i.e. 10-K, S-8, 8-K. If not specified, it'll return all documents
  • prior_to: Time prior which documents are to be retrieved. If not specified, it'll return all documents
  • ownership: defaults to include. Options are include, exclude, only.
  • no_of_entries: defaults to 100. Returns the number of entries to be returned. Maximum is 100.

get_all_filings(self, filing_type="", prior_to="", ownership="include", no_of_entries=100) -> lxml.html.HtmlElement

Returns the HTML in the form of lxml.html

  • filing_type: The type of document you want. i.e. 10-K, S-8, 8-K. If not specified, it'll return all documents
  • prior_to: Time prior which documents are to be retrieved. If not specified, it'll return all documents
  • ownership: defaults to include. Options are include, exclude, only.
  • no_of_entries: defaults to 100. Returns the number of entries to be returned. Maximum is 100.

get_10Ks(self, no_of_documents=1, as_documents=False) -> List[lxml.html.HtmlElement]

Returns the HTML in the form of lxml.html of concatenation of all the documents in the 10-K

  • no_of_documents (default: 1): numer of documents to be retrieved
  • When as_documents is set to True, it returns -> List[edgar.document.Documents] a list of Documents

get_document_type_from_10K(self, document_type, no_of_documents=1) -> List[lxml.html.HtmlElement]

Returns the HTML in the form of lxml.html of the document within 10-K

  • document_type: Tye type of document you want, i.e. 10-K, EX-3.2
  • no_of_documents (default: 1): numer of documents to be retrieved

get_data_files_from_10K(self, document_type, no_of_documents=1, isxml=False) -> List[lxml.html.HtmlElement]

Returns the HTML in the form of lxml.html of the data file within 10-K

  • document_type: Tye type of document you want, i.e. EX-101.INS
  • no_of_documents (default: 1): numer of documents to be retrieved
  • isxml (default: False): by default, things aren't case sensitive and is parsed with html in lxml. If this is True, then it is parsed with etree` which is case sensitive

Class Method

get_documents(self, tree: lxml.html.Htmlelement, no_of_documents=1, debug=False, as_documents=False) -> List[lxml.html.HtmlElement] Returns a list of strings, each string contains the body of the specified document from input

  • tree: lxml.html form that is returned from Company.getAllFilings
  • no_of_documents: number of document returned. If it is 1, the returned result is just one string, instead of a list of strings. Defaults to 1.
  • debug (default: False): if True, displays the URL and form
  • When as_documents is set to True, it returns -> List[edgar.document.Documents] a list of Documents

Edgar

Gets all companies from EDGAR

get_cik_by_company_name(company_name: str) -> str: Returns the CIK if given the exact name or the company

get_company_name_by_cik(cik: str) -> str: Returns the company name if given the CIK (with the 000s)

find_company_name(words: str) -> List[str]: Returns a list of company names by exact word matching

match_company_by_company_name(self, name, top=5) -> List[Dict[str, Any]]: Returns a list of dictionarys, with company names, CIK, and their fuzzy match score

  • top (default: 5) returns the top number of fuzzy matches. If set to None, it'll return the whole list (which is a lot)

XBRL

Parses data from XBRL

Properties

relevant_children

  • get children that are not context relevant_children_parsed
  • get children that are not context, unit, schemaRef
  • cleans tags

Documents

Filing and Documents Details for the SEC EDGAR Form (such as 10-K)

Documents(url, timeout=10)

Properties

url: str: URL of the document

content: dict: Dictionary of meta data of the document

content['Filing Date']: str: Document filing date

content['Accepted']: str: Document accepted datetime

content['Period of Report']: str: The date period that the document is for

element: lxml.html.HtmlElement: The HTML element for the Document (from the url) so it can be further parsed

Contribution

Buy Me A Coffee

More Repositories

1

linkedin_scraper

A library that scrapes Linkedin for user data
Python
1,919
star
2

tiktok-scraper

A scraper to download TikTok videos
Python
22
star
3

py-spotme

A CLI tool that creates AWS spot instances on the fly
Python
17
star
4

C-Port-Scanner

A simple port scanner, written in C
C
16
star
5

node-xml2json-cli

A node CLI wrapper for xml2json
JavaScript
13
star
6

py-image-comparer

Compares two images using Siamese Network (machine learning) trained from a Pytorch Implementation
Python
10
star
7

s3-as-a-datastore

s3 as a datastore: A way to use S3 as a key-value datastore instead of a real datastore. can be read as s3aadatastore
Python
9
star
8

node-ascii-animate

A tool that allows you to animate ascii in your terminal
JavaScript
9
star
9

nnnba

Analysis of NBA player stats and salaries of the 2016-17 for the 17-18 season
Python
9
star
10

jsonl-to-conll

A simple tool to convert JSONL to CONLL
Python
9
star
11

imgur-lite

Imgur-lite is a light weighted imgur app. This repository includes website that wraps around imgur-lite app, which allows quick browsing on imgur, especially on mobile.
JavaScript
5
star
12

py-sql2sql

A simple lightweight tool to perform ETL jobs between two SQL databases
Python
4
star
13

AutoChromedriver

Downloads and unzips chromedriver to curent directory
Python
4
star
14

node-minify-all

A tool that minifies all .js files in a given directory, including ones in nested folders
JavaScript
4
star
15

node-dancing-bear

An animation of a dancing bear
JavaScript
4
star
16

Commonly-Used-Pyspark-Commands

A list of commonly used pyspark commands
3
star
17

py-oauth2_google_login

Gets OAuth2 access token from Google/YouTube automatically using requests_oauthlib
Python
3
star
18

you-are-a-fish

A chat where users are fishes. Created using d3 and socket.io
JavaScript
3
star
19

node-download-vine

A tool to download files, including vines
JavaScript
3
star
20

node-git-lib

A library with different git commands for uses
HTML
3
star
21

py-spotcheck

A simple CLI tool to check the spot prices of AWS instances
Python
3
star
22

Yahoo-Fantasy-NBA-simulator

1000 ML Fantasy NBA Draft
Jupyter Notebook
3
star
23

node-checkout-cli

a CLI that allows users to pick the branch they want to checkout
HTML
3
star
24

ze2nb-cli

A wrapper for ze2nb to be used as a CLI
Python
2
star
25

.files

My dot files
Shell
2
star
26

AlexNet_Tutorial

Python
2
star
27

py-oauth2_facebook_login

Gets OAuth2 access token from Facebook automatically (with webdriver) using requests_oauthlib
Python
2
star
28

autolinker

A simple directive that turns all URLs within its div into links
JavaScript
2
star
29

psql2csv

A library and a CLI to download PostgreSQL schemas and tables
Python
2
star
30

ArconaiAudio

Python
2
star
31

nnnba_website

A wrapper site for NNNBA
JavaScript
2
star
32

node-time-bin

A module that takes in time series and outputs the binned version of it
JavaScript
2
star
33

Python-Port-Scanner

A simple port scanner, written in Python
Python
2
star
34

node-commit-cli

a CLI that allows users to automatically commit files
JavaScript
2
star
35

tampermonkey-scripts

JavaScript
1
star
36

lazy-g-cli

Because you are too lazy to type "grunt" or "gulp" sometimes
JavaScript
1
star
37

node-branch-cli

A CLI tool that allows manipulation of git branches in local git repository
JavaScript
1
star
38

C-ping

Ping written in C that shows what I want
C
1
star
39

player-recognition

Python
1
star
40

deploy-me

A front end that deploys apps, which is displayed once the app is successfully deployed
JavaScript
1
star
41

node-push-cli

a CLI that allows users to easily push files to current branch
HTML
1
star
42

Basic-C-Server

Basic web hosting, using C
C++
1
star
43

node-git-cli

A collection of various git-related CLI commands
1
star
44

node-kontains

A small tool that determines whether an object or an array contains an element
JavaScript
1
star
45

node-isUnique

A module that helps determine if an array has only unique elements
JavaScript
1
star
46

redirectm3u

Used to redirect blindy.tv
Go
1
star
47

node-zeroes

A tool to create an array filled with 0's
JavaScript
1
star
48

comparative-stock

JavaScript
1
star
49

node-numArray

A tool that creates array based on beginning and end numbers
JavaScript
1
star
50

node-xcept

Adds abilities for objects and arrays to omit variables
HTML
1
star
51

deep_sort_mask_rcnn

Python
1
star
52

py-nprint

A lightweight nested printing, for all your function within loops within function needs
Python
1
star
53

node-npm-save

A module that allows module npm install --save or --save-dev
JavaScript
1
star
54

tf-player-recognition

Python
1
star
55

node-keyway

A library that creates a keyway: the opposite of Object.keys
JavaScript
1
star
56

node-ones

A tool to create an array filled with 1's
HTML
1
star
57

instances

Scripts for installation on different VMs and dev environments
Shell
1
star
58

node-revert-cli

A CLI that allows users to pick the files they want to revert
JavaScript
1
star
59

node-merge-cli

a CLI that allows users to pick the branch they want to merge
JavaScript
1
star
60

node-jslib

A module that loads some modules that are useful in javascript
JavaScript
1
star
61

py-custom-google-search

Python
1
star
62

aws-cognito-cli

A simple CLI tool to get the AWS Cognito Access Token
Python
1
star
63

herault-prefecture-visa-booking

Python
1
star
64

pyurl

cURL, but with python
Python
1
star
65

rURL

Using rust to make URL calls instead of C
Rust
1
star
66

arxiver-firefox

Handy tool for Arxiv to save papers, and filter through them later. Included is the ability to search for a paper you have saved by keywords, author, title, description, etc.
JavaScript
1
star
67

py-dfault

A simple lightweight class that allows the user to fallback on default values
Python
1
star
68

py-instacart

Python
1
star
69

node-jsondata

A module that saves and loads json data from a file
JavaScript
1
star
70

node-ninstall

A CLI tool to install the same npm modules that you always install
JavaScript
1
star
71

py-cifar10

This library was created to allow an easy usage of CIFAR 10 DATA. This is a wrapper around the instructions givn on the CIFAR 10 site
Python
1
star