|
|
|
|
@ -1371,6 +1371,59 @@ def test_create_dry_run_order_limit_fill(
|
|
|
|
|
order_closed = exchange.fetch_dry_run_order(order["id"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
|
"side,price,error",
|
|
|
|
|
[
|
|
|
|
|
# order_book_l2_usd spread:
|
|
|
|
|
# best ask: 25.566
|
|
|
|
|
# best bid: 25.563
|
|
|
|
|
("sell", 22.0, False),
|
|
|
|
|
("sell", 25.55, False),
|
|
|
|
|
("sell", 26.00, True),
|
|
|
|
|
("buy", 30.0, False),
|
|
|
|
|
("buy", 25.57, False),
|
|
|
|
|
("buy", 22.57, True),
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
@pytest.mark.parametrize("exchange_name", EXCHANGES)
|
|
|
|
|
def test_create_dry_run_order_stoploss(
|
|
|
|
|
default_conf_usdt,
|
|
|
|
|
mocker,
|
|
|
|
|
exchange_name,
|
|
|
|
|
order_book_l2_usd,
|
|
|
|
|
side,
|
|
|
|
|
price,
|
|
|
|
|
error,
|
|
|
|
|
):
|
|
|
|
|
default_conf_usdt["dry_run"] = True
|
|
|
|
|
exchange = get_patched_exchange(mocker, default_conf_usdt, exchange=exchange_name)
|
|
|
|
|
if not exchange.get_option("stoploss_on_exchange"):
|
|
|
|
|
pytest.skip(f"{exchange_name} does not support on exchange stoploss orders")
|
|
|
|
|
|
|
|
|
|
mocker.patch.multiple(
|
|
|
|
|
EXMS,
|
|
|
|
|
exchange_has=MagicMock(return_value=True),
|
|
|
|
|
fetch_l2_order_book=order_book_l2_usd,
|
|
|
|
|
)
|
|
|
|
|
params = {
|
|
|
|
|
"pair": "LTC/USDT",
|
|
|
|
|
"amount": 1,
|
|
|
|
|
"stop_price": price,
|
|
|
|
|
"order_types": {"stoploss": "limit"},
|
|
|
|
|
"side": side,
|
|
|
|
|
"leverage": 1.0,
|
|
|
|
|
}
|
|
|
|
|
if not error:
|
|
|
|
|
order = exchange.create_stoploss(**params)
|
|
|
|
|
assert isinstance(order, dict)
|
|
|
|
|
assert order.get("ft_order_type") == "stoploss"
|
|
|
|
|
assert order["status"] == "open"
|
|
|
|
|
# assert order["price"] == price
|
|
|
|
|
else:
|
|
|
|
|
with pytest.raises(InvalidOrderException, match=r".*Stoploss would trigger immediately.*"):
|
|
|
|
|
exchange.create_stoploss(**params)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
|
|
|
"side,rate,amount,endprice",
|
|
|
|
|
[
|
|
|
|
|
|