From 5debfb4d0dfc17154f3bf1eaa90c9d283f4020ba Mon Sep 17 00:00:00 2001 From: James Simmons <53658028+simmonsj330@users.noreply.github.com> Date: Thu, 3 Nov 2022 14:37:43 -0400 Subject: [PATCH] `crypto/prt` fixes (#3279) * PRT fixes * adding error checking * fixing elif and pylint Co-authored-by: James Maslek --- .../cryptocurrency/crypto_controller.py | 46 +++++++++++++------ .../due_diligence/pycoingecko_model.py | 2 +- openbb_terminal/forecast/autoets_model.py | 2 + 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/openbb_terminal/cryptocurrency/crypto_controller.py b/openbb_terminal/cryptocurrency/crypto_controller.py index 3039fabe73a..5500bbc9493 100644 --- a/openbb_terminal/cryptocurrency/crypto_controller.py +++ b/openbb_terminal/cryptocurrency/crypto_controller.py @@ -133,7 +133,11 @@ class CryptoController(CryptoBaseController): "-s": "--symbol", } choices["headlines"] = {c: {} for c in finbrain_crypto_view.COINS} - # choices["prt"]["--vs"] = {c: {} for c in coingecko_coin_ids} # list is huge. makes typing buggy + choices["prt"]["--vs"] = None + choices["prt"]["--price"] = None + choices["prt"]["-p"] = "--price" + choices["prt"]["--top"] = None + choices["prt"]["-t"] = None choices["support"] = self.SUPPORT_CHOICES choices["about"] = self.ABOUT_CHOICES @@ -190,7 +194,8 @@ class CryptoController(CryptoBaseController): help="Coin to compare with", dest="vs", type=str, - required="-h" not in other_args, + # required="-h" not in other_args, + default=None, ) parser.add_argument( "-p", @@ -216,27 +221,40 @@ class CryptoController(CryptoBaseController): ) if ns_parser: - if ns_parser.vs: - current_coin_id = cryptocurrency_helpers.get_coingecko_id( - self.symbol - ) + num_args = 0 + for arg in vars(ns_parser): + if getattr(ns_parser, arg): + num_args = num_args + 1 + if num_args > 1: + console.print("[red]Please chose only one flag[/red]\n") + return + current_coin_id = cryptocurrency_helpers.get_coingecko_id(self.symbol) + if ns_parser.vs is not None: coin_found = cryptocurrency_helpers.get_coingecko_id(ns_parser.vs) if not coin_found: console.print( f"VS Coin '{ns_parser.vs}' not found in CoinGecko\n" ) return - pycoingecko_view.display_coin_potential_returns( - current_coin_id, - coin_found, - ns_parser.top, - ns_parser.price, - ) - else: + coin_found = None + if ( + ns_parser.vs is None + and ns_parser.top is None + and ns_parser.price is None + ): console.print( - "No coin selected. Use 'load' to load the coin you want to look at.\n" + "[red]Please chose a flag: --top, --vs, or --price [/red]\n" ) + return + pycoingecko_view.display_coin_potential_returns( + current_coin_id, + coin_found, + ns_parser.top, + ns_parser.price, + ) + else: + console.print("[red]Please load a coin first![/red]\n") @log_start_end(log=logger) def call_price(self, other_args): diff --git a/openbb_terminal/cryptocurrency/due_diligence/pycoingecko_model.py b/openbb_terminal/cryptocurrency/due_diligence/pycoingecko_model.py index d115b059d33..ae47021968e 100644 --- a/openbb_terminal/cryptocurrency/due_diligence/pycoingecko_model.py +++ b/openbb_terminal/cryptocurrency/due_diligence/pycoingecko_model.py @@ -194,7 +194,7 @@ def get_coin_potential_returns( main_coin, main_coin_data["usd"], main_coin_data["usd_market_cap"], - "", + main_coin, future_price, final_market_cap, market_cap_difference_percentage, diff --git a/openbb_terminal/forecast/autoets_model.py b/openbb_terminal/forecast/autoets_model.py index a6170ad6149..2e36abf93cb 100644 --- a/openbb_terminal/forecast/autoets_model.py +++ b/openbb_terminal/forecast/autoets_model.py @@ -20,6 +20,8 @@ warnings.simplefilter("ignore") logger = logging.getLogger(__name__) +# pylint: disable=E1123 + @log_start_end(log=logger) def get_autoets_data(