secedgar code example
Example Python code that uses the secedgar
module to retrieve and interact with SEC filings using the EDGAR database:
from secedgar.filings import Filing, FilingType
# Specify the company CIK (Central Index Key) and filing type
cik = "0000320193" # Replace with the CIK of the desired company
filing_type = FilingType.SEC_10K # Replace with the desired filing type
# Retrieve the filings
filings = Filing(cik=cik, filing_type=filing_type)
results = filings.get()
# Print the filing documents
for result in results:
print("Filing Date:", result.acceptance_datetime)
print("Filing Type:", result.form_type)
print("Filing Document:", result.filing_href)
print("--------------------------------------")
In this example, we import the Filing
class and FilingType
enumeration from the secedgar.filings
module.
We specify the company’s CIK (Central Index Key) using the cik
variable. You need to replace "0000320193"
with the CIK of the desired company.
We also specify the filing type using the filing_type
variable. In this example, we use FilingType.SEC_10K
to retrieve SEC 10-K filings. You can replace it with the desired filing type, such as FilingType.SEC_10Q
for 10-Q filings.
We create a Filing
object with the specified CIK and filing type. Then, we call the get()
method to retrieve the filings from the EDGAR database.
The get()
method returns a list of FilingResult
objects. We iterate over the results and print information about each filing, including the filing date (acceptance_datetime
), filing type (form_type
), and a link to the filing document (filing_href
).
Make sure you have the secedgar
Python module installed, which you can do using pip install secedgar
.
About secedgar
secedgar - A Python library to fetch SEC filings and forms from the EDGAR database.