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

Making the news command pretty with more data #2045

Merged
merged 4 commits into from
Jul 5, 2022
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
22 changes: 14 additions & 8 deletions openbb_terminal/common/newsapi_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

import logging

import pandas as pd

from openbb_terminal.decorators import check_api_key
from openbb_terminal.common import newsapi_model
from openbb_terminal.decorators import log_start_end
from openbb_terminal.rich_config import console
from openbb_terminal.helper_funcs import print_rich_table

logger = logging.getLogger(__name__)

Expand All @@ -16,7 +18,7 @@
def display_news(
term: str,
s_from: str,
num: int = 5,
num: int = 3,
show_newest: bool = True,
sources: str = "",
):
Expand All @@ -39,13 +41,17 @@ def display_news(

if articles:
for idx, article in enumerate(articles):
console.print(
article["publishedAt"].replace("T", " ").replace("Z", ""),
" ",
article["title"],
)
# Unnecessary to use name of the source because contained in link article["source"]["name"]
console.print(article["url"], "\n")
data = [
[article["publishedAt"].replace("T", " ").replace("Z", "")],
[f"{article['description']}"],
[article["url"]],
]

table = pd.DataFrame(
data, index=["published", "content", "link"], columns=["Content"]
)
print_rich_table(table, title=article["title"])

if idx >= num - 1:
break
2 changes: 1 addition & 1 deletion openbb_terminal/stocks/stocks_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def call_news(self, other_args: List[str]):
)
if other_args and "-" not in other_args[0][0]:
other_args.insert(0, "-l")
ns_parser = self.parse_known_args_and_warn(parser, other_args, limit=5)
ns_parser = self.parse_known_args_and_warn(parser, other_args, limit=3)
if ns_parser:
sources = ns_parser.sources
for idx, source in enumerate(sources):
Expand Down
50 changes: 38 additions & 12 deletions website/content/terminal/stocks/news/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,47 @@ optional arguments:

Example:
```
2022 Feb 16, 08:33 (✨) /stocks/ $ news
256 news articles for Amazon.com,+Inc. were found since 2022-02-09
2022 Jul 04, 16:54 (🦋) /stocks/ $ news
543 news articles for Apple+Inc. were found since 2022-06-27

2022-02-16 13:06:33 ViacomCBS renames itself Paramount
https://www.livemint.com/industry/media/viacomcbs-renames-itself-paramount-11645016266083.html

2022-02-16 13:00:34 Low-code development startup Genesis raises $200M round led by Tiger Global
https://siliconangle.com/2022/02/16/low-code-development-startup-genesis-raises-200m-round-led-tiger-global/
Three ways to patch your thinking about open-source software security
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Content │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ 2022-07-04 20:11:03 │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ What comes to mind when you hear “open source?” Is it a community? Better-quality software? A technology advantage │
│ that helps companies scale quickly? If so, congratulations. You understand the value developing with open-source │
│ software can bring to a business… │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ https://siliconangle.com/2022/07/04/three-ways-patch-thinking-open-source-software-security/ │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

2022-02-16 12:45:00 Ireland Prepaid Card and Digital Wallet Market Report 2022: Market is Expected to Record a CAGR of 10.9%, Increasing from US$2.74 Billion in 2022 to Reach US$4.15 Billion by 2026
https://www.prnewswire.com/news-releases/ireland-prepaid-card-and-digital-wallet-market-report-2022-market-is-expected-to-record-a-cagr-of-10-9-increasing-from-us2-74-billion-in-2022-to-reach-us4-15-billion-by-2026--301483505.html

2022-02-16 12:45:00 Ireland Prepaid Card and Digital Wallet Market Report 2022: Market is Expected to Record a CAGR of 10.9%, Increasing from US$2.74 Billion in 2022 to Reach US$4.15 Billion by 2026
https://finance.yahoo.com/news/ireland-prepaid-card-digital-wallet-124500072.html
HUUUGE, INC.: Informacja o kwartalnych przychodach ze sprzedaży
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Content │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ 2022-07-04 18:55:11 │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Spis treści:1. RAPORT BIEŻĄCY2. MESSAGE (ENGLISH VERSION)3. INFORMACJE O PODMIOCIE4. PODPISY OSÓB REPREZENTUJĄCYCH │
│ SPÓŁKĘ KOMISJA NADZORU FINANSOWEGO <html> <head> </head> <body><font face='Times New... │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ https://www.bankier.pl/wiadomosc/HUUUGE-INC-Informacja-o-kwartalnych-przychodach-ze-sprzedazy-8369875.html │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

2022-02-16 12:38:49 Futures largely flat ahead of retail sales data, Fed minutes
https://www.reuters.com/business/futures-largely-flat-ahead-retail-sales-data-fed-minutes-2022-02-16/

5 Carpooling Apps to Help You Save Money on Transportation
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Content │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ 2022-07-04 16:00:22 │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ When we were kids, our parents told us not to get into cars with strangers, but that’s before we all had │
│ smartphones in our pockets and the price of gas skyrocketed. Now, if you need to get around, carpooling is a way to │
│ save at the gas pump — or the electric… │
├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ https://www.thepennyhoarder.com/save-money/carpool-apps/ │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
```