def test_delete_pending_order(mt4: MT4Client, symbol: Symbol):
    # create a pending order
    optimistic_buy_price = symbol.tick.ask / 2
    order = mt4.order_send(symbol=symbol,
                           lots=symbol.volume_min,
                           order_type=OrderType.OP_BUYLIMIT,
                           price=optimistic_buy_price)

    # assert that the order was created and is pending
    assert order is not None
    assert order.order_type.is_pending

    # delete the order
    mt4.order_delete(order)
    search_results = [x for x in mt4.orders() if x.ticket == order.ticket]
    assert len(search_results) == 0
    print(f"Pending order # {order.ticket} was deleted.")
def test_close_all_orders(mt4: MT4Client):
    # close/delete all orders
    for order in mt4.orders():
        mt4.order_delete(order, close_if_opened=True)
    assert len(mt4.orders()) == 0