earningscall 1.2.1__py3-none-any.whl → 1.3.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- earningscall/api.py +36 -4
- earningscall/company.py +48 -0
- {earningscall-1.2.1.dist-info → earningscall-1.3.1.dist-info}/METADATA +14 -2
- {earningscall-1.2.1.dist-info → earningscall-1.3.1.dist-info}/RECORD +6 -6
- {earningscall-1.2.1.dist-info → earningscall-1.3.1.dist-info}/WHEEL +0 -0
- {earningscall-1.2.1.dist-info → earningscall-1.3.1.dist-info}/licenses/LICENSE +0 -0
earningscall/api.py
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
-
import importlib
|
1
|
+
import importlib.metadata
|
2
2
|
import logging
|
3
3
|
import os
|
4
4
|
import platform
|
5
5
|
import time
|
6
6
|
import urllib.parse
|
7
|
-
from importlib.metadata import PackageNotFoundError
|
8
7
|
from typing import Dict, Optional, Union
|
9
8
|
|
10
9
|
import requests
|
@@ -65,7 +64,7 @@ def purge_cache():
|
|
65
64
|
def get_earnings_call_version():
|
66
65
|
try:
|
67
66
|
return importlib.metadata.version("earningscall")
|
68
|
-
except PackageNotFoundError:
|
67
|
+
except importlib.metadata.PackageNotFoundError:
|
69
68
|
return None
|
70
69
|
|
71
70
|
|
@@ -164,7 +163,7 @@ def do_get(
|
|
164
163
|
log.warning(
|
165
164
|
f"Rate limited (429). Retrying in {wait_time} seconds... (Attempt {attempt + 1}/{max_attempts})"
|
166
165
|
)
|
167
|
-
time.sleep(wait_time)
|
166
|
+
time.sleep(float(wait_time))
|
168
167
|
|
169
168
|
return response # Return the last response if all retries failed
|
170
169
|
|
@@ -266,3 +265,36 @@ def download_audio_file(
|
|
266
265
|
for chunk in response.iter_content(chunk_size=8192):
|
267
266
|
f.write(chunk)
|
268
267
|
return local_filename
|
268
|
+
|
269
|
+
|
270
|
+
def download_slide_deck(
|
271
|
+
exchange: str,
|
272
|
+
symbol: str,
|
273
|
+
year: int,
|
274
|
+
quarter: int,
|
275
|
+
file_name: Optional[str] = None,
|
276
|
+
) -> Optional[str]:
|
277
|
+
"""
|
278
|
+
Get the slide deck for a given exchange, symbol, year, and quarter.
|
279
|
+
|
280
|
+
:param str exchange: The exchange to get the slide deck for.
|
281
|
+
:param str symbol: The symbol to get the slide deck for.
|
282
|
+
:param int year: The 4-digit year to get the slide deck for.
|
283
|
+
:param int quarter: The quarter to get the slide deck for (1, 2, 3, or 4).
|
284
|
+
:param file_name: Optionally specify the filename to save the slide deck to.
|
285
|
+
:return: The filename of the downloaded slide deck file.
|
286
|
+
:rtype Optional[str]: The filename of the downloaded slide deck file.
|
287
|
+
"""
|
288
|
+
params = {
|
289
|
+
"exchange": exchange,
|
290
|
+
"symbol": symbol,
|
291
|
+
"year": str(year),
|
292
|
+
"quarter": str(quarter),
|
293
|
+
}
|
294
|
+
local_filename = file_name or f"{exchange}_{symbol}_{year}_{quarter}_slides.pdf"
|
295
|
+
with do_get("slides", params=params, stream=True) as response:
|
296
|
+
response.raise_for_status()
|
297
|
+
with open(local_filename, "wb") as f:
|
298
|
+
for chunk in response.iter_content(chunk_size=8192):
|
299
|
+
f.write(chunk)
|
300
|
+
return local_filename
|
earningscall/company.py
CHANGED
@@ -164,3 +164,51 @@ class Company:
|
|
164
164
|
log.error(error_message)
|
165
165
|
raise InsufficientApiAccessError(error_message)
|
166
166
|
raise error
|
167
|
+
|
168
|
+
def download_slide_deck(
|
169
|
+
self,
|
170
|
+
year: Optional[int] = None,
|
171
|
+
quarter: Optional[int] = None,
|
172
|
+
event: Optional[EarningsEvent] = None,
|
173
|
+
file_name: Optional[str] = None,
|
174
|
+
) -> Optional[str]:
|
175
|
+
"""
|
176
|
+
Download the slide deck for a given year and quarter.
|
177
|
+
|
178
|
+
:param Optional[int] year: The year to get the slide deck for.
|
179
|
+
:param Optional[int] quarter: The quarter to get the slide deck for.
|
180
|
+
:param Optional[EarningsEvent] event: The event to get the slide deck for.
|
181
|
+
:param Optional[str] file_name: The file name to save the slide deck to.
|
182
|
+
|
183
|
+
:return: The filename of the downloaded slide deck file.
|
184
|
+
"""
|
185
|
+
if not self.company_info.exchange or not self.company_info.symbol:
|
186
|
+
return None
|
187
|
+
if (not year or not quarter) and event:
|
188
|
+
year = event.year
|
189
|
+
quarter = event.quarter
|
190
|
+
if not year or not quarter:
|
191
|
+
raise ValueError("Must specify either event or year and quarter")
|
192
|
+
if quarter < 1 or quarter > 4:
|
193
|
+
raise ValueError("Invalid quarter. Must be one of: {1,2,3,4}")
|
194
|
+
try:
|
195
|
+
resp = api.download_slide_deck(
|
196
|
+
exchange=self.company_info.exchange,
|
197
|
+
symbol=self.company_info.symbol,
|
198
|
+
year=year,
|
199
|
+
quarter=quarter,
|
200
|
+
file_name=file_name,
|
201
|
+
)
|
202
|
+
return resp
|
203
|
+
except requests.exceptions.HTTPError as error:
|
204
|
+
if error.response.status_code == 404:
|
205
|
+
return None
|
206
|
+
if error.response.status_code == 403:
|
207
|
+
plan_name = error.response.headers["X-Plan-Name"]
|
208
|
+
error_message = (
|
209
|
+
f"Your plan ({plan_name}) does not include Slide Decks. "
|
210
|
+
"Upgrade your plan here: https://earningscall.biz/api-pricing"
|
211
|
+
)
|
212
|
+
log.error(error_message)
|
213
|
+
raise InsufficientApiAccessError(error_message)
|
214
|
+
raise error
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: earningscall
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.3.1
|
4
4
|
Summary: The EarningsCall Python library provides convenient access to the EarningsCall API. It includes a pre-defined set of classes for API resources that initialize themselves dynamically from API responses.
|
5
5
|
Project-URL: Homepage, https://earningscall.biz
|
6
6
|
Project-URL: Documentation, https://github.com/EarningsCall/earningscall-python
|
@@ -257,7 +257,19 @@ from earningscall import get_company
|
|
257
257
|
company = get_company("aapl") # Lookup Apple, Inc by its ticker symbol, "AAPL"
|
258
258
|
|
259
259
|
print("Downloading audio file for Apple Inc. Q3 2021...")
|
260
|
-
audio_file = company.download_audio_file(year=2021, quarter=3, file_name="Apple
|
260
|
+
audio_file = company.download_audio_file(year=2021, quarter=3, file_name="Apple-Q3-2021.mp3")
|
261
|
+
print(f"Downloaded audio file to: {audio_file}")
|
262
|
+
```
|
263
|
+
|
264
|
+
## Download Slide Deck
|
265
|
+
|
266
|
+
```python
|
267
|
+
from earningscall import get_company
|
268
|
+
|
269
|
+
company = get_company("MSFT") # Lookup Microsoft by its ticker symbol, "MSFT"
|
270
|
+
|
271
|
+
slide_deck_filename = company.download_slide_deck(year=2025, quarter=1, file_name="Microsoft-Q1-2025-Slides.pdf")
|
272
|
+
print(f"Downloaded slide deck to: {slide_deck_filename}")
|
261
273
|
```
|
262
274
|
|
263
275
|
## Get Earnings Event Calendar
|
@@ -1,7 +1,7 @@
|
|
1
1
|
earningscall/__init__.py,sha256=J1cBpSRDBivNtYDB-LIMNBZu6rQ3-_1eCY6ACFHlHhE,470
|
2
|
-
earningscall/api.py,sha256=
|
2
|
+
earningscall/api.py,sha256=iFdgQG15ieAMdUDBiPQXgLetdvee0fLq2WoBiF8vP-c,9140
|
3
3
|
earningscall/calendar.py,sha256=nQcb0UsVwCDhvvcr7dqdY0PCqdVGohB7JDON7jtbRyM,725
|
4
|
-
earningscall/company.py,sha256=
|
4
|
+
earningscall/company.py,sha256=Bp2tVNzuH91AW4vOut_7th-w9tUxu9LeAUgRH35ypEc,8776
|
5
5
|
earningscall/errors.py,sha256=aLgwrrpMmYThYEZjCGOhqS57a-GoC0xj2BdbtJ20sy8,490
|
6
6
|
earningscall/event.py,sha256=Jf7KPvpeaF9KkeHe46LbL_HIYLXkyHrs3psq-ZY-bkI,692
|
7
7
|
earningscall/exports.py,sha256=G9eZqX_QydfS5O039Wa0rl4Si3KrC_pGyBZ_cxfUrtI,3147
|
@@ -9,7 +9,7 @@ earningscall/sectors.py,sha256=Xd6DLkAQ_fQkC2s-N9pReC8b_M3iy77OoFftoZj9FWY,5114
|
|
9
9
|
earningscall/symbols.py,sha256=NxabgKfZZI1YwDLUwh_MlNgyfkR9VZdcU-LqkGWwi28,6521
|
10
10
|
earningscall/transcript.py,sha256=P-CeTYhE5T78SXDHFEJ0AlVUFz2XPxDMtkeiorziBiw,1007
|
11
11
|
earningscall/utils.py,sha256=Qx8KhlumUdzyBSZRKMS6vpWlb8MGZpLKA4OffJaMdCE,1032
|
12
|
-
earningscall-1.
|
13
|
-
earningscall-1.
|
14
|
-
earningscall-1.
|
15
|
-
earningscall-1.
|
12
|
+
earningscall-1.3.1.dist-info/METADATA,sha256=RPZqQd2U_5UCovfMylo2FacWwv597qwuwCHmFrgO5ck,17045
|
13
|
+
earningscall-1.3.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
14
|
+
earningscall-1.3.1.dist-info/licenses/LICENSE,sha256=ktEB_UcRMg2cQlX9wiDs544xWncWizwS9mEZuGsCLrM,1069
|
15
|
+
earningscall-1.3.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|