mirror of
https://github.com/Ichinga-Samuel/aiomql.git
synced 2026-08-01 22:37:46 +00:00
v4.0.9
This commit is contained in:
@@ -4,17 +4,20 @@ from aiomql.lib.bot import Bot
|
||||
from aiomql.contrib.strategies import Chaos
|
||||
from aiomql.contrib.symbols import ForexSymbol
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
async def test_bot():
|
||||
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
|
||||
syms = ["BTCUSD", "SOLUSD", "ETHUSD"]
|
||||
symbols = [ForexSymbol(name=sym) for sym in syms]
|
||||
strategies = [Chaos(symbol=symbol, name="test_chaos") for symbol in symbols]
|
||||
strategies = [Chaos(symbol=symbol, name="test_chaos", params={"interval": 3}) for symbol in symbols]
|
||||
bot = Bot()
|
||||
bot.executor.timeout = 5
|
||||
bot.executor.timeout = 10
|
||||
bot.add_strategies(strategies=strategies)
|
||||
await bot.initialize()
|
||||
bot.executor.execute()
|
||||
assert len(bot.executor.coroutines) == 1
|
||||
assert len(bot.executor.coroutine_threads) == 1
|
||||
assert len(bot.executor.strategy_runners) == 3
|
||||
|
||||
assert bot.config.shutdown is True
|
||||
|
||||
@@ -9,9 +9,8 @@ def test_bot_sync():
|
||||
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
|
||||
syms = ["BTCUSD", "SOLUSD", "ETHUSD"]
|
||||
symbols = [ForexSymbol(name=sym) for sym in syms]
|
||||
strategies = [Chaos(symbol=symbol, name="test_chaos") for symbol in symbols]
|
||||
strategies = [Chaos(symbol=symbol, name="test_chaos", params={"interval": 3}) for symbol in symbols]
|
||||
bot = Bot()
|
||||
bot.config.task_queue.worker_timeout = 2
|
||||
bot.executor.timeout = 10
|
||||
bot.add_strategies(strategies=strategies)
|
||||
bot.initialize_sync()
|
||||
|
||||
@@ -6,7 +6,7 @@ from aiomql.core.task_queue import TaskQueue, QueueItem
|
||||
class TestTaskQueue:
|
||||
@classmethod
|
||||
def setup_class(cls):
|
||||
cls.task_queue = TaskQueue(timeout=5, worker_timeout=1)
|
||||
cls.task_queue = TaskQueue(absolute_timeout=6, worker_timeout=1)
|
||||
cls.data = {}
|
||||
|
||||
async def task_one(self):
|
||||
@@ -27,14 +27,10 @@ class TestTaskQueue:
|
||||
async def test_queue(self):
|
||||
item_one = QueueItem(self.task_one)
|
||||
self.task_queue.add(item=item_one, must_complete=False)
|
||||
assert len(self.task_queue.priority_tasks) == 0
|
||||
assert self.task_queue.queue.qsize() == 1
|
||||
self.task_queue.add(item=QueueItem(self.task_two), must_complete=True)
|
||||
assert len(self.task_queue.priority_tasks) == 1
|
||||
assert self.task_queue.queue.qsize() == 2
|
||||
self.task_queue.add(item=QueueItem(self.task_three), must_complete=False)
|
||||
await self.task_queue.run()
|
||||
assert len(self.data["task_one"]) >= 2
|
||||
assert len(self.data["task_two"]) == 10
|
||||
assert len(self.data["task_three"]) == 1
|
||||
assert len(self.task_queue.priority_tasks) == 0
|
||||
|
||||
Reference in New Issue
Block a user