TWS Advanced Trading Tools Webinar Notes
Overview
- Accumulate/Distribute Algo – Minimize market impact for large orders by slicing the order into increments and buying or selling over time, at pre-defined, randomized time intervals. Available for stocks, options, futures and forex.
- ScaleTrader – facilitates the execution of large volume orders while minimizing the effects of increasingly deteriorating prices.
- Other IB Algos – Use IB Algos for US Equities and US Equity Options to automatically balance market impact with risk on your large volume orders.
- OptionPortfolio Algo - Find the most cost-effective way to adjust the risk profile of your portfolio by any of the relevant Greek risk dimension factors you specify.
Accumulate/Distribute Algo
Initially, the Accumulate Distribute algorithm was designed to allow the trading of large blocks of stock without being detected in the market. As we went along, the Accumulate/Distribute algorithm evolved into much more, so that in its current state it can even be set up for high frequency trading.
The algorithm can be deployed for futures, options, forex or any product that can be traded through Interactive Brokers, and it can also be used to trade and then allocate the resulting positions among multiple accounts.
Define the Algo
But let’s start with the simple task of buying stock (Selling works the same way as buying but I will demonstrate everything from the buying perspective).
In this case: We’ll buy 1,000,000 shares of IBKR and want to issue orders in 500-share increments every 30 seconds.
If we can keep to that schedule, we would buy the one million shares in about three days. A 500-share buy order every 30 seconds would of course be immediately detected and subject to someone front running us, so we need to randomize these orders.
Using the algorithm, we can select “Randomize Time” and “Randomize Size.”
- Randomizing time within, say, 20% in the case of our 30-second time increments will cause the next order to be issued at some random time within 24 and 36 seconds after the last order was placed.
- Randomizing size within, 55% in the case of our 500-share size increment will cause the size of the next order to be any number of shares between 225 and 775 shares, rounded to the nearest 100 (i.e., the next order could be for any round lot size between 200 and 800 shares).
Order Types
The order can be a Limit, Market or Relative Order.
Note: Relative Orders are not supported for products where cancellation fees are levied by the listing exchange.
Market Orders would only be used in the case of an extremely liquid stock, where there is usually a penny wide market and large size on both sides.
Limit and Relative Orders are much more interesting.
- When you put in a Relative Order you must specify what it is relative to, and here you have a lot of choices.
- Of course, if it is relative to a fixed value then it is really a Limit Order, but you can make it relative to things like: the prevailing bid; the ask; the last price; the VWAP or moving VWAP; the moving average or exponential moving average; your last trade price or the number of shares you have bought so far. There are many possibilities.
For relative orders, you must also input an offset to the data point. Say you want to match the prevailing bid, than you put in BID and an offset of zero.
If you want to be aggressive, you could put in the BID +0.01 (one cent). In this case you may also want to make sure that you do not lift the offer if the market is one cent wide, so you may further specify that in no case would you bid more than two cents under the ask.
If you want additional restrictions you may specify, for example,
- that you want your bid to be no higher than the last trade price for the stock
- and no higher than one cent under your last buy price,
- and also no higher than the VWAP, or say the exponential moving average for the last 25 minutes.
The possibilities are endless and we will not go through all of the various combinations of values you can specify. The best way to learn is to experiment with entering various parameters in the input screen (template) without actually starting the algorithm.
The next question in specifying how you want the algorithm to operate is to decide whether or not you want to wait for the current order to be filled before the next order is submitted.
- If you do not, then additional orders will be transmitted every 24 to 36 seconds (using our example above) and they will accumulate into one or more sizable orders at the exchange.
- If you do check the box instructing the algorithm to wait for the fill before submitting the next order (which we think is a good idea) then the more difficult the buying conditions that you put in, the more likely it will be that the algo will fall behind the schedule of buying 500 shares every 30 seconds.
- So, then the next question becomes: If you have fallen behind, do you want to catch up with the original schedule if the conditions allow?
- Selecting “Yes”, means that the algorithm will not wait the 24 to 36 seconds between every order but that the next order will be submitted immediately after an order is filled until you are caught up.
- Next you need to input if you are working the order only during regular trading hours or other times.
- It sometimes happens that somebody comes along and -- either seriously or just to probe the market or push the stock around -- puts in a large offer.
- Since in our example you want to buy a million shares you cannot let such an opportunity go by without taking advantage of it. So you may want to jump at a large offer, but on the other hand you need to decide how much of your hand to show. You can instruct the algorithm to take any large offer in excess of any number of shares (e.g., in our case maybe 200,000) that satisfies your conditions as to price, but take not more than you need to complete your purchase.
Conditions
- There are a number of additional conditions regarding the operation of the algorithm that you can specify.
- Whenever these specified conditions are not satisfied, the algorithm can be instructed to stop permanently or to resume when the conditions are satisfied again.
- Keep in mind that the Accumulate/Distribute algorithm is designed to run unattended, as one trader may be running several hundred instances of it at the same time, working on various instruments or even working on the same instrument.

- The first such condition is the price range. You may specify a price range outside of which you do not want to buy the stock.
- Next, if there is news on the stock you may want the algo to stop for some period of time.
- Next you can make the Accumulate/Distribute algo active or not based upon your position in the stock.
- For example, you can run a buy algo and a sell algo at the same time and try to trade the stock back and forth for a profit. In that case you may want to suspend the buy algo if your position becomes longer than some amount.
- Or after having reached a long position in excess of some quantity, you may want to switch to an algo with different parameters.
- Yes, you can even run two or more buy algos for the same stock at the same time with different variables and switch back and forth between the two automatically by having each algo active or not depending, for example, on the size of your position in the stock.
- The next potential condition has to do with the path described by the stock price.
- You may, for example, specify that if the 10-minute VWAP is not at least as high as the 50-day moving average, you do not want to buy the stock.
- Go ahead and experiment with the Accumulate/Distribute input screen by putting in various conditions. You will see that as you put in the 10-minute VWAP or the 50-day moving average, the program displays the actual values of those parameters for you to review those values. This feature enables you to set up algorithms to trade chart points even when you are not viewing the chart.

- The next potential condition is similar to the last except that it calls for two symbols.
- Here you can put in any symbol and compare some data point regarding that symbol (e.g., 10-minute VWAP, etc.) to the same or a different data point regarding the second symbol. These comparative conditions can apply to the same symbol or to different symbols.
- For example, you could specify that you want to buy a certain stock only if it has been in a continuous uptrend.
- So in addition to the 10-minute VWAP being higher than the 50-day moving average, you would also like the 10-day moving average to be higher than the 30-day moving average on this stock.
- Or you may want the same condition to prevail for a related-product. In our example, you might specify certain conditions regarding IBKR stock in relation to the ETF “IAI”, the iShares Dow Jones U.S. Broker-Dealer Index.
- Of course, you are also free to compare two entirely different products like IAI and SPY and make that into a condition for the purchase of IBKR.
- You can also require that two relative measures be at least some fixed amount apart, higher or lower from each other. For example, you can specify that you want IBKR’s current price vs. its 10-day VWAP to be 2.1% lower than IAI’s current price vs. its 10-day VWAP.
START the algo
In addition to moving large blocks of stock through this algo one can implement many different trading strategies by running an algo on the buy side and running one on the sell side at the same time.
To fully appreciate the power of the algorithm and how one trader can do the work of ten or more by using it, you should experiment with the input screen.
Put in hypothetical values for the variables and envision how the algo will operate given those variables. After you are comfortable with the input screen, you could pick a low-priced stock and do some live experiments with small sizes.
It is important to note that you can stop the algo at any time, or you can change any of the parameters while the algorithm is active. These changes however will not become effective until you click on the APPLY button.
If you become a frequent user of Accumulate/Distribute, you will not want to fill out a new template for each occasion from scratch. Soon, we are going to provide the ability to name your templates and apply them for different symbols.
Monitor the Order Progress
The order Summary section for each algo provides real-time data so you can monitor the progress of the order.
Shares bought field uses a shading to indicate the percentage of the order complete.
When multiple algorithms are working, the AccumDist Summary tab displays order management lines for all of your Accumulate/Distribute algos -- allowing a single trader to effectively manage multiple orders simultaneously.
Algo in progress:
ScaleTrader
The ScaleTrader is an automated trading algorithm designed to run indefinitely until stopped or changed or until it encounters conditions where it stops and may be used for any product IB offers.
The ScaleTrader originates from the notion of averaging down or buying into a weak, declining market at ever lower prices as it bottoms -- or on the opposite side, selling into a rising market or scaling out of a long position.
If, in your judgment a stock is trading near the bottom of its trading range than you can program the scale trader to buy dips and sell at some minimum, specified profit repeatedly. Namely, buy more and more of the stock as it is approaching the bottom of the trading range and sell it as it recovers and buy it again in a subsequent decline. This is trading from the long side.
Similarly, in a somewhat more adventurous position, you can trade from the short side by selling into a rising price at ever higher levels and buy it back at lower levels as it comes down. If you think the stock is fluctuating along a trend line, the algorithm provides for the ability to incorporate such a rising or falling trend line to manage your position accordingly.
We will look the algorithm from the point of view of a long stock trader, but anything said here works also in the reverse and for other IB products, such as futures, options or forex.
Components
When you bring up the scale trader and enter a specific symbol, it will automatically display a price chart to help you specify your parameters.
- TOTAL ORDER SIZE (maximum position) is the total number of shares you are willing to buy as the price falls.
- INITIAL COMPONENT SIZE is the number of shares you are buying at the first price level, your STARTING PRICE.
- SUBSEQUENT COMP. SIZE is the additional number of shares you are buying at each PRICE INCREMENT, which in case of a buy scale is actually a decrement.
- STARTING PRICE
- PRICE INCREMENT
For example you can say buy 2,000 CSCO at $22.03 and 500 more every 2 cents down, maximum position 30,000.
After you entered these five parameters, the TOP PRICE and the BOTTOM PRICE will be calculated and displayed.
- If your initial component size and subsequent component size are the same -- then the TOP PRICE will be the same as the starting price.
- If the initial component size is greater than the subsequent component size then your TOP PRICE will be higher.
- Namely it will be the price at which you would have had to start buying the same amount as the subsequent component size at each price level in order to reach the same position at a lower price.
This feature is only important if you use the same scale to sell out of your position.
The BOTTOM PRICE is calculated and displayed. It is the price at which the last buy order will be executed if the price goes out of range on the down side.
- You can change this bottom price and if you do, the price increment will be changed to compensate for it.
- In fact you can grab the STARTING or the BOTTOM lines on the chart and move them around and as you do so, the price increment will change accordingly.
Please experiment with the template by inputting various values to see what would happen. The algorithm will not activated until you click the transmit button.
Order Types
Your orders can be limit or relative. Relative orders are offset against the bid price.
- If you choose to use relative orders with a zero offset, your scale buy orders will always join the bid, even if your scale would call for a higher bid price.
The advantage of this is that if the stock becomes volatile you can occasionally buy it at better prices than your limit would be, provided that you do get filled.
- If you were to input an offset of +0.01, than you will bid a penny higher than the best bid, provided that that price is equal or lower than the next buy price on your scale.
This way you are much more certain to get filled and still have the advantage of buying at a price lower than your scale price, should the stock suddenly “fall out of bed”.
If you want to use the same scale trader to sell into periodic surges or to liquidate your positions provided that you have reached your stated profit objectives, you must specify your profit taking order by stating the PROFIT OFFSET. This is the amount of profit you want on a round turn trade.
- If you put in $3.00 then your first sale will be $3 higher than the price at which your last buy took place.
As the stock advances, your position will be sold out in the “subsequent component sizes” and at the successive “price increments” that you used when you bought it. Your last sale will happen at the top price plus $3.00.
Restore Size after Taking Profit
- If you check this box, the algorithm will attempt to repurchase the shares you just sold at the price you originally bought them at. This feature allows you to buy and sell repeatedly in a fluctuating market, just like a market maker would, especially if you set your price increment and profit offset to low enough levels. The algorithm will remain active whenever the price is within the range of the (top price + profit) and the bottom price.
- If you do not check the “Restore Size after Taking Profit” box you will buy and sell at each price level only once and the algorithm will be finished.
Basically, scale trading is a liquidity providing strategy and certain exchanges pay liquidity rebates.
- We pass exchange fees, including rebates through to our unbundled customers.
- Liquidity rebates currently exceed all but our first tier of commissions.
Order Management
You may adjust any of the parameters of the algorithm through the order ticket while it is active. Right click on the order row and choose Modify | Order Ticket.
The Scale Progress box displays the complete scale price ladder, the Open/Filled component list for the parent scale order, and the Open/Filled component list for the child profit orders.
- You can right-click an order in the Order Management panel and choose to View Scale Progress for the selected order.
A new Scale Trader page (build 898) displays the order management section including all fields for creating scale orders, along with a new Scale Summary panel on the top half of the page.
- The Scale Summary shows one line for each original parent scale, and provides real-time status including filled and total quantity, filled, remaining, and total value, and the percent filled for each scale.
- To create this page, from the Page menu select Create ScaleTrader Page.
Other IB Algos
IBAlgos implement optimal trading strategies, which balance market impact with risk to achieve the best execution on your large volume orders. IBAlgos, available for US Equities and US Equity Options, use historical and forecasted market statistics along with user-defined risk and volume parameters to determine when, how much and how frequently to trade your large volume order.
You can create algo orders from the trading window or using the Order Ticket.
- On the trading page, create an order then in the order row Destination field select IBALGO.
- On the Order ticket select the IBAlgo tab.
You must use the order Destination field, not the market data Exchange field.
- Define the algorithm using the available input fields.
- Only those strategies valid for the instrument type will appear in the strategy selection list.
- Based on the strategy you select, the necessary parameters will be displayed.
Common Parameters:
- The level of Urgency/ Risk Aversion determines the pace at which the order is submitted over the day.
- higher urgency executes the order more quickly, opening it to greater market impact;
- lower urgency allows the order to fill over time and incur less market impact.
- The Urgency/Risk Aversion selections are driven by the size of the order; it is designed for orders that will impact a high percent of the Average Daily Volume and its performance may be insignificant for smaller orders.
- The Algos use a randomization feature to keep the order hidden, and by default always attempts to execute quickly.
- A start time and/or end time dictates when the algo will begin working and end working, regardless of whether or not the entire quantity has been filled.
Use the Calendar icon to format time field correctly.
- If an End Time is specified, an Allow trading past end time box is enabled to allow the algo to continue past the specified end time if the full quantity has not been filled.
- If Attempt Completion by End of Day is checked, TWS will try to complete the order today.
- Please note that a portion of the order may be unexecuted if the system determines that the risk of the price changing overnight is less than the extra cost of executing the whole order today.
- Check Attempt to never take liquidity to discourage the algo order from hitting the bid or lifting the offer if possible.
- This may help to avoid liquidity-taker fees, and could result in liquidity-adding rebates.
- However, it may also result in greater deviations from the benchmark, and in partial fills.
- The IB algo is designed to use best efforts not to take liquidity when this box is checked, however, there will be times that it cannot be avoided.
Stock Algos
Arrival Price Algo
Available for US Equities that trade on NYSE, AMEX and NASDAQ.
To achieve the bid/ask midpoint price at the time the order is submitted.
Input Fields:
- Max Percentage of Average Daily Volume -- Set from 1% to 50%.
- Urgency/Risk Aversion Level
- Get Done
- Aggressive
- Neutral
- Passive
- Start Time/End Time
- Allow trading past end time checkbox
- Attempt Completion by EOD checkbox
Percent of Volume Algo
Available for all US Equities.
To participate with volume at a defined rate. Order quantity and volume distribution over the day is determined using the target percent of volume you entered along with continuously updated volume forecasts calculated from TWS market data.
Input Fields
- Target percentage of participation of the Average Daily Volume from 1% to 50%.
- Start Time/End Time
- Attempt to never take liquidity
VWAP
Available for all US Equities.
To achieve the Volume-Weighted Average price (VWAP), calculated from the time you submit the order to the close of the market.
Input Fields
- Max Percentage of Average Daily Volume
- Start Time/End Time – when specified TWS confirms that acceptability of the time period using yesterday’s trading volume. If the time period you define is too short, you will receive a message with recommended time adjustments.
- Allow trading past end time checkbox
- Attempt to never take liquidity checkbox
Lower commissions than regular guaranteed VWAP orders, but unlike stock VWAP order type, the VWAP price is not guaranteed.
Options Algos
Balance Impact and Risk Algo (Options)
Available for US Equity and Index Options.
To balance the market impact of trading the option with the risk of price change over the time horizon of the order.
Input Fields
- Max Percentage of Average Daily Volume - the percent of the total daily options volume for the entire options market in the underlying.
- Urgency/Risk Aversion Level
- Get Done
- Aggressive
- Neutral
- Passive
- Attempt Completion by EOD checkbox
Minimize Impact Algo (Options)
Available for US Equity and Index Options
To minimize market impact by slicing the order over time to achieve a market average without going over the Max Percentage value. The max percent you define is the percent of the total daily options volume for the entire options market in the underlying.
Input Fields:
- Max Percentage (from 1% - 50%) of Average Daily Options Volume - if left blank defaults to 50%.
- Set the limit price in terms of volatility by using the VOL order type.
Options Portfolio Algo
Another TWS trading tool, the Option Portfolio, allows you to select, analyze and trade option combinations based on specified Greek risk factors (delta, gamma, vega and theta). This trading and risk management tool can provide mathematically optimized basket orders tailored to solve a desired risk position or hedge.
Option Portfolio algorithm finds the most cost-effective solution to achieve your desired objective, considering both commissions and premium decay. All calculations are done on IB’s back-end processors to help you adjust the risk profile of your portfolio by any of the Greek risk dimensions. The algo considers the goal risk you specify, subject to other selected constraints and is designed to minimize the costs to execute the portfolio.
Launch from the Trading menu. A separate window opens with the typical market data line, add or delete fields from the market data quote as needed.
Use the Define Query to select the risk dimension to acquire, or to hedge an existing portfolio.
- In the drop down menu, select delta, gamma, vega or theta and input the amount of the risk dimension that you want – units in this tool are same as in the OptionTrader and Risk NavigatorSM.
- To select a multiple maturities use Ctrl+Click.
- To select a range of strikes use the drop down pre-populated with the series and strikes of the listed underlying.
- The algo optimizes the proposed solution and contains only those listed expiries and strikes that you want to explore.
- In the Acquire list, along with the existing choices of Delta, Gamma, Vega and Theta, you can choose Reference Portfolio to have the tool find a simulated portfolio with P&L that matches or exceeds the expected P&L of a Reference Portfolio you define.
When Reference Portfolio is selected from the Acquire list, the Compose Portfolio panel opens
- Set expiry, call/put, buy or sell for all components to include in the reference portfolio
- Submit Query button will return a Simulated Portfolio
- In the Query section, a new P&L Charts tab is added to view the P&L curves for the Reference Portfolio you set up and the Simulated Portfolio that the Options Portfolio tool returns.
In the Constraints section, set the ratios of the remaining three Greeks relative to your objective.
- You can change the risk constraints – get the same gamma units for example, but also get other potential choices of the options to be traded.
Click the Submit Query button to send your set of requirements to the back-end processor, which responds with a solution that displays in the query results section. If you do not get data, relax the constraints.
Once a solution basket has been created by the back end you can link the Option Portfolio tool to the Risk Navigator with a button.
- The solution basket with current prices and exposure is loaded in the Risk Navigator as a “what-if” portfolio.
- P&L graph below shows the result of taking on the basket position(s).
- Use the Edit |Add From | My Portfolio to view the risk impact to your entire portfolio
You can Freeze the Updates to have more time to examine the proposed solution.
- The back end actually continues to be connected and recalculates every 10 seconds the then best solution – columns update more frequently
- Risk numbers continue to update only the proposed trades have been frozen.
- risk data on the underlying prices are constantly updating as in risk navigator.
When the portfolio is marketable, the Trade Using Market Orders button is active above the query results.
Intermediate/Advanced level features
- Long options only (checked by default) – uncheck to look at proposed solutions selling options, This is not a strategy for first time options traders.
- Include underlying leg in the possible mix of assets and see that it allows the solution portfolio to have the smallest delta position as possible and at a lower cost, by allowing the stock to be traded rather than acquiring options only.
- When any of the parameters is modified, you have to resubmit the query to get the proposed solution from the back end.
- Reference price – a sophisticated feature for you to specify the underlying price at which you would like the goal position to apply -- for a different solution than would have occurred at the current underlying price.
- Hold until field – By clicking the calendar icon, you can select a maturity until which you would consider holding the portfolio. Has significant impact with the premium decay or gain and is factored into the minimization of the costs on various solutions provided.
For example in the initial solutions, near market options were being proposed in order to arrive at the gamma, ITM options are being selected in their place so that the premium decay is smaller.
Any symbols displayed are for illustrative purposes only and do not portray a recommendation.
Interactive Brokers LLC is a member of NYSE, FINRA, SIPC