From 5c14e280a0f13f2f012f341b23aaa6405ced63ba Mon Sep 17 00:00:00 2001 From: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Date: Tue, 22 Nov 2022 14:17:47 +0100 Subject: [PATCH] Bug fixes (#3423) * Got basic testing file done * Continued progress on new integrated tests * Allow for dynamic parameters, update docs * Massive improvements * Improved CSV file * Renamed file per James2 * Added fixes * Added fixes * Combined the docs * Renamed file * Fixed typing issue and simplified code * Captures output for tests * Fixes 3418 * Fixed financial statement exports * Fixed sean seah * Handle no ticker * Added fixes * Removed unwanted changes * Removed unwanted changes * Removed unwanted changes * Fixed tests * Fixed tests --- .gitignore | 4 +- openbb_terminal/miscellaneous/i18n/en.yml | 4 +- .../behavioural_analysis/finnhub_model.py | 9 +++++ .../comparison_analysis/ca_controller.py | 3 ++ .../market_watch_model.py | 39 ++++++++----------- .../comparison_analysis/test_ca_controller.py | 3 ++ .../test_ca_controller/test_print_help.txt | 2 +- 7 files changed, 37 insertions(+), 27 deletions(-) diff --git a/.gitignore b/.gitignore index 71efbd7b893..48fce6544b3 100644 --- a/.gitignore +++ b/.gitignore @@ -30,8 +30,10 @@ openbb_terminal/portfolio/portfolios/* .coverage.* !openbb_terminal/reports/templates/*.ipynb *_tests.csv -*_sdk_audit.csv +integration_test_output/* +openbb_terminal/reports/templates/*.html website/functions +*_sdk_audit.csv website/terminaltest # pyinstaller artifacts diff --git a/openbb_terminal/miscellaneous/i18n/en.yml b/openbb_terminal/miscellaneous/i18n/en.yml index 315d1a34792..bc7129585af 100644 --- a/openbb_terminal/miscellaneous/i18n/en.yml +++ b/openbb_terminal/miscellaneous/i18n/en.yml @@ -279,9 +279,7 @@ en: stocks/ca/ticker: set ticker to get similar companies from stocks/ca/_ticker: Ticker to get similar companies from stocks/ca/tsne: run TSNE on all SP500 stocks and returns closest tickers - stocks/ca/getpoly: get similar stocks - stocks/ca/getfinnhub: get similar stocks - stocks/ca/getfinviz: get similar stocks + stocks/ca/get: get similar stocks stocks/ca/set: reset and set similar companies stocks/ca/add: add more similar companies stocks/ca/rmv: remove similar companies individually or all diff --git a/openbb_terminal/stocks/behavioural_analysis/finnhub_model.py b/openbb_terminal/stocks/behavioural_analysis/finnhub_model.py index 72e12aee763..92b6d685392 100644 --- a/openbb_terminal/stocks/behavioural_analysis/finnhub_model.py +++ b/openbb_terminal/stocks/behavioural_analysis/finnhub_model.py @@ -103,8 +103,17 @@ def get_headlines_sentiment( ---------- symbol : str Ticker of company + + Returns + ---------- + pd.DataFrame + The news article information """ start = datetime.now() - timedelta(days=30) + if not symbol: + console.print("[red]Do not run this command without setting a ticker.[/red]\n") + return pd.DataFrame() + articles = get_company_news( symbol.upper(), start_date=start.strftime("%Y-%m-%d"), diff --git a/openbb_terminal/stocks/comparison_analysis/ca_controller.py b/openbb_terminal/stocks/comparison_analysis/ca_controller.py index 112c9022959..0ec2ee52c79 100644 --- a/openbb_terminal/stocks/comparison_analysis/ca_controller.py +++ b/openbb_terminal/stocks/comparison_analysis/ca_controller.py @@ -582,6 +582,7 @@ class ComparisonAnalysisController(BaseController): symbols=self.similar, timeframe=ns_parser.s_timeframe, quarter=ns_parser.b_quarter, + export=ns_parser.export, ) @log_start_end(log=logger) @@ -654,6 +655,7 @@ class ComparisonAnalysisController(BaseController): symbols=self.similar, timeframe=ns_parser.s_timeframe, quarter=ns_parser.b_quarter, + export=ns_parser.export, ) @log_start_end(log=logger) @@ -693,6 +695,7 @@ class ComparisonAnalysisController(BaseController): symbols=self.similar, timeframe=ns_parser.s_timeframe, quarter=ns_parser.b_quarter, + export=ns_parser.export, ) @log_start_end(log=logger) diff --git a/openbb_terminal/stocks/fundamental_analysis/market_watch_model.py b/openbb_terminal/stocks/fundamental_analysis/market_watch_model.py index 97de896c433..84f27bee548 100644 --- a/openbb_terminal/stocks/fundamental_analysis/market_watch_model.py +++ b/openbb_terminal/stocks/fundamental_analysis/market_watch_model.py @@ -246,36 +246,31 @@ def get_sean_seah_warnings( df_financials = df_financials.set_index("Item") # Create dataframe to compute meaningful metrics from sean seah book - df_sean_seah = df_sean_seah.append( - df_financials.loc[ - [ - "Total Shareholders' Equity", - "Liabilities & Shareholders' Equity", - "Long-Term Debt", - ] - ] - ) + transfer_cols = [ + "Total Shareholders' Equity", + "Liabilities & Shareholders' Equity", + "Long-Term Debt", + ] + df_sean_seah = pd.concat([df_sean_seah, df_financials.loc[transfer_cols]]) # Clean these metrics by parsing their values to float df_sean_seah = df_sean_seah.applymap(lambda x: lambda_clean_data_values_to_float(x)) + df_sean_seah = df_sean_seah.T # Add additional necessary metrics - series = ( - df_sean_seah.loc["Net Income"] / df_sean_seah.loc["Total Shareholders' Equity"] + df_sean_seah["ROE"] = ( + df_sean_seah["Net Income"] / df_sean_seah["Total Shareholders' Equity"] ) - series.name = "ROE" - df_sean_seah = df_sean_seah.append(series) - series = df_sean_seah.loc["EBITDA"] / df_sean_seah.loc["Interest Expense"] - series.name = "Interest Coverage Ratio" - df_sean_seah = df_sean_seah.append(series) - - series = ( - df_sean_seah.loc["Net Income"] - / df_sean_seah.loc["Liabilities & Shareholders' Equity"] + df_sean_seah["Interest Coverage Ratio"] = ( + df_sean_seah["EBITDA"] / df_sean_seah["Interest Expense"] ) - series.name = "ROA" - df_sean_seah = df_sean_seah.append(series) + + df_sean_seah["ROA"] = ( + df_sean_seah["Net Income"] / df_sean_seah["Liabilities & Shareholders' Equity"] + ) + df_sean_seah = df_sean_seah.sort_index() + df_sean_seah = df_sean_seah.T n_warnings = 0 warnings = [] diff --git a/tests/openbb_terminal/stocks/comparison_analysis/test_ca_controller.py b/tests/openbb_terminal/stocks/comparison_analysis/test_ca_controller.py index ff7d2f53e24..2d26b3bdc01 100644 --- a/tests/openbb_terminal/stocks/comparison_analysis/test_ca_controller.py +++ b/tests/openbb_terminal/stocks/comparison_analysis/test_ca_controller.py @@ -285,6 +285,7 @@ def test_call_func_expect_queue(expected_queue, queue, func): symbols=["MOCK_SIMILAR_1", "MOCK_SIMILAR_2"], timeframe="MOCK_TIMEFRAME", quarter=True, + export="", ), ), ( @@ -299,6 +300,7 @@ def test_call_func_expect_queue(expected_queue, queue, func): symbols=["MOCK_SIMILAR_1", "MOCK_SIMILAR_2"], timeframe="MOCK_TIMEFRAME", quarter=True, + export="csv", ), ), ( @@ -313,6 +315,7 @@ def test_call_func_expect_queue(expected_queue, queue, func): symbols=["MOCK_SIMILAR_1", "MOCK_SIMILAR_2"], timeframe="MOCK_TIMEFRAME", quarter=True, + export="csv", ), ), ( diff --git a/tests/openbb_terminal/stocks/comparison_analysis/txt/test_ca_controller/test_print_help.txt b/tests/openbb_terminal/stocks/comparison_analysis/txt/test_ca_controller/test_print_help.txt index e7e02d21626..8ffb8f8795b 100644 --- a/tests/openbb_terminal/stocks/comparison_analysis/txt/test_ca_controller/test_print_help.txt +++ b/tests/openbb_terminal/stocks/comparison_analysis/txt/test_ca_controller/test_print_help.txt @@ -3,7 +3,7 @@ Ticker to get similar companies from: [unvl] tsne run TSNE on all SP500 stocks and returns closest tickers[/unvl] [YahooFinance] -[unvl] get stocks/ca/get[/unvl] [Finviz, Polygon, Finnhub] +[unvl] get get similar stocks[/unvl] [Finviz, Polygon, Finnhub] set reset and set similar companies add add more similar companies