def _fetch_report(self, company_code, cik, priorto, count, filing_type, output): """Fetch filings. Args: company_code (str): Code used to help find company filings. Often the company's ticker is used. cik (Union[str, int]): Central Index Key assigned by SEC. See https://www.sec.gov/edgar/searchedgar/cik.htm to search for a company's CIK. priorto (Union[str, datetime.datetime]): Most recent report to consider. Must be in form 'YYYYMMDD' or valid ``datetime.datetime`` object. filing_type (str): Choose from list of valid filing types. Includes '10-Q', '10-K', '8-K', '13-F', 'SD'. Returns: None """ priorto = _sanitize_date(priorto) cik = self._check_cik(cik) self._make_directory(company_code, cik, priorto, filing_type) # generate the url to crawl base_url = "http://www.sec.gov/cgi-bin/browse-edgar" params = { 'action': 'getcompany', 'owner': 'exclude', 'output': output, 'CIK': cik, 'type': filing_type, 'dateb': priorto, 'count': count } print("started {filing_type} {company_code}".format( filing_type=filing_type, company_code=company_code)) r = requests.get(base_url, params=params) if r.status_code == 200: data = r.text # get doc list data docs = self._create_document_list(data) try: self._save_in_directory(company_code, cik, priorto, filing_type, docs) except Exception as e: print(str(e)) # Need to use str for Python 2.5 else: raise EDGARQueryError(r.status_code) print("Successfully downloaded all the files")
def _fetch_report(self, company_code, cik, priorto, count, filing_type): """Fetch filings. Args: company_code (str): Code used to help find company filings. Often the company's ticker is used. cik (Union[str, int]): Central Index Key assigned by SEC. See https://www.sec.gov/edgar/searchedgar/cik.htm to search for a company's CIK. priorto (Union[str, datetime.datetime]): Most recent report to consider. Must be in form 'YYYYMMDD' or valid ``datetime.datetime`` object. filing_type (str): Choose from list of valid filing types. Includes '10-Q', '10-K', '8-K', '13-F', 'SD'. Returns: None """ priorto = _sanitize_date(priorto) cik = self._check_cik(cik) self._make_directory(company_code, cik, priorto, filing_type) # generate the url to crawl base_url = "http://www.sec.gov/cgi-bin/browse-edgar" params = {'action': 'getcompany', 'owner': 'exclude', 'output': 'xml', 'CIK': cik, 'type': filing_type, 'dateb': priorto, 'count': count} print("started {filing_type} {company_code}".format( filing_type=filing_type, company_code=company_code)) r = requests.get(base_url, params=params) if r.status_code == 200: data = r.text # get doc list data docs = self._create_document_list(data) try: self._save_in_directory( company_code, cik, priorto, filing_type, docs) except Exception as e: print(str(e)) # Need to use str for Python 2.5 else: raise EDGARQueryError(r.status_code) print("Successfully downloaded all the files")
def dateb(self, val): self._dateb = _sanitize_date(val)
def dateb(self): return _sanitize_date(self._dateb)