Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
c8b320d
(feat) upgrade dependencies
cardosofede Jun 19, 2023
d4ed15e
(feat) increase timeout for specific test
cardosofede Jun 19, 2023
f0d7a4a
(feat) upgraded python version to 3.10
cardosofede Jun 19, 2023
71f4eeb
(feat) improve event loop management
cardosofede Jun 20, 2023
6861b5d
(feat) upgrade python-telegram-bot version
cardosofede Jun 20, 2023
450a575
(feat) remove support to aiokafka since it wasn't used
cardosofede Jun 20, 2023
c213fdd
(feat) remove unused libraries
cardosofede Jun 20, 2023
f307cd6
(fix) import awaitable from typing
cardosofede Jun 20, 2023
662fb09
(fix) add alias to prevent lineno error
cardosofede Jun 20, 2023
7d3168c
(fix) revert changes on web3 version
cardosofede Jun 20, 2023
3a340e7
(temp) comment security test until final investigation
cardosofede Jun 20, 2023
440f564
(feat) comment bad implemented test in bronze connector
cardosofede Jun 20, 2023
c2b46aa
(feat) comment bad implemented test in bronze connector
cardosofede Jun 20, 2023
a292c19
(feat) update web3 to latest version
cardosofede Jun 20, 2023
f22fbd2
(temp) exclude polkadex from coverage
cardosofede Jun 21, 2023
0ad3ef2
(feat) improve event loops management
cardosofede Jun 21, 2023
e7fd1e9
(feat) use high level asyncio.run method
cardosofede Jun 21, 2023
604bdcc
(temp) comment broken test
cardosofede Jun 21, 2023
240986b
(feat) comment test that were causing issues
cardosofede Jun 21, 2023
cf8c3fa
(feat) comment test that were causing issues
cardosofede Jun 21, 2023
11df0ad
(feat) exclude tests with errors
cardosofede Jun 21, 2023
7749492
(feat) exclude tests of ndax and dexalot
cardosofede Jun 21, 2023
08c7cc8
(feat) skip MQTT test
cardosofede Jun 21, 2023
cf3b922
(feat) improve event loop management
cardosofede Jun 21, 2023
d09beac
(feat) just decrypt the secrets when start
cardosofede Jun 21, 2023
56d64c6
(feat) update asyncssh and pyopenssl to allow usage of management con…
cardosofede Jun 21, 2023
ee76b08
(feat) use asyncio.run
cardosofede Jun 21, 2023
29afe7f
(feat) freeze version of pyopenssl
cardosofede Jun 21, 2023
e1574a9
(feat) update setup.py
cardosofede Jun 22, 2023
7fbebe8
Merge branch 'development' into feat/environment_improvements
nikspz Jun 26, 2023
97fe138
Revert disabled MQTT unittests
TheHolyRoger Jun 26, 2023
c47b855
Fix occasionally failing MQTT unittests
TheHolyRoger Jun 26, 2023
2180590
Merge pull request #1 from TheHolyRoger/feat/environment_improvements
cardosofede Jun 26, 2023
80534e0
Merge branch 'development' into feat/environment_improvements
nikspz Jun 27, 2023
a4453d6
Merge branch 'development' into feat/environment_improvements
nikspz Jun 27, 2023
0bef60f
(feat) revert mqtt test exclusion
cardosofede Jun 27, 2023
5109a9e
(feat) revert changes in event loop management
cardosofede Jun 27, 2023
3aedaff
(feat) revert all test excluded
cardosofede Jun 27, 2023
e093e44
Merge branch 'development' into feat/environment_improvements
cardosofede Jun 27, 2023
ec7ca5a
Revert "(feat) revert changes in event loop management"
cardosofede Jun 27, 2023
373a932
Revert "(feat) revert mqtt test exclusion"
cardosofede Jun 27, 2023
4a4fc61
Update python 3.10 minor version and other dependencies
TheHolyRoger Jun 27, 2023
a110299
Update python
TheHolyRoger Jun 27, 2023
fc5d8ef
Fix creation of asyncio event loop
TheHolyRoger Jun 27, 2023
bf6c435
Revert config security changes
TheHolyRoger Jun 27, 2023
e77b053
Revert cross exchange unittests
TheHolyRoger Jun 27, 2023
bef6091
Increase create unitest timeout
TheHolyRoger Jun 27, 2023
b06f93f
Fix security config unit tests
TheHolyRoger Jun 27, 2023
6626ccc
Fix unittest mock imports
TheHolyRoger Jun 27, 2023
9fed2ec
Fix MQTT unit tests
TheHolyRoger Jun 27, 2023
28ba7a1
Fix MQTT config command
TheHolyRoger Jun 27, 2023
c308b03
MQTT: Add async sleep to clear task queues.
TheHolyRoger Jun 27, 2023
1f7d1df
MQTT: Stop heartbeat thread during stop
TheHolyRoger Jun 27, 2023
1e63720
Fix some more mock imports
TheHolyRoger Jun 28, 2023
86fe992
MQTT: Fix occasional status command failure
TheHolyRoger Jun 28, 2023
f9d3ecb
Merge pull request #2 from TheHolyRoger/fix/env-async
cardosofede Jun 28, 2023
c417c18
Revert other unittest changes
TheHolyRoger Jun 28, 2023
2d0395e
Revert coverage exclusions
TheHolyRoger Jun 28, 2023
1b0e9e7
Increase some unittest timeouts
TheHolyRoger Jun 28, 2023
7897c04
Fix kraken unittests
TheHolyRoger Jun 28, 2023
0e9f180
Fix foxbit unittests
TheHolyRoger Jun 28, 2023
47d2222
Revert amm_arb coverage exclusion
TheHolyRoger Jun 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ test:
--exclude-dir="test/connector" \
--exclude-dir="test/debug" \
--exclude-dir="test/mock" \
--exclude-dir="test/hummingbot/connector/gateway/amm"
--exclude-dir="test/hummingbot/connector/gateway/amm" \
--exclude-dir="test/hummingbot/strategy/uniswap_v3_lp"

run_coverage: test
coverage report
Expand Down
8 changes: 7 additions & 1 deletion bin/hummingbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,13 @@ async def main_async(client_config_map: ClientConfigAdapter):
def main():
chdir_to_data_directory()
secrets_manager_cls = ETHKeyFileSecretManger
ev_loop: asyncio.AbstractEventLoop = asyncio.get_event_loop()

try:
ev_loop: asyncio.AbstractEventLoop = asyncio.get_event_loop()
except Exception:
ev_loop: asyncio.AbstractEventLoop = asyncio.new_event_loop()
asyncio.set_event_loop(ev_loop)

client_config_map = load_client_config_map_from_file()
if login_prompt(secrets_manager_cls, style=load_style(client_config_map)):
ev_loop.run_until_complete(main_async(client_config_map))
Expand Down
8 changes: 7 additions & 1 deletion bin/hummingbot_quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,13 @@ def main():
else:
secrets_manager = secrets_manager_cls(args.config_password)

asyncio.get_event_loop().run_until_complete(quick_start(args, secrets_manager))
try:
ev_loop: asyncio.AbstractEventLoop = asyncio.get_event_loop()
except Exception:
ev_loop: asyncio.AbstractEventLoop = asyncio.new_event_loop()
asyncio.set_event_loop(ev_loop)

ev_loop.run_until_complete(quick_start(args, secrets_manager))


if __name__ == "__main__":
Expand Down
7 changes: 0 additions & 7 deletions conf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
"db": "**REMOVED***",
}

kafka_bootstrap_server = "***REMOVED***"

# whether to enable api mocking in unit test cases
mock_api_enabled = os.getenv("MOCK_API_ENABLED")

Expand Down Expand Up @@ -120,8 +118,3 @@
coinalpha_order_book_api_username = "***REMOVED***"
coinalpha_order_book_api_password = "***REMOVED***"
"""

kafka_2 = {
"bootstrap_servers": "***REMOVED***",
"zookeeper_servers": "***REMOVED***"
}
5 changes: 5 additions & 0 deletions hummingbot/client/command/status_command.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import threading
import time
from collections import OrderedDict, deque
from typing import TYPE_CHECKING, Dict, List
Expand Down Expand Up @@ -121,6 +122,10 @@ def validate_configs(

def status(self, # type: HummingbotApplication
live: bool = False):
if threading.current_thread() != threading.main_thread():
self.ev_loop.call_soon_threadsafe(self.status, live)
return

safe_ensure_future(self.status_check_all(live=live), loop=self.ev_loop)

async def status_check_all(self, # type: HummingbotApplication
Expand Down
1 change: 1 addition & 0 deletions hummingbot/client/config/config_crypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,5 @@ def _create_v3_keyfile_json(message_to_encrypt, password, kdf="pbkdf2", work_fac
'mac': encode_hex_no_prefix(mac),
},
'version': 3,
'alias': '', # Add this line to include the 'alias' field with an empty string value
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@


class FoxbitAPIUserStreamDataSource(UserStreamTrackerDataSource):
_INTERVAL_SLEEP_INTERRUPTION = 5.0

_logger: Optional[HummingbotLogger] = None

Expand Down Expand Up @@ -67,8 +68,9 @@ async def _connected_websocket_assistant(self) -> WSAssistant:
if is_authenticated:
return ws
else:
self.logger().info("Some issue happens when try to subscribe at Foxbit User Stream Data, check your credentials.")
raise
error_message = "Some issue happens when try to subscribe at Foxbit User Stream Data, check your credentials."
self.logger().info(error_message)
raise Exception(error_message)

except Exception as ex:
self.logger().error(
Expand Down Expand Up @@ -120,4 +122,4 @@ async def _subscribe_channels(self,
async def _on_user_stream_interruption(self,
websocket_assistant: Optional[WSAssistant]):
await super()._on_user_stream_interruption(websocket_assistant=websocket_assistant)
await self._sleep(5)
await self._sleep(self._INTERVAL_SLEEP_INTERRUPTION)
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ async def fetch_trading_pairs(cls, throttler: Optional[AsyncThrottler] = None) -

if response.status == 200:
data: Dict[str, Any] = await response.json()
raw_pairs = data.get("result", [])
raw_pairs = data.get("result", {})
converted_pairs: List[str] = []
for pair, details in raw_pairs.items():
if "." not in pair:
Expand Down
11 changes: 0 additions & 11 deletions hummingbot/connector/exchange/loopring/loopring_order_book.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ from typing import (
)

import ujson
from aiokafka import ConsumerRecord

from hummingbot.connector.exchange.loopring.loopring_order_book_message import LoopringOrderBookMessage
from hummingbot.core.data_type.common import TradeType
Expand Down Expand Up @@ -58,16 +57,6 @@ cdef class LoopringOrderBook(OrderBook):
"amount": msg[3]
}, timestamp=ts * 1e-3)

@classmethod
def snapshot_message_from_kafka(cls, record: ConsumerRecord, metadata: Optional[Dict] = None) -> OrderBookMessage:
msg = ujson.loads(record.value.decode())
return LoopringOrderBookMessage(OrderBookMessageType.SNAPSHOT, msg, timestamp=record.timestamp * 1e-3)

@classmethod
def diff_message_from_kafka(cls, record: ConsumerRecord, metadata: Optional[Dict] = None) -> OrderBookMessage:
msg = ujson.loads(record.value.decode())
return LoopringOrderBookMessage(OrderBookMessageType.DIFF, msg)

@classmethod
def from_snapshot(cls, snapshot: OrderBookMessage):
raise NotImplementedError("loopring order book needs to retain individual order data.")
Expand Down
9 changes: 0 additions & 9 deletions hummingbot/core/data_type/order_book.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ from typing import (

import numpy as np
import pandas as pd
from aiokafka import ConsumerRecord

from cython.operator cimport(
address as ref,
Expand Down Expand Up @@ -476,14 +475,6 @@ cdef class OrderBook(PubSub):
def get_quote_volume_for_price(self, is_buy: bool, price: float) -> OrderBookQueryResult:
return self.c_get_quote_volume_for_price(is_buy, price)

@classmethod
def snapshot_message_from_kafka(cls, record: ConsumerRecord, metadata: Optional[Dict] = None) -> OrderBookMessage:
pass

@classmethod
def diff_message_from_kafka(cls, record: ConsumerRecord, metadata: Optional[Dict] = None) -> OrderBookMessage:
pass

def restore_from_snapshot_and_diffs(self, snapshot: OrderBookMessage, diffs: List[OrderBookMessage]):
replay_position = bisect.bisect_right(diffs, snapshot)
replay_diffs = diffs[replay_position:]
Expand Down
17 changes: 8 additions & 9 deletions hummingbot/core/utils/async_call_scheduler.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
#!/usr/bin/env python

import asyncio
from async_timeout import timeout
import logging
from typing import (
Optional,
Coroutine,
NamedTuple,
Callable
)
from typing import Callable, Coroutine, NamedTuple, Optional

from async_timeout import timeout

import hummingbot
from hummingbot.logger import HummingbotLogger
from hummingbot.core.utils.async_utils import safe_ensure_future
from hummingbot.logger import HummingbotLogger


class AsyncCallSchedulerItem(NamedTuple):
Expand Down Expand Up @@ -42,7 +38,7 @@ def __init__(self, call_interval: float = 0.01):
self._coro_queue: asyncio.Queue = asyncio.Queue()
self._coro_scheduler_task: Optional[asyncio.Task] = None
self._call_interval: float = call_interval
self._ev_loop: asyncio.AbstractEventLoop = asyncio.get_event_loop()
self.reset_event_loop()

@property
def coro_queue(self) -> asyncio.Queue:
Expand All @@ -56,6 +52,9 @@ def coro_scheduler_task(self) -> Optional[asyncio.Task]:
def started(self) -> bool:
return self._coro_scheduler_task is not None

def reset_event_loop(self):
self._ev_loop: asyncio.AbstractEventLoop = asyncio.get_event_loop()

def start(self):
if self._coro_scheduler_task is not None:
self.stop()
Expand Down
12 changes: 10 additions & 2 deletions hummingbot/remote_iface/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,11 @@ def _on_cmd_config(self, msg: ConfigCommandMessage.Request):
invalid_params = []
for param in msg.params:
if param[0] in self._hb_app.configurable_keys():
self._hb_app.config(param[0], param[1])
self._ev_loop.call_soon_threadsafe(
self._hb_app.config,
param[0],
param[1]
)
response.changes.append((param[0], param[1]))
else:
invalid_params.append(param[0])
Expand Down Expand Up @@ -285,7 +289,9 @@ def _on_cmd_status(self, msg: StatusCommandMessage.Request):
response.msg = 'No strategy is currently running!'
return response
if msg.async_backend:
self._hb_app.status()
self._ev_loop.call_soon_threadsafe(
self._hb_app.status
)
else:
res = call_sync(
self._hb_app.strategy_status(),
Expand Down Expand Up @@ -849,6 +855,8 @@ def start(self, with_health: bool = True) -> None:
def stop(self, with_health: bool = True):
self.broadcast_status_update("offline", msg_type="availability")
super().stop()
if self._hb_thread:
self._hb_thread.stop()
self._remove_status_updates()
self._remove_notifier()
self._remove_log_handlers()
Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,18 @@ def main():
"0x-order-utils",
"aioconsole",
"aiohttp",
"aiokafka",
"asyncssh",
"appdirs",
"appnope",
"async-timeout",
"bidict",
"base58",
"cachetools",
"certifi",
"cryptography",
"cython",
"cytoolz",
"commlib-py",
"docker",
"diff-cover",
"dydx-python",
Expand All @@ -71,6 +73,7 @@ def main():
"flake8",
"hexbytes",
"importlib-metadata",
"injective-py"
"mypy-extensions",
"nose",
"nose-exclude",
Expand All @@ -85,6 +88,7 @@ def main():
"pyperclip",
"python-dateutil",
"python-telegram-bot",
"pyOpenSSL",
"requests",
"rsa",
"ruamel-yaml",
Expand Down
35 changes: 17 additions & 18 deletions setup/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,36 @@ dependencies:
- nomkl=1.0
- nose=1.3.7
- nose-exclude
- numpy=1.20.1
- numpy-base=1.20.1
- pandas=1.2.1
- pip=21.1.2
- numpy=1.23.5
- numpy-base=1.23.5
- pandas=1.5.3
- pip=23.1.2
- prompt_toolkit=3.0.20
- pydantic=1.9
- pytables=3.6.1
- python=3.8.2
- scipy=1.6.2
- sqlalchemy=1.4
- pydantic=1.9.2
- pytest==7.3.2
- python=3.10.12
- pytables=3.8.0
- scipy=1.10.1
- tabulate==0.8.9
- typing-extensions<4.6.0
- ujson=1.35
- zlib=1.2.11
- zlib=1.2.13
- pip:
- 0x-contract-addresses==3.0.0
- 0x-contract-wrappers==2.0.0
- 0x-order-utils==4.0.0
- aiohttp==3.*
- aiokafka==0.7.1
- aioprocessing==2.0.0
- aioresponses
- appdirs==1.4.3
- async-timeout
- asyncssh==2.7.2
- asyncssh==2.13.1
- pyOpenSSL==21.0.0
- appnope==0.1.3
- base58==2.1.1
- cachetools==4.0.0
- commlib-py==0.10.6
- cryptography==3.4.7
- cython==3.0a7
- cython==3.0.0a10
- diff-cover==5.1.2
- docker==5.0.3
- dydx-v3-python==2.0.1
Expand All @@ -56,15 +55,15 @@ dependencies:
- ptpython==3.0.20
- pyjwt==1.7.1
- pyperclip==1.7.0
- pytest==4.6.11
- python-telegram-bot==12.4.2
- python-telegram-bot==12.8
- requests==2.*
- rsa==4.7
- ruamel-yaml==0.16.10
- signalr-client-aio==0.0.1.6.2
- simplejson==3.17.2
- sqlalchemy==1.4.*
- substrate-interface==1.6.2
- solders==0.1.4
- web3==5.*
- web3==5.31.4
- websockets==9.1
- ujson==5.7.0
- git+https://github.com/CoinAlpha/python-signalr-client.git
3 changes: 1 addition & 2 deletions test/hummingbot/client/command/test_config_command.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import asyncio
import unittest
from collections import Awaitable
from decimal import Decimal
from test.mock.mock_cli import CLIMockingAssistant
from typing import Union
from typing import Awaitable, Union
from unittest.mock import MagicMock, patch

from pydantic import Field
Expand Down
2 changes: 1 addition & 1 deletion test/hummingbot/client/command/test_create_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async def async_sleep(*_, **__):

return async_sleep

def async_run_with_timeout(self, coroutine: Awaitable, timeout: float = 1):
def async_run_with_timeout(self, coroutine: Awaitable, timeout: float = 5):
ret = self.ev_loop.run_until_complete(asyncio.wait_for(coroutine, timeout))
return ret

Expand Down
2 changes: 1 addition & 1 deletion test/hummingbot/client/command/test_order_book_command.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import asyncio
import unittest
from collections import Awaitable
from typing import Awaitable
from unittest.mock import MagicMock, patch

from hummingbot.client.config.client_config_map import ClientConfigMap, DBSqliteMode
Expand Down
2 changes: 1 addition & 1 deletion test/hummingbot/client/command/test_ticker_command.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import asyncio
import unittest
from collections import Awaitable
from typing import Awaitable
from unittest.mock import MagicMock, patch

from hummingbot.client.config.client_config_map import ClientConfigMap, DBSqliteMode
Expand Down
Loading