From 18204202ac6e6f2f298541ae3d6938afa3c4b5f5 Mon Sep 17 00:00:00 2001 From: Theodore Aptekarev Date: Thu, 27 Apr 2023 18:24:13 +0200 Subject: [PATCH] Remove stocks/disc/cnews command (#4920) * Remove stocks/disc/cnews command from terminal and sdk * Remove disc/cnews tests and test data * Remove cnews from default sources, translations and intros * Remove old test data files that are not used anymore * Add pydocstyle ignore statement to pyproject toml * Fix print help in stocks/disc controller test --- .../sdk/controllers/stocks_sdk_controller.py | 1 - .../core/sdk/models/stocks_sdk_model.py | 2 - openbb_terminal/core/sdk/trail_map.csv | 1 - openbb_terminal/miscellaneous/i18n/en.yml | 1 - .../miscellaneous/sources/openbb_default.json | 18 ----- .../stocks/discovery/disc_controller.py | 74 +------------------ .../stocks/discovery/seeking_alpha_model.py | 38 ---------- .../stocks/discovery/seeking_alpha_view.py | 48 +----------- pyproject.toml | 1 + .../stocks/discovery/test_disc_controller.py | 20 +---- .../discovery/test_seeking_alpha_model.py | 5 -- .../discovery/test_seeking_alpha_view.py | 10 --- .../test_menu_quick_exit.txt | 37 ---------- .../test_menu_system_exit.txt | 41 ---------- .../test_disc_controller/test_print_help.txt | 1 - .../test_disc_controller/test_switch_help.txt | 37 ---------- .../test_display_news.txt | 3 - .../sdk/usage/intros/stocks/discovery.md | 2 +- 18 files changed, 6 insertions(+), 334 deletions(-) delete mode 100644 tests/openbb_terminal/stocks/discovery/txt/test_disc_controller/test_menu_quick_exit.txt delete mode 100644 tests/openbb_terminal/stocks/discovery/txt/test_disc_controller/test_menu_system_exit.txt delete mode 100644 tests/openbb_terminal/stocks/discovery/txt/test_disc_controller/test_switch_help.txt delete mode 100644 tests/openbb_terminal/stocks/discovery/txt/test_seeking_alpha_view/test_display_news.txt diff --git a/openbb_terminal/core/sdk/controllers/stocks_sdk_controller.py b/openbb_terminal/core/sdk/controllers/stocks_sdk_controller.py index 450f9a1b8f8..6153e6da712 100644 --- a/openbb_terminal/core/sdk/controllers/stocks_sdk_controller.py +++ b/openbb_terminal/core/sdk/controllers/stocks_sdk_controller.py @@ -108,7 +108,6 @@ class StocksController(model.StocksRoot): `ipo`: Get IPO calendar\n `losers`: Get top losers. [Source: Yahoo Finance]\n `lowfloat`: Returns low float DataFrame\n - `news`: Gets news. [Source: SeekingAlpha]\n `pipo`: Past IPOs dates. [Source: Finnhub]\n `rtat`: Gets the top 10 retail stocks per day\n `trending`: Returns a list of trending articles\n diff --git a/openbb_terminal/core/sdk/models/stocks_sdk_model.py b/openbb_terminal/core/sdk/models/stocks_sdk_model.py index 093557b4a1e..e1fe2fee376 100644 --- a/openbb_terminal/core/sdk/models/stocks_sdk_model.py +++ b/openbb_terminal/core/sdk/models/stocks_sdk_model.py @@ -156,7 +156,6 @@ class StocksDiscovery(Category): `ipo`: Get IPO calendar\n `losers`: Get top losers. [Source: Yahoo Finance]\n `lowfloat`: Returns low float DataFrame\n - `news`: Gets news. [Source: SeekingAlpha]\n `pipo`: Past IPOs dates. [Source: Finnhub]\n `rtat`: Gets the top 10 retail stocks per day\n `trending`: Returns a list of trending articles\n @@ -182,7 +181,6 @@ class StocksDiscovery(Category): self.ipo = lib.stocks_disc_finnhub_model.get_ipo_calendar self.losers = lib.stocks_disc_yahoofinance_model.get_losers self.lowfloat = lib.stocks_disc_shortinterest_model.get_low_float - self.news = lib.stocks_disc_seeking_alpha_model.get_news self.pipo = lib.stocks_disc_finnhub_model.get_past_ipo self.rtat = lib.stocks_disc_nasdaq_model.get_retail_tickers self.trending = lib.stocks_disc_seeking_alpha_model.get_trending_list diff --git a/openbb_terminal/core/sdk/trail_map.csv b/openbb_terminal/core/sdk/trail_map.csv index 6b5e91d3cf6..3f36f6facc1 100644 --- a/openbb_terminal/core/sdk/trail_map.csv +++ b/openbb_terminal/core/sdk/trail_map.csv @@ -418,7 +418,6 @@ stocks.disc.hotpenny,stocks_disc_shortinterest_model.get_today_hot_penny_stocks, stocks.disc.ipo,stocks_disc_finnhub_model.get_ipo_calendar, stocks.disc.losers,stocks_disc_yahoofinance_model.get_losers, stocks.disc.lowfloat,stocks_disc_shortinterest_model.get_low_float, -stocks.disc.news,stocks_disc_seeking_alpha_model.get_news, stocks.disc.pipo,stocks_disc_finnhub_model.get_past_ipo, stocks.disc.rtat,stocks_disc_nasdaq_model.get_retail_tickers, stocks.disc.trending,stocks_disc_seeking_alpha_model.get_trending_list, diff --git a/openbb_terminal/miscellaneous/i18n/en.yml b/openbb_terminal/miscellaneous/i18n/en.yml index eb46cce409b..45bd62fb070 100644 --- a/openbb_terminal/miscellaneous/i18n/en.yml +++ b/openbb_terminal/miscellaneous/i18n/en.yml @@ -202,7 +202,6 @@ en: stocks/disc/arkord: orders by ARK Investment Management LLC stocks/disc/upcoming: upcoming earnings release dates stocks/disc/trending: trending news - stocks/disc/cnews: customized news (buybacks, ipos, spacs, healthcare, politics) stocks/disc/lowfloat: low float stocks under 10M shares float stocks/disc/hotpenny: today's hot penny stocks stocks/disc/rtat: top 10 retail traded stocks per day diff --git a/openbb_terminal/miscellaneous/sources/openbb_default.json b/openbb_terminal/miscellaneous/sources/openbb_default.json index c29f0580116..131d9e15894 100644 --- a/openbb_terminal/miscellaneous/sources/openbb_default.json +++ b/openbb_terminal/miscellaneous/sources/openbb_default.json @@ -158,9 +158,6 @@ "trending": [ "SeekingAlpha" ], - "cnews": [ - "SeekingAlpha" - ], "lowfloat": [ "Fidelity" ], @@ -542,12 +539,6 @@ "FinancialModelingPrep", "YahooFinance" ], - "overview": [ - "YahooFinance", - "Finviz", - "FinancialModelingPrep", - "AlphaVantage" - ], "divs": [ "YahooFinance" ], @@ -561,15 +552,9 @@ "rot": [ "Finnhub" ], - "score": [ - "FinancialModelingPrep" - ], "warnings": [ "MarketWatch" ], - "mgmt": [ - "BusinessInsider" - ], "shrs": [ "YahooFinance" ], @@ -641,9 +626,6 @@ "sec": [ "Nasdaq" ], - "analysis": [ - "Elect" - ], "earnings": [ "AlphaVantage", "YahooFinance" diff --git a/openbb_terminal/stocks/discovery/disc_controller.py b/openbb_terminal/stocks/discovery/disc_controller.py index e87ecfb99c2..3a1770de8d9 100644 --- a/openbb_terminal/stocks/discovery/disc_controller.py +++ b/openbb_terminal/stocks/discovery/disc_controller.py @@ -1,4 +1,4 @@ -""" Discovery Controller Module """ +"""Discovery Controller Module.""" __docformat__ = "numpy" import argparse @@ -57,7 +57,6 @@ class DiscoveryController(BaseController): "trending", "lowfloat", "hotpenny", - "cnews", "rtat", "divcal", "heatmap", @@ -75,32 +74,7 @@ class DiscoveryController(BaseController): "shares", ] arkord_fund_choices = ["ARKK", "ARKF", "ARKW", "ARKQ", "ARKG", "ARKX", ""] - cnews_type_choices = [ - nt.lower() - for nt in [ - "Top-News", - "On-The-Move", - "Market-Pulse", - "Notable-Calls", - "Buybacks", - "Commodities", - "Crypto", - "Issuance", - "Global", - "Guidance", - "IPOs", - "SPACs", - "Politics", - "M-A", - "Consumer", - "Energy", - "Financials", - "Healthcare", - "MLPs", - "REITs", - "Technology", - ] - ] + PATH = "/stocks/disc/" dividend_columns = [ "Name", @@ -140,7 +114,6 @@ class DiscoveryController(BaseController): mt.add_cmd("arkord", "Cathies Ark") mt.add_cmd("upcoming", "Seeking Alpha") mt.add_cmd("trending", "Seeking Alpha") - mt.add_cmd("cnews", "Seeking Alpha") mt.add_cmd("lowfloat", "Fidelity") mt.add_cmd("hotpenny", "Shortinterest") mt.add_cmd("rtat", "NASDAQ Data Link") @@ -774,49 +747,6 @@ class DiscoveryController(BaseController): else None, ) - @log_start_end(log=logger) - def call_cnews(self, other_args: List[str]): - """Process cnews command""" - parser = argparse.ArgumentParser( - add_help=False, - formatter_class=argparse.ArgumentDefaultsHelpFormatter, - prog="cnews", - description="""Customized news. [Source: Seeking Alpha]""", - ) - parser.add_argument( - "-t", - "--type", - action="store", - dest="s_type", - choices=self.cnews_type_choices, - default="top-news", - help="number of news to display", - ) - parser.add_argument( - "-l", - "--limit", - action="store", - dest="limit", - type=check_positive, - default=5, - help="limit of news to display", - ) - if other_args and "-" not in other_args[0][0]: - other_args.insert(0, "-t") - - ns_parser = self.parse_known_args_and_warn( - parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED - ) - if ns_parser: - seeking_alpha_view.display_news( - news_type=ns_parser.s_type, - limit=ns_parser.limit, - export=ns_parser.export, - sheet_name=" ".join(ns_parser.sheet_name) - if ns_parser.sheet_name - else None, - ) - @log_start_end(log=logger) def call_hotpenny(self, other_args: List[str]): """Process hotpenny command""" diff --git a/openbb_terminal/stocks/discovery/seeking_alpha_model.py b/openbb_terminal/stocks/discovery/seeking_alpha_model.py index b633ec9cae5..15aee1f96b7 100644 --- a/openbb_terminal/stocks/discovery/seeking_alpha_model.py +++ b/openbb_terminal/stocks/discovery/seeking_alpha_model.py @@ -3,7 +3,6 @@ __docformat__ = "numpy" import logging from datetime import date, timedelta -from typing import Dict, List import pandas as pd from bs4 import BeautifulSoup @@ -213,40 +212,3 @@ def get_news_html(news_type: str = "Top-News") -> dict: articles_html = request(sa_url, headers={"User-Agent": get_user_agent()}).json() return articles_html - - -@log_start_end(log=logger) -def get_news(news_type: str = "Top-News", limit: int = 5) -> List: - """Gets news. [Source: SeekingAlpha] - - Parameters - ---------- - news_type : str - From: Top-News, On-The-Move, Market-Pulse, Notable-Calls, Buybacks, Commodities, Crypto, Issuance, Global, - Guidance, IPOs, SPACs, Politics, M-A, Consumer, Energy, Financials, Healthcare, MLPs, REITs, Technology - limit : int - Number of news to display - - Returns - ------- - List[dict] - List of dict news - """ - news_articles: Dict = get_news_html(news_type) - news_to_display = list() - - if "data" in news_articles: - for idx, news in enumerate(news_articles["data"]): - if idx > limit: - break - - news_to_display.append( - { - "publishOn": news["attributes"]["publishOn"].replace("T", " ")[:-6], - "id": news["id"], - "title": news["attributes"]["title"], - "url": news["links"]["canonical"], - } - ) - - return news_to_display diff --git a/openbb_terminal/stocks/discovery/seeking_alpha_view.py b/openbb_terminal/stocks/discovery/seeking_alpha_view.py index 7265448bd6e..fcc7df06b95 100644 --- a/openbb_terminal/stocks/discovery/seeking_alpha_view.py +++ b/openbb_terminal/stocks/discovery/seeking_alpha_view.py @@ -4,7 +4,7 @@ __docformat__ = "numpy" import logging import os from datetime import date -from typing import List, Optional +from typing import Optional import pandas as pd @@ -128,49 +128,3 @@ def news( df_articles, sheet_name, ) - - -@log_start_end(log=logger) -def display_news( - news_type: str = "top-news", - limit: int = 5, - export: str = "", - sheet_name: Optional[str] = None, -): - """Display news. [Source: SeekingAlpha] - - Parameters - ---------- - news_type : str - From: Top-News, On-The-Move, Market-Pulse, Notable-Calls, Buybacks, Commodities, Crypto, Issuance, Global, - Guidance, IPOs, SPACs, Politics, M-A, Consumer, Energy, Financials, Healthcare, MLPs, REITs, Technology - limit : int - Number of news to display - export : str - Export dataframe data to csv,json,xlsx file - """ - news_to_display: List = seeking_alpha_model.get_news(news_type, limit) - - if not news: - console.print("No news found.", "\n") - - else: - df_news = pd.DataFrame( - news_to_display, columns=["publishOn", "id", "title", "url"] - ) - df_news = df_news.drop("id", axis=1) - print_rich_table( - df_news, - show_index=False, - title=f"{news_type}", - export=bool(export), - limit=limit, - ) - - export_data( - export, - os.path.dirname(os.path.abspath(__file__)), - "cnews : " + news_type, - pd.DataFrame(news_to_display), - sheet_name, - ) diff --git a/pyproject.toml b/pyproject.toml index 889c4832760..a3a301f2765 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -161,6 +161,7 @@ build-backend = "poetry.core.masonry.api" [tool.pydocstyle] convention = "numpy" match = '((?!test_).)*\.py' +ignore = "D401" [tool.ruff] diff --git a/tests/openbb_terminal/stocks/discovery/test_disc_controller.py b/tests/openbb_terminal/stocks/discovery/test_disc_controller.py index 709d58d32bb..24ce8f95217 100644 --- a/tests/openbb_terminal/stocks/discovery/test_disc_controller.py +++ b/tests/openbb_terminal/stocks/discovery/test_disc_controller.py @@ -11,9 +11,7 @@ from openbb_terminal.core.session.current_user import PreferencesModel, copy_use from openbb_terminal.stocks.discovery import disc_controller -# pylint: disable=E1101 -# pylint: disable=W0603 -# pylint: disable=E1111 +# pylint: disable=E1101,W0603,E1111 @pytest.mark.vcr(record_mode="none") @@ -232,21 +230,6 @@ def test_call_func_expect_queue(expected_queue, queue, func): ], {"limit": 5, "export": "csv", "sheet_name": None}, ), - ( - "call_cnews", - "seeking_alpha_view.display_news", - [ - "--type=technology", - "--limit=5", - "--export=csv", - ], - { - "news_type": "technology", - "limit": 5, - "export": "csv", - "sheet_name": None, - }, - ), ( "call_fipo", "finnhub_view.future_ipo", @@ -376,7 +359,6 @@ def test_call_func(tested_func, mocked_func, other_args, called_with, mocker): "call_active", "call_arkord", "call_asc", - "call_cnews", "call_fipo", "call_gainers", "call_gtech", diff --git a/tests/openbb_terminal/stocks/discovery/test_seeking_alpha_model.py b/tests/openbb_terminal/stocks/discovery/test_seeking_alpha_model.py index bd3cac88d2d..dbf425662b5 100644 --- a/tests/openbb_terminal/stocks/discovery/test_seeking_alpha_model.py +++ b/tests/openbb_terminal/stocks/discovery/test_seeking_alpha_model.py @@ -30,8 +30,3 @@ def test_get_trending_list(recorder): @pytest.mark.vcr def test_get_news_html(): seeking_alpha_model.get_news_html() - - -@pytest.mark.vcr -def test_get_news(): - seeking_alpha_model.get_news() diff --git a/tests/openbb_terminal/stocks/discovery/test_seeking_alpha_view.py b/tests/openbb_terminal/stocks/discovery/test_seeking_alpha_view.py index 412c8602e44..c573c5ace9a 100644 --- a/tests/openbb_terminal/stocks/discovery/test_seeking_alpha_view.py +++ b/tests/openbb_terminal/stocks/discovery/test_seeking_alpha_view.py @@ -33,13 +33,3 @@ def test_news(): limit=2, export="", ) - - -@pytest.mark.vcr -@pytest.mark.record_stdout -def test_display_news(): - seeking_alpha_view.display_news( - news_type="Crypto", - limit=2, - export="", - ) diff --git a/tests/openbb_terminal/stocks/discovery/txt/test_disc_controller/test_menu_quick_exit.txt b/tests/openbb_terminal/stocks/discovery/txt/test_disc_controller/test_menu_quick_exit.txt deleted file mode 100644 index 515ede3df06..00000000000 --- a/tests/openbb_terminal/stocks/discovery/txt/test_disc_controller/test_menu_quick_exit.txt +++ /dev/null @@ -1,37 +0,0 @@ - -Discovery: - cls clear screen - ?/help show this menu again - q quit this menu, and shows back to main menu - quit quit to abandon program - -Geek of Wall St: - rtearn realtime earnings from and expected moves -Finnhub: - pipo past IPOs dates - fipo future IPOs dates -Yahoo Finance: - gainers show latest top gainers - losers show latest top losers - ugs undervalued stocks with revenue and earnings growth in excess of 25% - gtech tech stocks with revenue and earnings growth more than 25% - active most active stocks by intraday trade volume - ulc potentially undervalued large cap stocks - asc small cap stocks with earnings growth rates better than 25% -Fidelity: - ford orders by Fidelity Customers -cathiesark.com: - arkord orders by ARK Investment Management LLC -Seeking Alpha: - upcoming upcoming earnings release dates - trending trending news - cnews customized news (buybacks, ipos, spacs, healthcare, politics) -shortinterest.com - lowfloat low float stocks under 10M shares float -pennystockflow.com - hotpenny today's hot penny stocks -Finance Database: - fds advanced Equities search based on country, sector, industry, name and/or description -NASDAQ Data Link (Formerly Quandl): - rtat top 10 retail traded stocks per day - diff --git a/tests/openbb_terminal/stocks/discovery/txt/test_disc_controller/test_menu_system_exit.txt b/tests/openbb_terminal/stocks/discovery/txt/test_disc_controller/test_menu_system_exit.txt deleted file mode 100644 index d59edc6492e..00000000000 --- a/tests/openbb_terminal/stocks/discovery/txt/test_disc_controller/test_menu_system_exit.txt +++ /dev/null @@ -1,41 +0,0 @@ - -Discovery: - cls clear screen - ?/help show this menu again - q quit this menu, and shows back to main menu - quit quit to abandon program - -Geek of Wall St: - rtearn realtime earnings from and expected moves -Finnhub: - pipo past IPOs dates - fipo future IPOs dates -Yahoo Finance: - gainers show latest top gainers - losers show latest top losers - ugs undervalued stocks with revenue and earnings growth in excess of 25% - gtech tech stocks with revenue and earnings growth more than 25% - active most active stocks by intraday trade volume - ulc potentially undervalued large cap stocks - asc small cap stocks with earnings growth rates better than 25% -Fidelity: - ford orders by Fidelity Customers -cathiesark.com: - arkord orders by ARK Investment Management LLC -Seeking Alpha: - upcoming upcoming earnings release dates - trending trending news - cnews customized news (buybacks, ipos, spacs, healthcare, politics) -shortinterest.com - lowfloat low float stocks under 10M shares float -pennystockflow.com - hotpenny today's hot penny stocks -Finance Database: - fds advanced Equities search based on country, sector, industry, name and/or description -NASDAQ Data Link (Formerly Quandl): - rtat top 10 retail traded stocks per day - -The command selected doesn't exist - -Did you mean 'quit'? - diff --git a/tests/openbb_terminal/stocks/discovery/txt/test_disc_controller/test_print_help.txt b/tests/openbb_terminal/stocks/discovery/txt/test_disc_controller/test_print_help.txt index a641cc677f3..7e489878457 100644 --- a/tests/openbb_terminal/stocks/discovery/txt/test_disc_controller/test_print_help.txt +++ b/tests/openbb_terminal/stocks/discovery/txt/test_disc_controller/test_print_help.txt @@ -11,7 +11,6 @@ arkord orders by ARK Investment Management LLC [CathiesArk] upcoming upcoming earnings release dates [SeekingAlpha] trending trending news [SeekingAlpha] - cnews customized news (buybacks, ipos, spacs, healthcare, politics) [SeekingAlpha] lowfloat low float stocks under 10M shares float [Fidelity] hotpenny today's hot penny stocks [YahooFinance, Shortinterest] rtat top 10 retail traded stocks per day [Nasdaq] diff --git a/tests/openbb_terminal/stocks/discovery/txt/test_disc_controller/test_switch_help.txt b/tests/openbb_terminal/stocks/discovery/txt/test_disc_controller/test_switch_help.txt deleted file mode 100644 index 515ede3df06..00000000000 --- a/tests/openbb_terminal/stocks/discovery/txt/test_disc_controller/test_switch_help.txt +++ /dev/null @@ -1,37 +0,0 @@ - -Discovery: - cls clear screen - ?/help show this menu again - q quit this menu, and shows back to main menu - quit quit to abandon program - -Geek of Wall St: - rtearn realtime earnings from and expected moves -Finnhub: - pipo past IPOs dates - fipo future IPOs dates -Yahoo Finance: - gainers show latest top gainers - losers show latest top losers - ugs undervalued stocks with revenue and earnings growth in excess of 25% - gtech tech stocks with revenue and earnings growth more than 25% - active most active stocks by intraday trade volume - ulc potentially undervalued large cap stocks - asc small cap stocks with earnings growth rates better than 25% -Fidelity: - ford orders by Fidelity Customers -cathiesark.com: - arkord orders by ARK Investment Management LLC -Seeking Alpha: - upcoming upcoming earnings release dates - trending trending news - cnews customized news (buybacks, ipos, spacs, healthcare, politics) -shortinterest.com - lowfloat low float stocks under 10M shares float -pennystockflow.com - hotpenny today's hot penny stocks -Finance Database: - fds advanced Equities search based on country, sector, industry, name and/or description -NASDAQ Data Link (Formerly Quandl): - rtat top 10 retail traded stocks per day - diff --git a/tests/openbb_terminal/stocks/discovery/txt/test_seeking_alpha_view/test_display_news.txt b/tests/openbb_terminal/stocks/discovery/txt/test_seeking_alpha_view/test_display_news.txt deleted file mode 100644 index cc1de6bb010..00000000000 --- a/tests/openbb_terminal/stocks/discovery/txt/test_seeking_alpha_view/test_display_news.txt +++ /dev/null @@ -1,3 +0,0 @@ -Empty DataFrame -Columns: [publishOn, title, url] -Index: [] diff --git a/website/content/sdk/usage/intros/stocks/discovery.md b/website/content/sdk/usage/intros/stocks/discovery.md index f3001dc0f0d..ccb3e01970c 100644 --- a/website/content/sdk/usage/intros/stocks/discovery.md +++ b/website/content/sdk/usage/intros/stocks/discovery.md @@ -1,6 +1,6 @@ --- title: Discovery -keywords: [stocks, discovery, disc, menu, submenu, pipo, fipo, gainers, losers, ugs, gtech, active, ulc, asc, ford, arkord, upcoming, trending, cnews, lowfloat, hotpenny, rtat, divcal, dividends, short, trending, news, how to, usage, examples, filings, screener, overview] +keywords: [stocks, discovery, disc, menu, submenu, pipo, fipo, gainers, losers, ugs, gtech, active, ulc, asc, ford, arkord, upcoming, trending, lowfloat, hotpenny, rtat, divcal, dividends, short, trending, news, how to, usage, examples, filings, screener, overview] description: Introducing the Discovery menu, within the Stocks menu. This guide will empower the user to get the most out of this set of features. ---