Skip to content

Commit

Permalink
tests: add explicit test for stake_amount_filled
Browse files Browse the repository at this point in the history
  • Loading branch information
xmatthias committed Nov 5, 2024
1 parent 07f0e38 commit 12ab1cb
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/persistence/test_persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -2683,6 +2683,36 @@ def test_select_filled_orders(fee):
assert len(orders) == 0


@pytest.mark.usefixtures("init_persistence")
def test_select_filled_orders_usdt(fee):
create_mock_trades_usdt(fee)

trades = Trade.get_trades().all()

# Closed buy order, no sell order
orders = trades[0].select_filled_orders("buy")
assert isinstance(orders, list)
assert len(orders) == 1
assert orders[0].amount == 2.0
assert orders[0].filled == 2.0
assert orders[0].side == "buy"
assert orders[0].price == 10.0
assert orders[0].stake_amount == 20
assert orders[0].stake_amount_filled == 20

orders = trades[3].select_filled_orders("buy")
assert isinstance(orders, list)
assert len(orders) == 0
orders = trades[3].select_filled_or_open_orders()
assert isinstance(orders, list)
assert len(orders) == 1
assert orders[0].price == 2.0
assert orders[0].amount == 10
assert orders[0].filled == 0
assert orders[0].stake_amount == 20
assert orders[0].stake_amount_filled == 0


@pytest.mark.usefixtures("init_persistence")
def test_order_to_ccxt(limit_buy_order_open, limit_sell_order_usdt_open):
order = Order.parse_from_ccxt_object(limit_buy_order_open, "mocked", "buy")
Expand Down

0 comments on commit 12ab1cb

Please sign in to comment.