mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
parent
4a800fe467
commit
5844756ba1
|
@ -1148,8 +1148,8 @@ class Exchange:
|
|||
else:
|
||||
limit_rate = stop_price * (2 - limit_price_pct)
|
||||
|
||||
bad_stop_price = ((stop_price <= limit_rate) if side ==
|
||||
"sell" else (stop_price >= limit_rate))
|
||||
bad_stop_price = ((stop_price < limit_rate) if side ==
|
||||
"sell" else (stop_price > limit_rate))
|
||||
# Ensure rate is less than stop price
|
||||
if bad_stop_price:
|
||||
# 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', [
|
||||
('sell', 0.99, 99.0), # Default
|
||||
('sell', 0.999, 99.9),
|
||||
('sell', 1, 100),
|
||||
('sell', 1.1, InvalidOrderException),
|
||||
('buy', 0.99, 101.0), # Default
|
||||
('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):
|
||||
exchange = get_patched_exchange(mocker, default_conf_usdt, id='binance')
|
||||
|
||||
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):
|
||||
|
|
Loading…
Reference in New Issue
Block a user