Update Gateio stoploss adjust

This commit is contained in:
Matthias 2022-03-18 10:41:38 +01:00
parent f37038fb7d
commit 0c63c0bbb3
2 changed files with 9 additions and 4 deletions

View File

@ -61,4 +61,5 @@ class Gateio(Exchange):
Verify stop_loss against stoploss-order value (limit or price)
Returns True if adjustment is necessary.
"""
return stop_loss > float(order['stopPrice'])
return ((side == "sell" and stop_loss > float(order['stopPrice'])) or
(side == "buy" and stop_loss < float(order['stopPrice'])))

View File

@ -57,11 +57,15 @@ def test_cancel_stoploss_order_gateio(default_conf, mocker):
assert cancel_order_mock.call_args_list[0][1]['params'] == {'stop': True}
def test_stoploss_adjust_gateio(mocker, default_conf):
@pytest.mark.parametrize('sl1,sl2,sl3,side', [
(1501, 1499, 1501, "sell"),
(1499, 1501, 1499, "buy")
])
def test_stoploss_adjust_gateio(mocker, default_conf, sl1, sl2, sl3, side):
exchange = get_patched_exchange(mocker, default_conf, id='gateio')
order = {
'price': 1500,
'stopPrice': 1500,
}
assert exchange.stoploss_adjust(1501, order)
assert not exchange.stoploss_adjust(1499, order)
assert exchange.stoploss_adjust(sl1, order, side)
assert not exchange.stoploss_adjust(sl2, order, side)