Original): Dave Ginsburg
Originally published in the direction of artificial intelligence.
In the fast world of marketing, obtaining a quick but rigorous financial shutter of competitors can mean a difference between the use of occasion and the lack of a sign. In addition to press releases and information editions, the best source of unaffected insight often lies in your own SEC applications-in particular 10-four-quarterly quarterly reports. These documents define everything from the emerging risk to executive comments on performance and strategy.
Introduction
To eliminate the manual password for downloading PDF files, hunting by dozens of pages and notes from the magazines, I built a light Python tool set powered by OpenAI and SEC-UP. In one command you can:
- Determine up to six ticks and automatically pull your latest 10-Q applications (position 1a: Risk factors and position 2: MD and A).
- Download market data From Yahoo Finance to the last year-EPs, revenues, margins and action movements, all indexed to zero. It should be remembered that some of the trend lines are outside the traditional borders of the quarters, because some companies have custom amounts.
- SUMMARY Each section Through the API CHATGPT interface, conquering longer fragments so that they fit within the context. Note that the clints that can be changed to emphasize other areas in positions 1a and 2.
- Compile A distilled take-out point and four configurable charts in a polished PDF-ready report to be shared with the team.
While SEC-UPI (at 55 USD/month) supports heavy SEC extraction, and CHATGPT supplies quick analysis with a minimum expense of 136 tokens (for selected ticks) with GPT-4-Mini GPT-4-Mini, the whole process lasts within a few minutes.
Note that in the scheme of things, the cost of the SEC-UPE is not outside the line and it is a much more stable method of downloading reports than many alternatives. Future improvements of the script can automatically detect confidential transactions or material events in real time, charging various applications, but even in its current form, this script transforms quarterly applications ex officio into a strategic advantage.
In the following sections they describe the script, adopted approaches and other tools. The full Python script compatible with this description and you need to specify your API keys, as well as the basic directory for files.
1. Configuration and configuration
- API keys and customers
We pull out Sec-Uap and OpenAI keys from variable environments Queryapi, ExtraTRetapiand Openai client.
Why? The centralization of certificates at the top facilitates the replacement of new keys or switching to the test environment without hunting using the code. - Work catalog and Ticker list
All results (raw json, charts, pdf) land under /Home/Dave/Finance. We accept up to six ticks via a command line, immediately bolting the input number.
Why? A single “zone drops” for artifacts maintains order, and the flexibility of the CLI allows you to quickly process any subset of companies.
2. SEC 10-Q download and extraction
for each ticker:
• Query the latest 10-Q filing
• Pull two key sections:
– Item 1A: Risk Factors
– Item 2: Management Discussion & Analysis (MD&A)
• Save as `_10q.json`
- Why do we use SEC-UP Instead of scraping HTML:
Returns clean JSON objects for exactly needed sections – no fragile parsing XPath or PDF. - Error support for the section He assures that if one extraction fails, the script will continue to others.
3. Financial data and generation of charts
for each ticker:
• Download 12 months of daily closing prices via yfinance
• Pull quarterly EPS, Revenue, Gross Profit
• Compute quarterly gross margin % and normalize price to a 0-baseline
• Render four Matplotlib line charts
– EPS
– Revenue
– Gross Margin %
– Indexed Share-Price Change
- Why matplotlib + simple loops?
It is light, does not require fancy stylization and fully gives the script in the server environment. - Why normalize the first quarterly -to be agreed?
Quarterly snapshots smooth everyday noise and provide a permanent term to compare between companies.

4. A bit of GPT summary
Summarize section(text, section, ticker):
1. Split text into ≤15 000-char chunks
2. For each chunk:
– Build a precise GPT prompt:
• “Extract the most important … Respond with at most 8 concise bullet points …”
– Call gpt-4o-mini
– Regex‐extract the JSON array out of the raw reply
– Append and dedupe
3. Return the top 8 unique bullets
- Fragment
Long SEC sections (up to ~ 130,000 characters) would blow next to the GPT window ~ 16,000-token. By crossing 15,000 characters, each API connection remains safely within the borders. - JSON extraction with regex
Even with clear “JSON output” instructions, models sometimes prepare or join the free text. Simple Re.Search (R ” (.*)”) Against Pars -Błąd, insulating the JSON board. - Deduplication and limitation
We collect bullets from each piece, clearly transform them into strings (avoiding without stocks), and then store only the first 8 unique points. It gives a tight, indifferent summary. - Exponential withdrawal with vibration
Speed limits and temporary errors are served by again six times a bit, waiting 30 → 60 → 120 s between trials, as well as a bit of random “jitter” to avoid thunder of API interface calls.
5. PDF team
doc = SimpleDocTemplate('Full_Report.pdf')
for each ticker:
• Heading: ticker symbol
• Subheading: Key Risks
– Bullet list from JSON summary
• Subheading: Management Discussion & Analysis
– Bullet list from JSON summary
• Page break
• Final section: “Financial Performance Overview”
– Embed the four charts (EPS, Revenue, Margin, Price)
doc.build(elements)
- Why report?
It is a Pure-Python library with simple abstractions of flow documents (paragraphs, images, side breaks) and without external dependencies. - Why pdf?
A single, independent supplier, which can be e-mail, archived or printed without worrying about missing images or mixed files types.
6. Submission of all this
- Data collection
– RAW SEC TEXT + financial ranks - Analysis and summary
-Tomatized, prose distillation - Imagination
– Clear charts to compare key indicators - Reporting
– one pdf combining narrative and graphics
This pipeline ensures repeatability, scalability (add more ticks if necessary) and reliability (speed/withdrawal limit, fragment, JSON -SaFegords). It can be integrated with night tasks by reporting navigation desktops or be adapted to other SEC (e.g. 10-K, 8-K) with minimal changes.

7. Python script
Available at: https://github.com/daveginsburg/financial_reporting.git Or https://gist.github.com/daveginsburg/6cac66c83901d167cbac63e8f8bc410
Published via AI


















