Skip to content

Commit

Permalink
Add download option to skip accession numbers
Browse files Browse the repository at this point in the history
This improves efficiency when some filings have been already downloaded
to another location.
  • Loading branch information
spolcyn committed May 10, 2024
1 parent 4e5d100 commit 96ffc70
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sec_edgar_downloader/_Downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def get(
before: Optional[Date] = None,
include_amends: bool = False,
download_details: bool = False,
skip_accession_numbers: Optional[set[str]] = None,
) -> int:
"""Download filings and save them to disk.
Expand All @@ -84,6 +85,7 @@ def get(
Defaults to False.
:param download_details: denotes whether to download human-readable and easily
parseable filing detail documents (e.g. form 4 XML, 8-K HTML). Defaults to False.
:param skip_accession_numbers: Set of accession numbers to skip when downloading.
:return: number of filings downloaded.
Usage::
Expand Down Expand Up @@ -173,6 +175,7 @@ def get(
download_details,
# Save ticker if passed in to form file system path for saving filings
ticker=ticker_or_cik if not is_cik(ticker_or_cik) else None,
skip_accession_numbers=skip_accession_numbers,
),
self.user_agent,
)
Expand Down
3 changes: 3 additions & 0 deletions sec_edgar_downloader/_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ def get_to_download(cik: str, acc_num: str, doc: str) -> ToDownload:
def fetch_and_save_filings(download_metadata: DownloadMetadata, user_agent: str) -> int:
successfully_downloaded = 0
to_download = aggregate_filings_to_download(download_metadata, user_agent)
if download_metadata.skip_accession_numbers is not None:
to_download = [td for td in to_download if td.accession_number not in download_metadata.skip_accession_numbers]

for td in to_download:
try:
save_location = get_save_location(
Expand Down
1 change: 1 addition & 0 deletions sec_edgar_downloader/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class DownloadMetadata:
include_amends: bool = False
download_details: bool = False
ticker: Optional[str] = None
skip_accession_numbers: Optional[set[str]] = None


@dataclass
Expand Down

0 comments on commit 96ffc70

Please sign in to comment.