Slightly change test setup for dry_run_order_fill
This commit is contained in:
parent
12e17b80fe
commit
c963fd720b
@ -1207,12 +1207,17 @@ def test_create_dry_run_order_fees(
|
|||||||
assert order1['fee']['rate'] == fee
|
assert order1['fee']['rate'] == fee
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("side,startprice,endprice", [
|
@pytest.mark.parametrize("side,price,filled", [
|
||||||
("buy", 25.563, 25.566),
|
# order_book_l2_usd spread:
|
||||||
("sell", 25.566, 25.563)
|
# best ask: 25.566
|
||||||
|
# best bid: 25.563
|
||||||
|
("buy", 25.563, False),
|
||||||
|
("buy", 25.566, True),
|
||||||
|
("sell", 25.566, False),
|
||||||
|
("sell", 25.563, True),
|
||||||
])
|
])
|
||||||
@pytest.mark.parametrize("exchange_name", EXCHANGES)
|
@pytest.mark.parametrize("exchange_name", EXCHANGES)
|
||||||
def test_create_dry_run_order_limit_fill(default_conf, mocker, side, startprice, endprice,
|
def test_create_dry_run_order_limit_fill(default_conf, mocker, side, price, filled,
|
||||||
exchange_name, order_book_l2_usd):
|
exchange_name, order_book_l2_usd):
|
||||||
default_conf['dry_run'] = True
|
default_conf['dry_run'] = True
|
||||||
exchange = get_patched_exchange(mocker, default_conf, id=exchange_name)
|
exchange = get_patched_exchange(mocker, default_conf, id=exchange_name)
|
||||||
@ -1226,7 +1231,7 @@ def test_create_dry_run_order_limit_fill(default_conf, mocker, side, startprice,
|
|||||||
ordertype='limit',
|
ordertype='limit',
|
||||||
side=side,
|
side=side,
|
||||||
amount=1,
|
amount=1,
|
||||||
rate=startprice,
|
rate=price,
|
||||||
leverage=1.0
|
leverage=1.0
|
||||||
)
|
)
|
||||||
assert order_book_l2_usd.call_count == 1
|
assert order_book_l2_usd.call_count == 1
|
||||||
@ -1235,22 +1240,17 @@ def test_create_dry_run_order_limit_fill(default_conf, mocker, side, startprice,
|
|||||||
assert order["side"] == side
|
assert order["side"] == side
|
||||||
assert order["type"] == "limit"
|
assert order["type"] == "limit"
|
||||||
assert order["symbol"] == "LTC/USDT"
|
assert order["symbol"] == "LTC/USDT"
|
||||||
|
assert order["average"] == price
|
||||||
|
assert order['status'] == 'open' if not filled else 'closed'
|
||||||
order_book_l2_usd.reset_mock()
|
order_book_l2_usd.reset_mock()
|
||||||
|
|
||||||
|
# fetch order again...
|
||||||
order_closed = exchange.fetch_dry_run_order(order['id'])
|
order_closed = exchange.fetch_dry_run_order(order['id'])
|
||||||
assert order_book_l2_usd.call_count == 1
|
assert order_book_l2_usd.call_count == (1 if not filled else 0)
|
||||||
assert order_closed['status'] == 'open'
|
assert order_closed['status'] == ('open' if not filled else 'closed')
|
||||||
assert not order['fee']
|
assert order_closed['filled'] == (0 if not filled else 1)
|
||||||
assert order_closed['filled'] == 0
|
|
||||||
|
|
||||||
order_book_l2_usd.reset_mock()
|
order_book_l2_usd.reset_mock()
|
||||||
order_closed['price'] = endprice
|
|
||||||
|
|
||||||
order_closed = exchange.fetch_dry_run_order(order['id'])
|
|
||||||
assert order_closed['status'] == 'closed'
|
|
||||||
assert order['fee']
|
|
||||||
assert order_closed['filled'] == 1
|
|
||||||
assert order_closed['filled'] == order_closed['amount']
|
|
||||||
|
|
||||||
# Empty orderbook test
|
# Empty orderbook test
|
||||||
mocker.patch('freqtrade.exchange.Exchange.fetch_l2_order_book',
|
mocker.patch('freqtrade.exchange.Exchange.fetch_l2_order_book',
|
||||||
|
Loading…
Reference in New Issue
Block a user