Skip to content

Commit

Permalink
Properly support earningscall.api_key.
Browse files Browse the repository at this point in the history
Additionally, add event structure to Transcript object.
  • Loading branch information
EarningsCall committed May 28, 2024
1 parent 1225d89 commit 243e1ca
Show file tree
Hide file tree
Showing 8 changed files with 773 additions and 6 deletions.
12 changes: 12 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,15 @@ def test_save_symbols_v1():
def test_save_symbols_v1():
requests.get("https://earningscall.biz/symbols-v2.txt")
```



### Publishing a new Version to PyPI

Make your changes

```sh
git commit -a
git tag v0.0.6

```
4 changes: 4 additions & 0 deletions earningscall/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
from typing import Optional

from earningscall.symbols import Symbols, load_symbols
from earningscall.exports import get_company, get_all_companies

api_key: Optional[str] = None
6 changes: 3 additions & 3 deletions earningscall/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
import os
from typing import Optional

import earningscall
import requests


log = logging.getLogger(__file__)

DOMAIN = os.environ.get("ECALL_DOMAIN", "earningscall.biz")
API_BASE = f"https://v2.api.{DOMAIN}"
api_key: Optional[str] = None


def get_api_key():
global api_key
if api_key is None:
api_key = earningscall.api_key
if not api_key:
return os.environ.get("ECALL_API_KEY", "demo")
return api_key

Expand Down
1 change: 1 addition & 0 deletions earningscall/exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ def get_all_companies() -> [Company]:


def get_sp500_companies() -> [Company]:
## TODO: Actually only return SP500 companies.
for company_info in get_symbols().get_all():
yield Company(company_info=company_info)
6 changes: 4 additions & 2 deletions earningscall/transcript.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import logging
from dataclasses import dataclass
from typing import Optional

from dataclasses import dataclass, field
from dataclasses_json import dataclass_json
from earningscall.event import EarningsEvent

log = logging.getLogger(__file__)

Expand All @@ -11,4 +13,4 @@
class Transcript:

text: str

event: Optional[EarningsEvent] = field(default=None)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "earningscall"
version = "0.0.6"
version = "0.0.7"
description = "The EarningsCall Python library."
readme = "README.md"
authors = [
Expand Down
719 changes: 719 additions & 0 deletions tests/data/demo-symbols-v2-alpha.yaml

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions tests/test_get_transcript.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ def test_get_demo_company():
'Conference Call. At ')


@responses.activate
def test_get_demo_company_with_event_populated():
##
clear_symbols()
responses._add_from_file(file_path=data_path("symbols-v2.yaml"))
responses._add_from_file(file_path=data_path("demo-symbols-v2-alpha.yaml"))
##
company = get_company("aapl")
##
transcript = company.get_transcript(year=2022, quarter=1)
assert transcript.event.year == 2022
assert transcript.event.quarter == 1
assert transcript.event.conference_date.isoformat() == "2022-01-19T00:00:00-08:00"
assert transcript.text[:100] == ("Good day and welcome to the Apple Q1 Fiscal Year 2021 earnings conference "
"call. Today's call is bein")


# Uncomment and run following code to generate demo-symbols-v2.yaml file
#
# import requests
Expand All @@ -40,6 +57,18 @@ def test_get_demo_company():
# def test_save_symbols_v1():
# requests.get("https://v2.api.earningscall.biz/symbols-v2.txt?apikey=demo")

# Uncomment and run following code to generate demo-symbols-v2.yaml file
#
# import requests
#
# from responses import _recorder
#
#
# @_recorder.record(file_path="demo-symbols-v2-alpha.yaml")
# def test_save_symbols_v1():
# requests.get("https://v2.api.alpha.earningscall.biz/transcript?apikey=demo&exchange=NASDAQ&symbol=AAPL&year=2022&quarter=q1")
#


@responses.activate
def test_get_non_demo_company():
Expand Down

0 comments on commit 243e1ca

Please sign in to comment.