Congratulations on getting so far in our studies! I know that this lesson was very long, but hopefully not boring. We covered virtually all aspects of developing live trading applications and backtesters, so now, you are well equipped with powerful tools that should help you develop great trading strategies.
Let’s quickly summarize what we learned in this lesson and outline some vistas.
We now fully understand all four essential components of any trading app: receiving data, processing it, generating orders, and controlling their execution.
We are also familiar with the most typical technical issues, such as incorrectly emulating order execution or processing non-market prices, and we also know how to work around them.
Then, we learned how to synchronize multiple threads by using queues and threading event objects, and we know how to make sure that every component of the trading app runs exactly at the expected moment.
Next, we learned how to rebuild parts of strategy performance manually to check the correctness of a test or live orders generation and execution. Now, we can be 100% sure that we can rely on the code we wrote.
We even created our first Holy Grail of trading – and immediately broke it into pieces by critically reviewing the code, thus learning the main lesson of systematic trading: not the tiniest detail can be missed, intentionally or occasionally, and you should check your results twice before going to production to avoid very unpleasant surprises when trading with real money.
Now, let’s point out where we can go further in our development.
First, at the moment, our platform only supports market orders. Yes, from the previous lesson, you may remember that in many cases, market orders are preferred and that we can always emulate orders of all other types with market orders only. However, at least for development purposes, it would be great to add emulation for limit and stop orders.
In its present form, the code does not implement any risk management, neither at the position nor the strategy level. It is essential to add at least basic stop-loss orders that will protect the trading account from an unexpected catastrophic scenario.
It would also be great to calculate at least some very basic statistics about the strategy’s performance: at the moment, we can only analyze the equity time series, but we want to know more about the average trade value, number of trades, percent of profitable trades, and so on.
And of course, we can complicate the platform further by adding multiple strategies, grouping them into portfolios, and achieving the highest level of sophistication by adding multiple incoming live data streams. Although this is definitely outside the scope of this app, let me encourage you to be bold and curious, as any true researcher should be, and play with the existing code and try improving it –you will see that, in the long run, your efforts will be highly rewarded.
The remaining lessons of this app are dedicated to implementing trading strategies of specific types. We will add a few components to the backtesting platform we created in this lesson, but no significant changes will be made. Instead, we will focus on developing the strategic logic and analyzing its theoretical performance.
Leave a Reply