From 0699f1ccd1e8534d7bdd7c1d792297d355757dbd Mon Sep 17 00:00:00 2001 From: didier Date: Fri, 12 Mar 2021 20:56:49 +0000 Subject: [PATCH 1/7] Add comparison analysis option to main menu --- terminal.py | 1 + 1 file changed, 1 insertion(+) diff --git a/terminal.py b/terminal.py index 0292aae4dd1..fbbec26702e 100644 --- a/terminal.py +++ b/terminal.py @@ -62,6 +62,7 @@ def main(): "ta", "dd", "pred", + "ca", ] menu_parser.add_argument("opt", choices=choices) completer = NestedCompleter.from_nested_dict({c: None for c in choices}) From 1ef550986eeb8c25bc46fd3e1cf39eab6ff08201 Mon Sep 17 00:00:00 2001 From: didier Date: Fri, 12 Mar 2021 20:57:23 +0000 Subject: [PATCH 2/7] Fix help flag in case of Market Watch commands --- gamestonk_terminal/fundamental_analysis/market_watch_api.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gamestonk_terminal/fundamental_analysis/market_watch_api.py b/gamestonk_terminal/fundamental_analysis/market_watch_api.py index 741985fab57..2915af7c63e 100644 --- a/gamestonk_terminal/fundamental_analysis/market_watch_api.py +++ b/gamestonk_terminal/fundamental_analysis/market_watch_api.py @@ -63,6 +63,7 @@ def income(l_args, s_ticker): def balance(l_args, s_ticker): parser = argparse.ArgumentParser( + add_help=False, prog="balance", description=""" Prints either yearly or quarterly assets from balance sheet of the company. @@ -130,6 +131,7 @@ def balance(l_args, s_ticker): def cash(l_args, s_ticker): parser = argparse.ArgumentParser( + add_help=False, prog="cash_flow", description=""" Prints either yearly or quarterly cash flow operating activities of the company. From 762bbbb0c4cd69512e8961ef74d4237a84568c22 Mon Sep 17 00:00:00 2001 From: didier Date: Fri, 12 Mar 2021 20:57:43 +0000 Subject: [PATCH 3/7] Add help flag to comparison analysis menu --- gamestonk_terminal/comparison_analysis/ca_menu.py | 9 ++++++++- .../comparison_analysis/yahoo_finance_api.py | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gamestonk_terminal/comparison_analysis/ca_menu.py b/gamestonk_terminal/comparison_analysis/ca_menu.py index 1e79bbcf290..0e2d86fd19b 100644 --- a/gamestonk_terminal/comparison_analysis/ca_menu.py +++ b/gamestonk_terminal/comparison_analysis/ca_menu.py @@ -10,13 +10,16 @@ from gamestonk_terminal.comparison_analysis import yahoo_finance_api as yf_api def get_similar_companies(l_args, s_ticker): """ Get similar companies. [Source: Polygon API] """ parser = argparse.ArgumentParser( + add_help=False, prog="get", description="""Get similar companies to compare with.""", ) l_similar = [] try: - parse_known_args_and_warn(parser, l_args) + ns_parser = parse_known_args_and_warn(parser, l_args) + if not ns_parser: + return result = requests.get( f"https://api.polygon.io/v1/meta/symbols/{s_ticker}/company?&apiKey={cfg.API_POLYGON_KEY}" @@ -35,6 +38,7 @@ def get_similar_companies(l_args, s_ticker): def select_similar_companies(l_args): """ Select similar companies, e.g. NIO,XPEV,LI""" parser = argparse.ArgumentParser( + add_help=False, prog="select", description="""Select similar companies to compare with.""", ) @@ -54,6 +58,9 @@ def select_similar_companies(l_args): l_args.insert(0, "-s") ns_parser = parse_known_args_and_warn(parser, l_args) + if not ns_parser: + return + print("") return ns_parser.l_similar diff --git a/gamestonk_terminal/comparison_analysis/yahoo_finance_api.py b/gamestonk_terminal/comparison_analysis/yahoo_finance_api.py index 95dca00a14f..31d2c662a21 100644 --- a/gamestonk_terminal/comparison_analysis/yahoo_finance_api.py +++ b/gamestonk_terminal/comparison_analysis/yahoo_finance_api.py @@ -34,6 +34,7 @@ def check_one_of_ohlca(type_candles: str) -> str: def historical(l_args, df_stock, s_ticker, s_start, s_interval, similar): parser = argparse.ArgumentParser( + add_help=False, prog="historical", description="""Historical price comparison between similar companies [Source: Yahoo Finance] """, @@ -70,6 +71,8 @@ def historical(l_args, df_stock, s_ticker, s_start, s_interval, similar): # Alpha Vantage only supports 5 calls per minute, we need another API to get intraday data else: ns_parser = parse_known_args_and_warn(parser, l_args) + if not ns_parser: + return if ns_parser.l_similar: similar = ns_parser.l_similar @@ -112,6 +115,7 @@ def historical(l_args, df_stock, s_ticker, s_start, s_interval, similar): def correlation(l_args, df_stock, s_ticker, s_start, s_interval, similar): parser = argparse.ArgumentParser( + add_help=False, prog="corr", description=""" Correlation heatmap based on historical price comparison between similar companies. [Source: Yahoo Finance] @@ -149,6 +153,8 @@ def correlation(l_args, df_stock, s_ticker, s_start, s_interval, similar): # Alpha Vantage only supports 5 calls per minute, we need another API to get intraday data else: ns_parser = parse_known_args_and_warn(parser, l_args) + if not ns_parser: + return if ns_parser.l_similar: similar = ns_parser.l_similar From e28ff5bdbf49a8d21675e29aea92a633d61174d1 Mon Sep 17 00:00:00 2001 From: didier Date: Fri, 12 Mar 2021 21:12:11 +0000 Subject: [PATCH 4/7] Prediction prints to have flag to use or not use color --- gamestonk_terminal/helper_funcs.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gamestonk_terminal/helper_funcs.py b/gamestonk_terminal/helper_funcs.py index 137c419f793..4dfae92c5a6 100644 --- a/gamestonk_terminal/helper_funcs.py +++ b/gamestonk_terminal/helper_funcs.py @@ -300,10 +300,14 @@ def price_prediction_color(val: int, last_val: int) -> str: def print_pretty_prediction(df_pred: pd.DataFrame, last_price: float): - print(f"Actual price: {Fore.YELLOW}{last_price:.2f} ${Style.RESET_ALL}\n") - - print("Prediction:") - print(df_pred.apply(price_prediction_color, last_val=last_price).to_string()) + if gtff.USE_COLOR: + print(f"Actual price: {Fore.YELLOW}{last_price:.2f} ${Style.RESET_ALL}\n") + print("Prediction:") + print(df_pred.apply(price_prediction_color, last_val=last_price).to_string()) + else: + print(f"Actual price: {last_price:.2f} $\n") + print("Prediction:") + print(df_pred.to_string()) def check_ohlc(type_ohlc: str) -> str: From f2b8abf5cec75157695226dce45d66b75ab75b1c Mon Sep 17 00:00:00 2001 From: didier Date: Fri, 12 Mar 2021 21:12:38 +0000 Subject: [PATCH 5/7] Fix name of file to set ENABLE PREDICTION --- gamestonk_terminal/sentiment/sen_menu.py | 2 +- terminal.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gamestonk_terminal/sentiment/sen_menu.py b/gamestonk_terminal/sentiment/sen_menu.py index 369c74f69b4..af4b6cf6852 100644 --- a/gamestonk_terminal/sentiment/sen_menu.py +++ b/gamestonk_terminal/sentiment/sen_menu.py @@ -137,7 +137,7 @@ def sen_menu(s_ticker, s_start): # ----------------------------------------------------- TWITTER ------------------------------------------------- elif ns_known_args.cmd == "infer": if not gtff.ENABLE_PREDICT: - print("Predict is not enabled in config_terminal.py") + print("Predict is not enabled in feature_flags.py") print("Twitter inference menu is disabled") print("") continue diff --git a/terminal.py b/terminal.py index fbbec26702e..cc40b922fce 100644 --- a/terminal.py +++ b/terminal.py @@ -151,7 +151,7 @@ def main(): elif ns_known_args.opt == "pred": if not gtff.ENABLE_PREDICT: - print("Predict is not enabled in config_terminal.py") + print("Predict is not enabled in feature_flags.py") print("Prediction menu is disabled") print("") continue From e2b0ffb36c118edb2f267a649b72552b23cf85b8 Mon Sep 17 00:00:00 2001 From: didier Date: Fri, 12 Mar 2021 21:14:16 +0000 Subject: [PATCH 6/7] Remove unnecessary comments --- gamestonk_terminal/sentiment/sen_menu.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/gamestonk_terminal/sentiment/sen_menu.py b/gamestonk_terminal/sentiment/sen_menu.py index af4b6cf6852..c35cf5df95e 100644 --- a/gamestonk_terminal/sentiment/sen_menu.py +++ b/gamestonk_terminal/sentiment/sen_menu.py @@ -7,7 +7,6 @@ from gamestonk_terminal.sentiment import google_api, reddit_api, stocktwits_api from prompt_toolkit.completion import NestedCompleter -# ----------------------------------------------------------------------------------------------------------------------- def print_sentiment(): """ Print help """ @@ -45,7 +44,6 @@ def print_sentiment(): return -# ---------------------------------------------------- MENU ---------------------------------------------------- def sen_menu(s_ticker, s_start): # Add list of arguments that the discovery parser accepts @@ -105,7 +103,6 @@ def sen_menu(s_ticker, s_start): # Abandon the program return True - # ---------------------------------------------------- REDDIT --------------------------------------------------- elif ns_known_args.cmd == "watchlist": reddit_api.watchlist(l_args) @@ -121,7 +118,6 @@ def sen_menu(s_ticker, s_start): elif ns_known_args.cmd == "popular": reddit_api.popular_tickers(l_args) - # ---------------------------------------------------- STOCKTWITS ----------------------------------------------- elif ns_known_args.cmd == "bullbear": stocktwits_api.bullbear(l_args, s_ticker) @@ -134,7 +130,6 @@ def sen_menu(s_ticker, s_start): elif ns_known_args.cmd == "stalker": stocktwits_api.stalker(l_args) - # ----------------------------------------------------- TWITTER ------------------------------------------------- elif ns_known_args.cmd == "infer": if not gtff.ENABLE_PREDICT: print("Predict is not enabled in feature_flags.py") @@ -181,7 +176,6 @@ def sen_menu(s_ticker, s_start): twitter_api.sentiment(l_args, s_ticker) - # ----------------------------------------------------- GOOGLE --------------------------------------------------- elif ns_known_args.cmd == "mentions": google_api.mentions(l_args, s_ticker, s_start) @@ -194,6 +188,5 @@ def sen_menu(s_ticker, s_start): elif ns_known_args.cmd == "rise": google_api.rise(l_args, s_ticker) - # ------------------------------------------------------------------------------------------------------------ else: print("Command not recognized!") From 070e73c225e8b83541628b009435799dec46334a Mon Sep 17 00:00:00 2001 From: didier Date: Fri, 12 Mar 2021 21:16:07 +0000 Subject: [PATCH 7/7] Update readm with polygon API key --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 68f54389d0d..dfbf2fe998f 100644 --- a/README.md +++ b/README.md @@ -167,11 +167,12 @@ These are the ones where a key is necessary: * Quandl: https://www.quandl.com/tools/api * Reddit: https://www.reddit.com/prefs/apps * Twitter: https://developer.twitter.com + * Polygon: # https://polygon.io * Financial Modeling Prep: https://financialmodelingprep.com/developer When these are obtained, don't forget to update [config_terminal.py](/gamestonk_terminal/config_terminal.py). -Alternatively, you can also set them to the following environment variables: GT_API_KEY_ALPHAVANTAGE, GT_API_KEY_FINANCIALMODELINGPREP, GT_API_KEY_QUANDL, GT_API_REDDIT_CLIENT_ID, GT_API_REDDIT_CLIENT_SECRET, GT_API_REDDIT_USERNAME, GT_API_REDDIT_USER_AGENT, GT_API_REDDIT_PASSWORD, GT_API_TWITTER_KEY, GT_API_TWITTER_SECRET_KEY, GT_API_TWITTER_BEARER_TOKEN. +Alternatively, you can also set them to the following environment variables: GT_API_KEY_ALPHAVANTAGE, GT_API_KEY_FINANCIALMODELINGPREP, GT_API_KEY_QUANDL, GT_API_REDDIT_CLIENT_ID, GT_API_REDDIT_CLIENT_SECRET, GT_API_REDDIT_USERNAME, GT_API_REDDIT_USER_AGENT, GT_API_REDDIT_PASSWORD, GT_API_TWITTER_KEY, GT_API_TWITTER_SECRET_KEY, GT_API_TWITTER_BEARER_TOKEN, GT_API_POLYGON_KEY. Example: ```