When you place a new order using the API, the order id number must be greater than the previously used numbers. For example, if you place an order with an Order ID of 11, the next order you place should have an Order ID of at least 12. So when you place a new order, the order id must be greater than the previously used order id number.
In this example, a user is going to place two orders for IBM stock. The first order is a BUY order for 200 shares and set the limit price to $85.25. The second order will be an order to sell 100 shares with the limit price set to $84.25.
In this example, the first order is tagged with an Order ID of 1:
.placeOrder(1, IBM, BUY, $85.25, 200…)
Now, user can place a second order. This order is assigned an Order ID of 2:
.placeOrder(2, IBM, SELL, $84.25, 100…)
To modify an order using the API, resubmit the order you want to modify using the same order id, but with the price or quantity modified as required. Only certain fields such as price or quantity can be altered using this method. If you want to change the order type or action, you will have to cancel the order and submit a new order.
In this example, a user initially decides to buy 100 shares and sets the limit price to $85.25. Then, customer wants to modify the same order and change the limit price to $86.25. Note that the first order is assigned an Order ID of 3:
.placeOrder(3, IBM, BUY, $85.25, 100…)
You can now modify the limit price for this order by calling the same .placeOrder method and using the same Order ID of 3, with the limit price modified to $86.25
.placeOrder(3, IBM, BUY, $86.25, 100…)