Fix: Robust SEC Filing Retrieval via Local Caching & Deep Scanning#147
Open
LutherAbel wants to merge 3 commits intovirattt:mainfrom
Open
Fix: Robust SEC Filing Retrieval via Local Caching & Deep Scanning#147LutherAbel wants to merge 3 commits intovirattt:mainfrom
LutherAbel wants to merge 3 commits intovirattt:mainfrom
Conversation
This PR overhauls the SEC scraping logic to eliminate 402/403 errors and handle non-standard filing formats. Key Changes: 1. Offline Ticker Cache: Added `company_tickers.json` as a static asset. The scraper now prioritizes reading CIKs from disk to prevent API rate-limiting and IP bans. 2. Deep Scanning Logic: Increased filing scan depth from 5 to 80 in `sec_scraper.ts`. This ensures filings for active companies (e.g., SOFI, ENTG) aren't pushed out of view by high volumes of Form 4s. 3. Hard Fallback Interceptor: Updated `financial-search.ts` to intercept "402 Payment Required" errors. Failed API calls now automatically force-route to the direct SEC scraper. 4. Brute Force Payload Discovery: Improved logic to find exhibit links (e.g., 99.1 Press Releases) even in non-standard HTML structures. 5. System Prompt Restoration: Restored the full financial routing prompt while maintaining the new SEC intercept rules.
Author
|
Note on CI Failure: I noticed the CI build failed due to a frozen-lockfile error. This is because I modified package.json to fix the execution script (switching to tsx), but I am working in a Node.js/NPM environment and cannot regenerate the bun.lockb binary lockfile. Please run bun install to update the lockfile on your end. The logic changes themselves are verified and working. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
This PR addresses the "402 Payment Required" error that occurs when users do not have a paid subscription to the Financial Datasets API.
The Goal:
To allow the agent to seamlessly retrieve SEC filings (8-K, 6-K) directly from EDGAR when the paid API is unavailable, instead of failing or falling back to a generic web search.
Key Changes:
Verification:
Verified that queries like "search NBIS 6-k" and "search SOFI 8-k" now return correct data even without a paid API key.