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

Hotfix/ultima improvements (#5553) #4

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion openbb_terminal/common/ultima_newsmonitor_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ def get_top_headlines(ticker: str) -> dict:
): # If data request failed
console.print("[red]Status code not 200. Unable to retrieve data\n[/red]")
return {}
return data.json()
json = data.json()
if "message" in json:
console.print(f"[red]{json['message']}[/red]")
return {}
return json
console.print("[red]Ticker not supported. Unable to retrieve data\n[/red]")
return {}
6 changes: 5 additions & 1 deletion openbb_terminal/common/ultima_newsmonitor_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ def display_news(
console.print(row["URL"] + "\n")
console.print("------------------------")

top_headlines = ultima_newsmonitor_model.get_top_headlines(term)["summary"]
top_headlines = ultima_newsmonitor_model.get_top_headlines(term)
if "summary" in top_headlines:
top_headlines = top_headlines["summary"]
else:
return
if "Ultima Insights was unable to identify" in top_headlines:
console.print(
f"[red]Most Relevant Articles for {term} - {dt.datetime.now().strftime('%Y-%m-%d')}\n{top_headlines}[/red]"
Expand Down
Loading