Skip to content

Commit

Permalink
Added fix (#4710)
Browse files Browse the repository at this point in the history
* Added fix

* Fixed `load`, `find`, `price` and refactored code

* Modified line 1304 in parent_classes.py

---------

Co-authored-by: Danglewood <[email protected]>
Co-authored-by: Henrique Joaquim <[email protected]>
  • Loading branch information
3 people authored Apr 10, 2023
1 parent 8413d30 commit 96d21f7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
27 changes: 10 additions & 17 deletions openbb_terminal/cryptocurrency/crypto_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def call_prt(self, other_args):
help="Coin to compare with",
dest="vs",
type=str,
# required="-h" not in other_args,
required="-h" not in other_args and "--help" not in other_args,
default=None,
)
parser.add_argument(
Expand All @@ -187,11 +187,9 @@ def call_prt(self, other_args):
if other_args and "-" not in other_args[0][0]:
other_args.insert(0, "--vs")

ns_parser = self.parse_known_args_and_warn(
if ns_parser := self.parse_known_args_and_warn(
parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED
)

if ns_parser:
):
if self.symbol:
num_args = 0
for arg in vars(ns_parser):
Expand Down Expand Up @@ -240,7 +238,7 @@ def call_price(self, other_args):
parser.add_argument(
"-s",
"--symbol",
required="-h" not in other_args,
required="-h" not in other_args and "--help" not in other_args,
type=str,
dest="symbol",
help="Symbol of coin to load data for, ~100 symbols are available",
Expand All @@ -250,9 +248,7 @@ def call_price(self, other_args):
if other_args and "-" not in other_args[0][0]:
other_args.insert(0, "-s")

ns_parser = self.parse_known_args_and_warn(parser, other_args)

if ns_parser:
if ns_parser := self.parse_known_args_and_warn(parser, other_args):
upper_symbol = ns_parser.symbol.upper()
if "-USD" not in ns_parser.symbol:
upper_symbol += "-USD"
Expand Down Expand Up @@ -283,10 +279,9 @@ def call_candle(self, other_args):
dest="logy",
)

ns_parser = self.parse_known_args_and_warn(
if ns_parser := self.parse_known_args_and_warn(
parser, other_args, EXPORT_BOTH_RAW_DATA_AND_FIGURES
)
if ns_parser:
):
if not self.symbol:
console.print("No coin loaded. First use `load {symbol}`\n")
return
Expand Down Expand Up @@ -385,11 +380,9 @@ def call_headlines(self, other_args):
)
if other_args and "-" not in other_args[0][0]:
other_args.insert(0, "-c")
ns_parser = self.parse_known_args_and_warn(
if ns_parser := self.parse_known_args_and_warn(
parser, other_args, EXPORT_BOTH_RAW_DATA_AND_FIGURES
)

if ns_parser:
):
finbrain_crypto_view.display_crypto_sentiment_analysis(
symbol=ns_parser.coin, export=ns_parser.export
)
Expand Down Expand Up @@ -474,7 +467,7 @@ def call_find(self, other_args):
"--coin",
help="Symbol Name or Id of Coin",
dest="coin",
required="-h" not in other_args,
required="-h" not in other_args and "--help" not in other_args,
type=str,
)
parser.add_argument(
Expand Down
2 changes: 1 addition & 1 deletion openbb_terminal/parent_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ def call_load(self, other_args):
help="Coin to get. Must be coin symbol (e.g., btc, eth)",
dest="coin",
type=str,
required="-h" not in other_args,
required="-h" not in other_args and "--help" not in other_args,
)

parser.add_argument(
Expand Down

0 comments on commit 96d21f7

Please sign in to comment.