From 92e641bf0ef5c6c926d43a6c063004ec72660ed4 Mon Sep 17 00:00:00 2001 From: Jamie Perkins Date: Wed, 26 May 2021 22:29:56 -0400 Subject: [PATCH 1/2] fix etf overview not parsing lowercase symbols --- gamestonk_terminal/etf/stockanalysis_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gamestonk_terminal/etf/stockanalysis_model.py b/gamestonk_terminal/etf/stockanalysis_model.py index 9fbaead7849..255a231c3ef 100644 --- a/gamestonk_terminal/etf/stockanalysis_model.py +++ b/gamestonk_terminal/etf/stockanalysis_model.py @@ -100,7 +100,7 @@ def etf_overview(other_args: List[str]): if not ns_parser: return "" - if ns_parser.name not in etf_symbols: + if ns_parser.name.upper() not in etf_symbols: print("ETF symbol not available") return "" r1 = requests.get(f"https://stockanalysis.com/etf/{ns_parser.name}") From af6e5723bf39a5091a9b8c1c23718ca6d72f8ca2 Mon Sep 17 00:00:00 2001 From: Jamie Perkins Date: Wed, 26 May 2021 22:34:51 -0400 Subject: [PATCH 2/2] web command supports etf symbol --- gamestonk_terminal/etf/etf_controller.py | 4 +- gamestonk_terminal/etf/stockanalysis_model.py | 41 +++++++++++++++++-- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/gamestonk_terminal/etf/etf_controller.py b/gamestonk_terminal/etf/etf_controller.py index 33457dd9c66..f9c15d4e6b0 100644 --- a/gamestonk_terminal/etf/etf_controller.py +++ b/gamestonk_terminal/etf/etf_controller.py @@ -69,9 +69,9 @@ class ETFController: """Process Quit command - quit the program""" return True - def call_web(self, _): + def call_web(self, other_args: List[str]): """Process web command""" - open_web() + open_web(other_args) def call_search(self, other_args: List[str]): """Process search command""" diff --git a/gamestonk_terminal/etf/stockanalysis_model.py b/gamestonk_terminal/etf/stockanalysis_model.py index 255a231c3ef..bd703791831 100644 --- a/gamestonk_terminal/etf/stockanalysis_model.py +++ b/gamestonk_terminal/etf/stockanalysis_model.py @@ -29,9 +29,44 @@ def limit_number_of_holdings(num: str) -> int: return int(num) -def open_web(): - """Opens webbrowser to the website page""" - webbrowser.open("https://stockanalysis.com/etf/") +def open_web(other_args: List[str]): + + """ + Opens webbrowser to the website page + Parameters + ---------- + other_args : List[str] + Argparse arguments + + """ + parser = argparse.ArgumentParser(prog="web", add_help=False) + parser.add_argument( + "-n", "--name", type=str, dest="name", help="Symbol to look for", required=False + ) + + try: + if other_args: + if "-" not in other_args[0]: + other_args.insert(0, "-n") + + ns_parser = parse_known_args_and_warn(parser, other_args) + + if not ns_parser: + return "" + + if not ns_parser.name: + webbrowser.open("https://stockanalysis.com/etf/") + return "" + + if ns_parser.name.upper() in etf_symbols: + webbrowser.open(f"https://stockanalysis.com/etf/{ns_parser.name.lower()}") + else: + print("ETF symbol not available") + return "" + + except Exception as e: + print(e, "\n") + return "" def name_search(other_args: List[str]):