Editor’s note: While using automated computer systems and frameworks can generate considerable alpha for traders, systematic trading does still require technical analysis of the market and a sound understanding of coding.
However, coding isn’t the simplest of languages to understand. In an effort to help make programming less daunting to traders, chief investment officer at ACIES Asset Management, Andreas Clenow has written a practical guide to understanding the basics of how to build a quantitative analysis system.
“In my view, if you want to be in this business you need to understand programming,” he explains. “That scares people a lot, so I figured that I’d write a book that explains this in a way that almost everybody can get.”
“In my view, if you want to be in this business you need to understand programming. That scares people a lot, so I figured that I’d write a book that explains this in a way that almost everybody can get”
The following is an excerpt from his new book Trading Evolved: Anyone can build killer trading strategies in python, published with permission.
Chapter 1: About this book
This book will guide you step by step on how to get familiar with Python, how to set up a local quant modelling environment and how to construct and analyse trading strategies. It’s by no means an exhaustive book, either on Python, back testing or trading. It won’t make you an expert in either topic but will aim for giving you a solid foundation in all of them.
When approaching something as complex as back testing trading strategies, every step on the way can be done in a multitude of ways. This book does not attempt to cover all the different ways that you could approach Python trading strategies. A book like that would require many times the text mass of this book. But more importantly, a book of that type would likely scare away the bulk of the people that I want to address.
“When approaching something as complex as back testing trading strategies, every step on the way can be done in a multitude of ways”
The point of my books, all of my books, is to make a seemingly complex subject accessible. I want to take a subject matter which most people find daunting and explain it in a way that a newcomer to the field can understand and absorb.
My first book, Following the Trend (Clenow, Following the Trend, 2013), was based on exactly that premise. Having spent some time in the trend following hedge fund world, it surprised me when I realised how many myths and misunderstandings surrounded this particular type of trading strategy. When I decided to write an entire book just to explain one fairly simple trading strategy, I had not expected the incredible reception that it received worldwide. It was great fun to start off with an international bestseller, and no one was more surprised than I was over the publicity that this book received.
My second book, Stocks on the Move (Clenow, Stocks on the Move, 2015), was the result of a very common question that I kept getting. “Can the trend following approach be applied to stocks?” My initial, instinctive reply to that questions was “sure, but you would need to modify the rules a bit”. After giving it some thought, I realised that the topic warrants a book by itself, and that equity momentum models differ enough from trend following to be classified as a different strategy. Out of this, Stocks on the Move was born.
In my first two books, I tried hard to make everything accessible. Not just understandable but explained in such detail that anyone reading it would be able to replicate it. I researched low-cost software and data, making sure that it’s within anyone’s budget and that the trading strategies and back tests could be reconstructed by readers so that any claim I made could be verified.
It was great to see all the mails over the years from readers who went through the process to replicate and test it all. But there were also many mails from readers who lacked the technical skills to construct the back tests. Many used back testing software which is far too simplistic for any serious portfolio modelling, and some wouldn’t know where to start with setting up a more robust environment.
“I researched low-cost software and data, making sure that it’s within anyone’s budget and that the trading strategies and back tests could be reconstructed by readers so that any claim I made could be verified”
Out of this, a new book idea was born. A book focused on making quantitative back testing of trading strategies accessible to anyone.
The trading strategies in this book
This is not a book full of super-secret trading strategies which will turn a thousand dollars into a million next week. While I like to think that there are some clever trading strategies in this book, it’s not meant to be cutting edge, revolutionary stuff. I would think that most readers will learn some interesting things about trading models, but that’s not the main point of this book.
In order to teach you about using Python to test trading ideas, I need to show some trading ideas to test. I will show you a few models which I hope will be helpful. You will see complete trading models for ETFs, stocks and futures of varying degree of complexity. I will use these trading strategies as tools to explain what capabilities you will need and how to go about making these strategies real.
I often stress in my books that any trading strategy shown is a teaching tool and not meant for you to go out and trade. I will repeat this statement a few times throughout the book. I would strongly discourage anyone from copying anyone else’s trading strategies and blindly trading them. But this is after all where this book comes in.
“I would strongly discourage anyone from copying anyone else’s trading strategies and blindly trading them”
What I do recommend is that you read about other people’s trading strategies. Learn from them. Construct a suitable back testing environment and model the strategies. Then figure out what you like and what you don’t like. Modify the parts you like, find ways to incorporate them into your own approach and come up with ways to improve the way you trade.
You need to make the models your own to fully understand them, and you need to understand them to fully trust them. This book will give you the necessary tools and skillset to get this done.
How to read this book
If your mind is set on taking quantitative back testing of trading strategies seriously, then this is a book that you will probably want to spend quite a bit of time with. For many books, the contents can easily be digested by reading them once, cover to cover. That’s probably the case with my previous books, which each had a fairly small amount of key information to pass on, spending a lot of pages doing it.
As opposed to my previous books, this one has quite a bit of source code in it. My guiding principle has been that anyone with a fair understanding of computers and trading should be able to understand and absorb the contents of this book, without any prior programming knowledge required.
But I have also assumed that anyone who does not have experience building programming code will likely need to go over the book multiple times, with a computer nearby to try the code samples.
This is a practical book, and there is no substitute to actually trying things out for yourself.
My suggestion is that you start by reading through the entire book once, cover to cover. That gives you a good overview of the subject matter and you will find which areas are of most interest to you.
If Python is new to you, start off with the easier examples early in the book. Make sure that you understand the basics before moving to the heavy stuff.
“Make sure that you understand the basics before moving to the heavy stuff”
The most difficult part in this book, from a technical point of view, is probably to get your own data imported into the Zipline back tester so that you can run back tests based on that. I have tried to make this part as easy as I can for you, but there are plenty of ways that things can go wrong.
My most important advice here is not to give up. The initial learning curve may be a little steep, but few things worthwhile are easy. Don’t get scared off by the tech vocabulary and the scary-looking code. Yes, this will take a bit of work for most people to learn, but really, anyone can learn this.
By Andreas Clenow, who is the chief investment officer at ACIES Asset Management. He’s held numerous positions in the market, from partner to hedge fund manager at firms such as Equilateral Capital Management and Reuters. Clenow is the author of two previous books on trading including Following the Trend and Stocks on the Move.
Disclaimer Past performance is not a reliable indicator of future results.
CMC Markets is an execution-only service provider. The material (whether or not it states any opinions) is for general information purposes only, and does not take into account your personal circumstances or objectives. Nothing in this material is (or should be considered to be) financial, investment or other advice on which reliance should be placed. No opinion given in the material constitutes a recommendation by CMC Markets or the author that any particular investment, security, transaction or investment strategy is suitable for any specific person.
The material has not been prepared in accordance with legal requirements designed to promote the independence of investment research. Although we are not specifically prevented from dealing before providing this material, we do not seek to take advantage of the material prior to its dissemination.
CMC Markets does not endorse or offer opinion on the trading strategies used by the author. Their trading strategies do not guarantee any return and CMC Markets shall not be held responsible for any loss that you may incur, either directly or indirectly, arising from any investment based on any information contained herein.
*Tax treatment depends on individual circumstances and can change or may differ in a jurisdiction other than the UK.