checking params of cancel order and stop loss order
This commit is contained in:
parent
f0cfab7940
commit
12e8108015
@ -657,9 +657,11 @@ class FreqtradeBot(object):
|
|||||||
# the stoploss on exchange checked previously is not hit but
|
# the stoploss on exchange checked previously is not hit but
|
||||||
# it is too late and too risky to cancel the previous stoploss
|
# it is too late and too risky to cancel the previous stoploss
|
||||||
if trade.stop_loss > self.exchange.get_ticker(trade.pair)['bid']:
|
if trade.stop_loss > self.exchange.get_ticker(trade.pair)['bid']:
|
||||||
logger.info('stoploss on exchange update: too risky to update stoploss as '
|
logger.warning(
|
||||||
'current best bid price (%s) is higher than stoploss value (%s)',
|
'stoploss on exchange update: too risky to update stoploss as '
|
||||||
self.exchange.get_ticker(trade.pair)['bid'], trade.stop_loss)
|
'current best bid price (%s) is higher than stoploss value (%s).',
|
||||||
|
self.exchange.get_ticker(trade.pair)['bid'], trade.stop_loss
|
||||||
|
)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
if trade.stop_loss > order['info']['stopPrice']:
|
if trade.stop_loss > order['info']['stopPrice']:
|
||||||
|
@ -1082,13 +1082,18 @@ def test_handle_stoploss_on_exchange_trailing(mocker, default_conf, fee, caplog,
|
|||||||
assert freqtrade.handle_trade(trade) is False
|
assert freqtrade.handle_trade(trade) is False
|
||||||
assert trade.stop_loss == 0.00002344 * 0.95
|
assert trade.stop_loss == 0.00002344 * 0.95
|
||||||
|
|
||||||
mocker.patch('freqtrade.exchange.Exchange.cancel_order', MagicMock(return_value={
|
cancel_order_mock = MagicMock()
|
||||||
"orderId": 100,
|
stoploss_order_mock = MagicMock()
|
||||||
"status": "CANCELED",
|
mocker.patch('freqtrade.exchange.Exchange.cancel_order', cancel_order_mock)
|
||||||
}))
|
mocker.patch('freqtrade.exchange.Exchange.stoploss_limit', stoploss_order_mock)
|
||||||
|
|
||||||
assert freqtrade.handle_stoploss_on_exchange(trade) is False
|
assert freqtrade.handle_stoploss_on_exchange(trade) is False
|
||||||
assert freqtrade.exchange.cancel_order.call_count == 1
|
|
||||||
|
cancel_order_mock.assert_called_once_with(100, 'ETH/BTC')
|
||||||
|
stoploss_order_mock.assert_called_once_with(amount=85.25149190110828,
|
||||||
|
pair='ETH/BTC',
|
||||||
|
rate=0.00002344 * 0.95 * 0.99,
|
||||||
|
stop_price=0.00002344 * 0.95)
|
||||||
|
|
||||||
|
|
||||||
def test_process_maybe_execute_buy(mocker, default_conf) -> None:
|
def test_process_maybe_execute_buy(mocker, default_conf) -> None:
|
||||||
|
Loading…
Reference in New Issue
Block a user