Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Help requested. I'm hesitant to use the system, having learned some Python, but not being a nubee to trading

So I learned some Python through Udacity. I've traded professionally uses professional tools, as well as web based products for me personal account, but cannot pull the trigger without some help.

  1. The ever evolving Terms of Service for trading through IB doesn't soothe my worries.

  2. Is it correct that there are no transaction types? By order types I mean Buy, Sell, Sell Short, Sell Short Exempt, ... Instead you give a quantity. If it's positive, it's a Buy, and if it's negative it's a Sell?

What if erroneous code causes a sign switch on the quantity, either by multiplying by an accidental negative number or number overflow?

  1. Are there order types? Market On Open, Market On Close, Limit on Close? I would like to pass them through to IB. Where do I find these?

  2. Fat finger checks. Do they exist? Or do I have to write my own for every algo?

  3. Latency. How much time elapses from when a trigger occurs until the order arrives at IB? How much time elapses from when an execution occurs until the execution is updated in Quantopian?

  4. Is there a manual?

Any and all help would be appreciated.

7 responses

Abraham,

Regarding a manual, there are the help page and FAQs. You'll see various order types described there.

Others can answer your remaining questions better than I can.

Grant

Hello Abraham. Udacity has some great courses and a great tool to learn Python, glad they've worked for you. Let me try to help answer your questions:

  1. I think you're exaggerating a tad =). We've updated the terms of service once in the last 18 months. From your previous post, I can infer that you're concerned that we reserve the right to change or remove services in the future. I think you should look at other terms of service for comparison. TD Ameritrade says they "reserve the right to revise, modify, change, upgrade, suspend, impose limitations or restrictions on, deny access to, remove, or discontinue the Services at any time without prior notice." Interactive Brokers says "IB may terminate this Agreement or its services to Customer at any time." I readily admit that this is one of the least customer-friendly parts of our terms of use, but it is necessary in our industry and in our legal environment. I'm very open to learning ways to structure the agreement differently, but whatever they are, they have to pass muster with our legal advisors.

    At risk of repeating myself: We want you to succeed, and we need you to succeed. We will make every effort to make any future changes to our terms of use reasonable and supportive of your continued success. Whenever we push a new feature or make a major change - we post to the community. We want everyone to know of the change. Our goal is to be transparent at every step - and we're always open for feedback.

  2. We do have a few different types of orders, but they're not organized the way you've got outlined there. We have market, limit, and stop limit orders. Those are implemented in a few different ways. First is the way you describe - positive is a buy, negative is a sell. We also have a number of other convenience order methods, like order_target_percent() and others.

    If you have a code error that causes you to place an order in the wrong direction, that's a problem. It's going to be a problem whether the cause is a negative sign or a logic bug. The only answer there is good testing. As for overflows, or NaNs, or missing data, etc. if the algorithm hits something like that it throws an error and shuts down.

Round 2:

  1. Interactive Brokers does support a large number of order types. We only support a handful of them. Most of IB's custom order types can be implemented using Python in Quantopian. For instance, Ryan's got good market-on-open and market-on-close implementations here. We may support some of the IB custom order types in the future. On the other hand, we also plan on supporting other brokerages, and restricting ourselves to basic order types will make everyone's algo easier to port from brokerage to brokerage. It's an interesting challenge.

  2. We don't have built-in fat-finger checks. That's a pretty good idea. I'd like to hear more about what you'd think is a useful way to implement those. For now, one of your best tools is the backtest. Backtest and forward test your strategy to confirm that its executing the expected behavior. Tinker with the parameters. Log your inputs and track your outputs. If you get stuck, try asking the community, they're a helpful group

  3. We're still in our pilot program for live trading, so I think the answer on latency is going to evolve as we get more traders, more trading, more information, and future code modifications. I'll give you some nitty-gritty details. For now, it works like this: We get the trade data from Nanex's NxCore product. That gets to us in a few hundred millliseconds, most of the time. We put that trade data into a minute bar and push the minute bar to your algorithm. That generally takes another few hundred milliseconds, sometimes a couple of seconds. Your algorithm processes the data - that can be really fast, or it can take several seconds if you're doing heavy lifting. As handle_data() processes the data, it's passing orders into our database, and they are then passed on to IB. Again, that generally takes another few hundred milliseconds, sometimes a couple of seconds. All told, you're looking at 1-15 seconds for orders to get to IB, with most of them in 2-5 second range. Side note: if your algorithm takes longer than 50 seconds to do a computation, we throw an error and alert you that the algo is failing.

    If your algo depends on getting orders in faster than this, we unfortunately aren't prepared to support it. We're aiming at supporting strategies with a looser latency requirement.

  4. Grant's got the links for the manual, as it were, in his post above.

One thought I had as I was writing this reply. Our live trading program is a pilot program. It's not yet publicly available, and it's certainly not out of beta. Using beta (or pilot) products requires a leap of faith, and it often includes running into product infelicities and outright bugs. That means that pilot programs aren't for everyone. I can completely understand if someone is not ready to make the leap to live trading today. The good news is that there is a zero-risk, free way to figure out if the program is for you. Just start paper trading. For the duration of the beta, we will provide the service for free. Paper trading does not risk your investment - it's just paper.

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.

Abraham,

if you have traded professionally you are probably well aware of R and have used if for strategy research/ modeling. So why not do the trading algo in R as well and use it as an execution platform, together with interactive brokers ? I have developed an intraday trading framework that is "pure R". It supports all the order types that IB offers. But it also requires good knowledge of R to leverage these. If that is what you are interested in you can download it from my site here: (no strings attached. Its free)

http://censix.com/download/

Cheers
Soren

Hello Abraham,

You should also keep an eye on developments with zipline which is the Open Source backtester that Quantopian is based on. See: https://groups.google.com/forum/#!forum/zipline and https://github.com/quantopian/zipline

An interesting idea is to allow zipline to trade with IB using the IbPy API wrapper. This would potentially allow free (for now!) backtesting in Quantopian with free running of algo(s) via zipline/IbPy with zipline being extensible to encompass all IB order types.

P.

Hi Peter,

Cute..."hack Wall Street by hacking Quantopian." Not sure that's what they have in mind...

Grant

Hello Grant,

I don't know if it would be architecturally possible - I'm just curious because of this thread: https://groups.google.com/forum/#!topic/zipline/lZNHdoLXOKA

Free R to IB integration exists and Matlab to IB integration is available via some relatively inexpensive software ($349 then $99 pa from the 2nd year onwards) which could, in part, be competition for Quantopian live trading.

P.

It's certainly possible. Not too difficult either.