sec-edgar: error saving files

I installed the API and run the next couple of code lines. I got an error when I wanted to save the filing.

from secedgar.filings import FilingType, Filing
from datetime import datetime

filing = Filing(cik_lookup='aapl',
                filing_type=FilingType.FILING_10K,
                start_date=datetime(2015, 1, 1),
                end_date=datetime(2019, 1, 1))

filing.save('./reports')

The following error is rising when I run the last command:

`--------------------------------------------------------------------------- RuntimeError Traceback (most recent call last) <ipython-input-9-ae9d2e927b58> in <module> ----> 1 filing.save(‘FFS’)

~.conda\envs\Keras\lib\site-packages\secedgar\filings\filing.py in save(self, directory, dir_pattern, file_pattern) 222 223 loop = asyncio.get_event_loop() –> 224 loop.run_until_complete(self.client.wait_for_download_async(inputs))

~.conda\envs\Keras\lib\asyncio\base_events.py in run_until_complete(self, future) 568 future.add_done_callback(_run_until_complete_cb) 569 try: –> 570 self.run_forever() 571 except: 572 if new_task and future.done() and not future.cancelled():

~.conda\envs\Keras\lib\asyncio\base_events.py in run_forever(self) 523 self._check_closed() 524 if self.is_running(): –> 525 raise RuntimeError(‘This event loop is already running’) 526 if events._get_running_loop() is not None: 527 raise RuntimeError(

RuntimeError: This event loop is already running 10it [00:01, 9.88it/s]`

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 47 (32 by maintainers)

Most upvoted comments

Hi guys, let me try this later and will let you know. Thanks!

Sent from my iPhone

On 5 Mar 2021, at 23:19, Peter Stenger notifications@github.com wrote:

@esvhd Here is a link to a guide for something that @jackmoody11 outlined. https://help.dreamhost.com/hc/en-us/articles/115000695551-Installing-and-using-virtualenv-with-Python-3

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

@esvhd I just merged a PR into master that adds tqdm as a requirement, so that should be fixed now. Working on finalizing v0.3.3 release so that we can release that.

Can you try running the code without nest_asyncio? We are trying to determine if a fresh install will let you run the code without any issues or if it is a bug.

Hi @jackmoody11 - I just tried WITHOUT importing nest_asyncio in my newly created environment, after saving to ./edgar as @reteps suggested, the download worked as expected.

FYI - Interestingly, in my old base conda environment, without nest_asyncio, with ./edgar it still did not work…

Looks like it was related to save().

Looks like that’s it! I tried filing.save('./edgar') and it worked. Guess it didn’t recognise ~ as home directory? But somehow the process did not fail.

Thanks v much for looking into this.

Wait a second… I think there is a bug with ~ saves… can you try saving to ./files or something.

image