Downloader
Downloader
Bases: object
This is a document downloader.
Downloader will fetch documents from the EDGAR database based on parameters such as a text query, time period, company ticker, and file type.
Attributes:
Name | Type | Description |
---|---|---|
forms |
A set of all forms found from build_index_sec |
|
company_to_cik |
A dictionary containing values (company_name,ticker,CIK) |
|
headers |
Request headers to avoid bot detection for scraping |
Source code in sec_web_scraper/Downloader.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
|
__init__()
Initializes a Downloader object.
Source code in sec_web_scraper/Downloader.py
build_index_sec(st, ed, path_files='./index_sec/')
Creates an index of SEC EDGAR filings based on range of years from [st,ed]
Retrieves a list of filings starting from year st, quarter 1 to year ed, quarter 4. It will generate a tsv file for each (year,quarter) tuple that contains all the filings filed in that quarter and year.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
st |
int
|
starting year |
required |
ed |
int
|
ending year. |
required |
path_files |
str
|
file path for saving the built index |
'./index_sec/'
|
Returns:
Type | Description |
---|---|
None
|
None |
Source code in sec_web_scraper/Downloader.py
find_files_by_company(company_cik)
Filters our index based on company_cik in the given time period
This method will filter our index based on the company_cik provided to the function. Our index is a very large file and typically users will want to focus on a certain company. Nicely formats the data for users in a DataFrame for easy extraction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
company_cik |
str
|
A company's CIK. This can be found using get_company_info. |
required |
Returns:
Type | Description |
---|---|
pd.DataFrame
|
A pandas DataFrame containing the columns: ['CIK', 'Company Name', 'Form Type', 'Date Filed', 'Filename', 'url'] |
pd.DataFrame
|
Each entry in this DataFrame will contain 'Company CIK' = company_cik. |
pd.DataFrame
|
See pandas.DataFrame to learn more about Pandas DataFrames |
Raises:
Type | Description |
---|---|
Exception
|
Company CIK does not exist |
Source code in sec_web_scraper/Downloader.py
find_files_by_type(form_type)
Filters our index based on file type/form type.
This method will filter our index based on the form_type provided to the function. Our index is a very large file and typically users will want to focus on a certain form type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
form_type |
str
|
A form type found using get_forms() |
required |
Returns:
Type | Description |
---|---|
pd.DataFrame
|
A pandas DataFrame containing the columns: ['CIK', 'Company Name', 'Form Type', 'Date Filed', 'Filename', 'url'] |
pd.DataFrame
|
Each entry in this DataFrame will contain 'Form Type' = form_type. |
pd.DataFrame
|
See pandas.DataFrame to learn more about Pandas DataFrames |
Raises:
Type | Description |
---|---|
Exception
|
Form type does not exist |
Source code in sec_web_scraper/Downloader.py
get_company_info(company_name)
Returns a list of possible company names.
This method will return a list of possible company names given a query string company_name. It will find the top 10 matches based on the given string
Parameters:
Name | Type | Description | Default |
---|---|---|---|
company_name |
str
|
A query string |
required |
Returns:
Type | Description |
---|---|
list[tuple]
|
A list of tuples (CIK,ticker,title) |
list[tuple]
|
For example: |
list[tuple]
|
[(320193,'AAPL','Apple Inc'),(1418121,'APLE','Apple Hospitality REIT, Inc.')] |
Source code in sec_web_scraper/Downloader.py
get_forms()
pretty_print_forms()
Pretty Prints a list of all form types.
This method will pretty print a list of all form types found after the invocation of build_index_sec
Source code in sec_web_scraper/Downloader.py
read_tsv_files(path_files='./index_sec/')
Work in Progress.