From 3964705101a4a45f1e93ae6b13f5a76efea573d7 Mon Sep 17 00:00:00 2001 From: raviolispy <62662248+raviolispy@users.noreply.github.com> Date: Fri, 16 Sep 2022 23:04:01 -0400 Subject: [PATCH] #2212 Removed hist and trend comamnds from /stocks/ba (#2284) * Removed hist and trend comamnds from /stocks/ba * Removed trend and hist command from /stocks/ba help menu * Fixed whitespace issue * Fixed test_print_help for ba controller * Fixed pylint issues * fix test Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: Ravioli Spy Co-authored-by: James Maslek Co-authored-by: colin99d --- openbb_terminal/reports/equity.ipynb | 18 +-- .../behavioural_analysis/ba_controller.py | 107 ------------------ .../test_ba_controller.py | 42 ------- 3 files changed, 9 insertions(+), 158 deletions(-) diff --git a/openbb_terminal/reports/equity.ipynb b/openbb_terminal/reports/equity.ipynb index 6c510575db0b..553e23bfd38c 100644 --- a/openbb_terminal/reports/equity.ipynb +++ b/openbb_terminal/reports/equity.ipynb @@ -27,8 +27,8 @@ "\n", "from IPython.display import HTML\n", "\n", - "#import sys\n", - "#sys.path.append('../../')\n", + "# import sys\n", + "# sys.path.append('../../')\n", "\n", "from openbb_terminal import api as openbb\n", "from openbb_terminal.helper_classes import TerminalStyle\n", @@ -347,15 +347,15 @@ " while df_ratings.empty:\n", " days += 30\n", " df_ratings = df[datetime.datetime.now() - datetime.timedelta(days=days) :]\n", - " \n", + "\n", " if days > 100:\n", " break\n", - " \n", + "\n", " if not df_ratings.empty:\n", " avg_ratings = round(np.mean(df_ratings[\"Price Target\"].values), 2)\n", " else:\n", " avg_ratings = 0\n", - " \n", + "\n", "last_price = round(ticker_data[\"Close\"][-1], 2)" ] }, @@ -530,7 +530,9 @@ "outputs": [], "source": [ "fig, ax = plt.subplots(figsize=(11, 3), dpi=150)\n", - "openbb.stocks.qa.bw(ticker_data_all, \"Returns\", symbol, yearly=False, external_axes=[ax])\n", + "openbb.stocks.qa.bw(\n", + " ticker_data_all, \"Returns\", symbol, yearly=False, external_axes=[ax]\n", + ")\n", "fig.tight_layout()\n", "f = io.BytesIO()\n", "fig.savefig(f, format=\"svg\")\n", @@ -776,9 +778,7 @@ "body += openbb.widgets.tab_clickable_and_save_evt()\n", "\n", "report = openbb.widgets.html_report(\n", - " title=report_name, \n", - " stylesheet=openbb.widgets.html_report_stylesheet(), \n", - " body=body\n", + " title=report_name, stylesheet=openbb.widgets.html_report_stylesheet(), body=body\n", ")\n", "\n", "# to save the results\n", diff --git a/openbb_terminal/stocks/behavioural_analysis/ba_controller.py b/openbb_terminal/stocks/behavioural_analysis/ba_controller.py index 358f464265d9..5b3dac208c8e 100644 --- a/openbb_terminal/stocks/behavioural_analysis/ba_controller.py +++ b/openbb_terminal/stocks/behavioural_analysis/ba_controller.py @@ -14,7 +14,6 @@ finbrain_view, google_view, reddit_view, - sentimentinvestor_view, stocktwits_view, twitter_view, ) @@ -26,7 +25,6 @@ check_int_range, check_positive, valid_date, - valid_hour, ) from openbb_terminal.menu import session from openbb_terminal.parent_classes import StockBaseController @@ -62,8 +60,6 @@ class BehaviouralAnalysisController(StockBaseController): "headlines", "popular", "getdd", - "hist", - "trend", "snews", "jcdr", "jctr", @@ -858,109 +854,6 @@ def call_headlines(self, other_args: List[str]): else: console.print("No ticker loaded. Please load using 'load '\n") - @log_start_end(log=logger) - def call_hist(self, other_args: List[str]): - """Process hist command""" - parser = argparse.ArgumentParser( - add_help=False, - formatter_class=argparse.ArgumentDefaultsHelpFormatter, - prog="hist", - description="Plot historical sentiment data of RHI and AHI by hour", - ) - parser.add_argument( - "-s", - "--start", - type=valid_date, - default=(datetime.utcnow() - timedelta(days=7)).strftime("%Y-%m-%d"), - dest="start", - required="--end" in other_args, - help="The starting date (format YYYY-MM-DD) of the stock. Default: 7 days ago", - ) - - parser.add_argument( - "-e", - "--end", - type=valid_date, - default=datetime.utcnow().strftime("%Y-%m-%d"), - dest="end", - required="--start" in other_args, - help="The ending date (format YYYY-MM-DD) of the stock. Default: today", - ) - parser.add_argument( - "-n", - "--number", - default=100, - type=check_positive, - dest="number", - help="Number of results returned from Sentiment Investor. Default: 100", - ) - ns_parser = self.parse_known_args_and_warn( - parser, other_args, EXPORT_BOTH_RAW_DATA_AND_FIGURES, raw=True, limit=10 - ) - - if ns_parser: - if self.ticker: - sentimentinvestor_view.display_historical( - symbol=self.ticker, - start_date=ns_parser.start, - end_date=ns_parser.end, - number=ns_parser.number, - export=ns_parser.export, - raw=ns_parser.raw, - limit=ns_parser.limit, - ) - else: - console.print("No ticker loaded. Please load using 'load '\n") - - @log_start_end(log=logger) - def call_trend(self, other_args: List[str]): - """Process trend command""" - parser = argparse.ArgumentParser( - add_help=False, - formatter_class=argparse.ArgumentDefaultsHelpFormatter, - prog="trend", - description="Show most talked about tickers within the last one hour", - ) - parser.add_argument( - "-s", - "--start", - type=valid_date, - default=datetime.utcnow().strftime("%Y-%m-%d"), - dest="start", - help="The starting date (format YYYY-MM-DD). Default: Today", - ) - - parser.add_argument( - "-hr", - "--hour", - type=valid_hour, - default=0, - dest="hour", - help="Hour of the day in the 24-hour notation. Example: 14", - ) - - parser.add_argument( - "-n", - "--number", - default=10, - type=check_positive, - dest="number", - help="Number of results returned from Sentiment Investor. Default: 10", - ) - - ns_parser = self.parse_known_args_and_warn( - parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED, limit=10 - ) - - if ns_parser: - sentimentinvestor_view.display_trending( - start_date=ns_parser.start, - hour=ns_parser.hour, - export=ns_parser.export, - number=ns_parser.number, - ) - - @log_start_end(log=logger) def call_jcdr(self, other_args: List[str]): """Process jcdr command""" parser = argparse.ArgumentParser( diff --git a/tests/openbb_terminal/stocks/behavioural_analysis/test_ba_controller.py b/tests/openbb_terminal/stocks/behavioural_analysis/test_ba_controller.py index 45c45cc8aa7f..f8c254bc3e1c 100644 --- a/tests/openbb_terminal/stocks/behavioural_analysis/test_ba_controller.py +++ b/tests/openbb_terminal/stocks/behavioural_analysis/test_ba_controller.py @@ -391,45 +391,6 @@ def test_call_func_expect_queue(expected_queue, queue, func): export="csv", ), ), - ( - "call_hist", - [ - "--start=2020-12-01", - "--end=2020-12-07", - "--export=csv", - "--number=100", - "--raw", - "--limit=10", - ], - "sentimentinvestor_view.display_historical", - [], - dict( - symbol="MOCK_TICKER", - start_date=datetime(2020, 12, 1), - end_date=datetime(2020, 12, 7), - number=100, - export="csv", - raw=True, - limit=10, - ), - ), - ( - "call_trend", - [ - "--start=2020-12-01", - "--hour=9", - "--export=csv", - "--number=20", - ], - "sentimentinvestor_view.display_trending", - [], - dict( - start_date=datetime(2020, 12, 1), - hour=9, - export="csv", - number=20, - ), - ), ( "call_popular", ["--num=1", "--limit=2", "--sub=MOCK_SUB"], @@ -508,8 +469,6 @@ def test_call_func( "call_rise", "call_headlines", "call_snews", - "call_hist", - "call_trend", "call_popular", "call_getdd", ], @@ -535,7 +494,6 @@ def test_call_func_no_parser(func, mocker): @pytest.mark.parametrize( "func", [ - "call_hist", "call_headlines", "call_sentiment", "call_infer",