crypto/prt fixes (#3279)

* PRT fixes

* adding error checking

* fixing elif and pylint

Co-authored-by: James Maslek <jmaslek11@gmail.com>
This commit is contained in:
James Simmons
2022-11-03 14:37:43 -04:00
committed by GitHub
parent 2c5787b132
commit 5debfb4d0d
3 changed files with 35 additions and 15 deletions

View File

@@ -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):

View File

@@ -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,

View File

@@ -20,6 +20,8 @@ warnings.simplefilter("ignore")
logger = logging.getLogger(__name__)
# pylint: disable=E1123
@log_start_end(log=logger)
def get_autoets_data(