Downloading Files
API User-Agent Fields
The SEC requires all EDGAR users to identify themselves.
When the Downloader
is used for the first time, it will prompt the user for API key information then cache it and re-use it in future iterations.
In order to edit these values after initialization, visit .keys.yaml
in an associated data_directory.
Downloader Class
- class edgar.Downloader(data_dir: str = 'edgar_data', metadata=None)
Class for querying SEC-EDGAR database for files.
- generate_api_header()
Generate API key from command-line user input prompts.
- get_dates(tikr, **kwargs)
Return the filing submission txt closest to provided date.
- get_nearest_date_filename(tikr, date, return_date=False, prefer_recent=True, **kwargs)
Get the nearest date of the filename.
- Parameters
tikr (str) – a company identifier to query
date (str) – date in format AAAABBCC format (Year, Month, Day) with 0 padding
return_date (bool) –
prefer_recent (bool) –
document_type (str) – document type to unpack (10-Q, 8-K, or all)
- get_submissions(tikr, **kwargs)
Get list of submissions under tikr.
- Parameters
tikr (str) – a company identifier to query
document_type (str) – document type to unpack (10-Q, 8-K, or all)
- get_unpackable_files(tikr: str, document_type: str = 'all', **kwargs)
Get list of targets for unpack_file func.
- Parameters
tikr (str) – a company identifier to query
document_type (str) – document type to unpack (10-Q, 8-K, or all)
- query_server(tikr: str, document_type: str = 'all', delay_time: int = 1, force: bool = False, **kwargs)
Download SEC filings to a local directory for parsing by TIKR.
- Parameters
tikr (str) – a company identifier to query
force (bool) – if (True), then ignore locally downloaded files and overwrite them. Otherwise, attempt to detect previous download and abort server query.
start_date (optional) – The earliest date to look for filings
end_date (optional) – The latest filing date retrievable
max_num_filings – The maximum number of documents to retrieve. Retrieves all documents if set to None.
delay_time – The time (in seconds) delayed at the beginning of this function.
- unpack_bulk(tikr, force=False, loading_bar=False, desc='Inflating HTM', remove_raw=False, force_remove_raw=False, document_type='all', silent=False, include_supplementary=False)
Process all raw data from one company.
- Parameters
tikr (str) – company ticker associated with unpacking
force (bool) – if (True), then ignore locally downloaded files and overwrite them. Otherwise, attempt to detect previous download and abort server query.
loading_bar (bool) – if True, will time and show progress
document_type (str or DocumentType) – The type of filings in question
remove_raw (bool, Optional) – If True, will delete each raw file after it is extracted
force_remove_raw (bool, Optional) – If True, will delete all files in the unpacking directory even if some are not unpacked.
include_supplementary (bool = False) – If (True), then load all supplementary material as well.
- unpack_file(tikr, file, document_type='all', force=True, remove_raw=False, include_supplementary: bool = False, **kwargs)
Process raw data from one filing at one company.
See utility function for getting file names.
- Parameters
tikr (str) – company ticker associated with unpacking
filename (str) – filing submission to unpack
complete (bool) – If False, only unpacks 10-Q, otherwise all documents.
document_type (str) – document type to unpack (10-Q, 8-K, or all)
force (bool) – if (True), then ignore locally downloaded files and overwrite them. Otherwise, attempt to detect previous download and abort server query.
remove_raw (bool = False) – If (True), the raw data will be deleted after parsing.
include_supplementary (bool = False) – If (True), unpacks all supplementary documents to the main one.