Unlimited Securities

We removed the size limits on your security trading universe. Your algorithm has access to all stock prices, and doesn't have to define a tradeable universe during startup. You can read more about this change on the universe page.

Quantopian 2 API

We've expanded the Quantopian API to make it easier to manage the larger universes.

data.current(security_list, field) gets the most recent price/volume value. Learn more

data.history(security_list, field, bar_count, frequency) get a price/volume lookback window. Learn more

data.can_trade(security_list) make sure the securities are tradeable before ordering. Learn more.

data.is_stale(security_list) checks if current prices were forward filled, or are fresh this minute. Learn more

API Deprecations

A few areas of the old API were deprecated during the development of Quantopian 2. The majority of algorithms written in the old API will run on Q2 without any changes. Some algorithms will still run in backtest, but will get deprecation warnings. The deprecation warnings will refer to a specific section of the migration guide. You will need to remedy any deprecations before your algorithm can be submitted to the contest, live trading, or real money trading. If you are having trouble updating your algorithm, please contact our support team using the feedback button at the top of your algorithm page, and we will be happy to help.

As-Traded Pricing

In Quantopian 2, your algorithm gets "as-traded prices" at all times, resulting in more accurate pricing, volume, and order fill simulation. Read more about as-traded pricing.

Lookback Window Fully Dividend, Split, and Merger-Adjusted

In Quantopian 2, when your algorithm looks back at a historical window of data, that data is fully dividend-, split-, and merger-adjusted. Read more about adjusted prices.

handle_data Is Now Optional

handle_data() is no longer a required function. In Quantopian 1, all of the minutely data was pre-loaded and fed through handle_data(), one minute at a time. In Quantopian 2, the data is only loaded when you ask for it. The most efficient algorithms use scheduled functions and load data only when necessary. Functions that are placed in handle_data() will run every minute; that should only be done if truly necessary. The best practice is to omit handle_data() entirely. The only function that is required in an algorithm is initialize(context).

Orders Close at End of Day

In Quantopian 2, all orders are closed at the end of the day. This resolves what was one of the biggest differences between backtesting and real money performance with Q1. Previously with Q1, our backtester has held orders open until they were filled, even over multiple days. With Q2, backtest order behavior is just like real money trading. Limit and stop-loss orders will be particularly affected; these orders will need to be placed again every morning.

No More Daily Mode

The old backtester had two modes, "minute" and "daily." The daily mode was faster, but was very problematic. The results of a daily backtest were definitionally different from minute backtests, and real-money trading is entirely minutely. The daily mode ended up causing a lot of confusion. Q2's backtesting performance is much faster than Q1, particularly if the algorithm is built with best practices. An algorithm that rebalances once per day in minute mode will be just as fast as a daily-mode algorithm, and provide a more accurate simulation.

Default Commission Model

The default commission was first set in 2012, and we have much better information today about expected trade costs. The new default commission model is $0.0075 per share, with a minimum trade cost of $1.

Default Slippage Model

The old default slippage model permitted algorithms to take up to 25% of the trade volume per minute. When that happened, the trade incurred huge price impacts. The new default slippage model limits orders to 2.5% of the bar.

Fixed Slippage

When a fixed slippage model is used in Quantopian 2, all orders for a security are completely filled on the first subsequent bar with non-zero trade volume, regardless of how large the order is. This is a slight change from Quantopian 1, where the fill happened on the subsequent call of handle_data; it didn't need a non-zero trade volume to fill.

Custom Slippage

In Quantopian 2, the data object is now passed into your custom slippage model. Your custom slippage model can get prices, history windows, and more. That permits you to do create much more complex fill logic, including volatility analysis or other market conditions.

Backtest Pricing Data Source Change

For many years Quantopian has used Nanex's NxCore price and volume data for live trading, but has used a different data source for backtesting. With Quantopian 2, the backtester now also uses NxCore data for simulations between March 2012 and the current day. Data from before 2012 has not been updated to use NxCore, and still uses the previous vendor.

Zipline

Quantopian is built on our open-sourced backtester, Zipline. Most of these changes can be found in our latest zipline revisions.

Backtest Result Changes

Because the data and execution using Quantopian 2 is different than Quantopian 1, many algorithms will have slightly different results when they are re-run on Quantopian 2. A few algorithms will have significantly different results. If you're having difficulty with an algorithm running with Quantopian 2, please contact our support team using the feedback button at the top of your algorithm page, and we will be happy to help.

Get Started on Quantopian