summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormontezdesousa <79287829+montezdesousa@users.noreply.github.com>2024-02-12 10:46:13 +0000
committerGitHub <noreply@github.com>2024-02-12 10:46:13 +0000
commit39888269b3ef39642cea051620740f3e16d50b12 (patch)
treeffe70703e860b350b85060c5b1bdbafcf9d9eb68
parent6881314b6980f728ed8ebe879f73cde5bb910802 (diff)
[Feature] - Replace symbols in company/news (#6061)
* feat: replace symbols in /news * fix: integration tests * fix: integration tests api * fix: typo * Update test_intrinio_fetchers.py
-rw-r--r--openbb_platform/core/openbb_core/app/assets/parameter_pool.json2
-rw-r--r--openbb_platform/core/openbb_core/provider/standard_models/company_news.py8
-rw-r--r--openbb_platform/extensions/news/integration/test_news_api.py14
-rw-r--r--openbb_platform/extensions/news/integration/test_news_python.py12
-rw-r--r--openbb_platform/extensions/news/openbb_news/news_router.py8
-rw-r--r--openbb_platform/openbb/package/news.py20
-rw-r--r--openbb_platform/providers/benzinga/openbb_benzinga/models/company_news.py2
-rw-r--r--openbb_platform/providers/benzinga/tests/test_benzinga_fetchers.py2
-rw-r--r--openbb_platform/providers/fmp/openbb_fmp/models/company_news.py4
-rw-r--r--openbb_platform/providers/fmp/tests/test_fmp_fetchers.py2
-rw-r--r--openbb_platform/providers/intrinio/openbb_intrinio/models/company_news.py8
-rw-r--r--openbb_platform/providers/intrinio/tests/test_intrinio_fetchers.py2
-rw-r--r--openbb_platform/providers/polygon/openbb_polygon/models/company_news.py2
-rw-r--r--openbb_platform/providers/polygon/tests/test_polygon_fetchers.py2
-rw-r--r--openbb_platform/providers/tiingo/openbb_tiingo/models/company_news.py2
-rw-r--r--openbb_platform/providers/tiingo/tests/test_tiingo_fetchers.py2
-rw-r--r--openbb_platform/providers/yfinance/openbb_yfinance/models/company_news.py2
-rw-r--r--openbb_platform/providers/yfinance/tests/test_yfinance_fetchers.py2
-rw-r--r--website/generate_excel_markdown.py1
19 files changed, 47 insertions, 50 deletions
diff --git a/openbb_platform/core/openbb_core/app/assets/parameter_pool.json b/openbb_platform/core/openbb_core/app/assets/parameter_pool.json
index ae6beee70e9..a2d1f88c640 100644
--- a/openbb_platform/core/openbb_core/app/assets/parameter_pool.json
+++ b/openbb_platform/core/openbb_core/app/assets/parameter_pool.json
@@ -41,7 +41,7 @@
"index": "^IBEX"
},
"news": {
- "symbols": "AAPL,MSFT"
+ "symbol": "AAPL"
},
"regulators": {
"symbol": "AAPL",
diff --git a/openbb_platform/core/openbb_core/provider/standard_models/company_news.py b/openbb_platform/core/openbb_core/provider/standard_models/company_news.py
index 50cb0066a20..60bfaf8890d 100644
--- a/openbb_platform/core/openbb_core/provider/standard_models/company_news.py
+++ b/openbb_platform/core/openbb_core/provider/standard_models/company_news.py
@@ -20,10 +20,10 @@ from openbb_core.provider.utils.descriptions import (
class CompanyNewsQueryParams(QueryParams):
"""Company news Query."""
- symbols: str = Field(
+ symbol: str = Field(
min_length=1,
- description=QUERY_DESCRIPTIONS.get("symbols", "")
- + " Here it is a separated list of symbols.",
+ description=QUERY_DESCRIPTIONS.get("symbol", "")
+ + " This endpoint will accept multiple symbols separated by commas.",
)
limit: Optional[NonNegativeInt] = Field(
default=20, description=QUERY_DESCRIPTIONS.get("limit", "")
@@ -35,7 +35,7 @@ class CompanyNewsQueryParams(QueryParams):
default=None, description=QUERY_DESCRIPTIONS.get("end_date", "")
)
- @field_validator("symbols", mode="before")
+ @field_validator("symbol", mode="before")
@classmethod
def symbols_validate(cls, v: str) -> str: # pylint: disable=E0213
"""Validate the symbols."""
diff --git a/openbb_platform/extensions/news/integration/test_news_api.py b/openbb_platform/extensions/news/integration/test_news_api.py
index 67d476e8207..abb497ae09d 100644
--- a/openbb_platform/extensions/news/integration/test_news_api.py
+++ b/openbb_platform/extensions/news/integration/test_news_api.py
@@ -96,7 +96,7 @@ def test_news_world(params, headers):
[
(
{
- "symbols": "AAPL",
+ "symbol": "AAPL",
"limit": 20,
"provider": "benzinga",
"date": "2023-01-01",
@@ -121,7 +121,7 @@ def test_news_world(params, headers):
"authors": "Benzinga Insights",
"content_types": "headline",
"provider": "benzinga",
- "symbols": "AAPL,MSFT",
+ "symbol": "AAPL,MSFT",
"limit": 20,
}
),
@@ -130,7 +130,7 @@ def test_news_world(params, headers):
"published_utc": "2023-01-01",
"order": "desc",
"provider": "polygon",
- "symbols": "AAPL",
+ "symbol": "AAPL",
"limit": 20,
"start_date": None,
"end_date": None,
@@ -139,7 +139,7 @@ def test_news_world(params, headers):
(
{
"provider": "fmp",
- "symbols": "AAPL",
+ "symbol": "AAPL",
"limit": 20,
"page": 1,
"start_date": None,
@@ -149,7 +149,7 @@ def test_news_world(params, headers):
(
{
"provider": "yfinance",
- "symbols": "AAPL",
+ "symbol": "AAPL",
"limit": 20,
"start_date": None,
"end_date": None,
@@ -158,7 +158,7 @@ def test_news_world(params, headers):
(
{
"provider": "intrinio",
- "symbols": "AAPL",
+ "symbol": "AAPL",
"limit": 20,
"start_date": None,
"end_date": None,
@@ -167,7 +167,7 @@ def test_news_world(params, headers):
(
{
"provider": "tiingo",
- "symbols": "AAPL,MSFT",
+ "symbol": "AAPL,MSFT",
"limit": 20,
"source": "bloomberg.com",
"start_date": None,
diff --git a/openbb_platform/extensions/news/integration/test_news_python.py b/openbb_platform/extensions/news/integration/test_news_python.py
index 81c26d02dcd..b54745e1d2c 100644
--- a/openbb_platform/extensions/news/integration/test_news_python.py
+++ b/openbb_platform/extensions/news/integration/test_news_python.py
@@ -106,7 +106,7 @@ def test_news_world(params, obb):
"authors": None,
"content_types": "headline",
"provider": "benzinga",
- "symbols": "AAPL,MSFT",
+ "symbol": "AAPL,MSFT",
"limit": 20,
}
),
@@ -115,7 +115,7 @@ def test_news_world(params, obb):
"published_utc": "2024-01-10",
"order": "desc",
"provider": "polygon",
- "symbols": "AAPL",
+ "symbol": "AAPL",
"limit": 20,
"start_date": None,
"end_date": None,
@@ -124,7 +124,7 @@ def test_news_world(params, obb):
(
{
"provider": "fmp",
- "symbols": "AAPL",
+ "symbol": "AAPL",
"limit": 20,
"page": 1,
"start_date": None,
@@ -134,7 +134,7 @@ def test_news_world(params, obb):
(
{
"provider": "yfinance",
- "symbols": "AAPL",
+ "symbol": "AAPL",
"limit": 20,
"start_date": None,
"end_date": None,
@@ -143,7 +143,7 @@ def test_news_world(params, obb):
(
{
"provider": "intrinio",
- "symbols": "AAPL",
+ "symbol": "AAPL",
"limit": 20,
"start_date": None,
"end_date": None,
@@ -152,7 +152,7 @@ def test_news_world(params, obb):
(
{
"provider": "tiingo",
- "symbols": "AAPL,MSFT",
+ "symbol": "AAPL,MSFT",
"limit": 20,
"source": "bloomberg.com",
"start_date": None,
diff --git a/openbb_platform/extensions/news/openbb_news/news_router.py b/openbb_platform/extensions/news/openbb_news/news_router.py
index 906a31f527b..00546ac6602 100644
--- a/openbb_platform/extensions/news/openbb_news/news_router.py
+++ b/openbb_platform/extensions/news/openbb_news/news_router.py
@@ -43,13 +43,13 @@ async def world(
model="CompanyNews",
examples=[
"# Get news on the specified dates.",
- "obb.news.company(symbols='AAPL', start_date='2024-02-01', end_date='2024-02-07')",
+ "obb.news.company(symbol='AAPL', start_date='2024-02-01', end_date='2024-02-07')",
"# Display the headlines of the news.",
- "obb.news.company(symbols='AAPL', display='headline', provider='benzinga')",
+ "obb.news.company(symbol='AAPL', display='headline', provider='benzinga')",
"# Get news for multiple symbols.",
- "obb.news.company(symbols='aapl,tsla')",
+ "obb.news.company(symbol='aapl,tsla')",
"# Get news company's ISIN.",
- "obb.news.company(symbols='NVDA', isin='US0378331005')",
+ "obb.news.company(symbol='NVDA', isin='US0378331005')",
],
)
async def company(
diff --git a/openbb_platform/openbb/package/news.py b/openbb_platform/openbb/package/news.py
index fad232382e2..0fdc29fa225 100644
--- a/openbb_platform/openbb/package/news.py
+++ b/openbb_platform/openbb/package/news.py
@@ -24,10 +24,10 @@ class ROUTER_news(Container):
@validate
def company(
self,
- symbols: Annotated[
+ symbol: Annotated[
str,
OpenBBCustomParameter(
- description=" Here it is a separated list of symbols."
+ description="Symbol to get data for. This endpoint will accept multiple symbols separated by commas."
),
],
limit: Annotated[
@@ -55,8 +55,8 @@ class ROUTER_news(Container):
Parameters
----------
- symbols : str
- Here it is a separated list of symbols.
+ symbol : str
+ Symbol to get data for. This endpoint will accept multiple symbols separated by commas.
limit : Optional[Annotated[int, Ge(ge=0)]]
The number of data entries to return.
start_date : Optional[datetime.date]
@@ -168,15 +168,15 @@ class ROUTER_news(Container):
Example
-------
>>> from openbb import obb
- >>> obb.news.company(symbols="AAPL,MSFT", limit=20)
+ >>> obb.news.company(symbol="AAPL", limit=20)
>>> # Get news on the specified dates.
- >>> obb.news.company(symbols='AAPL', start_date='2024-02-01', end_date='2024-02-07')
+ >>> obb.news.company(symbol='AAPL', start_date='2024-02-01', end_date='2024-02-07')
>>> # Display the headlines of the news.
- >>> obb.news.company(symbols='AAPL', display='headline', provider='benzinga')
+ >>> obb.news.company(symbol='AAPL', display='headline', provider='benzinga')
>>> # Get news for multiple symbols.
- >>> obb.news.company(symbols='aapl,tsla')
+ >>> obb.news.company(symbol='aapl,tsla')
>>> # Get news company's ISIN.
- >>> obb.news.company(symbols='NVDA', isin='US0378331005')
+ >>> obb.news.company(symbol='NVDA', isin='US0378331005')
""" # noqa: E501
return self._run(
@@ -186,7 +186,7 @@ class ROUTER_news(Container):
"provider": provider,
},
standard_params={
- "symbols": symbols,
+ "symbol": symbol,
"limit": limit,
"start_date": start_date,
"end_date": end_date,
diff --git a/openbb_platform/providers/benzinga/openbb_benzinga/models/company_news.py b/openbb_platform/providers/benzinga/openbb_benzinga/models/company_news.py
index c65fc6ca930..a4c9f2db9ba 100644
--- a/openbb_platform/providers/benzinga/openbb_benzinga/models/company_news.py
+++ b/openbb_platform/providers/benzinga/openbb_benzinga/models/company_news.py
@@ -24,7 +24,7 @@ class BenzingaCompanyNewsQueryParams(CompanyNewsQueryParams):
"""
__alias_dict__ = {
- "symbols": "tickers",
+ "symbol": "tickers",
"display": "displayOutput",
"limit": "pageSize",
"start_date": "dateFrom",
diff --git a/openbb_platform/providers/benzinga/tests/test_benzinga_fetchers.py b/openbb_platform/providers/benzinga/tests/test_benzinga_fetchers.py
index fc6593f7451..d7658ed4b94 100644
--- a/openbb_platform/providers/benzinga/tests/test_benzinga_fetchers.py
+++ b/openbb_platform/providers/benzinga/tests/test_benzinga_fetchers.py
@@ -30,7 +30,7 @@ def test_benzinga_world_news_fetcher(credentials=test_credentials):
@pytest.mark.record_http
def test_benzinga_company_news_fetcher(credentials=test_credentials):
- params = {"symbols": "AAPL,MSFT"}
+ params = {"symbol": "AAPL,MSFT"}
fetcher = BenzingaCompanyNewsFetcher()
result = fetcher.test(params, credentials)
diff --git a/openbb_platform/providers/fmp/openbb_fmp/models/company_news.py b/openbb_platform/providers/fmp/openbb_fmp/models/company_news.py
index 11afa2a7323..a3d67d7ef79 100644
--- a/openbb_platform/providers/fmp/openbb_fmp/models/company_news.py
+++ b/openbb_platform/providers/fmp/openbb_fmp/models/company_news.py
@@ -18,7 +18,7 @@ class FMPCompanyNewsQueryParams(CompanyNewsQueryParams):
Source: https://site.financialmodelingprep.com/developer/docs/stock-news-api/
"""
- __alias_dict__ = {"symbols": "tickers"}
+ __alias_dict__ = {"symbol": "tickers"}
page: Optional[int] = Field(
default=0,
description="Page number of the results. Use in combination with limit.",
@@ -63,7 +63,7 @@ class FMPCompanyNewsFetcher(
base_url = "https://financialmodelingprep.com/api/v3/stock_news"
data = []
- url = f"{base_url}?page={query.page}&tickers={query.symbols}&limit={query.limit}&apikey={api_key}"
+ url = f"{base_url}?page={query.page}&tickers={query.symbol}&limit={query.limit}&apikey={api_key}"
response = await get_data_many(url, **kwargs)
if len(response) > 0:
diff --git a/openbb_platform/providers/fmp/tests/test_fmp_fetchers.py b/openbb_platform/providers/fmp/tests/test_fmp_fetchers.py
index e64f2f7c92c..195563e558f 100644
--- a/openbb_platform/providers/fmp/tests/test_fmp_fetchers.py
+++ b/openbb_platform/providers/fmp/tests/test_fmp_fetchers.py
@@ -170,7 +170,7 @@ def test_fmp_equity_historical_fetcher(credentials=test_credentials):
@pytest.mark.record_http
def test_fmp_company_news_fetcher(credentials=test_credentials):
- params = {"symbols": "AAPL,MSFT"}
+ params = {"symbol": "AAPL,MSFT"}
fetcher = FMPCompanyNewsFetcher()
result = fetcher.test(params, credentials)
diff --git a/openbb_platform/providers/intrinio/openbb_intrinio/models/company_news.py b/openbb_platform/providers/intrinio/openbb_intrinio/models/company_news.py
index a44067f0dd5..237b199c7d6 100644
--- a/openbb_platform/providers/intrinio/openbb_intrinio/models/company_news.py
+++ b/openbb_platform/providers/intrinio/openbb_intrinio/models/company_news.py
@@ -23,11 +23,7 @@ class IntrinioCompanyNewsQueryParams(CompanyNewsQueryParams):
Source: https://docs.intrinio.com/documentation/web_api/get_company_news_v2
"""
- __alias_dict__ = {"page": "next_page", "limit": "page_size"}
-
- symbols: str = Field(
- description="A comma separated list of Company identifiers (Ticker, CIK, LEI, Intrinio ID)."
- )
+ __alias_dict__ = {"symbol": "symbols", "page": "next_page", "limit": "page_size"}
class IntrinioCompanyNewsData(CompanyNewsData):
@@ -84,7 +80,7 @@ class IntrinioCompanyNewsFetcher(
urls = [
f"{base_url}/{symbol}/news?{query_str}&api_key={api_key}"
- for symbol in [s.strip() for s in query.symbols.split(",")]
+ for symbol in [s.strip() for s in query.symbol.split(",")]
]
return await amake_requests(urls, callback, **kwargs)
diff --git a/openbb_platform/providers/intrinio/tests/test_intrinio_fetchers.py b/openbb_platform/providers/intrinio/tests/test_intrinio_fetchers.py
index 6afacc629d0..a5cf2c6f0a6 100644
--- a/openbb_platform/providers/intrinio/tests/test_intrinio_fetchers.py
+++ b/openbb_platform/providers/intrinio/tests/test_intrinio_fetchers.py
@@ -88,7 +88,7 @@ def test_intrinio_currency_pairs_fetcher(credentials=test_credentials):
@pytest.mark.record_http
def test_intrinio_company_news_fetcher(credentials=test_credentials):
- params = {"symbols": "AAPL"}
+ params = {"symbol": "AAPL"}
fetcher = IntrinioCompanyNewsFetcher()
result = fetcher.test(params, credentials)
diff --git a/openbb_platform/providers/polygon/openbb_polygon/models/company_news.py b/openbb_platform/providers/polygon/openbb_polygon/models/company_news.py
index 1a0ea7e25ce..2bee7f864d1 100644
--- a/openbb_platform/providers/polygon/openbb_polygon/models/company_news.py
+++ b/openbb_platform/providers/polygon/openbb_polygon/models/company_news.py
@@ -18,7 +18,7 @@ class PolygonCompanyNewsQueryParams(CompanyNewsQueryParams):
Source: https://polygon.io/docs/stocks/get_v2_reference_news
"""
- __alias_dict__ = {"symbols": "ticker"}
+ __alias_dict__ = {"symbol": "ticker"}
published_utc: Optional[str] = Field(
default=None,
diff --git a/openbb_platform/providers/polygon/tests/test_polygon_fetchers.py b/openbb_platform/providers/polygon/tests/test_polygon_fetchers.py
index 8b7926f0713..ebc51911a31 100644
--- a/openbb_platform/providers/polygon/tests/test_polygon_fetchers.py
+++ b/openbb_platform/providers/polygon/tests/test_polygon_fetchers.py
@@ -76,7 +76,7 @@ def test_polygon_index_historical_fetcher(credentials=test_credentials):
@pytest.mark.record_http
def test_polygon_company_news_fetcher(credentials=test_credentials):
- params = {"symbols": "AAPL"}
+ params = {"symbol": "AAPL"}
fetcher = PolygonCompanyNewsFetcher()
result = fetcher.test(params, credentials)
diff --git a/openbb_platform/providers/tiingo/openbb_tiingo/models/company_news.py b/openbb_platform/providers/tiingo/openbb_tiingo/models/company_news.py
index 4b84f1bcf11..59026c6f6ac 100644
--- a/openbb_platform/providers/tiingo/openbb_tiingo/models/company_news.py
+++ b/openbb_platform/providers/tiingo/openbb_tiingo/models/company_news.py
@@ -20,7 +20,7 @@ class TiingoCompanyNewsQueryParams(CompanyNewsQueryParams):
Source: https://www.tiingo.com/documentation/news
"""
- __alias_dict__ = {"symbols": "tickers"}
+ __alias_dict__ = {"symbol": "tickers"}
source: Optional[str] = Field(
default=None, description="A comma-separated list of the domains requested."
diff --git a/openbb_platform/providers/tiingo/tests/test_tiingo_fetchers.py b/openbb_platform/providers/tiingo/tests/test_tiingo_fetchers.py
index 91d2148c9dd..72929120006 100644
--- a/openbb_platform/providers/tiingo/tests/test_tiingo_fetchers.py
+++ b/openbb_platform/providers/tiingo/tests/test_tiingo_fetchers.py
@@ -39,7 +39,7 @@ def test_tiingo_equity_historical_fetcher(credentials=test_credentials):
@pytest.mark.record_http
def test_tiingo_company_news_fetcher(credentials=test_credentials):
- params = {"symbols": "AAPL,MSFT"}
+ params = {"symbol": "AAPL,MSFT"}
fetcher = TiingoCompanyNewsFetcher()
result = fetcher.test(params, credentials)
diff --git a/openbb_platform/providers/yfinance/openbb_yfinance/models/company_news.py b/openbb_platform/providers/yfinance/openbb_yfinance/models/company_news.py
index ababaaad29d..44cff08c678 100644
--- a/openbb_platform/providers/yfinance/openbb_yfinance/models/company_news.py
+++ b/openbb_platform/providers/yfinance/openbb_yfinance/models/company_news.py
@@ -83,7 +83,7 @@ class YFinanceCompanyNewsFetcher(
**kwargs: Any,
) -> List[Dict]:
"""Extract data."""
- data = Ticker(query.symbols).get_news()
+ data = Ticker(query.symbol).get_news()
data = json.loads(json.dumps(data))
return data
diff --git a/openbb_platform/providers/yfinance/tests/test_yfinance_fetchers.py b/openbb_platform/providers/yfinance/tests/test_yfinance_fetchers.py
index 12de72c23de..19bf2b94ccc 100644
--- a/openbb_platform/providers/yfinance/tests/test_yfinance_fetchers.py
+++ b/openbb_platform/providers/yfinance/tests/test_yfinance_fetchers.py
@@ -159,7 +159,7 @@ def test_y_finance_futures_curve_fetcher(credentials=test_credentials):
@pytest.mark.record_http
def test_y_finance_company_news_fetcher(credentials=test_credentials):
- params = {"symbols": "AAPL,MSFT"}
+ params = {"symbol": "AAPL,MSFT"}
fetcher = YFinanceCompanyNewsFetcher()
result = fetcher.test(params, credentials)
diff --git a/website/generate_excel_markdown.py b/website/generate_excel_markdown.py
index ce438e90cc9..b86e5bf230c 100644
--- a/website/generate_excel_markdown.py
+++ b/website/generate_excel_markdown.py
@@ -116,6 +116,7 @@ class CommandLib:
"index": '"sp500"',
},
"news": {
+ "symbol": '"AAPL"',
"symbols": '"AAPL,MSFT"',
"start_date": '"2023-01-01"',
"end_date": '"2023-12-31"',