Archive for the 'Interactive Brokers' Category

Page 2 of 6

Ib Bug Fixes

Received several helpful bug resports and just committed bug fixes / improvements to subversion

  • Improved performance of EnumDescConverter by precaching attributes.
  • Bug Fixes on TickType and Error Message types (Incorrect Id)
  • Fixed esoteric IBClient Abort bug – do not use thread.abort!! It is not guaranteed.
  • Marked UnderlyingComponent as serializable.
Let me know if you guys run into any problems – once this is tested a bit more thoroughly, I’ll make a release.

Automated Trading 101

So you’ve just signed up for your Interactive Brokers account, downloaded my C# interface to Ib, and are ready to begin automated trading… what else is there? A LOT.

Because of this website, nearly every automated trader I have met has started this way:

  1. Manual trading with interactive brokers
  2. Seeing a strange phenomena in the market
  3. Building a simple widget to hook up to Ib
  4. Exploiting the mispricing until their trading volume grows and they realize Ib does not negotiate fees and on a bum day auto liquidates your account without any notice.
  5. Decides they need to go the institutional route, and figure out what their other options are.

This is exactly how I got started, and it is only after developing a full institutional system that I appreciated how good Interactive Brokers is, and why they can charge such a premium.

If you are still in steps 1 – 3, then you will want to stick with IB (in fact after step 5, for many people, sticking with IB will still be the right call). For those who have gotten to step 5, my next series of posts will cover your basic decision space.

Your first step is to get your requirements figured out. What contracts do you trade? Equities, Options, Futures, Bonds? Interactive Brokers is incredible in their support for cross asset class trading in a single account. Starting with them, it seems trivial to expect all clearing houses to let you short shares on the ASX and use your acquired buying power to buy futures on Eurex. This is simply not the case. Interactive Brokers provides both clearing services, and execution services. In institutional land these services are broken up, and the most important piece is partnering with the right clearing house.

Your clearing house determines which exchanges you can trade. They establish relationships with each exchange, and guarantee your trades. If you place a loosing bet in a leveraged account, you stand to loose more money than you have in the account, and if the clearing house mistakenly allows you to do this, they will have to cover your losses. I mentioned you have to choose your products, this is because if you want to trade futures on the LME and NYMEX, you will have to find a clearing house with relationships to both exchanges. Likewise if you would like to trade equities, you will need a clearing house that specializes in equities. Generally, clearing houses do not support all asset classes, and execution platforms certainly don’t. Example clearing houses are Advantage Futures, MF Global, NewEdge, Goldman Sachs etc.

So if clearing houses are the first piece of the puzzle, then execution platforms are the second. The clearing house will clear your trades and manage your account on behalf of an exchange, but to actually place trades, you will need an execution platform. For interactive brokers, this is their Trader Workstation front end, and their timberhill backend. In the futures market, there are a few major players, Trading Technologies, RTS (Real Time Systems Group), CQG, and Pats. These are the interfaces you will use to actually trade, and are generally all supported by the major clearing houses and exchanges, so you can use the same execution platform regardless of who you clear with.

image

The above diagram generally illustrates the basic relationship between the parties. What you will notice is that the only time money exchanges hands is at night. Intraday there is no relationship between your cash and your maximum position. That is strictly a risk management function of your clearing house. This is where your clearing house relationship becomes incredibly important. It is not uncommon for clearing houses to let you have much lower intraday margins than required by the exchange (how do you think velocity futures gives out $500 margin on intraday e-minis), but at night time the clearing house has to settle with the exchange. Here again, the clearing house will frequently lend you money to increase your margin , but in general over night is dangerous enough, no reason to over leverage it.

There is a lot more to this, but I want to cut to the technology. If you are going through this process, and want a lot more detail on the various fee structures and technology tradeoffs, please email hidden; JavaScript is required. I have worked with or thoroughly researched nearly every major futures clearing house and execution platform, as well as most of the equities options.

My next posts are going to continue to be overview posts, but I am particularly excited to cut to the technical / code, so stay tuned.

Interactive Brokers Order Listener

Sorry for the long gap on infrastructure lately – I actually have intentions of discussing my production system again (mostly written against Trading Technologies api), but I still do considerable work with Ib’s api and have run into trouble.

All of my prior interfaces with Ib have been for strictly self contained situations. Essentially where the program is placing orders and monitoring messages for the orders it has placed. I am now writing an interface to listen for any orders placed by any application or directly through the TWS interface. It appears I can use the RequestOpenOrders method with a clientId of -1 and receive all open orders at that moment in time, or I can use the RequestAutoOpenOrders to map TWS order messages to my client with a clientId of 0. But it does not appear there is any way to get all order updates from any target without constantly querying the open orders method.

Does anyone have a better way to do this?

9.64 Release

Library version 9.6.4.16 is out! It corresponds to the Ib 9.64 api, and fixes numerous issues, most pressingly the decimal parsing for invariant cultures – no more expecting 9,23 as 9.23!

If you have any problems, email hidden; JavaScript is required.

Download the release here, or go to the utilities page.

9.64 in the works

Just a heads up – I just saw the new 9.64 beta posted by Ib on May 5th, and will update the .Net library to support it. In the future if you see Ib make an update, give me a shout, it has been nearly a year between updates from them…