Custom Trading System 1: Rapid Prototyping to Live Trading

0 comments

This series of articles is intended as a general guide to designing one’s first trading system, whether from scratch or using some widely available tools. I will place more emphasis on the technical aspects of the implementation rather than the strategy design itself. However, the intended strategy design might affect your final implementation.

In this first article, we will discuss the transition from rapid prototyping to live trading.

How to Prototype Your Strategies Now

Before you go off and start designing your own trading system, I would advise that you do your research on the effectiveness of your trading algorithms. For this task, I would recommend using [Zorro]. There are many reasons:

  • Test, Train, Demo Trade, and Live Trade virtually any strategy.
  • The backtests are extremely fast, since it was primarily written in C/C++.
  • Walk-forward optimization testing
  • Connect with R for big data analysis.
  • Machine learning, including deep learning. CUDA is supported using R libraries, such as Keras and Tensorflow.
  • It can connect to any broker, thanks to its broker plugin API. (I wrote three such plugins, two of which are available on GitHub: [Ally Invest Plugin], [Sierra Chart Plugin])
  • It is easily extensible with any DLL library exporting C functions. (I also wrote [such a library].)

There are many more reasons to have Zorro in your arsenal, and many of them are addressed in The Financial Hacker’s blog post: [Hacker’s Tools].

The quickest way to get started with Zorro is to make your way through its [official walk-through]. You can also check out Kris Longmore’s Zorro-based strategy development course at [robotwealth.com].

How to Trade Your Strategy Now

Have you done your due diligence? Don’t take this question lightly – you can wipe out your account, or worse, owe money to your broker if you’re not careful.

So let’s say that you have designed a profitable strategy, and it has been optimized to stable parameters, and it performs well in a walk-forward optimization test, risk has been managed, drawdown is acceptable, your 95% monte carlo drawdown does not scare you, and your position sizing is appropriate. (I suppose you will need to add and subtract from this task list, depending on the strategy type.)

Let’s say you did all of that. You can trade live right now! Just simply connect Zorro to your broker, and you trade away.

For most independent low-volume, low-frequency traders, this will be a satisfactory configuration. However, once the trading volume becomes particularly large or frequent, or if bandwidth becomes a problem, a custom solution might be necessary.

Below, we will investigate trading live with Zorro, as opposed to live with your own custom system.

Trading Live with Zorro

Pros

  • No need to re-program your rapid prototype strategy into production code. That is, your final prototype becomes your live code.
  • Your pure Lite-C strategy will be compiled down to native binary code. This means your code will be relatively fast.
  • Zorro itself is relatively stable to use out of the box, and it receives regular updates.

Cons

  • If your live strategy uses R, this can potentially cause a speed bottleneck. Also, this will increase your memory requirements – this is especially relevant if you are operating on a dedicated VPS.
  • Zorro runs on Windows. A Windows VPS can be slightly more expensive than a Linux VPS due to licensing costs. Other Zorro users have been able to get Zorro running on Linux using Wine, but Zorro is not officially supported on Wine.
  • The Zorro scripts are necessarily single-threaded, which might have implications for scalability. One can work around this issue using multi-threaded DLL’s or by launching worker processes and communicating with them via IPC.
  • Perhaps you didn’t make your prototype in Zorro but in your favorite language, such as Python or C#. In this case, you would need to re-write your trading script in Lite-C and/or R.

Trading Live with a Custom System

Pros

  • You are in absolute control of the system, infrastructure, operating systems, and languages used. It can meet any of your specifications.
  • You are not constrained by any of Zorro’s limitations.
  • Once you have a code-complete implementation, you can more easily identify your bottlenecks and tailor your code to suit.
  • If you have built up a nice modular infrastructure, all you need to do is plug in a brand new strategy.

Cons

  • There is much more project management and engineering required. This will cost time and money.
  • There can be a long lead time to implementation. This lead time can be reduced using delegation.
  • If you identified a market inefficiency using Zorro, perhaps you will need to hurry up and re-code it in order to exploit it. Time is ticking – many of these inefficiencies do not last very long. (If you built up a modular infrastructure already, this might not be a problem.)

In our next Custom Trading System article, we will investigate various design considerations.

If there are any particular aspects of custom trading systems you would like me to cover, please let me know in the comments section below!

Andrew