New Book on Backtesting with Zipline

543 views
Skip to first unread message

Andreas Clenow

unread,
Aug 8, 2019, 10:22:59 AM8/8/19
to Zipline Python Opensource Backtester

Hi guys,


My third book is just released today. Trading Evolved is an in-depth guide into the world of Python based backtesting. Starting with the assumption of little to no prior knowledge, I'll take you on a ride which will eventually show you how to construct advanced trading models for equities and futures.


I started writing this book a year ago after finding a lack of this type of explanatory documentation in the Python world. The tools available to us are incredibly powerful, but it is not easy for most people to really get into this way of working. It can be a daunting process to learn about Python and backtesting, both from a technical and financial perspective.


My new book is highly practical and full of source code and detailed explanations. It's my intention that by the end of this book, you will be well on your way to becoming a professional systematic trader.


You can find the new book here: https://amzn.to/31tDkwn


A considerable amount of work has gone into writing this book and I hope that the community out there will have use for it. I would greatly appreciate reviews, comments and feedback.


Thank you,


Andreas

Peter Sikuda

unread,
Aug 8, 2019, 10:36:33 AM8/8/19
to Zipline Python Opensource Backtester
Hello Andreas,

would be interested in the book, but in electronic format (epub, pdf..). Also would like to see some sample and contents of the book.

Peter


Dňa štvrtok, 8. augusta 2019 16:22:59 UTC+2 Andreas Clenow napísal(-a):

Andreas Clenow

unread,
Aug 8, 2019, 10:41:27 AM8/8/19
to Zipline Python Opensource Backtester
Hi Peter,

The Amazon "look inside" feature takes a week or so to get enabled, for some tech reasons I haven't fully understood.

The Kindle version is available, for $9.99. I didn't publish pdf and epub, mostly because it usually takes a few hours before those files are all over various download sites. Sure, Kindle isn't all that hard to copy, but it tends to take a little longer. Having spent a year writing something, it can be a little annoying to see pdf copies sold over ebay and the like a few days after publication...

Peter Sikuda

unread,
Aug 8, 2019, 10:45:50 AM8/8/19
to Zipline Python Opensource Backtester
I see the Kindle version was just released and that is just fine (actually I meant the amazon mobi format not epub).
Will check it out, but it was not available on the page of paperback book.

Thanks,.

Dňa štvrtok, 8. augusta 2019 16:41:27 UTC+2 Andreas Clenow napísal(-a):

Peter Harrington

unread,
Aug 19, 2019, 4:11:58 PM8/19/19
to Zipline Python Opensource Backtester
Excellent job Andreas.  This book was sorely needed.  

caleb johnson

unread,
Aug 19, 2019, 4:44:08 PM8/19/19
to Zipline Python Opensource Backtester
Bought it and am going through now. Very helpful. (Though having some problems installing Zipline through Anaconda. Which is how I wound up here.)

HamstersAndGuineaPigs

unread,
Aug 19, 2019, 4:51:48 PM8/19/19
to Zipline Python Opensource Backtester
I agree. We’re missing a basic getting started guide on this topic, including code snippets on how to get daily close data (also in Europe). Don't get started about Quantopian etc, it needs to run locally not in the cloud. And I need to trade live.

For the rest - Andreas thank you for your books! Have been trading your momentum strategy but it’s lagging behind in this volatile market. So need to test others and had to write my own backtesting code to get there because I couldn't get Zipline to work properly locally. Took me 6 months!

Andreas Clenow

unread,
Aug 20, 2019, 1:57:09 AM8/20/19
to Zipline Python Opensource Backtester
Thanks guys! I hope you'll find use for the book.

I have started an errata and updates log on my website. Seems like I got a bit unlucky in timing, in that Conda 4.7 refuses to install Zipline. Workaround is on the errata page. 


For me, this is all a hobby. Writing books and such doesn't generate enough money to matter, but I enjoy it, and I'll keep doing it for as long as it's fun and as long as people seem to like it. If you want to vote for further books, Amazon reviews is a good way to do it. :)

Also, on the actual strategies in the book: My personal view is that the most valuable learning experience in the book should be the chapter on term structure trading. If you understand this concept, you should be able to construct some very interesting, non correlated models with attractive return to risk properties.


caleb johnson

unread,
Aug 20, 2019, 7:45:54 AM8/20/19
to Zipline Python Opensource Backtester
Thanks. I will definitely post a review once I've finished the book (soon).
Message has been deleted

maxim gir

unread,
Sep 2, 2019, 7:54:19 PM9/2/19
to Zipline Python Opensource Backtester
Hi Adreas, I've almost finished reading your book. I'm not a new to Quantopian Zipline libraries but still find some section useful for me, especially futures trading. I think the only part is missing in your book is how to deploy the algorithms live. 
I was really disappointed when Quantopian removed live trading functionalities few years ago and I wasnt able to find any alternatives to it since then. I wish they can offer this servive in future. I tried QuantConnect, but its compiler is just so not pythonic and not user friendly that i gave up on them. Hopefully , someone can find a robust solution for Zipline live trading in future and can write a tutorial / book on it. 

Andreas Clenow

unread,
Sep 3, 2019, 1:49:00 AM9/3/19
to Zipline Python Opensource Backtester
Hi Maxim,

Yes, you are right, but it was a deliberate omission. 

I considered incorporating Zipline Live and detailing how to get live trading up and running. There is a big risk with writing such a chapter though.

With a book such as this one, with this amount of code and covering a fragmented tech like Python, there is bound to be errors and issues. I could have had a typo in my code, or certain user configurations could result in errors of all kinds. But without live trading, the worst thing that can happen is that the code crashes, or a backtest shows a bit weird results. 

With live trading in there, the worst thing that can happen is that readers blow up their account due to some big. And that's when I would need to duck and cover for the incoming lawsuits. 

I agree that this is an important topic, but writing about it is a legal mine field, in particular for a regulated asset manager.

maxim gir

unread,
Sep 3, 2019, 8:19:19 PM9/3/19
to Zipline Python Opensource Backtester

Andreas, 


Thank you for your reply. Now I understand why you didn’t include the section on live trading integration which would be a nice logical conclusion to your overwise excellent book.


On the side note, if someone decided to go live trading with Zipline, which python package would be a good start (preferably with IB and/or Crypto exchanges integration)? In your reply you mentioned Zipline-live but it’s still using old Zipline under Python 2.7 and doesn’t have much attention on GitHub recently and didn’t find any mention that anyone trades real money with it.  There is also Pyalgotrader which is not compatible with IB, Enigma Catalyst was promising for crypto trading but was suddenly dropped by Enigma and virtually dead now. 


Or the only solution left for amateur python traders/developers to use cloud solutions such as QuantConnect, QuantRocket etc. which are pain to use in my view? I’m just asking for your personal opinion and of course a disclaimer that we all should be aware about trading risk and should blame only ourselves for all trading losses etc 😊


Maxim

ajjcoppola

unread,
Sep 3, 2019, 9:47:49 PM9/3/19
to Zipline Python Opensource Backtester
Maxim,
Live trading with a version of Zipline-live(Zipline+IB) is being done by a few people(including my brother and I).
There is a long "install/usage" thead on the 
workspace.  You can join that Slack channel and peruse the thread.

The install and usage path is rather convoluted.  For me, I'm using an AWS conda instance, with a Jupyter GUI that hooks up to an IB-TWS instance anywhere.
We are working on containerizing it, and have plans to use that commercially(although currently, we are only doing trading for ourselves), with the potential future clients running their own IB-TWS, so don't have any time to help people with their various install problems...which, yes, did take us a way-too-long time to sort through.  I now understand one of the reasons that Q got out of the business!

We do though, plan on Github releasing a container that just works, with the environment we use.
For example, we have no incentive or reason to run zipline or live trading on a windows machine so if you want that, you'd have to do it yourself.

The other hidden problem with live trading is there really is no free data that is reliable, so you'll have to pay for data.  Q handles all that for you on their platform.
The way I look at it is that you should be able to make enough money to support your data-feed fees, otherwise just use TDAmeritrade, Robinhood, etc.

Another platform you don't mention is Alpaca.  That might be a good fit for you.  

As Andreas mentions, there are many legal hurdles with delivering Algo Trading to others.  Doing it for yourself is fine.
Our model will be to deliver a software app/tool and have the user control the trading, even if that is only to set up the link to the trading API and push buttons to execute strategies.  Essentially, using an automation tool(e.g. zipline-live) to drive a trading station. 

alan

maxim gir

unread,
Sep 3, 2019, 11:43:04 PM9/3/19
to Zipline Python Opensource Backtester

Hi Alan,


Thank you for your reply and for all your time that you and your brother dedicated developing Zipline-live. I like your idea to deliver a tool to give a user control the trading and the flexibility to run Zipline strategies on his own machine. If you can deliver such a product which can be in a form of a docker file with clear instructions how to install it on AWS it would be a huge progress, and many users would be happy to purchase it for a reasonable price. If you can integrate futures trading in your package it would be an additional bonus. As for now, I couldn’t find any similar products on the market.


Also, you mentioned Alpaca as an alternative to run Zipline but it looks like it only supports Alpaca which is not an option at least for me (I’m from Canada and we don’t have Alpaca here so my only option is IB).


Meanwhile, it would be appreciated if you can send me a slack invite to your channel, so I can get a closer look at your package.


Again, thank you for your work,


Maxim

ajjcoppola

unread,
Sep 4, 2019, 1:11:45 AM9/4/19
to Zipline Python Opensource Backtester
Maxim,
Sorry if I mislead you.  
First, I didn't develop zipline-live, yet we are modifying a version of it.
Second, the containerized version is not developed yet, and there is no firm schedule for it at this moment.
   It'll take me about 2-weeks of wall-clock time when I start to work on it.
Finally, the slack channel is not mine. I believe that if you go to the link above, you can request to be added.
alan

maxim gir

unread,
Sep 4, 2019, 7:42:02 AM9/4/19
to Zipline Python Opensource Backtester
Alan,

Thanks for the clarifications and pointing me in the right direction.  

By the way if someone interested to join zipline-live slack channel, a slack invite can be found here http://www.zipline-live.io/contact

Maxim

Ayoub Ennassiri

unread,
Oct 28, 2019, 11:43:47 PM10/28/19
to Zipline Python Opensource Backtester
Hi Andreas, 

I've just bought the kindle version and I'm going through it. From the first look, I like its practical side. I'll provide you with a more detailed feedback once I advance in reading it. 

As I've been using zipline for quite a while, I'm afraid that people starting with it will encounter many issues in deploying it. For example, the fact that IEX for benchmark data is not available anymore, quandl as well, can be frustrating when first deploying zipline. 

I think that a new release that deals with these issues (separates the required data from the core code), reduces the number of dependencies and that moves the dependencies to a higher releases (including python 3.5 > 3.7), etc would be beneficial to both Zipline and your book. 

I'm interested in contributing to this open source project and checking if there is a core contributor team (I think that Quantopian is now putting more focus on their internal roadmap). 

Thanks
Ayoub 

LAKSHMI VENKATESH

unread,
Oct 30, 2019, 5:42:45 AM10/30/19
to Zipline Python Opensource Backtester
Hi Andreas,
Excellent work. Will buy the kindle version today!. We are looking to use Zipline to backtest Derivatives, more specifically, 

  • FX Forwards
  • Futures
  • Options
along with stocks.

Is it possible to do so? By any chance have you covered it in your book.

thank you
Lakshmi V

Andreas Clenow

unread,
Oct 30, 2019, 5:55:56 AM10/30/19
to Zipline Python Opensource Backtester
Stocks and futures are no problem. If you want to model other types of derivatives you'll need to be prepared to make extensive modifications to the framework. As usual with Python, anything is possible if you're happy to put in some hard work and get it done yourself.
Reply all
Reply to author
Forward
0 new messages