mirror of
https://github.com/Ichinga-Samuel/aiomql.git
synced 2026-08-19 14:58:07 +00:00
v4
This commit is contained in:
+35
-16
@@ -2,42 +2,61 @@ from aiomql.lib.symbol import Symbol
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
@pytest.fixture(scope="function")
|
||||
def btc_usd():
|
||||
return Symbol(name='BTCUSD')
|
||||
return Symbol(name="BTCUSD")
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
@pytest.fixture(scope="function")
|
||||
async def buy_order(btc_usd):
|
||||
sym = btc_usd
|
||||
sym_info = await sym.mt5.symbol_info(sym.name)
|
||||
dsl = (sym_info.trade_stops_level + sym_info.spread) * 2 * sym_info.point
|
||||
sl = sym_info.ask - dsl
|
||||
tp = sym_info.ask + dsl
|
||||
return {'action': sym.mt5.TRADE_ACTION_DEAL, 'symbol': sym.name, 'volume': sym_info.volume_min,
|
||||
'type': sym.mt5.ORDER_TYPE_BUY, 'price': sym_info.ask, 'sl': sl, 'tp': tp}
|
||||
return {
|
||||
"action": sym.mt5.TRADE_ACTION_DEAL,
|
||||
"symbol": sym.name,
|
||||
"volume": sym_info.volume_min,
|
||||
"type": sym.mt5.ORDER_TYPE_BUY,
|
||||
"price": sym_info.ask,
|
||||
"sl": sl,
|
||||
"tp": tp,
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
@pytest.fixture(scope="function")
|
||||
async def sell_order(btc_usd):
|
||||
sym = btc_usd
|
||||
sym_info = await sym.mt5.symbol_info(sym.name)
|
||||
return {'action': sym.mt5.TRADE_ACTION_DEAL, 'symbol': sym.name, 'volume': sym_info.volume_min,
|
||||
'type': sym.mt5.ORDER_TYPE_SELL, 'price': sym_info.bid}
|
||||
return {
|
||||
"action": sym.mt5.TRADE_ACTION_DEAL,
|
||||
"symbol": sym.name,
|
||||
"volume": sym_info.volume_min,
|
||||
"type": sym.mt5.ORDER_TYPE_SELL,
|
||||
"price": sym_info.bid,
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture(scope='class')
|
||||
@pytest.fixture(scope="class")
|
||||
async def make_buy_sell_orders():
|
||||
sym = Symbol(name='BTCUSD')
|
||||
sym = Symbol(name="BTCUSD")
|
||||
sym_info = await sym.mt5.symbol_info(sym.name)
|
||||
dsl = (sym_info.trade_stops_level + sym_info.spread) * 2 * sym_info.point
|
||||
sl = sym_info.ask - dsl
|
||||
tp = sym_info.ask + dsl
|
||||
req = {'action': sym.mt5.TRADE_ACTION_DEAL, 'symbol': sym.name, 'volume': sym_info.volume_min,
|
||||
'type': sym.mt5.ORDER_TYPE_BUY, 'price': sym_info.ask, 'sl': sl, 'tp': tp}
|
||||
req = {
|
||||
"action": sym.mt5.TRADE_ACTION_DEAL,
|
||||
"symbol": sym.name,
|
||||
"volume": sym_info.volume_min,
|
||||
"type": sym.mt5.ORDER_TYPE_BUY,
|
||||
"price": sym_info.ask,
|
||||
"sl": sl,
|
||||
"tp": tp,
|
||||
}
|
||||
await sym.mt5.order_send(req)
|
||||
req['type'] = sym.mt5.ORDER_TYPE_SELL
|
||||
req['price'] = sym_info.bid
|
||||
req['sl'] = sym_info.bid + dsl
|
||||
req['tp'] = sym_info.bid - dsl
|
||||
req["type"] = sym.mt5.ORDER_TYPE_SELL
|
||||
req["price"] = sym_info.bid
|
||||
req["sl"] = sym_info.bid + dsl
|
||||
req["tp"] = sym_info.bid - dsl
|
||||
await sym.mt5.order_send(req)
|
||||
|
||||
Reference in New Issue
Block a user