Skip to content

Commit

Permalink
Merge branch 'development' into refactor/remove-bitmax-from-config
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisocana authored Apr 1, 2021
2 parents 4d25aa3 + 95d2cda commit 681ee8b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 26 deletions.
2 changes: 1 addition & 1 deletion hummingbot/client/config/config_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def get_erc20_token_addresses() -> Dict[str, List]:
address_file_path = TOKEN_ADDRESSES_FILE_PATH
token_list = {}

resp = requests.get(token_list_url, timeout=3)
resp = requests.get(token_list_url, timeout=1)
decoded_resp = resp.json()

for token in decoded_resp["tokens"]:
Expand Down
28 changes: 14 additions & 14 deletions hummingbot/connector/exchange/beaxy/beaxy_exchange.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ cdef class BeaxyExchange(ExchangeBase):
tracked_order.last_state = order_update['order_status']

if order_update['filled_size']:
execute_price = Decimal(order_update['limit_price'] if order_update['limit_price'] else order_update['average_price'])
execute_amount_diff = Decimal(order_update['filled_size']) - tracked_order.executed_amount_base
execute_price = Decimal(str(order_update['limit_price'] if order_update['limit_price'] else order_update['average_price']))
execute_amount_diff = Decimal(str(order_update['filled_size'])) - tracked_order.executed_amount_base

# Emit event if executed amount is greater than 0.
if execute_amount_diff > s_decimal_0:
Expand Down Expand Up @@ -398,9 +398,9 @@ cdef class BeaxyExchange(ExchangeBase):
if tracked_order.is_done:
if not tracked_order.is_failure and not tracked_order.is_cancelled:

new_confirmed_amount = Decimal(order_update['size'])
new_confirmed_amount = Decimal(str(order_update['size']))
execute_amount_diff = new_confirmed_amount - tracked_order.executed_amount_base
execute_price = Decimal(order_update['limit_price'] if order_update['limit_price'] else order_update['average_price'])
execute_price = Decimal(str(order_update['limit_price'] if order_update['limit_price'] else order_update['average_price']))

# Emit event if executed amount is greater than 0.
if execute_amount_diff > s_decimal_0:
Expand Down Expand Up @@ -748,8 +748,8 @@ cdef class BeaxyExchange(ExchangeBase):
res = await self._api_request('get', BeaxyConstants.TradingApi.TRADE_SETTINGS_ENDPOINT)
for symbol_data in res['symbols']:
symbol = self.convert_from_exchange_trading_pair(symbol_data['name'])
self._maker_fee_percentage[symbol] = Decimal(symbol_data['maker_fee'])
self._taker_fee_percentage[symbol] = Decimal(symbol_data['taker_fee'])
self._maker_fee_percentage[symbol] = Decimal(str(symbol_data['maker_fee']))
self._taker_fee_percentage[symbol] = Decimal(str(symbol_data['taker_fee']))

self._last_fee_percentage_update_timestamp = current_timestamp
except asyncio.CancelledError:
Expand All @@ -774,8 +774,8 @@ cdef class BeaxyExchange(ExchangeBase):

for balance_entry in account_balances:
asset_name = balance_entry['currency']
available_balance = Decimal(balance_entry['available_balance'])
total_balance = Decimal(balance_entry['total_balance'])
available_balance = Decimal(str(balance_entry['available_balance']))
total_balance = Decimal(str(balance_entry['total_balance']))
self._account_available_balances[asset_name] = available_balance
self._account_balances[asset_name] = total_balance
remote_asset_names.add(asset_name)
Expand Down Expand Up @@ -855,8 +855,8 @@ cdef class BeaxyExchange(ExchangeBase):

for msg in msgs:
asset_name = msg['currency']
available_balance = Decimal(msg['available_balance'])
total_balance = Decimal(msg['total_balance'])
available_balance = Decimal(str(msg['available_balance']))
total_balance = Decimal(str(msg['total_balance']))
self._account_available_balances[asset_name] = available_balance
self._account_balances[asset_name] = total_balance

Expand All @@ -882,8 +882,8 @@ cdef class BeaxyExchange(ExchangeBase):
execute_amount_diff = s_decimal_0

if order_status == 'partially_filled':
order_filled_size = Decimal(order['trade_size'])
execute_price = Decimal(order['trade_price'])
order_filled_size = Decimal(str(order['trade_size']))
execute_price = Decimal(str(order['trade_price']))

execute_amount_diff = order_filled_size - tracked_order.executed_amount_base

Expand Down Expand Up @@ -917,9 +917,9 @@ cdef class BeaxyExchange(ExchangeBase):

elif order_status == 'completely_filled':

new_confirmed_amount = Decimal(order['size'])
new_confirmed_amount = Decimal(str(order['size']))
execute_amount_diff = new_confirmed_amount - tracked_order.executed_amount_base
execute_price = Decimal(order['limit_price'] if order['limit_price'] else order['average_price'])
execute_price = Decimal(str(order['limit_price'] if order['limit_price'] else order['average_price']))

# Emit event if executed amount is greater than 0.
if execute_amount_diff > s_decimal_0:
Expand Down
22 changes: 11 additions & 11 deletions hummingbot/core/utils/trading_pair_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
Any,
Optional,
)
from hummingbot.core.utils.async_utils import safe_gather
from hummingbot.logger import HummingbotLogger
from hummingbot.client.settings import CONNECTOR_SETTINGS, ConnectorType
import logging
import asyncio
import requests

from .async_utils import safe_ensure_future

Expand All @@ -35,6 +35,8 @@ def __init__(self):
safe_ensure_future(self.fetch_all())

async def fetch_all(self):
tasks = []
fetched_connectors = []
for conn_setting in CONNECTOR_SETTINGS.values():
module_name = f"{conn_setting.base_name()}_connector" if conn_setting.type is ConnectorType.Connector \
else f"{conn_setting.base_name()}_api_order_book_data_source"
Expand All @@ -46,15 +48,13 @@ async def fetch_all(self):
module = getattr(importlib.import_module(module_path), class_name)
args = {}
args = conn_setting.add_domain_parameter(args)
safe_ensure_future(self.call_fetch_pairs(module.fetch_trading_pairs(**args), conn_setting.name))
tasks.append(asyncio.wait_for(asyncio.shield(module.fetch_trading_pairs(**args)), timeout=3))
fetched_connectors.append(conn_setting.name)

self.ready = True

async def call_fetch_pairs(self, fetch_fn, exchange_name):
results = await safe_gather(*tasks, return_exceptions=True)
self.trading_pairs = dict(zip(fetched_connectors, results))
# In case trading pair fetching returned timeout, using empty list
try:
self.trading_pairs[exchange_name] = await fetch_fn
except (asyncio.TimeoutError, asyncio.CancelledError, requests.exceptions.RequestException):
self.logger().error(f"Connector {exchange_name} failed to retrieve its trading pairs. "
f"Trading pairs autocompletion won't work.")
self.trading_pairs[exchange_name] = []
for connector, result in self.trading_pairs.items():
if isinstance(result, asyncio.TimeoutError):
self.trading_pairs[connector] = []
self.ready = True
12 changes: 12 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python

from setuptools import setup
from setuptools.command.build_ext import build_ext
from Cython.Build import cythonize
import numpy as np
import os
Expand All @@ -17,6 +18,16 @@
os.environ["CFLAGS"] = "-std=c++11"


# Avoid a gcc warning below:
# cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid
# for C/ObjC but not for C++
class BuildExt(build_ext):
def build_extensions(self):
if '-Wstrict-prototypes' in self.compiler.compiler_so:
self.compiler.compiler_so.remove('-Wstrict-prototypes')
super().build_extensions()


def main():
cpu_count = os.cpu_count() or 8
version = "20210309"
Expand Down Expand Up @@ -165,6 +176,7 @@ def main():
"bin/hummingbot.py",
"bin/hummingbot_quickstart.py"
],
cmdclass={'build_ext': BuildExt},
)


Expand Down

0 comments on commit 681ee8b

Please sign in to comment.