Click or drag to resize
Cancel Order Example

Note: This is preliminary documentation provided only as a preview, and is subject to change. Please contact the author for pricing and licensing information.

This topic demonstrates how an order can be canceled.

  1. Import the following namespace:

    C#
    using ETradeNet.Order;
  2. Implement the following method:

    C#
    async Task<string> CancelOrderAsync(string accountId, string orderId, IOrderInitializer init)
    {
        using (var order = new OrderService(init))
        {
            var response = await order.CancelAsync(accountId, orderId);
            return response.CancelResponse.ResultMessage;
        }
    }
We recommend that you accommodate for cancellation by passing a CancellationToken wherever possible (i.e., in all calls that don't result in a Stream). The example above only omits it for clarity.
See Also