Lean (Quant Connect) vs. Zipline-reloaded

Hi Stefan & Community,
I recently purchased the ML for trading book and have found that Quantopian is shut down and therefore Zipline is no longer supported. I see that there is a Zipline library that has been updated by you Stefan, to work with updated versions of python. However as I am only now beginning the code for my machine learning program, I am wondering if it would make more sense for me to use LEAN with Quantconnect as it is being maintaned by a company and I don’t have to be as concerned that the library that I am using will cease to be maintained after I write my code. Is this a reasonable concern? Besides the obvious benefit of having the code samples that Stefan has written, are there functional bennefits to using Zipline over Quantconnect’s Lean? If so what are they?

2 Likes

Update: Since I didn’t get any responses I thought I would follow up on this myself. I attempted to work with Zipline initially because there was a lot of example code provided by Stefan. However, I found it hard to work with because it doesn’t seem to have a large community maintaining it these days. We eventually decided to go with backtrader which seems to be the most popular library for backtesting these days. I would be interested in what others are using for backtesting, whether it’s Zipline, Backtrader or another library.

Sorry for the extremely late reply. Just released the latest version here.

QuantConnect has the advantage that it provide access to data through their platform. Similar to Quantopian before they shut down.

Zipline, in contrast, runs offline so you have full control but are on your own when it comes to data. Backtrader is similar - it’s much simpler but has also not seen a release in over .two years… It really depends on what you are looking for and how much development you want to invest yourself.

3 Likes

I had used QuantConnect for a month. I paid for the Researcher subscription which was quite affordable: $8 a month + $20 a month for a backtesting node. They have data for backtesting up to 1 minute resolution, good learning resources and a neat webUI, however there were a few things that I did not like and stopped using their platform. Most of all it was extremely slow as compared to Python-based software I used on my laptop, ie. it took nearly half an hour to complete a backtest over a 14 month time period, so that gives a rate of 10 trading days or daily bars per 1 minute of backtesting which was unacceptable to me. I suspect the slowness was mostly due to the fact that the Python API is a wrapper for their native C# API, so you cannot take advantage of vectorization and other optimizations offered by numpy, pandas or other Python libraries people use for dealing with numerical data - there is a lot if iterations at every step instead. Also LEAN is not really Zipline and it has its own specifics.
I think QuantRocket could be better, because it is 100% Python, but the subscription is very expensive and they do not host it for you - you have to deploy it yourself in the cloud or on your own premises.

2 Likes

Thank you for sharing, this is quite interesting. Just starting to look into Python vs C# performance comparison.

My 2 cents here. I’ve been developing my own trading system for 1 year already, and when I was deciding what library/framework/platform to use I ended up using backtrader, because it is super fast, its core code is easy to understand and modify (I added a few major features for my particular needs) and offers plenty of functionality off-the-shelve. It is true though that it doesn’t provide native integration for downloading market data, but that is fine because I needed to code my own data integration layer anyways.
To place orders in the exchanges, I also had to create my own integration with Binance.
In conclusion, I guess it all depends on your use cases. Each option will have pros and cons. What is sure, is that sooner or later you will have to spend quite some time coding lol!

I gave QuantConnect a solid try, and I just really didn’t like it.

Zorro Trader is actually impressive, but I’m frustrated by how disorganized everything becomes when going from research phase in jupyter to backtesting and optimization in zorro.

The backtest analysis from zipline (I’ve seen in videos) looks really solid, so I’m hoping it will workout.

What’s really enticing to me about zipline is the potential to organize my whole research-to-deployment workflow inside one git repo and use VS Code for every step of the journey.

2 Likes

Zipline is very flexible. You can model any investment strategy imaginable. Of course, all that flexibility comes with trade-offs : Limited documentation and support leaving you having to debug technical issues on your own most of the time, among other.

I have found other backtest engines to be good, but not as flexible as Zipline when it comes to modelling and running simulations that are realistic.

At this moment there is a pesky little issue when trying to import Zipline to your programme for ingesting data and running backtests which I hope will be resolved soon.

Best of luck

What about running Lean locally with Lean CLI?
Would it be superior to Zipline?