Skip to content

Commit

Permalink
reformatted for black
Browse files Browse the repository at this point in the history
  • Loading branch information
AdiSai committed Oct 31, 2023
1 parent 645976f commit a9e1a76
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from openbb_provider.utils.helpers import get_querystring
from pydantic import Field, field_validator


class UltimaStockNewsQueryParams(StockNewsQueryParams):
"""Ultima Stock News query.
Expand Down Expand Up @@ -56,7 +57,7 @@ def extract_data(

base_url = "https://api.ultimainsights.ai/v1/getOpenBBProInsights"

querystring = str(query).split('=')[1].split("'")[1].replace(' ', '')
querystring = str(query).split("=")[1].split("'")[1].replace(" ", "")

data = []
url = f"{base_url}/{querystring}"
Expand All @@ -74,13 +75,15 @@ def transform_data(
) -> List[UltimaStockNewsData]:
results = []
for ele in data:
for key in ['8k_filings', 'articles', 'industry_summary']:
for key in ["8k_filings", "articles", "industry_summary"]:
for item in ele[key]:
# manual assignment required for Pydantic to work
item['ticker'] = ele['ticker']
item['date'] = datetime.strptime(item['publishedDate'], '%Y-%m-%d %H:%M:%S')
item['title'] = item['headline']
item['url'] = item['url']
item['publisher'] = item['publisher']
item["ticker"] = ele["ticker"]
item["date"] = datetime.strptime(
item["publishedDate"], "%Y-%m-%d %H:%M:%S"
)
item["title"] = item["headline"]
item["url"] = item["url"]
item["publisher"] = item["publisher"]
results.append(UltimaStockNewsData.model_validate(item))
return results
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ def get_data(url: str, **kwargs: Any) -> Dict:
if "Bearer" not in auth:
auth = f"Bearer {auth}"
result = helpers.make_request(
url, timeout=10, headers={"accept": "application/json", "Authorization": auth}, **kwargs
url,
timeout=10,
headers={"accept": "application/json", "Authorization": auth},
**kwargs,
)
if result.status_code != 200:
data = result.json()
Expand Down
2 changes: 1 addition & 1 deletion openbb_platform/providers/ultima/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "openbb-ultima"
version = "0.1.0a3"
version = "0.1.0a4"
description = "Ultima Insights extension for OpenBB"
authors = ["Ultima Insights Team <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit a9e1a76

Please sign in to comment.