In this lesson we will walk through how to create a basket of orders for multiple instruments in the TWS BasketTrader and submit them. The TWS BasketTrader is a powerful tool that is useful when the user wants to submit multiple orders at one time and monitor the progress of those orders. BasketTrader can be accessed in both Classic TWS and Mosaic as well as being on a preconfigured page in the Layout Library.
To access BasketTrader from Mosaic click on the New Window Area in the top left corner, scroll down to the Other Tools section and highlight “More Advanced Tools” and choose BasketTrader. The BasketTrader will appear as a separate window. You can configure the settings and data column layout of the BasketTrader by clicking on the configure wrench icon in the top right-hand corner of the screen. Click on settings on the left-hand side to choose whether to:
- Instantly remove basket orders from pending page
- Show statistics for main and attached orders separately
- Ignore loading zero quantity orders
- And adjust the font size
Click on the BasketTrader layout section to choose which data columns to be shown in the BasketTrader.
In this case Financial Instrument, Bid, Ask, and Last are shown. You can add any of the columns in the Available Columns area by clicking on the plus sign to expand a bucket to view its contents, or type into the search bar. Let’s type Change and add Change % by highlighting it and clicking the “Add” button. Click Apply and OK.
The BasketTrader consists of five areas: At the top you can choose a file to upload to use as the basket. We will go into how to create basket files and upload them in the next lesson. Directly below is the Order Panel, followed by the Execute Basket buttons, Summary panel, and Trade log. You can create multiple baskets by clicking on the plus tab in the upper left-hand corner.
For this lesson we will manually create a basket. BasketTrader supports orders for multiple instruments and asset classes. In the Orders area click on a box in the Financial Instrument column and enter a symbol. We will type AAPL and select stock. You can select whether to round up to 100 shares or leave as an odd lot. We will choose to round up to 100 and click ok. We can edit the Action and Quantity by clicking on the Total Quantity, Time in Force, Order Type, and destination. For our next order we will enter a sell Limit order for 500 shares in ticker SPY. Type SPY in the box under AAPL, change the Action from buy to sell and click on the Total Quantity. Scroll down and select 500 shares. We can also adjust the price by clicking on the value in the Limit Price column, let’s select bid -200% of the spread.
Now we will enter an option order for IBKR. Type IBKR underneath SPY and select option, the option chain will appear. Select the expiration, the right, and the month. Once the option is selected it will appear in the order window. Close out the Option Chain and we will change this to a 10 lot and a market order. For our last order type in ES, scroll down to Futures and select December. Let’s change this to a Sell order, change the quantity to 5, and enter a limit price. You can add in as many orders as you like and export the file as a csv by clicking on File in the upper left-hand corner and Save basket as, name the file and pick the directory you’d like to save it in.
At the bottom of the Order section there are 5 buttons. Configure allows you to configure the Settings and Layout. Insert will insert a row into the Order area. Delete will Delete a row from the Order Area. Clear will clear out the order page. And reverse will change the Action from buy to sell or sell to buy. You can also convert all Limit orders to market if you like.
Underneath the Order section is the Execute Basket area in which, with a press of a single button you can Transmit the basket, pause the basket execution, cancel all outstanding orders in the basket, or cancel all outstanding orders and reverse the action. You can also transmit a percentage of the basket if you do not want to send 100% of the basket at once by changing the percentage. When ready to send the basket click submit and the Summary area will populate showing the progress of the Buy and Sell orders. You can see the progress in Orders, Contracts, and Dollar amount filled. The trade log below will show completed orders.
The TWS BasketTrader is a powerful tool that allows you to submit multiple orders at once in multiple instruments and asset classes. Please see the lesson on uploading and creating basket files for more information.
I am struggling to generate a csv file with stop loss orders that maps the AuxPrice field once loaded in Basket trader. The fields for the csv file do not appear to be formatted in the same way as those in the TWS basket trader.
Hello Edward, thank you for reaching out. Please view this FAQ with instructions to upload a CSV Basket file to BasketTrader:
https://www.ibkr.com/faq?id=64159770
We hope this helps!
For some reason the TRAIL Stp function does not work properly when I upload a CSV Basket file to basket trader. I usually enter bracket orders with a Profit target and a Trail Stp – No issues with parent order and profit target but Trail Stops always remains AT market level and does not move along the corresponding trailing amount. These are all the fields I use in my CSV and corresponding values (i use a $0.90 trailing amount in below example) What do I do wrong? Any field missing? Action = SELL Symbol = AAPL Quantity = 200 SecType = STK Exchange = SMART Currency = USD TimeInForce = DAY OrderType = TRAIL LmtPrice = (blank) AuxPrice = 0.90 StopPrice = (blank) Account = xxxxxxxx AutoCancelDate = xxxxx Rth = TRUE OrderId = (blank) ParentOrderId = (same as parentID) Thanks!
Hi Ron, thank you for reaching out. It is not possible to create a bracket order as described. If you have further questions on this issue, please create a web ticket for this inquiry; we have a category specifically for “API.” One of our API experts will be happy to guide you! http://spr.ly/IBKR_ClientServicesCampus