Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Could you please confirm these key points about Quantipian / Zipline (and update FAQ?)

I've been studying Quantopian documentation for the past few days and it seems that a lot of critical information is scattered across Community posts and API docs while I expected it to be somewhere in the FAQ. People ask the same questions over and over again.

I am ok using search, but it feels not very productive and in many cases the answers are 1-2 years old, so it's not clear whether they are still valid or not.

Key points:

  1. Quantopian is designed for intraday trading - live trading will always use GTD orders, however backtesting always uses GTC orders
  2. As a consequence, in order to reuse the same algo in backtesting and live, it should manually cancel all orders at 3:59 PM (bar ending at 3:59)
  3. For overnight position strategies the algo should manually re-submit orders at the beginning of each new day (including stops)
  4. Trailing stops are not supported - should be done manually
  5. Regular stops are tricky too, for clean backtesting stops should be placed at the next bar after the market order is filled (and use the actual fill price as a base)
  6. Order modifications are not supported - should be resubmitted
  7. OCO orders are not supported - there is no way to submit a stop order after the main order is filled (partially or in full)
  8. There is no way to define stock universe using stock average volume or price range, only as a percentile of the Dollar Volume traded
  9. Positions and orders are tracked by Zipline framework and may, in theory, diverge from IB (overnight positions, stock delisting, M&A, manual orders, margin call etc). (Asked separately)

Questions / Calls to action:

A. Could you please confirm that the points above are correct?
B. Would Quantopian staff consider making an API FAQ or at least putting these in the "Important Concepts" section?
C. Many of the answers also imply re-implementing tricky order management concepts by hand, which seems like something Zipline should do, or again should be a part of some sort of a "cookbook", hopefully tested and approved by the staff and the community?

Thank you!

4 responses

Hi Alex,

Welcome to Quantopian! Most of those points are correct, with a few modifications:

8.You can use the Pipeline API to select a universe of stocks using volume and pricing ranges. Here is the documentation and an example algo.
9.The portfolio object (context.portfolio) is also pulled from your IB account in live trading. In general here is how the process works: when you deploy the algorithm, it will sync with your IB account and pull in the existing positions, cash, account metrics (leverage), etc. If you hold existing stock positions in the IB account, they will be included in your portfolio. Then every minute it will continue to sync and update with your IB account. For example, if you manually purchase something outside of the algorithm, it will be sync'd in the next minute. Thus, the algo has account and portfolio access to the IB account.

We have a single corporate actions data feed that is supplied to zipline paper trading algorithms and those connected to IB. So stock delistings, acquisitions, etc will have identical behavior. The main differences between zipline trading and IB trading algos are the slippage and borrowing costs. In simulated trading, the slippage is controlled via set_slippage , whereas in IB trading it's market availability. The second difference is short borrowing costs are not included in zipline, and it's in our backlog to integrate this data.

Answering your list of questions:
A. Mostly, with a few clarifications (see above)
B. FAQ is tricky because with a large community (over 60,000 worldwide) people have different questions. That said, we can certainly made our documentation easier to navigate and integrate the answers.
C. We're working on many different parts of the platform: adding new data sources , adding new markets, expanding the API, improving speed/performance, and much much more. There are many features we want to add, and we have a long backlog of features. One of these is additional order types, but it's not currently being worked on. You're welcome to contribute your code to Zipline, it will help give a jump start!

Cheers,
Alisa

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.

Thank you, Alisa!
8. This is great, I can't believe I missed this! I am going to try them right away.

B. I agree there are many specific questions, but it feels like order duration types, stops etc should be important to anyone
C. Understood. In fact, even algorithm examples from the documentation have bugs (not handling nan numbers etc). BTW, what about the code which actually talks to IB, is that open sourced? I could not find it in Zipline repo.

That piece of code isn't open sourced. We've built and maintained other libraries for the python community (zipline, pyfolio, qdb, coal-mine, pgcontents and more).

Enjoy working on your algo!

I would like to use zipline to trade live at IB.

  • Is anyone using zipline to trade live at a broker?
  • Is there an API interface that connects zipline to IB?

Please advise. Thank you!