formatting fixes round 1

This commit is contained in:
Jamie
2021-05-02 16:03:15 -04:00
parent ae64ad88fa
commit 7f7cec8451
3 changed files with 30 additions and 32 deletions

View File

@@ -10,8 +10,8 @@ This menu aims to explore crypto world, and the usage of the following commands
* show the top 7 coins from coingecko
* [top](#top)
* view top coins from coinmarketcap [coinmarketcap.com]
* [add](#add)
* add a coin/currency pair for Binance
* [select](#select)
* select a coin/currency pair for Binance
* [book](#book)
* get and show market (order) book
@@ -68,17 +68,17 @@ This command displays the top n cryptocurrencies from coinmarketcap.com.
<img width="990" alt="crypto" src="https://user-images.githubusercontent.com/25267873/115787544-4746d100-a3ba-11eb-9433-b7cb9142404a.png">
## add <a name="add"></a>
Add a coin/currency to the current object. Note that in binance, the exchange "ticker" is usually COINCURR, such as BTCEUR
## select <a name="select"></a>
Select a coin/currency to the current object. Note that in binance, the exchange "ticker" is usually COINCURR, such as BTCEUR
for BTC to EURO. There is no USD, but it uses a coin tethered to the USD (USDT), which is the default. Some symbols
are a combination of coins, as `ETHBTC` is a valid symbol
````
usage: add [-c --coin] [-q --quote]
usage: select [-c --coin] [-q --quote]
````
* -c/--coin Coin to load. If not specified, BTC will be loaded to prevent errors later.
* -q/--quote Quote currency. Defaults to `USDT` (which is 1-to-1 with USD)
Note that the usage `load btc` will also work, as it will add `-c` if not detected.
Note that the usage `select btc` will also work, as it will add `-c` if not detected.
## book <a name="book"></a>
Gets and shows the order book for the given coin/currency. Shows the cumulative amount of orders.

View File

@@ -25,11 +25,10 @@ def check_valid_binance_str(symbol: str) -> str :
# pylint: disable=inconsistent-return-statements
def add_binance_coin(other_args: List[str]):
def select_binance_coin(other_args: List[str]):
"""
Define current_coin from binance
Parameters
----------
other_args: List[str]
@@ -41,7 +40,7 @@ def add_binance_coin(other_args: List[str]):
Coin that is defined on binance
"""
parser = argparse.ArgumentParser(
prog="add_coin",
prog="select",
add_help=False,
description="Define the coin to be used from binance",
)
@@ -66,17 +65,18 @@ def add_binance_coin(other_args: List[str]):
coin = ns_parser.coin + ns_parser.quote
if check_valid_binance_str(coin):
print(f"{ns_parser.coin.upper()} loaded vs {ns_parser.quote.upper()}")
return ns_parser.coin.upper(), ns_parser.quote.upper()
except Exception as e:
print(e)
print("")
print(e, "\n")
return None, None
def order_book(coin: str, other_args: List[str]):
"""
Get order book for currency
Parameters
----------
coin: str
@@ -115,13 +115,13 @@ def order_book(coin: str, other_args: List[str]):
plot_order_book(bids, asks, coin)
except Exception as e:
print(e)
print("")
print(e, "\n")
def show_candles(coin: str, other_args: List[str]):
"""
Get klines/candles for coin
Parameters
----------
coin: str
@@ -219,13 +219,13 @@ def show_candles(coin: str, other_args: List[str]):
)
except Exception as e:
print(e)
print("")
print(e, "\n")
def balance(coin: str):
"""
Get account holdings for asset
Parameters
----------
coin: str
@@ -248,6 +248,5 @@ def balance(coin: str):
print("")
return
except Exception as e:
print(e)
print("")
print(e, "\n")
return

View File

@@ -29,7 +29,7 @@ class CryptoController:
"trades",
"candle",
"balance",
"add",
"select",
]
def __init__(self):
@@ -59,7 +59,7 @@ class CryptoController:
print(" top view top coins from coinmarketcap")
print("")
print("Binance:")
print(" add add coin as current")
print(" select select coin/currency to use")
print(" book show order book")
print(" candle get klines/candles and plot")
print(" balance show coin balance")
@@ -94,11 +94,11 @@ class CryptoController:
return True
def call_load(self, other_args):
"""Load command - get df from gecko"""
"""Process load command"""
self.current_coin, self.current_df = pycoingecko_view.load(other_args)
def call_view(self, other_args):
"""View command - plot loaded coin"""
"""Process view command"""
if self.current_coin:
pycoingecko_view.view(self.current_coin, self.current_df, other_args)
@@ -107,39 +107,38 @@ class CryptoController:
print("")
def call_trend(self, _):
"""Trend command - show top 7 gecko coins"""
"""Process trend command"""
pycoingecko_view.trend()
def call_top(self, other_args):
"""Top command - get top n coins from coinmarketcap"""
"""Process top command"""
cmc_view.get_cmc_top_n(other_args)
def call_book(self, other_args):
"""Book command - get order book from binance"""
"""Process book command"""
binance_model.order_book(self.current_coin + self.current_currency, other_args)
def call_candle(self, other_args):
"""Candle command - show candle chart from binance"""
"""Process candle command"""
binance_model.show_candles(
self.current_coin + self.current_currency, other_args
)
def call_balance(self, _):
"""Balance command - check current holdings of coin in binance"""
"""Process balance command"""
binance_model.balance(self.current_coin)
def call_add(self, other_args):
"""Add command - set current coin for binance operations"""
self.current_coin, self.current_currency = binance_model.add_binance_coin(
def call_select(self, other_args):
"""Process select command"""
self.current_coin, self.current_currency = binance_model.select_binance_coin(
other_args
)
print(f"{self.current_coin} loaded vs {self.current_currency}")
print("")
def menu():
crypto_controller = CryptoController()
crypto_controller.print_help(crypto_controller)
crypto_controller.print_help(None)
plt.close("all")
while True:
# Get input command from user