Setting up a trading algo that works smoothly, like a well-oiled machine, is not a trivial endeavor. There are many, many parameters that you have to take into account. It begins with the signals your algo is generating to the margins in your account, volatility, gains and, of course, risk. Certainly you’ve used our previous tips to build your algo and to draft your strategy. So how do you incorporate all those elements and optimize your algo for the greatest precision?
How do all the quants make their algos run smoothly like a Swiss watch? You have to treat your algo like a machine, built up with numerous mechanisms. Because of course, that’s what an algo really is. I like to call those mechanisms boxes. Now don’t despair if you think it all sounds a bit too complicated. By the time you reach this article’s conclusion you’ll have realized that it’s all quite simple and logical.
An Algo Made of Boxes
So what is the approach quants use that I like to call boxes? You divide your algo into separate mechanisms, or boxes, if you will. Each box will become a stand-alone mechanism that receives input data and generates an output. There will be one box that we can consider the brain; that box decides if it is a go/no go for the specific trade. The brain box gets all the inputs from all the other boxes.
Signal Box- The signal box scans prices and parameters, such as the moving average or any other condition you have written into it. Basically, these inputs are the rules of engagement you had early written for your algo. One simple rule could be, let’s say, 14 days moving average < 30 days moving average = signal to sell. Typically, this box will be running prices in several pairs.
In other words, its input data and its output would normally be three parameters; an entry signal, a recommended stop loss and a limit. Of course, once again, these inputs are according to the parameters you have already defined.
Risk Box- The risk box, as its name implies, is the box in charge of risk monitoring. This one is a bit more complicated. The risk box gets input from several sources. It gets the risk, i.e. stop loss required, from the signal box. Moreover, the risk box constantly reads your available margin.
Its output is a go/no go on each trade that exists, based on the parameters you entered. For example, how much you want to risk in total or the minimal available margin to be left in the account.
Let’s say you have a free margin of 11% and you set up a minimal margin of 10% in the risk box. The signal box will send output of an upcoming trade.
The risk box can calculate that the executed trade would take 2% from your remaining margin. You started with 11% so that would leave your free margin at 9%. Therefore, the output from your risk box will be a no go for this trade.
If you had had 13% free margin rather than the 11%, the output would be a go. Of course, there are many more options to program into this box but this is the simplest one.
Volatility Box- The volatility box might be the most complicated to program. However, volatility charting is something we covered fairly thoroughly in these articles – Volatility & Your Trade, The World of the VIX, Using VIX Alternatives. The box’s task is to chart market volatility and provide an output if volatility is about to change dramatically. A major change to volatility could, of course, warrant a change in your strategy.
Execution Box (aka the Brain Box)- Easily can be considered the most important box of all. This box is in charge of making the finally decision. It gets input from all the other boxes and decides if the trade should be opened or not. It also decides if a strategy needs to be changed.
For example, if the volatility box signals an upcoming surge in volatility the execution box may decide to close some trades. Or it could instruct the signal box to change into a secondary signal model suited to high volatility. There are many other ideas that you can program into it.
How Boxes Help You Win
All of those boxes can help you make your algo run more smoothly and efficiently. How? Quite simply because it lets you optimize your algo to a much higher level. It provides you with flexibility to easily adjust each mechanism. More importantly, it lets you monitor the inputs and outputs of each box and assess which needs fixing.
Algo Box: The Bottom-line
Of course, the partitioning into various boxes is not a new algo concept. It’s also not rigid; there’s no need to do it exactly as I did. If you’re intrigued by the Algo mechanism box concept and want to delve into it a bit farther you’re in luck. I highly recommend the book Inside the Black Box by Rishi K. Narang. I’ve found that it sheds a great deal of light on what some might construe as a complicated strategy.
And for those of you that are short of time? You can use this as a basic guide on how to make your algo run smoothly, without reinventing the wheel.