mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-03 16:02:04 +00:00
fix stock_news data
This commit is contained in:
@@ -7,9 +7,10 @@ from typing import Dict, List, Literal, Optional
|
||||
from openbb_provider.abstract.fetcher import Fetcher
|
||||
from openbb_provider.helpers import data_transformer, get_querystring
|
||||
from openbb_provider.models.global_news import GlobalNewsData, GlobalNewsQueryParams
|
||||
from pydantic import Field
|
||||
from openbb_provider.models.stock_news import StockNewsData
|
||||
from pydantic import Field, validator
|
||||
|
||||
from openbb_benzinga.utils.helpers import BenzingaBaseNewsData, get_data
|
||||
from openbb_benzinga.utils.helpers import BenzingaImage, get_data
|
||||
|
||||
|
||||
class BenzingaGlobalNewsQueryParams(GlobalNewsQueryParams):
|
||||
@@ -79,8 +80,17 @@ class BenzingaGlobalNewsQueryParams(GlobalNewsQueryParams):
|
||||
)
|
||||
|
||||
|
||||
class BenzingaGlobalNewsData(BenzingaBaseNewsData):
|
||||
url: str
|
||||
class BenzingaGlobalNewsData(StockNewsData):
|
||||
"""Benzinga Global News data."""
|
||||
|
||||
class Config:
|
||||
fields = {"date": "created", "text": "body"}
|
||||
|
||||
image: List[BenzingaImage] = Field(description="The images associated with the news.")
|
||||
|
||||
@validator("date", pre=True)
|
||||
def time_validate(cls, v): # pylint: disable=E0213
|
||||
return datetime.strptime(v, "%a, %d %b %Y %H:%M:%S %z")
|
||||
|
||||
|
||||
class BenzingaGlobalNewsFetcher(
|
||||
@@ -107,7 +117,7 @@ class BenzingaGlobalNewsFetcher(
|
||||
api_key = credentials.get("benzinga_api_key")
|
||||
|
||||
base_url = "https://api.benzinga.com/api/v2/news"
|
||||
querystring = get_querystring(query.dict(), [])
|
||||
querystring = get_querystring(query.dict(by_alias=True), [])
|
||||
request_url = f"{base_url}?{querystring}&token={api_key}"
|
||||
data = get_data(request_url)
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ from typing import Dict, List, Literal, Optional
|
||||
from openbb_provider.abstract.fetcher import Fetcher
|
||||
from openbb_provider.helpers import data_transformer, get_querystring
|
||||
from openbb_provider.models.stock_news import StockNewsData, StockNewsQueryParams
|
||||
from pydantic import Field
|
||||
from pydantic import Field, validator
|
||||
|
||||
from openbb_benzinga.utils.helpers import BenzingaBaseNewsData, get_data
|
||||
from openbb_benzinga.utils.helpers import BenzingaImage, get_data
|
||||
|
||||
|
||||
class BenzingaStockNewsQueryParams(StockNewsQueryParams):
|
||||
@@ -76,9 +76,20 @@ class BenzingaStockNewsQueryParams(StockNewsQueryParams):
|
||||
)
|
||||
|
||||
|
||||
class BenzingaStockNewsData(BenzingaBaseNewsData):
|
||||
class BenzingaStockNewsData(StockNewsData):
|
||||
"""Benzinga Stock News data."""
|
||||
|
||||
class Config:
|
||||
fields = {"date": "created", "text": "body"}
|
||||
|
||||
image: List[BenzingaImage] = Field(
|
||||
description="The images associated with the news."
|
||||
)
|
||||
|
||||
@validator("date", pre=True)
|
||||
def time_validate(cls, v): # pylint: disable=E0213
|
||||
return datetime.strptime(v, "%a, %d %b %Y %H:%M:%S %z")
|
||||
|
||||
|
||||
class BenzingaStockNewsFetcher(
|
||||
Fetcher[
|
||||
|
||||
@@ -25,26 +25,71 @@ class PolygonFundamentalQueryParams(QueryParams):
|
||||
Source: https://polygon.io/docs/stocks#!/get_vx_reference_financials
|
||||
"""
|
||||
|
||||
ticker: Optional[str] = Field(alias="symbol", description="The symbol of the company if no CIK is provided.")
|
||||
cik: Optional[str] = Field(description="The CIK of the company if no symbol is provided.")
|
||||
ticker: Optional[str] = Field(
|
||||
alias="symbol", description="The symbol of the company if no CIK is provided."
|
||||
)
|
||||
cik: Optional[str] = Field(
|
||||
description="The CIK of the company if no symbol is provided."
|
||||
)
|
||||
company_name: Optional[str] = Field(description="The name of the company.")
|
||||
company_name_search: Optional[str] = Field(alias="company_name.search", description="The name of the company to search.")
|
||||
sic: Optional[str] = Field(description="The Standard Industrial Classification (SIC) of the company.")
|
||||
filing_date: Optional[date] = Field(description="The filing date of the financial statement.")
|
||||
filing_date_lt: Optional[date] = Field(alias="filing_date.lt", description="The filing date less than the given date.")
|
||||
filing_date_lte: Optional[date] = Field(alias="filing_date.lte", description="The filing date less than or equal to the given date.")
|
||||
filing_date_gt: Optional[date] = Field(alias="filing_date.gt", description="The filing date greater than the given date.")
|
||||
filing_date_gte: Optional[date] = Field(alias="filing_date.gte", description="The filing date greater than or equal to the given date.")
|
||||
period_of_report_date: Optional[date] = Field(description="The period of report date of the financial statement.")
|
||||
period_of_report_date_lt: Optional[date] = Field(alias="period_of_report_date.lt", description="The period of report date less than the given date.")
|
||||
period_of_report_date_lte: Optional[date] = Field(alias="period_of_report_date.lte", description="The period of report date less than or equal to the given date.")
|
||||
period_of_report_date_gt: Optional[date] = Field(alias="period_of_report_date.gt", description="The period of report date greater than the given date.")
|
||||
period_of_report_date_gte: Optional[date] = Field(alias="period_of_report_date.gte", description="The period of report date greater than or equal to the given date.")
|
||||
timeframe: Optional[Literal["annual", "quarterly", "ttm"]] = Field(alias="period", description="The timeframe of the financial statement.")
|
||||
include_sources: Optional[bool] = Field(description="Whether to include the sources of the financial statement.")
|
||||
order: Optional[Literal["asc", "desc"]] = Field(description="The order of the financial statement.")
|
||||
limit: Optional[PositiveInt] = 100 = Field(description="The limit of the financial statement.")
|
||||
sort: Optional[Literal["filing_date", "period_of_report_date"]] = Field(description="The sort of the financial statement.")
|
||||
company_name_search: Optional[str] = Field(
|
||||
alias="company_name.search", description="The name of the company to search."
|
||||
)
|
||||
sic: Optional[str] = Field(
|
||||
description="The Standard Industrial Classification (SIC) of the company."
|
||||
)
|
||||
filing_date: Optional[date] = Field(
|
||||
description="The filing date of the financial statement."
|
||||
)
|
||||
filing_date_lt: Optional[date] = Field(
|
||||
alias="filing_date.lt", description="The filing date less than the given date."
|
||||
)
|
||||
filing_date_lte: Optional[date] = Field(
|
||||
alias="filing_date.lte",
|
||||
description="The filing date less than or equal to the given date.",
|
||||
)
|
||||
filing_date_gt: Optional[date] = Field(
|
||||
alias="filing_date.gt",
|
||||
description="The filing date greater than the given date.",
|
||||
)
|
||||
filing_date_gte: Optional[date] = Field(
|
||||
alias="filing_date.gte",
|
||||
description="The filing date greater than or equal to the given date.",
|
||||
)
|
||||
period_of_report_date: Optional[date] = Field(
|
||||
description="The period of report date of the financial statement."
|
||||
)
|
||||
period_of_report_date_lt: Optional[date] = Field(
|
||||
alias="period_of_report_date.lt",
|
||||
description="The period of report date less than the given date.",
|
||||
)
|
||||
period_of_report_date_lte: Optional[date] = Field(
|
||||
alias="period_of_report_date.lte",
|
||||
description="The period of report date less than or equal to the given date.",
|
||||
)
|
||||
period_of_report_date_gt: Optional[date] = Field(
|
||||
alias="period_of_report_date.gt",
|
||||
description="The period of report date greater than the given date.",
|
||||
)
|
||||
period_of_report_date_gte: Optional[date] = Field(
|
||||
alias="period_of_report_date.gte",
|
||||
description="The period of report date greater than or equal to the given date.",
|
||||
)
|
||||
timeframe: Optional[Literal["annual", "quarterly", "ttm"]] = Field(
|
||||
alias="period", description="The timeframe of the financial statement."
|
||||
)
|
||||
include_sources: Optional[bool] = Field(
|
||||
description="Whether to include the sources of the financial statement."
|
||||
)
|
||||
order: Optional[Literal["asc", "desc"]] = Field(
|
||||
description="The order of the financial statement."
|
||||
)
|
||||
limit: Optional[PositiveInt] = Field(
|
||||
default=100, description="The limit of the financial statement."
|
||||
)
|
||||
sort: Optional[Literal["filing_date", "period_of_report_date"]] = Field(
|
||||
description="The sort of the financial statement."
|
||||
)
|
||||
|
||||
|
||||
class BaseStockQueryParams(QueryParams):
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
### THIS FILE IS AUTO-GENERATED. DO NOT EDIT. ###
|
||||
|
||||
|
||||
|
||||
from openbb_core.app.static.container import Container
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Stock News Data Model."""
|
||||
|
||||
|
||||
from datetime import date
|
||||
from datetime import date as dateType
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import Field, NonNegativeInt, validator
|
||||
@@ -29,24 +29,9 @@ class StockNewsQueryParams(QueryParams):
|
||||
|
||||
|
||||
class StockNewsData(Data):
|
||||
"""Stock News data.
|
||||
"""Stock News data."""
|
||||
|
||||
Returns
|
||||
-------
|
||||
date : date
|
||||
The published date of the news.
|
||||
title : str
|
||||
The title of the news.
|
||||
image : Optional[str]
|
||||
The image URL of the news.
|
||||
text : str
|
||||
The text/body of the news.
|
||||
url : str
|
||||
The URL of the news.
|
||||
"""
|
||||
|
||||
date: date
|
||||
title: str
|
||||
image: Optional[str]
|
||||
text: Optional[str]
|
||||
url: str
|
||||
date: dateType = Field(description="The published date of the news.")
|
||||
title: str = Field(description="The title of the news.")
|
||||
text: Optional[str] = Field(default=None, description="The text/body of the news.")
|
||||
url: str = Field(description="The URL of the news.")
|
||||
|
||||
Reference in New Issue
Block a user