software for
data-driven traders

JupyterLab screenshot
Research and trade
quantitative strategies
in global markets
using Python
Learn for free with a generous free tier. See what's free

feature icon Choose Your Backtester

One size does NOT fit all

The backtesting or analysis library that's right for you depends on the style of your trading strategies. End of day or intraday? 8 symbols, or 8000? Event-driven or factor-based? QuantRocket supports multiple open-source Python backtesting and analysis libraries, allowing you to fit the right tool to the job.

The popular backtester that originally powered Quantopian

Key features:

  • The world's best-known backtester, with over a decade of real-world use
  • Maintained, modernized, and continuously enhanced by QuantRocket
  • Support for equities and futures
  • 1-minute US stock data included
  • Live trading (automated or manual)
  • Pairs with Pyfolio, an open-source performance analysis library
Pyfolio Tear Sheet
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())

    ...

See Zipline code examples or read the Zipline docs

Screen and analyze large universes of securities with Pipeline

Key features:

  • Historical, point-in-time screening and ranking of securities using price, fundamental, and alternative data
  • Define rules and perform computations that are too complex for point-and-click screening tools
  • Designed for large datasets that other code platforms struggle to handle
  • Can be paired with Zipline for backtesting, Alphalens for factor analysis, or used as a standalone tool
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)

See Pipeline code examples or read the Pipeline docs

Quickly analyze the predictive value of alpha factors with Alphalens

Key features:

  • View the relative performance of baskets of stocks bucketed by alpha factor
  • Ideal for long-short or factor model strategies
  • Pairs well with the Pipeline API
  • Quickly assess whether an alpha factor is predictive
  • Use as an initial research step to determine if further investigation is warranted
Alphalens Tear Sheet

See Alphalens code examples or read the Alphalens docs

Moonshot is the backtester for data scientists

Key features:

  • Based on Pandas, the centerpiece of the Python data science stack
  • Fast, vectorized, multi-strategy backtests and parameter scans
  • Daily or intraday strategies
  • Equities, futures, and FX
  • Live trading (automated or manual)
  • Open source, designed by and for QuantRocket
  • Learn more about Moonshot in the Intro Video
import pandas as pd
from moonshot import Moonshot

class MovingAverageStrategy(Moonshot):

    CODE = "demo-50ma"
    DB = "demo-stk-1d"

    def prices_to_signals(self, prices: pd.DataFrame):
        # Buy when the close is above the 50-period moving average.
        closes = prices.loc["Close"]
        mavgs = closes.rolling(50).mean()
        signals = closes > mavgs.shift()
        return signals.astype(int)
    

See Moonshot code examples or read the Moonshot docs

First class support for machine learning strategies with MoonshotML

Key features:

  • Walk-forward optimization: Rolling and expanding walk-forward optimization, widely considered the best technique for validating machine learning models in finance.
  • Incremental/out-of-core learning: Train models and run backtests even when your data is too large to fit in memory.
  • Multiple machine learning/deep learning packages: Including scikit-learn, Keras + TensorFlow, and XGBoost.
import pandas as pd
from moonshot import MoonshotML

class DemoMLStrategy(MoonshotML):

    CODE = "demo-ml"
    DB = "demo-stk-1d"

    def prices_to_features(self, prices: pd.DataFrame):
        closes = prices.loc["Close"]
        features = {}
        # use past returns...
        features["returns_1d"]= closes.pct_change()
        # ...to predict next day returns
        targets = closes.pct_change().shift(-1)
        return features, targets

    def predictions_to_signals(self, predictions: pd.DataFrame, prices: pd.DataFrame):
        # buy when the model predicts a positive return
        signals = predictions > 0
        return signals.astype(int)
    

See MoonshotML code examples or read the machine learning docs

Unrivaled Speed

QuantRocket backtests run up to 75x faster than QuantConnect for data-intensive strategies.

Source: "Why Backtests Run Fast or Slow: A Comparison of Zipline, Moonshot, and Lean"

feature icon Global Data Made Easy

Research without the wrangling

Most quants spend 80% of their time wrangling data and only 20% doing research.
QuantRocket puts a wealth of global market data at your fingertips so you can focus on analysis.

What will you ask the data?

>>> prices = get_prices('us-stk-1d').loc["Close"]
>>> sectors = get_securities_reindexed_like(prices, fields=["Sector"]).loc["Sector"]
>>> eps = get_sharadar_fundamentals_reindexed_like(prices, fields=["EPS"]).loc["EPS"]
>>> eps.groupby(sectors).mean()
>>> prices = get_prices("us-stk-1d").loc["Close"]
>>> borrow_fees = get_ibkr_borrow_fees_reindexed_like(prices)
>>> borrow_fees.where(prices < 1).rank(axis=1)
>>> at_close = prices.xs("16:00:00", level="Time")
>>> near_close = prices.xs("15:30:00", level="Time")
>>> is_up_for_session = (near_close - at_close.shift()) / at_close.shift()
>>> last_half_hour_returns = (at_close - near_close) / near_close
>>> last_half_hour_returns.where(is_up_for_session)
>>> cl_prices = get_prices("cl-fut-1min", times="14:00:00").loc["Close"]
>>> gold_prices = get_prices("us-stk-1d", sids="FIBBG000CRF6Q8").loc["Close"]
>>> contract_nums = get_contract_nums_reindexed_like(cl_prices, limit=2)
>>> month_1_prices = cl_prices.where(contract_nums==1).mean(axis=1)
>>> month_2_prices = cl_prices.where(contract_nums==2).mean(axis=1)
>>> cl_in_contango = month_2_prices > month_1_prices
>>> gold_prices.where(cl_in_contango)

Find your data in the Data Library

feature icon Deploy Anywhere

Run anywhere

Linux, Mac, or Windows. In the cloud, on your laptop, or inside your VPN. QuantRocket runs anywhere Docker runs.

Connect from anywhere

Use QuantRocket as a standalone end-to-end trading platform, or connect to it from other trading applications to query data, submit orders, or use other components you need.

Your servers, your way

Hosted platforms limit your compute resources and require uploading your secrets to third-party servers. QuantRocket's ready-to-use trading infrastructure runs on your servers. Give your hardware as much power as you want, and keep your secrets safe.

feature icon Flexible and Customizable

A platform you can shape to your needs

The search for alpha often takes you down highly individualized paths that result in unique requirements for your strategies. Customization can be essential to getting a quant platform to do what you want.

QuantRocket has an open architecture that runs on Docker and uses JupyterLab as its user interface, making it extremely flexible and extensible. You can run custom scripts to collect data from an alternative data source or calculate custom indicators. You have complete access to the environment and filesystem just as you would with a custom-built system.

Hosted platforms can't offer the same flexibility. If a hosted platform doesn't offer a dial or button that does what you want, you're stuck.

Custom requirements often aren't apparent at first but arise as you get deeper into your research and trading. This makes it risky to adopt a platform that doesn't support extensive customization.

Extend QuantRocket with custom scripts

A simple custom script:

# /codeload/scripts.py

def alert_canceled():
    """Alert if any orders were cancelled today."""

    today = pd.Timestamp.today().date()
    f = io.StringIO()
    download_order_statuses(f, start_date=today)
    orders = pd.read_csv(f)
    cancelled_orders = orders[orders.Status=="Cancelled"]

    for line in cancelled_orders.to_string().splitlines():
        logger.warning(line)

Schedule it to run daily after the close:

30 16 * * mon-fri quantrocket satellite exec 'codeload.scripts.alert_canceled'

A few examples of what's possible:

  • Schedule daily downloads of third party data
  • Create an options trading script that uses QuantRocket's Python API to query data and place orders using the blotter
  • Create and schedule multi-step maintenance tasks such as creating futures calendar spreads based on changing rollover rules
  • Calculate computationally intensive indicators from intraday data and store them in a custom database to make backtests run faster
  • Collect the order files from multiple trading strategies and apply cross-strategy risk management before submitting orders to the blotter
  • Run third-party backtesters such as backtrader

Powered by Open Source...

QuantRocket's flexible, fault-tolerant, and performant stack is built on top of the best open source software available.

...with Tools You Know...

JupyterLab

QuantRocket's home base is JupyterLab, the IDE of choice for data scientists. (VS Code is also supported.)

...and Attention to Detail

Comprehensive hover documentation with auto-complete is available for all of QuantRocket's APIs.

JupyterLab

feature icon Live Trading

Multi-strategy, multi-account

Trade multiple strategies in multiple accounts, or even with multiple brokers, with different allocations for each. QuantRocket keeps it all straight.

Automated or semi-manual

Fully automate your strategies, or manually review the order file before placing it.

Built-in scheduler

Automate data collection and live trading using standard Unix cron.

Supported Brokers

Alpaca

feature icon Real-time Data

Real-time market data, powered by your choice of provider.
An intuitive API with a flexible feature set, powered by QuantRocket.

feature icon Track Your Live Trading

Backtesting is only the first step. Once you go live, you need a clear picture of performance to assess whether live trading is mirroring your backtest.

feature icon Watch an Intro Video

See how to run an intraday momentum strategy using Moonshot, QuantRocket's pandas-based backtester, all the way from data collection to backtesting to live trading to performance tracking.

Find more example strategies in the Code Library

Questions?