fix candle/book exiting if coin wasnt selected

This commit is contained in:
didier
2021-05-03 15:20:51 +01:00
parent cca2f431db
commit b8fa347043
2 changed files with 25 additions and 11 deletions

View File

@@ -73,15 +73,17 @@ def select_binance_coin(other_args: List[str]):
return None, None
def order_book(coin: str, other_args: List[str]):
def order_book(other_args: List[str], coin: str, currency: str):
"""Get order book for currency
Parameters
----------
coin: str
Coin to get order book for
other_args: List[str]
Argparse arguments
coin: str
Coin to get symbol of
currency : str
Currency against which to check symbol
"""
limit_list = [5, 10, 20, 50, 100, 500, 1000, 5000]
parser = argparse.ArgumentParser(
@@ -98,6 +100,12 @@ def order_book(coin: str, other_args: List[str]):
)
try:
if not coin or not currency:
print("Coin needs to be selected prior to this command\n")
return
else:
coin += currency
ns_parser = parse_known_args_and_warn(parser, other_args)
if not ns_parser:
return
@@ -113,16 +121,17 @@ def order_book(coin: str, other_args: List[str]):
print(e, "\n")
def show_candles(coin: str, other_args: List[str]):
def show_candles(other_args: List[str], coin: str, currency: str):
"""Get klines/candles for coin
Parameters
----------
coin: str
Coin to get symbol of
other_args: List[str]
Argparse arguments
coin: str
Coin to get symbol of
currency : str
Currency against which to check symbol
"""
client = Client(cfg.API_BINANCE_KEY, cfg.API_BINANCE_SECRET)
@@ -165,9 +174,16 @@ def show_candles(coin: str, other_args: List[str]):
)
try:
if not coin or not currency:
print("Coin needs to be selected prior to this command\n")
return
else:
coin += currency
ns_parser = parse_known_args_and_warn(parser, other_args)
if not ns_parser:
return
candles = client.get_klines(
symbol=coin,
interval=interval_map[ns_parser.interval],

View File

@@ -115,13 +115,11 @@ class CryptoController:
def call_book(self, other_args):
"""Process book command"""
binance_model.order_book(self.current_coin + self.current_currency, other_args)
binance_model.order_book(other_args, self.current_coin, self.current_currency)
def call_candle(self, other_args):
"""Process candle command"""
binance_model.show_candles(
self.current_coin + self.current_currency, other_args
)
binance_model.show_candles(other_args, self.current_coin, self.current_currency)
def call_balance(self, _):
"""Process balance command"""