The Gateway to Algorithmic and Automated Trading

DMZ AlgoEngine: One step to heaven

Published in Automated Trader Magazine Issue 19 Q4 2010

One of the problems with reviewing software in a market as rapidly evolving as auto/algo trading is that by the time the review is published in Automated Trader a new version of the product has often already been released. As a result, the Editor’s technology mailbag has of late been filling up with readers’ letters clamouring for us to peep over the technology horizon and take a look at a product before it is actually released. So we thought we better had. Therefore, in a change from Automated Trader’s usual practice of reviewing a piece of production software, in this issue we give a “preview review” of a pending new release of DMZ Trading Solution’s existing AlgoEngine product. As Automated Trader’s Founder, Andy Webb, and the Wrecking Crew quickly discovered simplicity and functionality are not mutually exclusive.

Figure 1a
Figure 1a

Figure 1b

Figure 1b

Figure 1c

Figure 1c

DMZ Trading's AlgoEngine has been on the market for about a year now and in that time has attracted clients from around the globe. The software's premise is simple; take an existing mechanical trading platform with an API and leverage that combination to provide a means for traders to automate their existing mechanical trading systems (that they would otherwise trade manually). As a business model, this has quite a bit to recommend it; you have immediate access to a target market of mechanical traders, many of whom are seriously up for the idea of a fast track route to automated enfranchisement.

Our initial introduction to DMZ was courtesy of regular AT contributor Shaun Downey of CQG (which is the mechanical trading platform alluded to above - though CQG also does quite a bit more than just that). Given the range of trading experience in the Wrecking Crew, DMZ were happy to provide us with a pre-release copy of the next production version of AlgoEngine for review in return for constructive suggestions. (Which clearly proves that they haven't met the Wrecking Crew, whose speciality is mostly destruction - typically of the office phones when trades go wrong.)

The basics

AlgoEngine is a standalone application that uses the CQG API as both a data source and a trading gateway. The software can monitor the status of CQG conditions (basically rule based events) as well as any entry signals defined in CQG trading systems. It then reacts to any status changes in these conditions or signals to enter trades automatically. On the exit side, it incorporates simple tick-based profit target and stop loss functionality, but can also reference CQG conditions as an alternative/additional exit mechanism.

In addition, the pre-release software we were given to evaluate included the ability to create custom execution strategies. More on this later, but suffice to say this allows considerable flexibility as regards execution management that can significantly improve P & L.

Installation and updates

Installing AlgoEngine is trivial; download the install package, run it and then enter your log in details. However, before you hit "Go" to complete the log in process you need to make sure CQG is running and that you have opened and logged into its DOM Trader window. If you don't, AlgoEngine will simply flag an error message telling you to do this.

New software builds seem to be a bit of a theme with DMZ; the company appears to be on pretty much a continuous "build - test - release" cycle. Every time you log on, a quick version check is automatically run and if a newer version is available, you are asked if you want to download it. After a while we lost count of the number of new versions we got through, but we weren't complaining as the response time to any of our feedback items was impressive. On two occasions, we made suggestions to DMZ on one day and found a new release incorporating the requisite changes awaiting us at log in the following morning.

While you might expect this with the pre-release software we were testing, DMZ appears to follow a similar strategy with its production software as well. If a user spots a bug or requests an enhancement that doesn't require massive re-engineering, a revised software release is also made pretty much instantaneously.

The basics - data and time frame

The first step in setting up AlgoEngine to operate a trading signal is to create an expression so that it knows which market and in which time frame it will be operating. One way of doing this is to click the "i" button highlighted with a red rectangle in Figure 1a.

This opens the Expressions dialogue box shown in Figure 1b. A pleasant surprise (especially for one member of the Wrecking Crew, who has a Point & Figure fetish) was the number of CQG chart types supported, which is pretty much all of them. Once you have inserted the symbol (in Figure 1b we have used the DAX stock index future) and chosen your chart type, click Generate and then Done to return to the main Edit Strategy dialogue. Click the Load button (highlighted with blue rectangle in Figure 1a) to move to the next step and choose your desired entry/exit signals.

Incidentally, if you are trading using straightforward time bars, you can short circuit the process just described by simply entering the desired symbol in the Expression field (yellow rectangle Figure 1), clicking the Chart Parameters tab and entering the desired bar length in the Intraday field (green rectangle in Figure 1c). More on the Chart Parameters tab later, but for now it's worth observing that the value in the Intraday field is linked to the time units selected in the Historical drop down immediately above. Having Use Intraday selected (as in Figure 1c) means that the trading time frame will be two minutes.

Choosing a trading strategy

Once the load button has been clicked, the other fields in the Strategy Setup tab become accessible. The first decision to make is whether you wish to use entry signals based upon entry signals from an existing CQG trading strategy or individual CQG conditions. (Note that the ability to trade using conditions is only available in the Plus and Premium versions of AlgoEngine - see Figure 2 for a complete table of version functionality.)

Figure 2

Figure 2

If you check the Trading System Mode radio button, the Strategy drop down list becomes available, from which you can select your CQG trading strategy.

As a very simple example, we knocked up an extremely crude (and rubbish) reversal strategy (code for the initial long entry signal is in Figure 3a) based upon a three bar pattern of a low on bar two with higher lows on bars one and three (for a long entry - vice versa for a short entry). We also added similarly crude follow up long and short pyramiding signals (code for the long pyramid signal is in Figure 3b).

Figure 3a
Figure 3a

Figure 3b

Figure 3b

One of the advantages of Trading System Mode is that multiple entry signals from the same CQG trading strategy can be selected and run in parallel (see red rectangle highlight in Figure 4). It's sometimes possible to achieve a similar overall effect using Condition Mode and combination of multiple conditions, but there are limitations. For example, the code shown in Figure 3b would not be possible in a CQG condition because CQG conditions do not have access to the Trading System position functions in the CQG Formula Toolbox (only CQG trading systems can access that).

AlgoEngine can reference any parameters that a CQG trading system or condition contains (see green highlight rectangle in Figure 4). It's worth bearing in mind that this can include data or models calculated outside CQG but connected to it by its API (e.g. MATLAB functions). Parameters can also be tweaked for individual implementations of a CQG trading strategy or system. This fits nicely with a concept mentioned recently by several Automated Trader readers; namely the ability to run multiple instances of the same basic trading model but each with different parameters. Spreading trading capital around in this manner delivers useful diversification and addresses some of the issues arising from the optimum parameters identified during model testing and optimisation differing from those that actually occur in live trading.

As mentioned earlier, AlgoEngine offers three ways to exit trades: fixed profit target, fixed stop loss or CQG condition. A key point here is that a single condition can contain multiple "or" statements, thereby allowing multiple exit methods from within one condition. In addition, as with entry conditions, AlgoEngine also allows the user to access and specify the exact parameters defined in a CQG user condition (see magenta highlight rectangles in Figure 5).

AlgoEngine allows you to set the maximum position size you can accumulate at any one time (see blue rectangle highlight in Figure 5); this must always be the same or higher than the Max Trades Per Bar setting immediately below it in Figure 5. If operating in Trading System Mode, the Condition Trade Size field will be greyed out and AlgoEngine will use the initial position size specified in the CQG Define User Formulas Trade Systems Size tab (subject to the constraint of the Max Position field in Figure 5).

Figure 4
Figure 4

Figure 5

Figure 5
Figure 6
Figure 6

The Max Trades Per Bar setting is particularly important in the context of the Recalculate Every Tick check box. If checked, this will recalculate all the values within a condition or trading strategy every time a new trade quote arrives. This can result in multiple trades being triggered on the same bar as the entry trigger may flip flop multiple times between true and false. Making the right decision about whether or not to check this box is of critical importance. If you have simulated the performance of a strategy or condition within CQG in real time with Chart Preferences Recalc set to Recalculate at End of Bar and you then check Recalculate Every Tick in AlgoEngine for that same strategy/condition in live trading, you will be in for a big surprise (and almost certainly a very unpleasant one).

The OSL checkbox in Figure 5 is for Opposing Signal Liquidation; enabling this ensures that any existing position is closed before a new trade is opened in the opposite direction. If this was unchecked and a long signal was followed by a short signal, the short trade would only liquidate the existing long position and leave the overall position flat. However, if it was checked, the long position would be exited and a new short position would be opened.

One of the advantages of our extremely crude reversal strategy code outlined above is that it can trigger multiple (assuming Recalc Every Tick was checked and Max Position and Max Trades Per Bar were set high enough) long and short positions on the same bar. (See Figure 6 where the second bar has both a higher high and lower low than both the bars on either side of it.) This made it ideal for testing the OSL setting, which we found performed consistently exactly as it should.

Chart Parameters

As mentioned earlier, the chart parameters tab provides an alternative to the expressions dialogue for defining the desired tradable and timeframe. While most AlgoEngine users will probably opt for leaving the Historical drop down list set to Intraday, as can be seen from Figure 7a there's nothing to stop you trading using multi-annual bars should you desire.

The Lookback field needs to be adjusted to allow for the longest dated parameter setting in a strategy. If, for example, your strategy references a 50 period moving average then the Lookback setting will need to be set to 50 at the very least. The Lookback setting also affects how far back AlgoEngine can "remember" trading events; so if you are using five minute bars with a Lookback setting of five and opened a short position 30 minutes ago, AlgoEngine won't be aware of it now.

The Continuation section of the tab (magenta rectangular highlight in Figure 7b) provides access to all the various contract continuation settings available in CQG, while the Session section (blue rectangular highlight in Figure 7b) allows users to select which trading sessions (including CQG Custom Sessions) the particular strategy or condition will be active during.

Figure 7a
Figure 7a
Figure 7b
Figure 7b
Figure 8a
Figure 8a
Figure 8b
Figure 8b
Figure 8c
Figure 8c
Figure 9
Figure 9

Order execution

The Execution tab is where a lot of AlgoEngine's newest pre-release functionality resides. The order types available in the Execution Algo drop down list vary depending upon whether you are in Trading System (Figure 8a) or Condition (Figure 8b) Mode. In the former mode, in addition to AlgoEngine market and limit orders, you also have access to the order types available to CQG trade systems in the Define User Formulas dialogue (Figure 8c).

However, the real entertainment starts if you select User Defined from the Execution Algo list. A host of new options immediately become available. The value you enter in the Clip Size field denotes the individual clip size in the case of icebergs and the maximum size of randomly generated clip sizes in the case of randbergs. Orders can be shown in the market or hidden until the market reaches your price target and in the case of hidden orders, limit or market orders can be selected. The Initial Entry Price, allows you to either join the best bid/offer or create custom execution algorithms (more on these below) by clicking the Define Rules arrow. Custom execution algos are by definition active, but otherwise resting orders at the initial entry level are alternatively available. Finally, if you have selected a Conditional Exit on the Strategy Setup tab, the Conditional Exits drop down allows you to specify the type of execution that should be used if that condition is triggered.

Defining order execution rules

Clicking the Define Rules arrow allows you to define your own order execution rules. All you have to do is select the desired combination of options from the Frequency, Condition and Action drop down lists in Figure 10a and then enter appropriate values in the corresponding Interval, Threshold and Ticks text fields.

Finally, click the Validate button to check that the execution rule you have defined is valid and does not contain a logic flaw. If there is an error, AlgoEngine will reject the proposed rule and the background for the rule will remain pink. For example, in Figure 10b the rule will not validate because order side volume cannot be less than 0 (i.e. negative).

Multiple execution rules can be combined for a single order. Figure 10c shows a combination of two rules; the first states that AlgoEngine should wait for three seconds and, if the order has not been filled, to cross the spread with a market order. The second rule states that if at any time the opposing price in the order book worsens by three or more ticks then the order should be cancelled. The green background to each rule indicates that they have both been successfully validated.

Real time operation

Once you have completed the setup of AlgoEngine for a particular combination of strategy/condition and market, clicking the play button next to the appropriate order(s) in the top panel of Figure 11 sets it live. Trading strategies and conditions that are live in the market have a green background, inactive ones have a pink background. Apart from the play button, other command buttons allow you to stop, delete, copy or edit strategies/conditions. The current centre of the order book is automatically displayed for each market included in a strategy/condition in the Market Data panel, while other panels include outstanding orders and their status (e.g. in transit or in order book), completed trades and open positions/P&L. In addition to the ability to pull orders individually or en masse, clicking the flame icon next to an open position automatically liquidates it.

During the live testing period, we didn't spot any discrepancies between the positions, orders and trades displayed in AlgoEngine and the CQG Orders and Positions window, which was reassuring. In fact we found the whole process of running AlgoEngine pretty reassuring, even allowing for the fact we were running pre-release and not production software.

This issue's Wrecking Crew members mostly consisted of arcade traders who were using models either for decision support or for completely systematic trading. Given CQG's widespread presence in arcades, this was decidedly convenient, as it gave us a realistic chance to see how quickly and effectively existing CQG trading strategies and conditions could be ported to automated trading by the "average trader".

Figure 10a
Figure 10a

Figure 10b

Figure 10b

Figure 10c

Figure 10c

Most of the Wrecking Crew quickly got the hang of plugging things together, though it took a while for some of them to remember that if you change the code of a strategy or condition in CQG you have to restart AlgoEngine so it can reload the revised version. There were also some very full and frank discussion between Crew members about the true meaning and implications of Recalculate on Every Tick, and one or two members took a while to get their heads around the importance of the Lookback setting on the Parameters tab.

However, once those issues were sorted, the general consensus was that for existing CQG users this was about as easy a route from mechanical to automated trading as one could devise, though the relative simplicity of the CQG macro language wouldn't make it exponentially more demanding for new CQG users either.

Reality checking

One of the most important questions regarding any automated trading tool is how well does it cope when things go wrong? Well we had a great opportunity to find out when reviewing AlgoEngine. A particularly staggering display of incompetence by BT meant that more than a month after ordering a particular DSL service for four dedicated lines we still didn't have it. That meant that we had to conduct the review over a single backup ADSL connection that was also carrying a pile of other email and magazine production traffic.

Figure 11

Figure 11

The consequences were fairly predictable in that we ended up seeing a great deal of Figure 12a from CQG. However, what was rather more comforting was that we always saw Figures 12b and 12c from AlgoEngine first. And then when the next batch of vast print PDF files finally made it to the FTP server we finally saw Figure 12d. The bottom line is that if things go pear shaped AlgoEngine lets you know immediately.

While he was extremely reticent about what he had actually done, our resident Linux bore sys admin guru Pete somehow managed to find us some extra bandwidth from somewhere before the end of the review period, so we were also able to observe everything running normally. (Though the production department were a bit mystified as to why the Q4 cover took three days to upload to the printers.)

Figure 12a
Figure 12a

Figure 12b

Figure 12b

Figure 12c

Figure 12c

Figure 12d

Figure 12d

Pricing and value

At present, the three versions (see Figure 2) of AlgoEngine are priced at USD500, USD750 and USD1000 per month respectively. This is promotional pricing and will eventually revert to standard pricing (USD750, USD1000 and USD1500 per month) probably in late 2010 or early 2011.

Even at the standard pricing, that looks decent value - not only in relation to other automated trading platforms, but also in comparison with the cost of developing your own code to interface with the CQG API as an alternative. For existing CQG users keen to switch from mechanical to automated trading, the value proposition is even stronger; as we found, they can be up and auto-trading live within an hour. On that point, it's worth mentioning that AlgoEngine runs with both live and simulated CQG trading, which also offers a great opportunity to "sanity check" back tested models before deploying them with real cash. (Sadly we didn't get the chance to try the real cash bit as inexplicably the Editor still refuses to fund a trading account from his colossal budget.)

Conclusion

We were testing pre-release software, so understandably we encountered the odd hiccup (e.g. help files that didn't reflect the latest functionality and the occasional fatal exception) but the Wrecking Crew and review regulars all agreed on one thing (a miracle in itself). Once the pre-release version we tested hits production (and assuming the functionality remains unchanged) this will be by far the simplest and most effective route to automated trading that we have seen so far - it really is a case of plug'n'trade.

Apart from the simplicity and effectiveness of AlgoEngine, one other thing that made a big impression on the review team was the ability to define custom order execution rules. Although we were only running in simulation mode, the improvement in P&L that could be achieved for even the simplest trading model by just selecting from the odd drop down list and tapping in the odd number was striking.

Crew Views

Almost without exception this issue's Wrecking Crew guest artistes would qualify as potential users of AlgoEngine, so we asked two of them to provide an insight on how it might fit into their existing trading routines.

Allan B (arcade based prop trader mostly using momentum based trading models): At present I'm using relatively simple mechanical trading systems written in CQG's macro language and executing trades manually. AlgoEngine could therefore potentially be a handy productivity and diversification trading tool for me in that I could use the time I would be saving on manual trade management to develop additional trading models.

Gerry K (arcade based statistical arbitrage trader): AlgoEngine might fit very nicely with my existing trading activity. One advantage of the CQG API is that it allows me to access a range of external applications that hugely expedite the development and trading process. I'm running reasonably computationally intensive tests for properties such as cointegration across a very large number of combinations of stocks at a tick by tick level. Using the API, I can do this in MATLAB and in the process also utilise Accelereyes Jacket (which was reviewed in Automated Trader a while back). Jacket allows me to run the analysis extremely quickly in the MATLAB environment using NVIDIA GPUs and then pass the output values in real time to CQG trading systems. The only snag is that this process generates a lot of trades that have to be handled manually, so potentially worthwhile opportunities often have to be passed up when things get busy. AlgoEngine could help overcome this problem by snapping neatly onto the end of my current workflow to provide trade automation.