Quantopian Alternatives
Quantopian icon →   QuantRocket icon

How You Can Still Use Quantopian

Quantopian shut down, but its lecture series and open-source tools are available in QuantRocket.

Quantopian was a crowdsourced hedge fund that operated a popular web platform that allowed users to research and backtest quantitative trading strategies. The hedge fund and community platform shut down in 2020, but the tools and educational materials that Quantopian released under open-source licenses continue to be maintained, modernized, enhanced, and made available in QuantRocket. Find out why QuantRocket is the best Quantopian alternative.

The Quantopian Lectures

Anyone can become an expert in quant finance with the Quantopian Lecture Series.

The Quantopian Lecture Series is a comprehensive, 45-part lecture series for learning quantitative finance. The series introduces Python's scientific computing libraries and covers numerous topics in statistics and finance. Released under a Creative Commons license, the lectures are available in QuantRocket (renamed the Quant Finance Lectures) and have been updated to use QuantRocket data and modern versions of Python libraries.

Quantopian Lectures

Quantopian Tools: Pipeline, Alphalens, Zipline, and Pyfolio

Quantopian proposed a 4-step quant workflow using its open-source libraries.
You can follow the exact workflow in QuantRocket.

Step 1: Define your trading universe and build an alpha factor using Pipeline.

The Pipeline API, part of Quantopian's Zipline library, lets you screen, filter, rank, and analyze large universes of securities using price, fundamental, and alternative data. Without writing much code, you can define rules and perform computations that are too complex for point-and-click screening tools, and you can apply your rules to large datasets that other code platforms struggle to handle.

from zipline.pipeline import sharadar

# trailing-twelve month fundamentals
fundamentals = sharadar.Fundamentals.slice("ART")

# create a universe of the top 50% of stocks by market cap
# that also pay dividends
liquid_stocks = fundamentals.MARKETCAP.latest.percentile_between(50, 100)
pay_dividends = fundamentals.DIVYIELD.latest > 0
universe = liquid_stocks & pay_dividends

# Select the cheapest 100 stocks by enterprise multiple from among
# the universe of liquid, dividend-paying stocks  
enterprise_multiple = fundamentals.EVEBITDA.latest
stocks_to_buy = enterprise_multiple.bottom(100, mask=universe)
Alphalens Tear Sheet

Step 2: Analyze the predictiveness of your alpha factor with Alphalens.

Alphalens, a visualization library that pairs tightly with Pipeline, shows you the relative performance of baskets of stocks bucketed by your alpha factor. Quantopian created Alphalens to help researchers quickly assess whether an alpha factor is predictive enough to warrant further research. Quantopian advised researchers to use Alphalens "early and often."

Step 3: Create a trading strategy based on your alpha factor using Zipline.

If you ever wrote a backtest on Quantopian's platform, you've used Zipline, Quantopian's open source backtester. (The zipline package was rebranded as quantopian inside Quantopian's platform.) Zipline supports equities and futures strategies using daily or minute data and has over a decade of real-world use. QuantRocket has updated Zipline to support live trading, new datasets, better autocomplete, and numerous other enhancements.

import zipline.api as algo

def initialize(context: algo.Context):

    context.assets_to_buy = []

    # Rebalance every day, 30 minutes before market close.
    algo.schedule_function(
        rebalance,
        algo.date_rules.every_day(),
        algo.time_rules.market_close(minutes=30),
    )

def rebalance(context: algo.Context, data: algo.BarData):

    positions = context.portfolio.positions

    # Exit positions we no longer want to hold
    for asset, position in positions.items():
        if asset not in context.assets_to_buy:
            algo.order_target_value(asset, 0, style=MarketOrder())

    ...
Pyfolio Tear Sheet

Step 4: Backtest your trading strategy and analyze the results with Pyfolio.

Pyfolio is a performance and risk analysis library for use with Zipline. A Pyfolio tear sheet shows you everything you need to know about your trading strategy's performance: risk metrics, drawdowns, cumulative returns, performance vs benchmark, exposure, position concentration, total holdings, daily turnover, and more. If Alphalens offers a quick, preliminary assessment of your alpha factor's predictive value, Pyfolio gives you an in-depth look at what to expect if you take your trading strategy live.

Start with the Zipline Intro tutorial in the Code Library for a walk-through of the Quantopian workflow, then check out the Pipeline Tutorial for a more detailed introduction to Pipeline.

Should I use Quantopian's tools outside of QuantRocket?

While it is possible to fork your own copy of Quantopian's open-source libraries on GitHub and try using the libraries on your own, this is not for anyone faint of heart (or pressed for time). The libraries are complex, hard to install, and harder to maintain. They don't include any built-in data integrations, so you must add these yourself before you can use the libraries for research. Various community-led Zipline forks have fizzled over the years due to the amount of maintenance and integration work involved.

Let QuantRocket do the heavy lifting, and get turnkey access to Quantopian's tools so you can focus on being a researcher, not a full-time software engineer.

About QuantRocket

QuantRocket is a Python-based platform for researching, backtesting, and trading quantitative strategies. It provides a JupyterLab environment, offers a suite of data integrations, and supports multiple backtesters: Zipline, the open-source backtester that originally powered Quantopian; Alphalens, an alpha factor analysis library; Moonshot, a vectorized backtester based on pandas; and MoonshotML, a walk-forward machine learning backtester. Built on Docker, QuantRocket can be deployed locally or to the cloud and has an open architecture that is flexible and extensible.

Learn more or install QuantRocket now to get started.

QuantRocket and Quantopian are not affiliated with each other, and this article about Quantopian alternatives does not imply any endorsement of QuantRocket by Quantopian or vice versa.
Questions?