Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Upcoming Features, Backtester Changes

Unusually for us, we have several changes coming out together all in a bundle. We wanted to give people a little advance notice of them. This should all ship in the next few days.

In general, we try to avoid making changes to the website that change backtest results. Backtest results should be reproducible, and if they're not, we should have a good reason why not. Some of the changes we're releasing will affect backtest results. I'm sure this is not the last time we'll do this, unfortunately, but we'll continue to keep it to the minimum. Here are the changes, listed roughly in order of how much we think they will impact backtest results.

  • No more end-of-day order cancellation: Today, open orders are canceled at the end of the trading day, including partially filled orders. When we make this update, orders will no longer be cancelled automatically. Paired with this change is the ability for you to cancel orders from within your algorithm. For most backtests this won't make a difference - the orders are filled right away. Algos with orders that take more than one day to fill will see different results.
  • Daylight Savings Time bugfix: Right now when you trade, the first minute bar is marked 14:31 UTC, every day. Unfortunately, that's not correct - during daylight savings time, the first bar should be 13:31 UTC. That bug will be corrected. The behavior of "sell at close" and similar strategies will need to be updated after we fix the bug. This fix will impact some of the end-of-day returns and risk metric calculations; sometimes the day was "ending" prematurely because of DST.
  • Batch transform change: Batch transform will start emitting data one data bar earlier than it used to. If you have a batch transform with a window_length of 10 days, the first data emitted by batch transform is on the 11th day. The behavior will be changed to emit the first data on the 10th day. This behavior is "more correct." This change is bundled with a new rolling-datapanel implementation which will increase batch transform performance by 100X. You can see the code change on zipline.
  • Slippage Update: The current implementation of slippage bundles all of your orders in a given bar (minute or daily) together before applying the slippage model. In the new release, each order is handled separately. For example, consider a scenario where your algorithm places four separate orders for 25 shares of Apple in the same minute bar (or daily bar, depending on your test mode). Today, the slippage model treats that as a single order of 100 shares when calculating the price impact. In the new release, the slippage model processes them separately: first, a 25-share trade; then another 25-share trade, with the knowledge of the previous 25 share's impact; then another 25-share trade, with the knowledge of the previous 50 shares' impact; then the final 25 shares trade, with the knowledge of the previous 75 shares' impact. This change only affects algorithms with more than one order execution of the same stock within handle_data.

We're expanding support for orders and order management. These changes won't affect backtest results. These should give everyone a lot more flexibility while writing algorithms.

  • We now support limit orders, stop orders, and stop limit orders. These are in addition to the existing order type which is a market order.
  • The order method will return a unique order ID which you can use in your algorithm's logic.
  • You can check the status of a particular order using get_order(id)
  • You can cancel an order using cancel_order(order)
  • You can now see your open orders using get_open_orders(sid=sid). If the sid parameter isn't specified then it returns all open orders. If you specify a sid, it returns open orders for that sid.

UPDATE 2013-MAY-8: We are also making a change to the benchmark returns. We found a bug in our benchmark returns calculation. It will result in a small change in the benchmark, which will have some cascading effects to Sharpe, Sortino, etc.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

15 responses

Jolly good stuff.

When can we start using it?

With regard to execution in backtests; whole order will not executed in one bar if there is no volume. Is this also handled in the slippage?

Will the orders include trailing order for limit orders, stop orders, and stop limit orders

Since trading frequency is per bar (Daily / minute) a VWAP / TWAP order would be great. IB provides these orders.

If I say you'll get it later today, then I'll guarantee that we find a blocking bug that keeps us from shipping. So I won't say today.

The case where there is no volume in a given bar is not changed by any of these changes. The order stays open longer (forever), which is different. But the actual behavior is the same. If an order is unfilled in a given bar, the order remains open, and is evaluated again in the next bar.

Trailing orders haven't been built yet. However, the building blocks are there - anyone can code those up now. I agree we can also make them "native" trading objects in the future.

VWAP/TWAP is another interesting idea. All of the tools are there for someone to build that, and we can also do it "natively" in the future.

I just made an update to the main post with an additional change that will make the release.

Supporting this would be better natively. Many brokers already provide the needed orders. Trailing stops and trailing stop limits are a must when trading especially in these times.

This sounds great, Dan! I can sense it getting more ready for real trading with these nuances that are being tweaked. As an IB customer, I'm certainly looking forward to the future and putting some concentrated effort on Quantopian.

Thanks Ken! We definitely are closer to live trading every day. Can't wait to get you trading.

Certainly -- I'm assuming paper trading first to kick the tires.

Which brings up a question... are you going to have a separate Quantopian paper-trading system first (I assume so, given the walk-forward comments), and then an IB customer could also next connect to their IB paper account, and then finally go live? Is this the sort of expected (and prudent) transition? Or, will the paper only be for IB customers with their paper account?

Your progression sounds right to me.

  1. backtest with in-sample data
  2. backtest with out-of-sample data
  3. walkforward aka paper trade. 15-minute delayed data. Zipline (Quantopian's engine) as the "order fulfillment" engine.

Those first 2 steps will always be free. I think step 3 will be free, too, but it depends on whether or not we can keep the data costs low. The steps below will be free to start, but we will have to charge eventually. Realtime data costs money.

  1. Connected to IB, using IB's papertrade mode. realtime data.
  2. Connected to IB, using real dollars, IB doing the trade execution.

You might not need to charge directly as:
1) Many brokers will be more than willing to share their fees with you
2) Quantopians can invest in each other's strategies for a fee and pnl share out of which you can take a transaction cost
3) Quatopian can allocate some prop capital to successful strategies if they are in agreement with the author's strategy
4) You guys can act as talent scouts to identify emerging managers and good strategies for funds which you can provided a platform for the institutions to invest if they like the author's proposed fee structure

Sounds good Dan, on the progression!

As far as "data costing money", if we're trading into IB, then why not let the individual user leverage their paid IB data feed for their Quantopian account? I assume you're connecting via an IB Gateway session, so with our credentials, an intermediate (Quantopian-to-IB) program using the API would be able to get whatever data package the user has with no extra charge. I would not expect that IB would charge a redistribution fee if the account owner is the only one using it. You're just facilitating a connection to IB, for which Quantopian doesn't have separate credentials. (at least that's how I assume it will work.)

Or, was that more a comment on "we need to charge something eventually to provide data, this service, etc. in general". That I can see.
It will be interesting to see what cost model you all develop. Suminda has some out-of-the-box ideas above.
I'm sure that's quite the discussion up there, but first things... :)

@Ken My phrasing wasn't good, but you got it. It more "we need to charge, and live trading is the right point to do so."

@Suminda Our dream business is one where we don't have to charge our members. Shared fees and order routing fees are exciting to think about, but we need to get some trade volume of note before the dollars begin to add up. The other models you suggest are interesting, and we've definitely thought about variations on them. One of the things we need to do is to make sure our interests are aligned with our members. that makes things like prop capital somewhat tricky. Perhaps we'll sort that out tho.

You can make member strategies available to prop shops and institutions though. This would be much more in transaction fees than picking pennies by charging the mainly retail client base.

Also the chance to invest in other successful strategies would be a bonus for the users where you can take a transaction fee.

I mean all this on free structure the strategy developer specifies. This was each developer will look like a micro hedge fund.