Improve some more tests by adding proper orders
This commit is contained in:
parent
6e691a016d
commit
83cac7bee2
@ -2609,7 +2609,7 @@ def open_trade_usdt():
|
|||||||
pair='ADA/USDT',
|
pair='ADA/USDT',
|
||||||
open_rate=2.0,
|
open_rate=2.0,
|
||||||
exchange='binance',
|
exchange='binance',
|
||||||
open_order_id='123456789',
|
open_order_id='123456789_exit',
|
||||||
amount=30.0,
|
amount=30.0,
|
||||||
fee_open=0.0,
|
fee_open=0.0,
|
||||||
fee_close=0.0,
|
fee_close=0.0,
|
||||||
@ -2634,6 +2634,23 @@ def open_trade_usdt():
|
|||||||
cost=trade.open_rate * trade.amount,
|
cost=trade.open_rate * trade.amount,
|
||||||
order_date=trade.open_date,
|
order_date=trade.open_date,
|
||||||
order_filled_date=trade.open_date,
|
order_filled_date=trade.open_date,
|
||||||
|
),
|
||||||
|
Order(
|
||||||
|
ft_order_side='exit',
|
||||||
|
ft_pair=trade.pair,
|
||||||
|
ft_is_open=True,
|
||||||
|
order_id='123456789_exit',
|
||||||
|
status="open",
|
||||||
|
symbol=trade.pair,
|
||||||
|
order_type="limit",
|
||||||
|
side="sell",
|
||||||
|
price=trade.open_rate,
|
||||||
|
average=trade.open_rate,
|
||||||
|
filled=trade.amount,
|
||||||
|
remaining=0,
|
||||||
|
cost=trade.open_rate * trade.amount,
|
||||||
|
order_date=trade.open_date,
|
||||||
|
order_filled_date=trade.open_date,
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
return trade
|
return trade
|
||||||
|
@ -830,6 +830,8 @@ def test_rpc_force_exit(default_conf, ticker, fee, mocker) -> None:
|
|||||||
assert cancel_order_mock.call_count == 2
|
assert cancel_order_mock.call_count == 2
|
||||||
assert trade.amount == amount
|
assert trade.amount == amount
|
||||||
|
|
||||||
|
trade = Trade.query.filter(Trade.id == '3').first()
|
||||||
|
|
||||||
# make an limit-sell open trade
|
# make an limit-sell open trade
|
||||||
mocker.patch(
|
mocker.patch(
|
||||||
'freqtrade.exchange.Exchange.fetch_order',
|
'freqtrade.exchange.Exchange.fetch_order',
|
||||||
|
@ -2759,6 +2759,8 @@ def test_check_handle_cancelled_exit(
|
|||||||
cancel_order_mock = MagicMock()
|
cancel_order_mock = MagicMock()
|
||||||
limit_sell_order_old.update({"status": "canceled", 'filled': 0.0})
|
limit_sell_order_old.update({"status": "canceled", 'filled': 0.0})
|
||||||
limit_sell_order_old['side'] = 'buy' if is_short else 'sell'
|
limit_sell_order_old['side'] = 'buy' if is_short else 'sell'
|
||||||
|
limit_sell_order_old['id'] = open_trade_usdt.open_order_id
|
||||||
|
|
||||||
patch_exchange(mocker)
|
patch_exchange(mocker)
|
||||||
mocker.patch.multiple(
|
mocker.patch.multiple(
|
||||||
'freqtrade.exchange.Exchange',
|
'freqtrade.exchange.Exchange',
|
||||||
@ -3098,7 +3100,27 @@ def test_handle_cancel_exit_limit(mocker, default_conf_usdt, fee) -> None:
|
|||||||
close_date=arrow.utcnow().datetime,
|
close_date=arrow.utcnow().datetime,
|
||||||
exit_reason="sell_reason_whatever",
|
exit_reason="sell_reason_whatever",
|
||||||
)
|
)
|
||||||
order = {'remaining': 1,
|
trade.orders = [
|
||||||
|
Order(
|
||||||
|
ft_order_side='buy',
|
||||||
|
ft_pair=trade.pair,
|
||||||
|
ft_is_open=True,
|
||||||
|
order_id='123456',
|
||||||
|
status="closed",
|
||||||
|
symbol=trade.pair,
|
||||||
|
order_type="market",
|
||||||
|
side="buy",
|
||||||
|
price=trade.open_rate,
|
||||||
|
average=trade.open_rate,
|
||||||
|
filled=trade.amount,
|
||||||
|
remaining=0,
|
||||||
|
cost=trade.open_rate * trade.amount,
|
||||||
|
order_date=trade.open_date,
|
||||||
|
order_filled_date=trade.open_date,
|
||||||
|
),
|
||||||
|
]
|
||||||
|
order = {'id': "123456",
|
||||||
|
'remaining': 1,
|
||||||
'amount': 1,
|
'amount': 1,
|
||||||
'status': "open"}
|
'status': "open"}
|
||||||
reason = CANCEL_REASON['TIMEOUT']
|
reason = CANCEL_REASON['TIMEOUT']
|
||||||
|
Loading…
Reference in New Issue
Block a user