Don't run refind order on stoploss
This commit is contained in:
parent
977ccaac16
commit
77c28187a6
@ -897,7 +897,9 @@ class FreqtradeBot:
|
||||
except InsufficientFundsError as e:
|
||||
logger.warning(f"Unable to place stoploss order {e}.")
|
||||
# Try to figure out what went wrong
|
||||
self.handle_insufficient_funds(trade)
|
||||
# TODO: test without refinding order logic
|
||||
# TODO: Also reenable the test test_create_stoploss_order_insufficient_funds
|
||||
# self.handle_insufficient_funds(trade)
|
||||
|
||||
except InvalidOrderException as e:
|
||||
trade.stoploss_order_id = None
|
||||
|
@ -1333,42 +1333,42 @@ def test_create_stoploss_order_invalid_order(mocker, default_conf, caplog, fee,
|
||||
assert rpc_mock.call_args_list[1][0][0]['order_type'] == 'market'
|
||||
|
||||
|
||||
def test_create_stoploss_order_insufficient_funds(mocker, default_conf, caplog, fee,
|
||||
limit_buy_order_open, limit_sell_order):
|
||||
sell_mock = MagicMock(return_value={'id': limit_sell_order['id']})
|
||||
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
||||
# def test_create_stoploss_order_insufficient_funds(mocker, default_conf, caplog, fee,
|
||||
# limit_buy_order_open, limit_sell_order):
|
||||
# sell_mock = MagicMock(return_value={'id': limit_sell_order['id']})
|
||||
# freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
||||
|
||||
mock_insuf = mocker.patch('freqtrade.freqtradebot.FreqtradeBot.handle_insufficient_funds')
|
||||
mocker.patch.multiple(
|
||||
'freqtrade.exchange.Exchange',
|
||||
fetch_ticker=MagicMock(return_value={
|
||||
'bid': 0.00001172,
|
||||
'ask': 0.00001173,
|
||||
'last': 0.00001172
|
||||
}),
|
||||
buy=MagicMock(return_value=limit_buy_order_open),
|
||||
sell=sell_mock,
|
||||
get_fee=fee,
|
||||
fetch_order=MagicMock(return_value={'status': 'canceled'}),
|
||||
stoploss=MagicMock(side_effect=InsufficientFundsError()),
|
||||
)
|
||||
patch_get_signal(freqtrade)
|
||||
freqtrade.strategy.order_types['stoploss_on_exchange'] = True
|
||||
# mock_insuf = mocker.patch('freqtrade.freqtradebot.FreqtradeBot.handle_insufficient_funds')
|
||||
# mocker.patch.multiple(
|
||||
# 'freqtrade.exchange.Exchange',
|
||||
# fetch_ticker=MagicMock(return_value={
|
||||
# 'bid': 0.00001172,
|
||||
# 'ask': 0.00001173,
|
||||
# 'last': 0.00001172
|
||||
# }),
|
||||
# buy=MagicMock(return_value=limit_buy_order_open),
|
||||
# sell=sell_mock,
|
||||
# get_fee=fee,
|
||||
# fetch_order=MagicMock(return_value={'status': 'canceled'}),
|
||||
# stoploss=MagicMock(side_effect=InsufficientFundsError()),
|
||||
# )
|
||||
# patch_get_signal(freqtrade)
|
||||
# freqtrade.strategy.order_types['stoploss_on_exchange'] = True
|
||||
|
||||
freqtrade.enter_positions()
|
||||
trade = Trade.query.first()
|
||||
caplog.clear()
|
||||
freqtrade.create_stoploss_order(trade, 200)
|
||||
# stoploss_orderid was empty before
|
||||
assert trade.stoploss_order_id is None
|
||||
assert mock_insuf.call_count == 1
|
||||
mock_insuf.reset_mock()
|
||||
# freqtrade.enter_positions()
|
||||
# trade = Trade.query.first()
|
||||
# caplog.clear()
|
||||
# freqtrade.create_stoploss_order(trade, 200)
|
||||
# # stoploss_orderid was empty before
|
||||
# assert trade.stoploss_order_id is None
|
||||
# assert mock_insuf.call_count == 1
|
||||
# mock_insuf.reset_mock()
|
||||
|
||||
trade.stoploss_order_id = 'stoploss_orderid'
|
||||
freqtrade.create_stoploss_order(trade, 200)
|
||||
# No change to stoploss-orderid
|
||||
assert trade.stoploss_order_id == 'stoploss_orderid'
|
||||
assert mock_insuf.call_count == 1
|
||||
# trade.stoploss_order_id = 'stoploss_orderid'
|
||||
# freqtrade.create_stoploss_order(trade, 200)
|
||||
# # No change to stoploss-orderid
|
||||
# assert trade.stoploss_order_id == 'stoploss_orderid'
|
||||
# assert mock_insuf.call_count == 1
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("init_persistence")
|
||||
|
Loading…
Reference in New Issue
Block a user