mirror of
https://github.com/Ichinga-Samuel/aiomql.git
synced 2026-08-16 21:38:06 +00:00
v4
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
import logging
|
||||
|
||||
from aiomql.lib.bot import Bot
|
||||
from aiomql.core import Config
|
||||
from aiomql.contrib.strategies import FingerTrap, Chaos
|
||||
from aiomql.contrib.strategies import Chaos
|
||||
from aiomql.contrib.symbols import ForexSymbol
|
||||
|
||||
|
||||
async def test_bot():
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
syms = ['Volatility 75 Index', 'Volatility 100 Index', 'Volatility 50 Index']
|
||||
syms = ['BTCUSD', 'SOLUSD', 'ETHUSD']
|
||||
symbols = [ForexSymbol(name=sym) for sym in syms]
|
||||
stgs = [Chaos(symbol=symbol, name='test_chaos') for symbol in symbols]
|
||||
bot = Bot()
|
||||
@@ -16,9 +15,8 @@ async def test_bot():
|
||||
bot.executor.timeout = 30
|
||||
bot.add_strategies(strategies=stgs)
|
||||
await bot.initialize()
|
||||
await bot.executor.execute()
|
||||
assert bot.executor.no_of_running_strategies == 3
|
||||
assert len(bot.executor.coroutines) == 1
|
||||
assert len(bot.executor.coroutine_threads) == 1
|
||||
assert len(bot.executor.tasks) == 5
|
||||
assert bot.config.shutdown is True
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ from datetime import datetime, UTC
|
||||
from aiomql import TimeFrame
|
||||
from aiomql.contrib.backtesting import BackTestEngine
|
||||
from aiomql.contrib.backtesting.get_data import GetData
|
||||
from aiomql._utils import round_down
|
||||
from aiomql._utils import round_down, round_up
|
||||
from aiomql.core.constants import OrderType, TradeAction
|
||||
|
||||
import pytest
|
||||
@@ -136,8 +136,8 @@ class TestBackTestEngine:
|
||||
tf = TimeFrame.H2
|
||||
start_pos = 2
|
||||
rates = await self.bte.get_rates_from_pos(symbol='BTCUSD', timeframe=tf, start_pos=start_pos, count=24)
|
||||
assert int(rates[-1][0]) == round_down(int(now.replace(hour=7).timestamp()), tf.seconds)
|
||||
assert len(rates) == 24
|
||||
assert int(rates[-1][0]) == round_down(int(now.replace(hour = now.hour - start_pos).timestamp()), tf.seconds)
|
||||
|
||||
async def test_get_rates_from_pos2(self, bte2):
|
||||
now = datetime(2024, 2, 4, 12, 15, tzinfo=UTC)
|
||||
|
||||
@@ -41,9 +41,8 @@ class TestBotFactoryAndExecutor:
|
||||
await asyncio.sleep(1)
|
||||
|
||||
def test_add_workers(self):
|
||||
assert len(self.bot.executor.coroutines) == 2
|
||||
# exit function already added
|
||||
assert len(self.bot.executor.functions) == 2
|
||||
assert len(self.bot.executor.coroutines) == 3
|
||||
assert len(self.bot.executor.functions) == 1
|
||||
# task_queue already added coroutine_thread
|
||||
assert len(self.bot.executor.coroutine_threads) == 2
|
||||
|
||||
|
||||
Reference in New Issue
Block a user