earningscall 0.0.4__tar.gz

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.
Files changed (34) hide show
  1. earningscall-0.0.4/.github/workflows/release.yml +127 -0
  2. earningscall-0.0.4/.gitignore +34 -0
  3. earningscall-0.0.4/.python-version +1 -0
  4. earningscall-0.0.4/CHANGELOG.md +0 -0
  5. earningscall-0.0.4/DEVELOPMENT.md +25 -0
  6. earningscall-0.0.4/LICENSE +21 -0
  7. earningscall-0.0.4/PKG-INFO +101 -0
  8. earningscall-0.0.4/README.md +85 -0
  9. earningscall-0.0.4/TODO.md +5 -0
  10. earningscall-0.0.4/earningscall/__init__.py +2 -0
  11. earningscall-0.0.4/earningscall/api.py +67 -0
  12. earningscall-0.0.4/earningscall/company.py +51 -0
  13. earningscall-0.0.4/earningscall/errors.py +25 -0
  14. earningscall-0.0.4/earningscall/event.py +28 -0
  15. earningscall-0.0.4/earningscall/exports.py +17 -0
  16. earningscall-0.0.4/earningscall/sectors.py +234 -0
  17. earningscall-0.0.4/earningscall/symbols.py +226 -0
  18. earningscall-0.0.4/earningscall/transcript.py +14 -0
  19. earningscall-0.0.4/earningscall/utils.py +15 -0
  20. earningscall-0.0.4/pyproject.toml +71 -0
  21. earningscall-0.0.4/requirements-dev.lock +48 -0
  22. earningscall-0.0.4/requirements.lock +37 -0
  23. earningscall-0.0.4/scripts/get_all_company_transcripts.py +14 -0
  24. earningscall-0.0.4/scripts/get_single_transcript.py +7 -0
  25. earningscall-0.0.4/scripts/list_all_companies.py +4 -0
  26. earningscall-0.0.4/tests/data/msft-transcript-response.yaml +715 -0
  27. earningscall-0.0.4/tests/data/symbols-v2.yaml +3079 -0
  28. earningscall-0.0.4/tests/data/symbols.txt +10 -0
  29. earningscall-0.0.4/tests/data/symbols.yaml +2514 -0
  30. earningscall-0.0.4/tests/test_earnings_event.py +38 -0
  31. earningscall-0.0.4/tests/test_get_transcript.py +38 -0
  32. earningscall-0.0.4/tests/test_helper.py +0 -0
  33. earningscall-0.0.4/tests/test_simple.py +27 -0
  34. earningscall-0.0.4/tests/test_symbols.py +49 -0
@@ -0,0 +1,127 @@
1
+ # https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
2
+ name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
3
+
4
+ on: push
5
+
6
+ jobs:
7
+ build:
8
+ name: Build distribution 📦
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - name: Set up Python
14
+ uses: actions/setup-python@v5
15
+ with:
16
+ python-version: "3.x"
17
+ - name: Install pypa/build
18
+ run: >-
19
+ python3 -m
20
+ pip install
21
+ build
22
+ --user
23
+ - name: Install Rye
24
+ run: |
25
+ curl -sSf https://rye.astral.sh/get | RYE_NO_AUTO_INSTALL=1 RYE_INSTALL_OPTION="--yes" bash
26
+ # $(HOME)/.rye/shims/rye pin $(PYTHON_VERSION)
27
+ # $(HOME)/.rye/shims/rye sync --no-lock
28
+ # https://rye.astral.sh/guide/publish/
29
+ - name: Build a binary wheel and sdist
30
+ run: |
31
+ source ~/.rye/env
32
+ rye sync
33
+ rye build
34
+ - name: Store the distribution packages
35
+ uses: actions/upload-artifact@v3
36
+ with:
37
+ name: python-package-distributions
38
+ path: dist/
39
+
40
+ publish-to-pypi:
41
+ name: >-
42
+ Publish Python 🐍 distribution 📦 to PyPI
43
+ if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
44
+ needs:
45
+ - build
46
+ runs-on: ubuntu-latest
47
+ environment:
48
+ name: pypi
49
+ url: https://pypi.org/p/earningscall
50
+ permissions:
51
+ id-token: write # IMPORTANT: mandatory for trusted publishing
52
+
53
+ steps:
54
+ - name: Download all the dists
55
+ uses: actions/download-artifact@v3
56
+ with:
57
+ name: python-package-distributions
58
+ path: dist/
59
+ - name: Publish distribution 📦 to PyPI
60
+ uses: pypa/gh-action-pypi-publish@release/v1
61
+
62
+ github-release:
63
+ name: >-
64
+ Sign the Python 🐍 distribution 📦 with Sigstore
65
+ and upload them to GitHub Release
66
+ needs:
67
+ - publish-to-pypi
68
+ runs-on: ubuntu-latest
69
+
70
+ permissions:
71
+ contents: write # IMPORTANT: mandatory for making GitHub Releases
72
+ id-token: write # IMPORTANT: mandatory for sigstore
73
+
74
+ steps:
75
+ - name: Download all the dists
76
+ uses: actions/download-artifact@v3
77
+ with:
78
+ name: python-package-distributions
79
+ path: dist/
80
+ - name: Sign the dists with Sigstore
81
+ uses: sigstore/gh-action-sigstore-python@v2.1.1
82
+ with:
83
+ inputs: >-
84
+ ./dist/*.tar.gz
85
+ ./dist/*.whl
86
+ - name: Create GitHub Release
87
+ env:
88
+ GITHUB_TOKEN: ${{ github.token }}
89
+ run: >-
90
+ gh release create
91
+ '${{ github.ref_name }}'
92
+ --repo '${{ github.repository }}'
93
+ --notes ""
94
+ - name: Upload artifact signatures to GitHub Release
95
+ env:
96
+ GITHUB_TOKEN: ${{ github.token }}
97
+ # Upload to GitHub Release using the `gh` CLI.
98
+ # `dist/` contains the built packages, and the
99
+ # sigstore-produced signatures and certificates.
100
+ run: >-
101
+ gh release upload
102
+ '${{ github.ref_name }}' dist/**
103
+ --repo '${{ github.repository }}'
104
+
105
+ publish-to-testpypi:
106
+ name: Publish Python 🐍 distribution 📦 to TestPyPI
107
+ needs:
108
+ - build
109
+ runs-on: ubuntu-latest
110
+
111
+ environment:
112
+ name: testpypi
113
+ url: https://test.pypi.org/p/earningscall
114
+
115
+ permissions:
116
+ id-token: write # IMPORTANT: mandatory for trusted publishing
117
+
118
+ steps:
119
+ - name: Download all the dists
120
+ uses: actions/download-artifact@v3
121
+ with:
122
+ name: python-package-distributions
123
+ path: dist/
124
+ - name: Publish distribution 📦 to TestPyPI
125
+ uses: pypa/gh-action-pypi-publish@release/v1
126
+ with:
127
+ repository-url: https://test.pypi.org/legacy/
@@ -0,0 +1,34 @@
1
+ # Distribution / packaging
2
+ .DS_Store
3
+ .Python
4
+ .venv
5
+ env/
6
+ build/
7
+ develop-eggs/
8
+ dist/
9
+ downloads/
10
+ eggs/
11
+ .eggs/
12
+ lib/
13
+ lib64/
14
+ parts/
15
+ sdist/
16
+ var/
17
+ *.egg-info/
18
+ .installed.cfg
19
+ *.egg
20
+ log
21
+ /dumps
22
+ /bin/dumps
23
+ /logs
24
+
25
+ /dist
26
+ *.pyc
27
+ *.iws
28
+ *.zip
29
+ workspace.xml
30
+ tasks.xml
31
+ /.idea
32
+ /build
33
+ /sc.egg-info
34
+ /packages
@@ -0,0 +1 @@
1
+ 3.12.3
File without changes
@@ -0,0 +1,25 @@
1
+ # Development
2
+
3
+ TODO: Add rye installation instructions.
4
+
5
+ This project uses Rye: https://rye.astral.sh/
6
+
7
+
8
+ ### Saving Server-Side Responses for a Mocked Unit test
9
+
10
+ You can use the following test code to save responses from the server as a .YAML file:
11
+
12
+ ```python
13
+ import requests
14
+
15
+ from responses import _recorder
16
+
17
+ @_recorder.record(file_path="symbols.yaml")
18
+ def test_save_symbols_v1():
19
+ requests.get("https://earningscall.biz/symbols.txt")
20
+
21
+
22
+ @_recorder.record(file_path="symbols-v2.yaml")
23
+ def test_save_symbols_v1():
24
+ requests.get("https://earningscall.biz/symbols-v2.txt")
25
+ ```
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 EarningsCall
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,101 @@
1
+ Metadata-Version: 2.3
2
+ Name: earningscall
3
+ Version: 0.0.4
4
+ Summary: The EarningsCall Python library.
5
+ Project-URL: Documentation, https://github.com/EarningsCall/earningscall-python
6
+ Project-URL: Issues, https://github.com/EarningsCall/earningscall-python/issues
7
+ Project-URL: Source, https://github.com/EarningsCall/earningscall-python
8
+ Author-email: EarningsCall <dev@earningscall.biz>
9
+ License-File: LICENSE
10
+ Requires-Python: >=3.8
11
+ Requires-Dist: dataclasses-json>=0.6.4
12
+ Requires-Dist: dataclasses>=0.6
13
+ Requires-Dist: more-itertools>=10.0.0
14
+ Requires-Dist: requests>=2.30.0
15
+ Description-Content-Type: text/markdown
16
+
17
+ # EarningsCall Python Library
18
+
19
+ The EarningsCall Python library provides convenient access to the EarningsCall API from
20
+ applications written in the Python language. It includes a pre-defined set of
21
+ classes for API resources that initialize themselves dynamically from API
22
+ responses.
23
+
24
+ # Installation
25
+
26
+ You don't need this source code unless you want to modify the package. If you just want to use the package, just run:
27
+
28
+ ```sh
29
+ pip install --upgrade earningscall
30
+ ```
31
+
32
+ # Requirements
33
+
34
+ * Python 3.8+ (PyPI supported)
35
+
36
+
37
+ ## Get Transcript for a Single Quarter
38
+
39
+ ```python
40
+ from earningscall import get_company
41
+
42
+
43
+ company = get_company("aapl") # Lookup Apple, Inc by its ticker symbol, "AAPL"
44
+
45
+ transcript = company.get_transcript(year=2021, quarter=3)
46
+ print(f"{company} Q3 2021 Transcript Text: \"{transcript.text[:100]}...\"")
47
+ ```
48
+
49
+ Output
50
+
51
+ ```text
52
+ Apple Inc. Q3 2021 Transcript Text: "Good day, and welcome to the Apple Q3 FY 2021 Earnings Conference Call. Today's call is being record..."
53
+ ```
54
+
55
+
56
+ ## Get All Transcripts for a company
57
+
58
+
59
+ ```python
60
+ from earningscall import get_company
61
+
62
+
63
+ company = get_company("aapl") # Lookup Apple, Inc by its ticker symbol, "AAPL"
64
+
65
+ print(f"Getting all transcripts for: {company}..")
66
+ # Retrieve all earnings conference call events for a company, and iterate through each one
67
+ for event in company.events():
68
+ transcript = company.get_transcript(event) # Fetch the earnings call transcript for this event
69
+ print(f"* Q{event.quarter} {event.year}")
70
+ if transcript:
71
+ print(f" Transcript Text: \"{transcript.text[:100]}...\"")
72
+ else:
73
+ print(f" No transcript found.")
74
+
75
+ ```
76
+
77
+ Output
78
+
79
+ ```text
80
+ Getting all transcripts for: Apple Inc...
81
+ * Q4 2023
82
+ Transcript Text: "Good day and welcome to the Apple Q4 Fiscal Year 2023 earnings conference call. Today's call is bein..."
83
+ * Q3 2023
84
+ Transcript Text: "Good day and welcome to the Apple Q3 Fiscal Year 2023 earnings conference call. Today's call is bein..."
85
+ * Q2 2023
86
+ Transcript Text: "At this time for opening remarks and introductions, I would like to turn the call over to Suhasini T..."
87
+ * Q1 2023
88
+
89
+ ...
90
+ ```
91
+
92
+
93
+
94
+ ## List All Companies
95
+
96
+ ```python
97
+ from earningscall import get_all_companies
98
+
99
+ for company in get_all_companies():
100
+ print(f"{company.company_info} -- {company.company_info.sector} -- {company.company_info.industry}")
101
+ ```
@@ -0,0 +1,85 @@
1
+ # EarningsCall Python Library
2
+
3
+ The EarningsCall Python library provides convenient access to the EarningsCall API from
4
+ applications written in the Python language. It includes a pre-defined set of
5
+ classes for API resources that initialize themselves dynamically from API
6
+ responses.
7
+
8
+ # Installation
9
+
10
+ You don't need this source code unless you want to modify the package. If you just want to use the package, just run:
11
+
12
+ ```sh
13
+ pip install --upgrade earningscall
14
+ ```
15
+
16
+ # Requirements
17
+
18
+ * Python 3.8+ (PyPI supported)
19
+
20
+
21
+ ## Get Transcript for a Single Quarter
22
+
23
+ ```python
24
+ from earningscall import get_company
25
+
26
+
27
+ company = get_company("aapl") # Lookup Apple, Inc by its ticker symbol, "AAPL"
28
+
29
+ transcript = company.get_transcript(year=2021, quarter=3)
30
+ print(f"{company} Q3 2021 Transcript Text: \"{transcript.text[:100]}...\"")
31
+ ```
32
+
33
+ Output
34
+
35
+ ```text
36
+ Apple Inc. Q3 2021 Transcript Text: "Good day, and welcome to the Apple Q3 FY 2021 Earnings Conference Call. Today's call is being record..."
37
+ ```
38
+
39
+
40
+ ## Get All Transcripts for a company
41
+
42
+
43
+ ```python
44
+ from earningscall import get_company
45
+
46
+
47
+ company = get_company("aapl") # Lookup Apple, Inc by its ticker symbol, "AAPL"
48
+
49
+ print(f"Getting all transcripts for: {company}..")
50
+ # Retrieve all earnings conference call events for a company, and iterate through each one
51
+ for event in company.events():
52
+ transcript = company.get_transcript(event) # Fetch the earnings call transcript for this event
53
+ print(f"* Q{event.quarter} {event.year}")
54
+ if transcript:
55
+ print(f" Transcript Text: \"{transcript.text[:100]}...\"")
56
+ else:
57
+ print(f" No transcript found.")
58
+
59
+ ```
60
+
61
+ Output
62
+
63
+ ```text
64
+ Getting all transcripts for: Apple Inc...
65
+ * Q4 2023
66
+ Transcript Text: "Good day and welcome to the Apple Q4 Fiscal Year 2023 earnings conference call. Today's call is bein..."
67
+ * Q3 2023
68
+ Transcript Text: "Good day and welcome to the Apple Q3 Fiscal Year 2023 earnings conference call. Today's call is bein..."
69
+ * Q2 2023
70
+ Transcript Text: "At this time for opening remarks and introductions, I would like to turn the call over to Suhasini T..."
71
+ * Q1 2023
72
+
73
+ ...
74
+ ```
75
+
76
+
77
+
78
+ ## List All Companies
79
+
80
+ ```python
81
+ from earningscall import get_all_companies
82
+
83
+ for company in get_all_companies():
84
+ print(f"{company.company_info} -- {company.company_info.sector} -- {company.company_info.industry}")
85
+ ```
@@ -0,0 +1,5 @@
1
+ # A list of things left to do for this project
2
+
3
+ * Allow user to set API Key
4
+ * If user is using "demo" API key, and user tries to get non-demo symbol, throw a nice error message
5
+
@@ -0,0 +1,2 @@
1
+ from earningscall.symbols import Symbols, load_symbols
2
+ from earningscall.exports import get_company, get_all_companies
@@ -0,0 +1,67 @@
1
+ import logging
2
+ import os
3
+ from typing import Optional
4
+
5
+ import requests
6
+
7
+
8
+ log = logging.getLogger(__file__)
9
+
10
+ DOMAIN = os.environ.get("ECALL_DOMAIN", "earningscall.biz")
11
+ API_BASE = f"https://v2.api.{DOMAIN}"
12
+ api_key: Optional[str] = None
13
+
14
+
15
+ def get_api_key():
16
+ global api_key
17
+ if api_key is None:
18
+ return os.environ.get("ECALL_API_KEY", "demo")
19
+ return api_key
20
+
21
+
22
+ def get_events(exchange: str,
23
+ symbol: str):
24
+
25
+ log.debug(f"get_events exchange: {exchange} symbol: {symbol}")
26
+ params = {
27
+ "apikey": get_api_key(),
28
+ "exchange": exchange,
29
+ "symbol": symbol,
30
+ }
31
+ response = requests.get(f"{API_BASE}/events", params=params)
32
+ if response.status_code != 200:
33
+ return None
34
+ return response.json()
35
+
36
+
37
+ def get_transcript(exchange: str,
38
+ symbol: str,
39
+ year: int,
40
+ quarter: int) -> Optional[str]:
41
+
42
+ log.debug(f"get_transcript year: {year} quarter: {quarter}")
43
+ params = {
44
+ "apikey": "demo",
45
+ "exchange": exchange,
46
+ "symbol": symbol,
47
+ "year": str(year),
48
+ "quarter": str(quarter),
49
+ }
50
+ response = requests.get(f"{API_BASE}/transcript", params=params)
51
+ if response.status_code != 200:
52
+ return None
53
+ return response.json()
54
+
55
+
56
+ def get_symbols_v1():
57
+ response = requests.get(f"{API_BASE}/symbols.txt")
58
+ if response.status_code != 200:
59
+ return None
60
+ return response.text
61
+
62
+
63
+ def get_symbols_v2():
64
+ response = requests.get(f"{API_BASE}/symbols-v2.txt")
65
+ if response.status_code != 200:
66
+ return None
67
+ return response.text
@@ -0,0 +1,51 @@
1
+ import logging
2
+ from typing import Optional
3
+
4
+ from earningscall import api
5
+ from earningscall.event import EarningsEvent
6
+ from earningscall.symbols import CompanyInfo
7
+ from earningscall.transcript import Transcript
8
+
9
+ log = logging.getLogger(__file__)
10
+
11
+
12
+ class Company:
13
+
14
+ company_info: CompanyInfo
15
+ name: str
16
+ _events: [EarningsEvent]
17
+
18
+ def __init__(self, company_info):
19
+ self.company_info = company_info
20
+ self.name = company_info.name
21
+ self._events = None
22
+
23
+ def __str__(self):
24
+ return str(self.name)
25
+
26
+ def name(self) -> str:
27
+ return self.company_info.name
28
+
29
+ def _get_events(self):
30
+ raw_response = api.get_events(self.company_info.exchange, self.company_info.symbol)
31
+ return [EarningsEvent.from_dict(event) for event in raw_response["events"]]
32
+
33
+ def events(self) -> [EarningsEvent]:
34
+ if not self._events:
35
+ self._events = self._get_events()
36
+ return self._events
37
+
38
+ def get_transcript(self,
39
+ year: Optional[int] = None,
40
+ quarter: Optional[int] = None,
41
+ event: Optional[EarningsEvent] = None) -> Optional[Transcript]:
42
+
43
+ if (not year or not quarter) and event:
44
+ year = event.year
45
+ quarter = event.quarter
46
+ elif (not year or not quarter) and not event:
47
+ raise ValueError("Must specify either event or year and quarter")
48
+ resp = api.get_transcript(self.company_info.exchange, self.company_info.symbol, year, quarter)
49
+ if not resp:
50
+ return None
51
+ return Transcript.from_dict(resp)
@@ -0,0 +1,25 @@
1
+
2
+
3
+ class BaseError(RuntimeError):
4
+ """
5
+ Base error
6
+ """
7
+
8
+ def __init__(self, msg=None):
9
+ self.msg = msg
10
+
11
+ def __str__(self):
12
+ if self.msg:
13
+ return str(self.msg)
14
+ return ""
15
+
16
+
17
+ class ClientError(BaseError):
18
+ """
19
+ Used to return 4XX errors.
20
+ """
21
+ status: int = 400 # https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400
22
+
23
+
24
+ class MissingApiKeyError(ClientError):
25
+ pass
@@ -0,0 +1,28 @@
1
+ import logging
2
+ from dataclasses import dataclass, field
3
+ from datetime import datetime
4
+ from typing import Optional
5
+
6
+ from dataclasses_json import config
7
+ from dataclasses_json import dataclass_json
8
+ from marshmallow import fields
9
+
10
+ log = logging.getLogger(__file__)
11
+
12
+
13
+ @dataclass_json
14
+ @dataclass
15
+ class EarningsEvent:
16
+ """
17
+ EarningsEvent
18
+ """
19
+ year: int
20
+ quarter: int
21
+ conference_date: Optional[datetime] = field(
22
+ default=None,
23
+ metadata=config(
24
+ encoder=lambda date: date.isoformat() if date else None,
25
+ decoder=lambda date: datetime.fromisoformat(date) if date else None,
26
+ mm_field=fields.DateTime(format="iso")
27
+ )
28
+ )
@@ -0,0 +1,17 @@
1
+ from earningscall.symbols import get_symbols
2
+
3
+ from earningscall.company import Company
4
+
5
+
6
+ def get_company(symbol: str) -> Company:
7
+ return Company(company_info=get_symbols().lookup_company(symbol))
8
+
9
+
10
+ def get_all_companies() -> [Company]:
11
+ for company_info in get_symbols().get_all():
12
+ yield Company(company_info=company_info)
13
+
14
+
15
+ def get_sp500_companies() -> [Company]:
16
+ for company_info in get_symbols().get_all():
17
+ yield Company(company_info=company_info)