Useful extensions for sec-edgar-downloader.
Project description
sec-downloader
Useful extensions for sec-edgar-downloader. Built with nbdev.
Install
pip install sec_downloader
Features
- Files are downloaded to a temporary folder, immediately read into memory, and then deleted.
- Use “glob” pattern to select which files are read to memory.
How to use
Download from ticker
Let’s demonstrate how to download a single file (latest 10-Q filing details in HTML format) to memory.
from sec_downloader import Downloader
dl = Downloader("MyCompanyName", "email@example.com")
html = dl.get_latest_html("10-Q", "AAPL")
# Use dl.get_latest_n_html("10-Q", "AAPL", n=5) to get the latest 5 10-Qs
print(f"{html[:50]}...")
<?xml version="1.0" ?><!--XBRL Document Created wi...
Note The company name and email address are used to form a user-agent string that adheres to the SEC EDGAR’s fair access policy for programmatic downloading. Source
Which is implemented approximately as:
from sec_edgar_downloader import Downloader as SecEdgarDownloader
from sec_downloader import DownloadStorage
ONLY_HTML = "**/*.htm*"
storage = DownloadStorage(filter_pattern=ONLY_HTML)
with storage as path:
dl = SecEdgarDownloader("MyCompanyName", "email@example.com", path)
dl.get("10-Q", "AAPL", limit=1, download_details=True)
# all files are now deleted and only stored in memory
content = storage.get_file_contents()[0].content
print(f"{content[:50]}...")
<?xml version="1.0" ?><!--XBRL Document Created wi...
Downloading multiple documents:
storage = DownloadStorage()
with storage as path:
dl = SecEdgarDownloader("MyCompanyName", "email@example.com", path)
dl.get("10-K", "GOOG", limit=2)
# all files are now deleted and only stored in memory
for path, content in storage.get_file_contents():
print(f"Path: {path}\nContent [len={len(content)}]: {content[:30]}...\n")
Path: sec-edgar-filings/GOOG/10-K/0001652044-22-000019/full-submission.txt
Content [len=15044932]: <SEC-DOCUMENT>0001652044-22-00...
Path: sec-edgar-filings/GOOG/10-K/0001652044-23-000016/full-submission.txt
Content [len=15264470]: <SEC-DOCUMENT>0001652044-23-00...
Download from Accession Number
dl = Downloader("MyCompanyName", "email@example.com")
html = dl.get_primary_doc_html(accession_number="0000320193-23-000077")
print(f"{html[:50]}...")
<?xml version="1.0" ?><!--XBRL Document Created wi...
Contributing
Follow these steps to install the project locally for development:
- Install the project with the command
pip install -e ".[dev]"
.
Note We highly recommend using virtual environments for Python development. If you’d like to use virtual environments, follow these steps instead: - Create a virtual environment
python3 -m venv .venv
- Activate the virtual environmentsource .venv/bin/activate
- Install the project with the commandpip install -e ".[dev]"
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for sec_downloader-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f42399329cfbf2d57eafb8ee3395b6835f3297462c7a441edcacbf7d659a1ca |
|
MD5 | 988db94f6c533b2442b1d1b33a994d53 |
|
BLAKE2b-256 | 83e70bf3b72f4f13082c889a585ed2b0e69c9759756185438635053ee49cdb7d |