Skip to content

Commit

Permalink
Fix new api update from binance
Browse files Browse the repository at this point in the history
  • Loading branch information
mlguys committed Apr 25, 2024
1 parent c6354bc commit 034584c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 14 additions & 1 deletion hummingbot/connector/exchange/binance/binance_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,20 @@ def is_exchange_information_valid(exchange_info: Dict[str, Any]) -> bool:
:param exchange_info: the exchange information for a trading pair
:return: True if the trading pair is enabled, False otherwise
"""
return exchange_info.get("status", None) == "TRADING" and "SPOT" in exchange_info.get("permissions", list())
is_spot = False
is_trading = False

if exchange_info.get("status", None) == "TRADING":
is_trading = True

permissions_sets = exchange_info.get("permissionSets", list())
for permission_set in permissions_sets:
# PermissionSet is a list, find if in this list we have "SPOT" value or not
if "SPOT" in permission_set:
is_spot = True
break

return is_trading and is_spot


class BinanceConfigMap(BaseConnectorConfigMap):
Expand Down
4 changes: 2 additions & 2 deletions hummingbot/core/rate_oracle/sources/binance_rate_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async def get_prices(self, quote_token: Optional[str] = None) -> Dict[str, Decim
results = {}
tasks = [
self._get_binance_prices(exchange=self._binance_exchange),
self._get_binance_prices(exchange=self._binance_us_exchange, quote_token="USD"),
# self._get_binance_prices(exchange=self._binance_us_exchange, quote_token="USD"),
]
task_results = await safe_gather(*tasks, return_exceptions=True)
for task_result in task_results:
Expand All @@ -43,7 +43,7 @@ async def get_prices(self, quote_token: Optional[str] = None) -> Dict[str, Decim
def _ensure_exchanges(self):
if self._binance_exchange is None:
self._binance_exchange = self._build_binance_connector_without_private_keys(domain="com")
self._binance_us_exchange = self._build_binance_connector_without_private_keys(domain="us")
# self._binance_us_exchange = self._build_binance_connector_without_private_keys(domain="us")

@staticmethod
async def _get_binance_prices(exchange: 'BinanceExchange', quote_token: str = None) -> Dict[str, Decimal]:
Expand Down

0 comments on commit 034584c

Please sign in to comment.