def test_modify_pending_order(mt4: MT4Client, symbol: Symbol):
    # create a pending order
    optimistic_buy_price = symbol.tick.ask / 2
    slippage = 1
    sl_points = 100
    tp_points = 100
    order = mt4.order_send(symbol=symbol,
                           lots=symbol.volume_min,
                           order_type=OrderType.OP_BUYLIMIT,
                           price=optimistic_buy_price,
                           slippage=slippage,
                           sl_points=sl_points,
                           tp_points=tp_points)
    original_price = order.open_price

    # lower the price and widen the sl/tp windows
    new_price = original_price * 0.9
    new_points = 100

    # modify order
    order = mt4.order_modify(order=order,
                             price=new_price,
                             sl_points=new_points,
                             tp_points=new_points)
    assert order.open_price < original_price
    assert order.sl < new_price
    assert order.tp > new_price
    print(f"Order open_price/sl/tp: {order.open_price}/{order.sl}/{order.tp}")
def test_modify_open_order(mt4: MT4Client, symbol: Symbol):
    # create a market order
    order = mt4.order_send(symbol=symbol,
                           lots=symbol.volume_min,
                           order_type=OrderType.OP_BUY)

    # add sl/tp stops
    bid = symbol.tick.bid
    points = 200
    sl = bid - points * symbol.point
    tp = bid + points * symbol.point

    # modify order
    order = mt4.order_modify(order=order, sl=sl, tp=tp)
    assert order.sl < bid
    assert order.tp > bid
    print(f"Order open_price/sl/tp: {order.open_price}/{order.sl}/{order.tp}")