As a trader, if you are using the IBKR API, you should know how to place an order. Placing an order is the primary purpose of using the IBKR API. It is necessary to set the order attributes by choosing various fields before sending an order. Interactive Brokers connects you to more than 100 stock markets around the world and offers a large variety of orders you can place on its platform. All the orders you place using the API can be placed using TWS. You can place various orders using TWS, ranging from simple orders to IB Algos and bracket orders.
When you want to place a complex order, you should see if you can send it by TWS or not. TWS informs us about the validity of the order by showing a gray order type, or it does not show the order. After getting the order ID, the contract object, and the order object, you can invoke place order. When TWS receives a valid order, it will notify you using messages about order status or execution details.
Open Order: After you place an order, the open order method informs us about the details of the order, like contract details. You can also see the orderState object, which shows the commission, initial margin, and maintenance margin. When you submit a valid order, the order status is shown.
Order Execution: You will find execution details after an order executes. These details will be shown only as a summary. You will receive information about the order ID, the execution ID, and other relevant information. You will see various callbacks for execution details if you receive more than one fill. Every callback will show information about the order ID, which is different from the API order ID. The executed order shows you the number of executed shares. You will be informed about the liquidity status of the executed shares.
Modify orders: If you want to change your order, you can return to your order object and edit it. The changes will be saved in your original order. If you placed an order manually through TWS, you should be connected using client ID 0, and then you should bind the order before changing it. This will give the order an API order ID. If you are connecting to TWS during another session, you must bind the order with client ID 0, just as manual TWS orders are bound before they can be modified.
Cancel Order: If you decide to cancel an order from the API, you should use the cancel order function. It will cancel your order if it was placed by you. The client ID should be the same.
It is better for traders to learn the IBKR API to perform common activities.