Accumulate/Distribute Algo

Today I’m here to introduce you to the Accumulate Distribute algo. You can deploy the algo for all products traded at IB, but it was originally conceived as a way to submit large stock orders and make it more difficult for others to detect the orders in the market. As we’ll see, the algo evolved to much more than was originally conceived, and can even be programmed for high frequency trading and can allocate shares across multiple accounts. But it is important to note that its power to accumulate and/or distribute several large positions simultaneously over longer periods of time while remaining undetected in the market cannot be overstated.

For the sake of this introductory webinar, we’ll focus on setting the algo up to purchase a large block of stock. While this order is considered from the buy perspective, the algo works the same way for a sell order although the values may be different, so everything we talk about today is relevant for both buy and sell orders.


A/D Tool Overview

If you are an IB customer, you already know that we provide several different ways to open each TWS tool. Today we’re starting from within the Mosaic, IB’s comprehensive order, research and analytics interface. Using the New Window dropdown, scroll all the way to the bottom and click More Advanced Tools. Then click Accumulate/Distribute to open the algo.

The interface basically comprises four sections:

The top section includes the quote panel to enter the underlying, tabs to create multiple orders that can run simultaneously, and the algorithm’s order parameters.

The Conditions section allows us to specify certain changeable conditions that must remain true for the algo to keep running.

The panels at the bottom of the window provide order and trade monitoring. The Orders panel is editable, and offers an easy way to change order parameters on the fly. Use the buttons above these panels to transmit, save, and otherwise manually control the algo’s behavior. Important messages will appear in red above these buttons, for example if we have left off a needed value or entered an incorrect one. It’s important to note here that these conditions are optional; there is no need for you to activate or fill in any of the condition fields if you have no need for them. The algo will work as long as the first three lines are filled in properly.

The read-only Summary section on the right of the window provides at-a-glance progress details for the algo.

OK, now we’re ready to create an algo to purchase 1,000,000 shares of IBKR.


Set up the Order

First we need to enter the ticker in the Quote Panel.

Now we’ll define the order. Let’s specify that we want to buy 1,000,000 shares in 500 share increments every 30 seconds. Keeping to this schedule we would purchase the 1,000,000 shares within about three days. But a 500 share order every 30 seconds would likely be detected and possibly subject us to someone front running our order. Our answer is to use the built-in randomization to randomize the time interval and share increment size.

Check “Randomize time” to submit the orders at any random time plus or minus 20% of the specified time interval. So for our 30-second interval, this means the orders will be submitted intermittently at any time interval between 24 and 36 seconds.

The “Randomize size” feature submits components that will be plus or minus 55% of the specified size, rounded up or down to the nearest round lot. For our 500 share increment, this means each order size could be anywhere from between 200 (actually 225 rounded down) and 800 (775 rounded up).

In addition to the randomize features, the algo has other attributes that will help the order remain undetected or if it is detected will make it very difficult to take advantage of. For obvious reasons we will not explain these features.

On stock orders, we can choose from market, limit, relative or Retail Price Improvement (RPI) order types. The order type is context-sensitive based on the asset type to ensure that we use a valid type. For example, since RPI orders are only for stocks, we wouldn’t see this selection if we were creating an algo for an option.

We would only consider using a market order in the case of an extremely liquid stock with a penny wide market and large size on both sides of the quote. The RPI, limit, and relative orders are more interesting.

The RPI is similar to a relative order, except that the offset must be greater than zero. If we use a Relative order we’ll need to specify what the order price is relative TO. If we were to set it relative to a fixed value, it would actually be a limit order. By default, the relative order price is pegged to the current bid if we leave the offset at zero, but we can easily make it more aggressive by setting the offset to a penny. We can further specify that we are not willing to bid higher than the prevailing bid, the ask or last price, the VWAP or moving VWAP; the moving average or exponential moving average, the last trade price etc. For this example, let’s specify that we want the order price relative to just the bid with a zero offset. This will allow the price to fall while you continue buying the stock. In most instances, a zero offset to the bid will do the best job for you in balancing your requirements for a fill at a good price and within a reasonable period of time. We’ll set the maximum priice to use the Value xx.xx (changes based on the current price; basically we’ll set to the ask minus two cents). This is the maximum price that we’re willing to pay.

We could continue to add more restrictions by clicking the “and” button, for example you could specify that while you want to be even with the bid AND you also want to be at least 3 cents under the offer, you would only be buying when the market widens out for the stock. Since we don’t have enough time to go through all of the almost endless possibilities today, I would encourage you to experiment with entering various parameters using your paper account, or if you’re not yet a customer using the TWS Demo that you can access from our website.

Now we need to specify whether we want the Accumulate/Distribute algo to wait for the current component to fill before it increases the size by another increment. If we don’t do this, unfilled orders could accumulate into one or more sizable orders at the exchange. Remember though that if we do activate this feature, the more difficult the buying conditions that we implement, the more likely it is that the algo will fall behind our schedule of buying 500 shares every 30 seconds.

We can tell the algo to catch up with the schedule in the event that it falls behind by checking the “Catch up in time” checkbox. This will allow the algo to immediately submit the next size component when the current one fills, without waiting for the programmed, random interval of between 24 – 36 seconds to elapse.

Next we will decide whether or not we want the algo to work only during regular trading hours, and then think about whether we want to jump at a large offer. It sometimes happens that somebody comes along and puts in a large offer – either seriously or just to probe the market or push the stock around. We don’t want to let such an opportunity go by, but we need to decide how much of our hand to show. We can instruct the algo to take any large offer in excess of a certain amount of shares that still satisfies our price conditions – in this case we’ll say 200,000 –, but not take more than we need to complete the order.


Specify Conditions

OK, now we’ve defined the basic order, but there are a number of other conditions we can specify regarding the operation of the algorithm. Keep in mind when we’re setting these conditions that the Accumulate Distribute algo is designed to run on its own, as a single trader may potentially be running several hundred instances at one time.

If any of these conditions become false, the algo will stop. We can instruct the algo to stop permanently, or to resume if and when the conditions become true again.

The first item is the price range. When we set up the order type and price, we specified that it be relative to the bid but no higher than xx.xx. Although we already set a maximum price, we might want the order to work only when the price is within a certain specified range.

Next, if there is news on the stock, we might want to stop the algo for a period of time.

We might also want the algo to deactivate based on our position in the stock. For example, we could run a buy algo and a sell algo at the same time on the same ticker, and try to trade the stock back and forth for a profit. In that case, we might want to suspend the “buy” algo if our position became longer than some preset amount. Or we might want to change the conditions or order parameters once we reach a certain position size.

The next three conditions are more complex. We can set up a condition based on the path described by the stock price. For example, we could specify that, if the 10 minute VWAP isn’t AT LEAST as high as the 50-day moving average, we don’t want to buy the stock. Notice that as we specify these conditions, the algo translates the condition into an actual number value so that you can clearly see the condition result and modify it as needed. Using this feature, we can set up algos to trade chart points without having to open and look at the chart.

The next condition is similar but requires two symbols. It lets us compare some data point for the first symbol to the same or different data point for the second symbol. We can compare the conditions on the same or different symbols. If we want to buy IBKR ONLY if it’s been on a continuous uptrend, we could specify that not only must the 10-minute VWAP be at least as high as the 50-day moving average, but also that IBKR’s 10-day moving average be higher than its 30-day moving average. You can basically include or exclude any pattern of prices as a condition or trigger for the algo to jump into action.

Or maybe we want to define our condition not in absolute terms but relative to the market, and compare IBKR’s price versus its moving average to the SPY price versus its moving average. Or even to another stock or ETF such as the IAI, which is the iShare Dow Jones US Broker-Dealer index. In this example, we could specify that the two relative measures be at least some fixed amount apart. So let’s specify that IBKR’s current price versus its 10-day VWAP must be say 2% lower than the IAI’s current price versus its 10-day VWAP. Again, note that the values we are comparing display below the entry fields so that we can see immediately if the conditions we enter are exactly the ones that we want to use.


Order Buttons

Now that we have the order parameters and conditions defined, we’re ready to preview the order and then transmit. Use the row of buttons on top of the Orders|Log|Trade panels to manually control the algo.

Click the Preview button to show the order in the Orders panel, and to display the Preview box with the order description and the margin impact of the order.

When we’re satisfied and ready to start the algo, we’ll click the Transmit button. We can change any of the algo settings on the fly, for example we might want to change the 500 share increment to 300. Just remember to click Transmit again to restart the algo.

Additionally, use the Stop button to stop the algo manually, and click Start to restart.


Order Summary

The small Summary on the right of the window shown above lets us see the current status of the whole order by showing how many shares have been submitted, how many were bought, and how many remain to be submitted. The Order Summary displays the last trade price and average price of the total order, and shows the last time a size component was submitted (to increase the position size) and the next time another component of the order is scheduled to be sent.

The Accumulate/Distribute Summary tab is similar to the Pending page in TWS. While the summary we just discussed shows the order progress for this one algo, the Accumulate/Distribute Summary page displays ALL algo orders, line by line.


Templates

I think you can see how powerful the Accumulate Distribute algo can be, and at the same time you can understand how time consuming it could become to set up orders and conditions for tens or hundreds of algos. This is why we have created the template feature. This allows us to name and save all the current algo setup, and then simply open the template and use a new underlying to get the algo ready to go. Let’s save our current algo by clicking Template and then Save Template As. We’ll name it BuyMillion. Now let’s start to create another algo by clicking the plus sign and then entering a new underlying symbol. Now let’s go back to the Template command and select Load Template. We select our BuyMillion template and you can see how all of the parameters and conditions are populated. Values that didn’t translate and need our attention are highlighted in pink.

We can make any changes we want to the algo regardless of whether or not it uses a template, but if we become a frequent user of the algo and have some favorite conditions, the Accumulate Distribute templates will save a lot of time.


Wrap it up!

In addition to moving large blocks of stock through this algo, we can implement many different trading strategies by running an algo on both the buy side and the sell side at the same time. To fully appreciate the power and flexibility of the Accumulate Distribute algo and to understand how it allows one trader to do the work of many, we encourage you to experiment. Put in hypothetical values for the variables and envision how the algo might operate with those variables. If you’re already an IB customer, you can test drive the algo under market conditions using your papertrader account. If you’re not yet a customer, you can experiment using the TWS demo. To open the demo, go to the IB homepage and select the Trading Demos splash screen. Next click Take a Test Drive to get to the demos page. To get help with setting up the algo, please check out the Accumulate/Distribute section of the TWS Users’ Guide. Thanks for joining me today to take a look at the Accumulate/Distribute algorithm.

Any symbols displayed are for illustrative purposes only and do not portray a recommendation.

Interactive Brokers LLC is a member of NYSE, FINRA, SIPC