earningscall 0.0.17__py3-none-any.whl → 0.0.18__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 +74 -4
- earningscall/company.py +57 -2
- earningscall/symbols.py +1 -1
- {earningscall-0.0.17.dist-info → earningscall-0.0.18.dist-info}/METADATA +1 -1
- {earningscall-0.0.17.dist-info → earningscall-0.0.18.dist-info}/RECORD +7 -7
- {earningscall-0.0.17.dist-info → earningscall-0.0.18.dist-info}/WHEEL +0 -0
- {earningscall-0.0.17.dist-info → earningscall-0.0.18.dist-info}/licenses/LICENSE +0 -0
earningscall/api.py
CHANGED
@@ -46,7 +46,22 @@ def purge_cache():
|
|
46
46
|
return cache_session().cache.clear()
|
47
47
|
|
48
48
|
|
49
|
-
def do_get(
|
49
|
+
def do_get(
|
50
|
+
path: str,
|
51
|
+
use_cache: bool = False,
|
52
|
+
**kwargs,
|
53
|
+
) -> requests.Response:
|
54
|
+
"""
|
55
|
+
Do a GET request to the API.
|
56
|
+
|
57
|
+
Args:
|
58
|
+
path (str): The path to request.
|
59
|
+
use_cache (bool): Whether to use the cache.
|
60
|
+
**kwargs: Additional arguments to pass to the request.
|
61
|
+
|
62
|
+
Returns:
|
63
|
+
requests.Response: The response from the API.
|
64
|
+
"""
|
50
65
|
params = {
|
51
66
|
**api_key_param(),
|
52
67
|
**kwargs.get("params", {}),
|
@@ -56,7 +71,11 @@ def do_get(path: str, use_cache: bool = False, **kwargs):
|
|
56
71
|
if use_cache and earningscall.enable_requests_cache:
|
57
72
|
return cache_session().get(url, params=params)
|
58
73
|
else:
|
59
|
-
return requests.get(
|
74
|
+
return requests.get(
|
75
|
+
url,
|
76
|
+
params=params,
|
77
|
+
stream=kwargs.get("stream"),
|
78
|
+
)
|
60
79
|
|
61
80
|
|
62
81
|
def get_events(exchange: str, symbol: str):
|
@@ -72,8 +91,25 @@ def get_events(exchange: str, symbol: str):
|
|
72
91
|
return response.json()
|
73
92
|
|
74
93
|
|
75
|
-
def get_transcript(
|
76
|
-
|
94
|
+
def get_transcript(
|
95
|
+
exchange: str,
|
96
|
+
symbol: str,
|
97
|
+
year: int,
|
98
|
+
quarter: int,
|
99
|
+
level: Optional[int] = None,
|
100
|
+
) -> Optional[str]:
|
101
|
+
"""
|
102
|
+
Get the transcript for a given exchange, symbol, year, and quarter.
|
103
|
+
|
104
|
+
Args:
|
105
|
+
exchange (str): The exchange to get the transcript for.
|
106
|
+
symbol (str): The symbol to get the transcript for.
|
107
|
+
year (int): The year to get the transcript for.
|
108
|
+
quarter (int): The quarter to get the transcript for.
|
109
|
+
|
110
|
+
Returns:
|
111
|
+
Optional[str]: The transcript for the given exchange, symbol, year, and quarter.
|
112
|
+
"""
|
77
113
|
log.debug(f"get_transcript year: {year} quarter: {quarter}")
|
78
114
|
params = {
|
79
115
|
**api_key_param(),
|
@@ -81,6 +117,7 @@ def get_transcript(exchange: str, symbol: str, year: int, quarter: int) -> Optio
|
|
81
117
|
"symbol": symbol,
|
82
118
|
"year": str(year),
|
83
119
|
"quarter": str(quarter),
|
120
|
+
"level": str(level or 1),
|
84
121
|
}
|
85
122
|
response = do_get("transcript", params=params)
|
86
123
|
if response.status_code != 200:
|
@@ -102,3 +139,36 @@ def get_sp500_companies_txt_file():
|
|
102
139
|
if response.status_code != 200:
|
103
140
|
return None
|
104
141
|
return response.text
|
142
|
+
|
143
|
+
|
144
|
+
def download_audio_file(
|
145
|
+
exchange: str,
|
146
|
+
symbol: str,
|
147
|
+
year: int,
|
148
|
+
quarter: int,
|
149
|
+
file_name: Optional[str] = None,
|
150
|
+
) -> Optional[str]:
|
151
|
+
"""
|
152
|
+
Get the audio for a given exchange, symbol, year, and quarter.
|
153
|
+
|
154
|
+
Args:
|
155
|
+
exchange (str): The exchange to get the audio for.
|
156
|
+
symbol (str): The symbol to get the audio for.
|
157
|
+
year (int): The year to get the audio for.
|
158
|
+
quarter (int): The quarter to get the audio for.
|
159
|
+
filename (Optional[str]): The filename to save the audio to.
|
160
|
+
"""
|
161
|
+
params = {
|
162
|
+
**api_key_param(),
|
163
|
+
"exchange": exchange,
|
164
|
+
"symbol": symbol,
|
165
|
+
"year": str(year),
|
166
|
+
"quarter": str(quarter),
|
167
|
+
}
|
168
|
+
local_filename = file_name or f"{exchange}_{symbol}_{year}_{quarter}.mp3"
|
169
|
+
with do_get("audio", params=params, stream=True) as response:
|
170
|
+
response.raise_for_status()
|
171
|
+
with open(local_filename, "wb") as f:
|
172
|
+
for chunk in response.iter_content(chunk_size=8192):
|
173
|
+
f.write(chunk)
|
174
|
+
return local_filename
|
earningscall/company.py
CHANGED
@@ -39,9 +39,22 @@ class Company:
|
|
39
39
|
return self._events
|
40
40
|
|
41
41
|
def get_transcript(
|
42
|
-
self,
|
42
|
+
self,
|
43
|
+
year: Optional[int] = None,
|
44
|
+
quarter: Optional[int] = None,
|
45
|
+
event: Optional[EarningsEvent] = None,
|
43
46
|
) -> Optional[Transcript]:
|
47
|
+
"""
|
48
|
+
Get the transcript for a given year and quarter.
|
44
49
|
|
50
|
+
Args:
|
51
|
+
year (Optional[int]): The year to get the transcript for.
|
52
|
+
quarter (Optional[int]): The quarter to get the transcript for.
|
53
|
+
event (Optional[EarningsEvent]): The event to get the transcript for.
|
54
|
+
|
55
|
+
Returns:
|
56
|
+
Optional[Transcript]: The transcript for the given year and quarter.
|
57
|
+
"""
|
45
58
|
if not self.company_info.exchange or not self.company_info.symbol:
|
46
59
|
return None
|
47
60
|
if (not year or not quarter) and event:
|
@@ -49,7 +62,49 @@ class Company:
|
|
49
62
|
quarter = event.quarter
|
50
63
|
if (not year or not quarter) and not event:
|
51
64
|
raise ValueError("Must specify either event or year and quarter")
|
52
|
-
resp = api.get_transcript(
|
65
|
+
resp = api.get_transcript(
|
66
|
+
self.company_info.exchange,
|
67
|
+
self.company_info.symbol,
|
68
|
+
year, # type: ignore
|
69
|
+
quarter, # type: ignore
|
70
|
+
level=None, # TODO: Pass level to API
|
71
|
+
)
|
72
|
+
# TODO: Parse Advanced transcript data
|
53
73
|
if not resp:
|
54
74
|
return None
|
55
75
|
return Transcript.from_dict(resp) # type: ignore
|
76
|
+
|
77
|
+
def download_audio_file(
|
78
|
+
self,
|
79
|
+
year: Optional[int] = None,
|
80
|
+
quarter: Optional[int] = None,
|
81
|
+
event: Optional[EarningsEvent] = None,
|
82
|
+
file_name: Optional[str] = None,
|
83
|
+
) -> Optional[str]:
|
84
|
+
"""
|
85
|
+
Download the audio file for a given year and quarter.
|
86
|
+
|
87
|
+
Args:
|
88
|
+
year (Optional[int]): The year to get the audio for.
|
89
|
+
quarter (Optional[int]): The quarter to get the audio for.
|
90
|
+
event (Optional[EarningsEvent]): The event to get the audio for.
|
91
|
+
file_name (Optional[str]): The file name to save the audio to.
|
92
|
+
|
93
|
+
Returns:
|
94
|
+
Optional[str]: The audio for the given year and quarter.
|
95
|
+
"""
|
96
|
+
if not self.company_info.exchange or not self.company_info.symbol:
|
97
|
+
return None
|
98
|
+
if (not year or not quarter) and event:
|
99
|
+
year = event.year
|
100
|
+
quarter = event.quarter
|
101
|
+
if (not year or not quarter) and not event:
|
102
|
+
raise ValueError("Must specify either event or year and quarter")
|
103
|
+
resp = api.download_audio_file(
|
104
|
+
exchange=self.company_info.exchange,
|
105
|
+
symbol=self.company_info.symbol,
|
106
|
+
year=year, # type: ignore
|
107
|
+
quarter=quarter, # type: ignore
|
108
|
+
file_name=file_name,
|
109
|
+
)
|
110
|
+
return resp
|
earningscall/symbols.py
CHANGED
@@ -8,7 +8,7 @@ from earningscall.errors import InsufficientApiAccessError
|
|
8
8
|
from earningscall.sectors import sector_to_index, industry_to_index, index_to_sector, index_to_industry
|
9
9
|
|
10
10
|
# WARNING: Add new indexes to the *END* of this list
|
11
|
-
EXCHANGES_IN_ORDER = ["NYSE", "NASDAQ", "AMEX", "TSX", "TSXV", "OTC"]
|
11
|
+
EXCHANGES_IN_ORDER = ["NYSE", "NASDAQ", "AMEX", "TSX", "TSXV", "OTC", "LSE"]
|
12
12
|
|
13
13
|
log = logging.getLogger(__file__)
|
14
14
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: earningscall
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.18
|
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
|
@@ -1,14 +1,14 @@
|
|
1
1
|
earningscall/__init__.py,sha256=0mANmPlE7LEWtOGzV2cmmlPfBIWBWlWRDkyqPHJ1jm8,333
|
2
|
-
earningscall/api.py,sha256=
|
3
|
-
earningscall/company.py,sha256=
|
2
|
+
earningscall/api.py,sha256=jTkPI-RVOOv4fiQ6RNpTuc-ef210t9zsO2qfF2lTMqw,4463
|
3
|
+
earningscall/company.py,sha256=L0XZc1d4RzL_GP_p7vt8NmXDKl1C0vz18UkSVsfjxK4,3894
|
4
4
|
earningscall/errors.py,sha256=EA-d6qIYgQs9csp8JptQiAaYoM0M9HhCGJgKA9GAWPg,440
|
5
5
|
earningscall/event.py,sha256=Jf7KPvpeaF9KkeHe46LbL_HIYLXkyHrs3psq-ZY-bkI,692
|
6
6
|
earningscall/exports.py,sha256=i9UWHY6Lq1OzZTZX_1SdNzrNd_PSlPwpB337lGMK4oM,837
|
7
7
|
earningscall/sectors.py,sha256=Xd6DLkAQ_fQkC2s-N9pReC8b_M3iy77OoFftoZj9FWY,5114
|
8
|
-
earningscall/symbols.py,sha256=
|
8
|
+
earningscall/symbols.py,sha256=39tL7oP1HT8BturwKW7mgS33dX2Y_X8cw5GKK0aV02k,6354
|
9
9
|
earningscall/transcript.py,sha256=vuI0FOSaWDGKYaUxq1i6cnBZQJ2TAuARAWAhHlfuNRc,329
|
10
10
|
earningscall/utils.py,sha256=Qx8KhlumUdzyBSZRKMS6vpWlb8MGZpLKA4OffJaMdCE,1032
|
11
|
-
earningscall-0.0.
|
12
|
-
earningscall-0.0.
|
13
|
-
earningscall-0.0.
|
14
|
-
earningscall-0.0.
|
11
|
+
earningscall-0.0.18.dist-info/METADATA,sha256=r1Kas9LcEs00qZLL1e7AC3KGicw9FyFw9S1j87DFBhM,7177
|
12
|
+
earningscall-0.0.18.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
13
|
+
earningscall-0.0.18.dist-info/licenses/LICENSE,sha256=ktEB_UcRMg2cQlX9wiDs544xWncWizwS9mEZuGsCLrM,1069
|
14
|
+
earningscall-0.0.18.dist-info/RECORD,,
|
File without changes
|
File without changes
|