Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue in earnings transcript not allowing FY 2025 to be retrieved #6500

Merged
merged 25 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e84379c
remove ultima + althub
jmaslek Feb 27, 2024
8b68f23
move twitter keys
jmaslek Feb 27, 2024
6a8a1ea
Merge branch 'develop' of https://github.com/OpenBB-finance/OpenBBTer…
jmaslek Feb 29, 2024
21cc561
Merge branch 'develop' of https://github.com/OpenBB-finance/OpenBBTer…
jmaslek Mar 11, 2024
9f9cba3
Merge branch 'develop' of https://github.com/OpenBB-finance/OpenBBTer…
jmaslek Mar 12, 2024
2914c7e
Merge branch 'develop' of https://github.com/OpenBB-finance/OpenBBTer…
jmaslek Mar 13, 2024
61400fc
Merge branch 'develop' of https://github.com/OpenBB-finance/OpenBBTer…
jmaslek Mar 14, 2024
19c6371
Merge branch 'develop' of https://github.com/OpenBB-finance/OpenBBTer…
jmaslek Mar 14, 2024
8651771
Merge branch 'develop' of https://github.com/OpenBB-finance/OpenBBTer…
jmaslek Mar 14, 2024
5d6344c
Merge branch 'develop' of https://github.com/OpenBB-finance/OpenBBTer…
jmaslek Mar 14, 2024
853e3fe
Merge branch 'develop' of https://github.com/OpenBB-finance/OpenBBTer…
jmaslek Mar 15, 2024
25536e3
Merge branch 'develop' of https://github.com/OpenBB-finance/OpenBBTer…
jmaslek May 2, 2024
fea3821
Merge branch 'develop' of https://github.com/OpenBB-finance/OpenBBTer…
jmaslek May 9, 2024
9d4e054
Merge branch 'develop' of https://github.com/OpenBB-finance/OpenBBTer…
jmaslek May 14, 2024
926d344
Merge branch 'develop' of https://github.com/OpenBB-finance/OpenBBTer…
jmaslek May 18, 2024
92f3da4
Merge branch 'develop' of https://github.com/OpenBB-finance/OpenBBTer…
jmaslek May 31, 2024
ffdf8a6
Merge branch 'develop' of https://github.com/OpenBB-finance/OpenBBTer…
jmaslek Jun 3, 2024
21ba826
Merge branch 'develop' of https://github.com/OpenBB-finance/OpenBBTer…
jmaslek Jun 3, 2024
a8b8a14
Merge branch 'develop' of https://github.com/OpenBB-finance/OpenBBTer…
jmaslek Jun 11, 2024
13b870e
Merge branch 'develop' of https://github.com/OpenBB-finance/OpenBBTer…
jmaslek Jun 12, 2024
61576f4
Merge branch 'develop' of https://github.com/OpenBB-finance/OpenBBTer…
jmaslek Jun 13, 2024
e2b8345
Add one to date validator to allow FY diff.
jmaslek Jun 13, 2024
4481bc4
Typo in spelling
jmaslek Jun 13, 2024
0ff2e53
multiple items allowed
deeleeramone Jun 14, 2024
f1ced4f
static assets
deeleeramone Jun 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class EarningsCallTranscriptQueryParams(QueryParams):
"""Earnings Call Transcript rating Query."""

symbol: str = Field(description=QUERY_DESCRIPTIONS.get("symbol", ""))
year: int = Field(description="Year of the earnings call transcript.")
year: Union[int, str] = Field(description="Year of the earnings call transcript.")

@field_validator("symbol", mode="before", check_fields=False)
@classmethod
Expand Down
10 changes: 5 additions & 5 deletions openbb_platform/openbb/assets/reference.json
Original file line number Diff line number Diff line change
Expand Up @@ -21196,21 +21196,21 @@
"message": null
},
"description": "Get earnings call transcripts for a given company.",
"examples": "\nExamples\n--------\n\n```python\nfrom openbb import obb\nobb.equity.fundamental.transcript(symbol='AAPL', year=2020, provider='fmp')\n```\n\n",
"examples": "\nExamples\n--------\n\n```python\nfrom openbb import obb\nobb.equity.fundamental.transcript(symbol='AAPL', year='2020', provider='fmp')\n```\n\n",
"parameters": {
"standard": [
{
"name": "symbol",
"type": "str",
"description": "Symbol to get data for.",
"type": "Union[str, List[str]]",
"description": "Symbol to get data for. Multiple items allowed for provider(s): fmp.",
"default": "",
"optional": false,
"choices": null
},
{
"name": "year",
"type": "int",
"description": "Year of the earnings call transcript.",
"type": "Union[Union[int, str], List[Union[int, str]]]",
"description": "Year of the earnings call transcript. Multiple items allowed for provider(s): fmp.",
"default": "",
"optional": false,
"choices": null
Expand Down
26 changes: 19 additions & 7 deletions openbb_platform/openbb/package/equity_fundamental.py
Original file line number Diff line number Diff line change
Expand Up @@ -3636,9 +3636,17 @@ def trailing_dividend_yield(
@validate
def transcript(
self,
symbol: Annotated[str, OpenBBField(description="Symbol to get data for.")],
symbol: Annotated[
Union[str, List[str]],
OpenBBField(
description="Symbol to get data for. Multiple comma separated items allowed for provider(s): fmp."
),
],
year: Annotated[
int, OpenBBField(description="Year of the earnings call transcript.")
Union[int, str, List[Union[int, str]]],
OpenBBField(
description="Year of the earnings call transcript. Multiple comma separated items allowed for provider(s): fmp."
),
],
provider: Annotated[
Optional[Literal["fmp"]],
Expand All @@ -3652,10 +3660,10 @@ def transcript(
Parameters
----------
symbol : str
Symbol to get data for.
year : int
Year of the earnings call transcript.
symbol : Union[str, List[str]]
Symbol to get data for. Multiple comma separated items allowed for provider(s): fmp.
year : Union[int, str, List[Union[int, str]]]
Year of the earnings call transcript. Multiple comma separated items allowed for provider(s): fmp.
provider : Optional[Literal['fmp']]
The provider to use, by default None. If None, the priority list configured in the settings is used. Default priority: fmp.
Expand Down Expand Up @@ -3689,7 +3697,7 @@ def transcript(
Examples
--------
>>> from openbb import obb
>>> obb.equity.fundamental.transcript(symbol='AAPL', year=2020, provider='fmp')
>>> obb.equity.fundamental.transcript(symbol='AAPL', year='2020', provider='fmp')
""" # noqa: E501

return self._run(
Expand All @@ -3707,5 +3715,9 @@ def transcript(
"year": year,
},
extra_params=kwargs,
info={
"symbol": {"fmp": {"multiple_items_allowed": True}},
"year": {"fmp": {"multiple_items_allowed": True}},
},
)
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""FMP Earnings Call Transcript Model."""

# pylint: disable=unused-argument

from datetime import datetime
from typing import Any, Dict, List, Optional

Expand All @@ -8,7 +10,7 @@
EarningsCallTranscriptData,
EarningsCallTranscriptQueryParams,
)
from openbb_fmp.utils.helpers import create_url, get_data_many
from openbb_core.provider.utils.helpers import amake_requests
from pydantic import field_validator


Expand All @@ -18,20 +20,18 @@ class FMPEarningsCallTranscriptQueryParams(EarningsCallTranscriptQueryParams):
Source: https://site.financialmodelingprep.com/developer/docs/earning-call-transcript-api/
"""

@field_validator("year", mode="before", check_fields=False)
@classmethod
def time_validate(cls, v: int): # pylint: disable=E0213
"""Return the year as an integer."""
current_year = datetime.now().year
return current_year if v > current_year or v < 1950 else v
__json_schema_extra__ = {
"symbol": {"multiple_items_allowed": True},
"year": {"multiple_items_allowed": True},
}


class FMPEarningsCallTranscriptData(EarningsCallTranscriptData):
"""FMP Earnings Call Transcript Data."""

@field_validator("date", mode="before", check_fields=False)
@classmethod
def date_validate(cls, v: str): # pylint: disable=E0213
def date_validate(cls, v):
"""Return the date as a datetime object."""
return datetime.strptime(v, "%Y-%m-%d %H:%M:%S")

Expand All @@ -42,7 +42,7 @@ class FMPEarningsCallTranscriptFetcher(
List[FMPEarningsCallTranscriptData],
]
):
"""Transform the query, extract and transform the data from the FMP endpoints."""
"""FMP Earnings Call Transcript Fetcher."""

@staticmethod
def transform_query(params: Dict[str, Any]) -> FMPEarningsCallTranscriptQueryParams:
Expand All @@ -57,16 +57,23 @@ async def aextract_data(
) -> List[Dict]:
"""Return the raw data from the FMP endpoint."""
api_key = credentials.get("fmp_api_key") if credentials else ""

url = create_url(
4,
f"batch_earning_call_transcript/{query.symbol}",
api_key,
query,
["symbol"],
)

return await get_data_many(url, **kwargs)
symbols = query.symbol.split(",")
years = query.year.split(",") if isinstance(query.year, str) else [query.year]

def generate_url(symbol, year):
"""Generate the URL."""
url = (
f"https://financialmodelingprep.com/api/v4/batch_earning_call_transcript/{symbol}?"
+ f"year={year}&apikey={api_key}"
)
return url

urls: List = []
for symbol in symbols:
for year in years:
urls.append(generate_url(symbol, year))

return await amake_requests(urls, **kwargs) # type: ignore

@staticmethod
def transform_data(
Expand Down
Loading