Click or drag to resize

Orders replacement

Orders replacement in the trading algorithms creating is more advanced way than the Orders cancel and the following registration. To replace the order you should call the IConnectorReRegisterOrder(Order, Decimal, Decimal) method or pass the new order object IConnectorReRegisterOrder(Order, Order) at once.

As the result or orders replacement the new Order, object created, which contains old order information plus the changed part. Subsequently, if you want to work with the changed order (for example, to cancel or to change it again), you must use this new Order object.

The following example shows how "to move" the order at the best price:

C#
if (registeredOrder.Security.BestBid != null && registeredOrder.Security.BestAsk != null)
{
    // registeredOrder - successfully registered order.
    var newOrder = registeredOrder.Clone();

    // changing the price to be the best on order book
    newOrder.Price = (registeredOrder.Direction == OrderDirections.Buy ? registeredOrder.Security.BestBid : registeredOrder.Security.BestAsk).Price;

    // sending request the replace our order with new price
    trader.ReRegisterOrder(registeredOrder, newOrder);
}
See Also

Other Resources