Prompt Title: Parsing SEC Filings Python

Created 1 year ago
Votes 0
Views 377 times
0
Human: Web search results: [1] "Apr 22, 2023 · sec-api is a Python package allowing you to search the entire SEC filings corpus and access over 650 terabytes of data. It includes: SEC Filing Search and Full-Text Search API. Real-Time Stream API. XBRL-to-JSON Converter API + Financial Statements. 10-K/10-Q/8-K Section Extraction API. Filing Download & PDF Render API." URL: https://pypi.org/project/sec-api/ [2] "Feb 2, 2023 · Py-xbrl is a python library that allows the user to easily parse XBRL-Documents. Py-xbrl is primarily build to parse Instance Documents (originally from the SEC) but can also be used to parse any type of XBRL Document as long as it follows the XBRL 2.1 Specification (2003) ^1 or the iXBRL 1.1 Specification (2013) ^2." URL: https://pypi.org/project/py-xbrl/ [3] "May 12, 2020 · py-sec-xbrl. SEC EDGAR Parser based on Python 3. Intruduction. This is a tool intended to parse XBRL files from SEC. Thus, the focus is to parse XBRL XML files so that data is more easily accessible. The idea is to provide a tool for you to code you want instead of a tool that implements a workflow but is rigid." URL: https://pypi.org/project/py-sec-xbrl/ [4] "Let’s explore how to extract and generate financial statements from 10-Q and 10-K SEC EDGAR filings using Python, pandas dataframes and SEC API. You can find and run the entire source code as ..." URL: https://medium.com/@jan_5421/extracting-financial-statements-from-sec-filings-xbrl-to-json-f83542ade90 [5] "Apr 11, 2019 · I am trying to identify specific data points from SEC Filings on a routine basis however I want to automate this instead of having to manually go search a companies CIK ID and Form filing. So far, I have been able to get to a point where I am downloading metadata about all filings received by the SEC in a given time period. It looks like this:" URL: https://stackoverflow.com/questions/55622895/how-to-use-beautiful-soup-to-scrape-secs-edgar-database-and-receive-desire-data Current date: 5/16/2023 Instructions: Using the provided web search results, write a comprehensive reply to the given query. Make sure to cite results using [[number](URL)] notation after the reference. If the provided search results refer to multiple subjects with the same name, write separate answers for each subject. Query: Python code to extract tables from SEC N-CSR xbrl filing and save the data
ChatGPT:

Based on the search results, there are several Python libraries that can be used to parse XBRL documents from the SEC's EDGAR database, including sec-api[1], py-xbrl[2], and py-sec-xbrl[3]. These libraries can be used to extract data from SEC filings, including N-CSR filings.

Here's a basic example of how you might use the sec-api library to download and parse an XBRL document:

python
from sec_api import QueryApi query_api = QueryApi(api_key="YOUR_SEC_API_KEY") query = { "query": { "query_string": { "query": "ticker:AAPL AND formType:\"N-CSR\"" } }, "from": "0", "size": "10", "sort": [{ "filedAt": { "order": "desc" } }] } filings = query_api.get_filings(query) # Now you have the filings, you can parse the XBRL data

Once you have the XBRL data, you can use the py-xbrl library to parse it:

python
from pyxbrl import XBRLParser xbrl_parser = XBRLParser() xbrl = xbrl_parser.parse(open("path_to_your_xbrl_file")) # Now you have the parsed XBRL data, you can extract the tables

Please note that this is a simplified example and you'll need to adapt it to your specific needs. Also, you'll need to replace "YOUR_SEC_API_KEY" with your actual SEC API key, and "path_to_your_xbrl_file" with the actual path to your XBRL file.

Also, remember that parsing XBRL documents can be complex due to the flexible nature of the XBRL format. You might need to write custom code to handle specific edge cases or to extract specific pieces of data.

If you're interested in a more detailed guide on how to extract financial statements from SEC filings, you might find this Medium article helpful[4]. It provides a step-by-step guide on how to extract and generate financial statements from 10-Q and 10-K SEC EDGAR filings using Python, pandas dataframes, and the SEC API. Although it's not specifically about N-CSR filings, the general principles should be similar.

Remember that this is not investment advice and there is inherent risk in investing.

avatar
CinderZhang
Shared 1 prompt
Created 1 year ago

Leave a Comment

Related Tag Prompts

0
0
SEC responds to defendants.
1 year ago 2023-03-23 23:57:48 SEC