@@ -1148,8 +1148,8 @@ class Exchange:
|
|||||||
else:
|
else:
|
||||||
limit_rate = stop_price * (2 - limit_price_pct)
|
limit_rate = stop_price * (2 - limit_price_pct)
|
||||||
|
|
||||||
bad_stop_price = ((stop_price <= limit_rate) if side ==
|
bad_stop_price = ((stop_price < limit_rate) if side ==
|
||||||
"sell" else (stop_price >= limit_rate))
|
"sell" else (stop_price > limit_rate))
|
||||||
# Ensure rate is less than stop price
|
# Ensure rate is less than stop price
|
||||||
if bad_stop_price:
|
if bad_stop_price:
|
||||||
# This can for example happen if the stop / liquidation price is set to 0
|
# This can for example happen if the stop / liquidation price is set to 0
|
||||||
|
|||||||
@@ -3492,14 +3492,22 @@ def test_stoploss_order_unsupported_exchange(default_conf, mocker):
|
|||||||
@pytest.mark.parametrize('side,ratio,expected', [
|
@pytest.mark.parametrize('side,ratio,expected', [
|
||||||
('sell', 0.99, 99.0), # Default
|
('sell', 0.99, 99.0), # Default
|
||||||
('sell', 0.999, 99.9),
|
('sell', 0.999, 99.9),
|
||||||
|
('sell', 1, 100),
|
||||||
|
('sell', 1.1, InvalidOrderException),
|
||||||
('buy', 0.99, 101.0), # Default
|
('buy', 0.99, 101.0), # Default
|
||||||
('buy', 0.999, 100.1),
|
('buy', 0.999, 100.1),
|
||||||
|
('buy', 1, 100),
|
||||||
|
('buy', 1.1, InvalidOrderException),
|
||||||
])
|
])
|
||||||
def test__get_stop_limit_rate(default_conf_usdt, mocker, side, ratio, expected):
|
def test__get_stop_limit_rate(default_conf_usdt, mocker, side, ratio, expected):
|
||||||
exchange = get_patched_exchange(mocker, default_conf_usdt, id='binance')
|
exchange = get_patched_exchange(mocker, default_conf_usdt, id='binance')
|
||||||
|
|
||||||
order_types = {'stoploss_on_exchange_limit_ratio': ratio}
|
order_types = {'stoploss_on_exchange_limit_ratio': ratio}
|
||||||
assert exchange._get_stop_limit_rate(100, order_types, side) == expected
|
if isinstance(expected, type) and issubclass(expected, Exception):
|
||||||
|
with pytest.raises(expected):
|
||||||
|
exchange._get_stop_limit_rate(100, order_types, side)
|
||||||
|
else:
|
||||||
|
assert exchange._get_stop_limit_rate(100, order_types, side) == expected
|
||||||
|
|
||||||
|
|
||||||
def test_merge_ft_has_dict(default_conf, mocker):
|
def test_merge_ft_has_dict(default_conf, mocker):
|
||||||
|
|||||||
Reference in New Issue
Block a user