Skip to content

Commit

Permalink
Merge branch 'development' into feat/beaxy
Browse files Browse the repository at this point in the history
  • Loading branch information
ccraighead authored Mar 7, 2021
2 parents 0ba1c59 + 1055c6d commit a095e23
Show file tree
Hide file tree
Showing 67 changed files with 5,334 additions and 196 deletions.
49 changes: 0 additions & 49 deletions .github/ISSUE_TEMPLATE/exchange_request.md

This file was deleted.

20 changes: 18 additions & 2 deletions hummingbot/client/command/balance_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,17 @@ async def show_balances(self):

eth_address = global_config_map["ethereum_wallet"].value
if eth_address is not None:
df = await self.ethereum_balances_df()
lines = [" " + line for line in df.to_string(index=False).split("\n")]
eth_df = await self.ethereum_balances_df()
lines = [" " + line for line in eth_df.to_string(index=False).split("\n")]
self._notify("\nethereum:")
self._notify("\n".join(lines))

# XDAI balances
xdai_df = await self.xdai_balances_df()
lines = [" " + line for line in xdai_df.to_string(index=False).split("\n")]
self._notify("\nxdai:")
self._notify("\n".join(lines))

async def exchange_balances_df(self, # type: HummingbotApplication
exchange_balances: Dict[str, Decimal],
exchange_limits: Dict[str, str]):
Expand Down Expand Up @@ -182,6 +188,16 @@ async def ethereum_balances_df(self, # type: HummingbotApplication
df.sort_values(by=["Asset"], inplace=True)
return df

async def xdai_balances_df(self, # type: HummingbotApplication
):
rows = []
bals = await UserBalances.xdai_balances()
for token, bal in bals.items():
rows.append({"Asset": token, "Amount": round(bal, 4)})
df = pd.DataFrame(data=rows, columns=["Asset", "Amount"])
df.sort_values(by=["Asset"], inplace=True)
return df

async def asset_limits_df(self,
asset_limit_conf: Dict[str, str]):
rows = []
Expand Down
2 changes: 1 addition & 1 deletion hummingbot/client/hummingbot_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def _initialize_markets(self, market_names: List[Tuple[str, List[str]]]):
if conn_setting.use_ethereum_wallet:
ethereum_rpc_url = global_config_map.get("ethereum_rpc_url").value
# Todo: Hard coded this execption for now until we figure out how to handle all ethereum connectors.
if connector_name in ["balancer", "uniswap"]:
if connector_name in ["balancer", "uniswap", "perpetual_finance"]:
private_key = get_eth_wallet_private_key()
init_params.update(wallet_private_key=private_key, ethereum_rpc_url=ethereum_rpc_url)
else:
Expand Down
49 changes: 30 additions & 19 deletions hummingbot/client/ui/completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
DERIVATIVES,
STRATEGIES,
CONF_FILE_PATH,
SCRIPTS_PATH
SCRIPTS_PATH,
ConnectorType
)
from hummingbot.client.ui.parser import ThrowingArgumentParser
from hummingbot.core.utils.wallet_setup import list_wallets
Expand All @@ -28,15 +29,21 @@ def file_name_list(path, file_extension):
return sorted([f for f in listdir(path) if isfile(join(path, f)) and f.endswith(file_extension)])


SPOT_PROTOCOL_CONNECTOR = {x.name for x in CONNECTOR_SETTINGS.values() if x.type == ConnectorType.Connector}
DERIVATIVE_PROTOCOL_CONNECTOR = {x.name for x in CONNECTOR_SETTINGS.values() if x.type == ConnectorType.Derivative and not x.centralised}


class HummingbotCompleter(Completer):
def __init__(self, hummingbot_application):
super(HummingbotCompleter, self).__init__()
self.hummingbot_application = hummingbot_application
self._path_completer = WordCompleter(file_name_list(CONF_FILE_PATH, "yml"))
self._command_completer = WordCompleter(self.parser.commands, ignore_case=True)
self._connector_completer = WordCompleter(CONNECTOR_SETTINGS.keys(), ignore_case=True)
self._exchange_completer = WordCompleter(EXCHANGES, ignore_case=True)
self._exchange_completer = WordCompleter(CONNECTOR_SETTINGS.keys(), ignore_case=True)
self._spot_completer = WordCompleter(EXCHANGES.union(SPOT_PROTOCOL_CONNECTOR), ignore_case=True)
self._spot_exchange_completer = WordCompleter(EXCHANGES, ignore_case=True)
self._derivative_completer = WordCompleter(DERIVATIVES, ignore_case=True)
self._derivative_exchange_completer = WordCompleter(DERIVATIVES.difference(DERIVATIVE_PROTOCOL_CONNECTOR), ignore_case=True)
self._connect_option_completer = WordCompleter(CONNECT_OPTIONS, ignore_case=True)
self._export_completer = WordCompleter(["keys", "trades"], ignore_case=True)
self._balance_completer = WordCompleter(["limit", "paper"], ignore_case=True)
Expand Down Expand Up @@ -96,25 +103,21 @@ def _complete_options(self, document: Document) -> bool:
return "(" in self.prompt_text and ")" in self.prompt_text and "/" in self.prompt_text

def _complete_exchanges(self, document: Document) -> bool:
text_before_cursor: str = document.text_before_cursor
return "-e" in text_before_cursor or \
"--exchange" in text_before_cursor or \
any(x for x in ("exchange name", "name of exchange", "name of the exchange")
return any(x for x in ("exchange name", "name of exchange", "name of the exchange")
if x in self.prompt_text.lower())

def _complete_derivatives(self, document: Document) -> bool:
text_before_cursor: str = document.text_before_cursor
return "--exchange" in text_before_cursor or \
"perpetual" in text_before_cursor or \
any(x for x in ("derivative name", "name of derivative", "name of the derivative")
return "perpetual" in text_before_cursor or \
any(x for x in ("derivative connector", "derivative name", "name of derivative", "name of the derivative")
if x in self.prompt_text.lower())

def _complete_connect_options(self, document: Document) -> bool:
text_before_cursor: str = document.text_before_cursor
return text_before_cursor.startswith("connect ")

def _complete_connectors(self, document: Document) -> bool:
return "connector" in self.prompt_text
def _complete_spot_connectors(self, document: Document) -> bool:
return "spot" in self.prompt_text

def _complete_export_options(self, document: Document) -> bool:
text_before_cursor: str = document.text_before_cursor
Expand Down Expand Up @@ -175,9 +178,13 @@ def get_completions(self, document: Document, complete_event: CompleteEvent):
for c in self._wallet_address_completer.get_completions(document, complete_event):
yield c

elif self._complete_connectors(document):
for c in self._connector_completer.get_completions(document, complete_event):
yield c
elif self._complete_spot_connectors(document):
if "(Exchange/AMM)" in self.prompt_text:
for c in self._spot_completer.get_completions(document, complete_event):
yield c
else:
for c in self._spot_exchange_completer.get_completions(document, complete_event):
yield c

elif self._complete_connect_options(document):
for c in self._connect_option_completer.get_completions(document, complete_event):
Expand All @@ -199,14 +206,18 @@ def get_completions(self, document: Document, complete_event: CompleteEvent):
for c in self._history_completer.get_completions(document, complete_event):
yield c

elif self._complete_derivatives(document):
if "(Exchange/AMM)" in self.prompt_text:
for c in self._derivative_completer.get_completions(document, complete_event):
yield c
else:
for c in self._derivative_exchange_completer.get_completions(document, complete_event):
yield c

elif self._complete_exchanges(document):
for c in self._exchange_completer.get_completions(document, complete_event):
yield c

elif self._complete_derivatives(document):
for c in self._derivative_completer.get_completions(document, complete_event):
yield c

elif self._complete_trading_pairs(document):
for c in self._trading_pair_completer.get_completions(document, complete_event):
yield c
Expand Down
1 change: 1 addition & 0 deletions hummingbot/connector/connector_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
'kucoin': 'green',
'liquid': 'green',
'loopring': 'yellow',
'probit': 'yellow',
'okex': 'green',
'terra': 'green'
}
Expand Down
Loading

0 comments on commit a095e23

Please sign in to comment.