This commit is contained in:
Ichinga Samuel
2024-01-18 02:26:27 +01:00
parent 4b5f267509
commit 63f22fc081
43 changed files with 387 additions and 545 deletions
-10
View File
@@ -1,10 +0,0 @@
from aiomql import MetaTrader
import pytest
from .fixtures import *
@pytest.mark.asyncio
class BaseTest:
""""""
mt5 = MetaTrader()
-31
View File
@@ -1,31 +0,0 @@
import json
import os
from aiomql import MetaTrader as mt5, Config
import pytest
@pytest.fixture(scope="session")
def get_default_config():
data = {"win_percentage": 0.90, "record_dir": "Trade Records"}
obj = open('mt5.json', 'w')
json.dump(data, obj)
obj.close()
yield
os.remove('mt5.json')
@pytest.fixture(scope="session")
def get_config():
data = {"win_percentage": 0.8, "record_dir": "Trade_Records"}
obj = open('config.json', 'w')
json.dump(data, obj)
obj.close()
yield
os.remove('config.json')
@pytest.fixture(autouse=True, scope="session")
def init():
config = Config(filename="test_config.json")
mt5._initialize()
mt5._login(login=config.account_number, password=config.password, server=config.server)
-5
View File
@@ -1,5 +0,0 @@
{
"account_number": 160286827,
"password": "TheN@me0fTheW!nd",
"server": "ForexTimeFXTM-Demo01"
}
-13
View File
@@ -1,13 +0,0 @@
from aiomql import config
from . import get_config, get_default_config
def test_default_config_file(get_default_config):
conf = config.Config()
assert conf.win_percentage == 0.90
def test_config_file_name(get_config):
conf = config.Config(filename='config.json')
assert conf.win_percentage == 0.8
-7
View File
@@ -1,7 +0,0 @@
from aiomql import TradeAction
class TestConstants:
def test_trade_action(self):
assert TradeAction.DEAL == 1
View File
-11
View File
@@ -1,11 +0,0 @@
from aiomql.symbol import Symbol
from . import *
class TestSymbol(BaseTest):
sym = Symbol(name="EURJPY")
async def test_init(self):
await self.sym.init()
assert self.sym.select is True
-22
View File
@@ -1,22 +0,0 @@
from . import *
from aiomql import Terminal
class TestTerminal(BaseTest):
terminal = Terminal()
async def test_version(self):
res = await self.terminal.version
assert len(res) == 3
async def test_info(self):
res = await self.terminal.info()
assert res.connected is True
async def test_error(self):
res = await self.terminal.last_error()
assert res.code == 1
async def test_symbols_get(self):
res = await self.terminal.symbols_get()
sym = next(res)
assert isinstance(sym.name, str)