Skip to content

Commit

Permalink
Fixed bugs:
Browse files Browse the repository at this point in the history
- Omitting the optional --ft for file type with the getxbrl varient
would not download any of the filings. Now works with the --ft omitted.
    - TODO explicitly check in the case where --ft is provided that it is
    10-K or 10-Q

- Expection handling performed a sy.exit when we could not find an RSS
feed for a date in the future.
    - Now prints a warning and continues
    - TODO check current date and do not expect an RSS feed for a month
    in the future!
  • Loading branch information
robren committed May 8, 2017
1 parent 1cbfe10 commit 0878a90
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 3 additions & 1 deletion sec_edgar_download/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
-t --ticker <ticker> Ticker symbol
--version Show version.
--fm <from-month> From month: digits 1 to 12
--tm <to-month> To monthd: digits 1 to 12
--tm <to-month> To month: digits 1 to 12
--ft <form-type> 10-K or 10-Q
--wd <dir> Working-directory [default : ./edgar]
Expand Down Expand Up @@ -67,6 +67,8 @@ def main(args=None):
cik = ix.get_cik(ticker)

form_type = arguments['--ft']
if form_type is None:
form_type = 'All'

indexer = ix.SecIndexer(work_dir)
indexer.download_xbrl_data(cik, from_year, to_year, form_type)
Expand Down
11 changes: 4 additions & 7 deletions sec_edgar_download/indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __init__(self, work_dir="edgar/"):

# FIXME, need to use a private logger not the root one.
# logging.basicConfig(filename='logging.log',level=logging.DEBUG)
logging.basicConfig(level=logging.DEBUG)
logging.basicConfig(level=logging.INFO)

self._prep_directories()
self._prep_database_table()
Expand Down Expand Up @@ -203,15 +203,15 @@ def _download_sec_feed(self, year, month):
if not os.path.exists(feed_file):
edgar_filings_feed = ('http://www.sec.gov/Archives/edgar/monthly/'
+ feed_filename)
logging.debug('Edgar Filings Feed =%s', edgar_filings_feed)
logging.debug('Edgar Filings Feed = %s', edgar_filings_feed)

response = None
try:
response = requests.get(edgar_filings_feed, timeout=4)
response.raise_for_status()
except requests.exceptions.RequestException as err:
logging.exception("RequestException:%s", err)
os.sys.exit(1)
#os.sys.exit(1)

with open(feed_file, 'w') as file:
file.write(response.text)
Expand Down Expand Up @@ -265,9 +265,8 @@ class variable edgar_keys.
assert label == 'xbrlFiles'
xbrl_url = _parse_xbrlfiles(edgar_sub_elem, edgar_ns, item)
edgar_dict[key].append(xbrl_url)

else:
# logging.debug('text = %s',edgar_sub_elem.text)
# logging.debug('text = %s',edgar_sub_elem.text)
edgar_dict[key].append(edgar_sub_elem.text)

return edgar_dict
Expand Down Expand Up @@ -301,8 +300,6 @@ def _prep_database_table(self):
columns)
table_parms = ('''CREATE TABLE IF NOT EXISTS feeds ({})'''
.format(columns))
print(table_parms)

conn = sqlite3.connect(self.database)
curr = conn.cursor()
curr.execute(table_parms)
Expand Down

0 comments on commit 0878a90

Please sign in to comment.