IB API

As Fidelity is dropping support for basket trading, I’m looking for alternative brokerage firms. In particular, I’m looking at switching to Interactive Brokers and using its API for TWS to create my own basket-trading app. Has anyone had experience with their API? Is it reliable? It appears to be relatively straight-forward, but, as always, the devil is in the details.

I’ve also read reviews that their customer service is abysmal - don’t know how much that would matter, though I’ve gotten spoiled with the support at Fidelity. Of course, when you make the effort to call customer service, it’s usually something important/time-sensitive, just when poor service would matter the most.

Thanks,
Jim

IB’s API is “solid”, but you have to know what you’re doing to use it. I haven’t used their pre baked basket trading feature, but I’ve programmed extensively to the API building custom automated solutions. Does TDAmeritrade seem to offer what you need? They have a REST api that will be far easier to use and understand than IBs.

I use IB and their API and will ditto what lintiness said. The system is solid, it can be difficult to wrap your head around, and you might want to look at TDA or Alpaca.

That said, I trust their system. It has the flexibility to trade stocks, options, futures, and pretty much whatever else you may want to trade. However, I don’t believe crypto is available through the api.

If you go the IB/api route, there is a good support group at groups.io.

1 Like

I totally live off the IP API these days. It’s been mostly very good, though it did end up costing me in the five figures one day last year when their streaming NQ quotes (Nasdaq 100 futures) got polluted with quotes from something trading around $40. It’s amazing what kind of fills you get on a $40 limit order for a $14000 security, even a highly liquid one.

Their response: we looked and that never happened. Do you have the TWS log files? No I didn’t, and they weren’t about to trust my own log files that showed it clearly happening.

So yeah, it’s a nice handy system, but you need a lot of defensive structure built around it to guard against whatever garbage that may occasionally flow. I suppose that could be said for any such thing, which is part of why I stuck with them.

  • Jamie
2 Likes

I used the IB Excel link for a long time.
I used it to gather real time quotes, do calculations, and recommend trades to myself.
That worked well.

I never had the nerve (nor desire) to close the loop and have my calculations place an order.
Somehow, I have the feeling that that’s a poor life choice.

Jim

8 Likes

I used the IB API happily for many years automatically trading, primarily around earnings. It worked well, but it is absolutely true it’s dangerous and you have to be extremely careful. It’s very easy to make an expensive mistake.

I no longer do that type of trading and switched my account to Fidelity about five years ago. If you trade enough to notice the quality of your fills, you are going to be unhappy with IB’s fills compared to Fidelity. I remember when I switched and my market orders would be filled somewhere between the bid and ask fairly regularly. This was not just from market movements and I’m still not sure why it happens as often as it does. For limit orders with Fidelity, your fills won’t only come when the bid or ask is about to be traded through.

I haven’t seen this discussed in general, in fact, I think most traders are pretty happy with IB. So YMMV, but that’s what I experienced.

1 Like

I use the basket trader every day. It took me a while to get it set up the way I wanted but now it is simple to use.

I upload a file of potential trade entries. If they execute then the trade log gives me the exit price that I’ve specified.

Very slick. But with a learning curve.

Thanks for all of the feedback! I didn’t know that TDAmeritrade had an API - it does look promising. In addition, their customer service appears to have good reviews, and they have an office nearby, thus that may be the way to go. I wonder how their trade executions compare with Fidelity, as I’ve found the latter to give good fills.

Thanks for pointing out that IB’s data is not always accurate (e.g., bid/ask prices). I’ll be sure to incorporate data from additional sources as part of a verification step.

I miss FolioFN - they made this whole process a piece of cake (though their fills didn’t appear to be as good as Fidelity’s).

-Jim

1 Like

I have had accounts at both TD Ameritrade and Fidelity for many years. Trade price improvements seem to be roughly the same. TDA’s site is easier for me to navigate and get things done, Fidelity research is somewhat better. Be aware that TDA was acquired by Schwab last year and the two companies are in the process of integrating their software packages and features. Supposably the end package will have the best of both (by their definition). Hopefully that will include the TDA API.

RAMc

1 Like

If you trade enough to notice the quality of your fills, you are going to be unhappy with IB’s fills compared to Fidelity.
I remember when I switched and my market orders would be filled somewhere
between the bid and ask fairly regularly.

This anecdote does not match my experience, the experience of others, or the research available on the subject.
That’s not at all the same as saying your experience didn’t happen, I believe you.
But IB has a very solid reputation for the best fills.
I like the negative commissions I get sometimes, and the typical price improvement is impressive.
It’s entirely normal to put in a limit bid to hit the ask and getting a lower fill.
I’ve even by accident put in a bid with a limit above the ask by accident, and getting a fill well within the spread.

They do have frequent data outages, most often from one exchange among many.
I imagine the other brokers do too, but don’t tell you.

And there are bugs, some annoying.
My biggest gripe was when an ignored account of mine with “portfolio margin” dropped in market value
below their required limiting balance ($100k) for the portfolio margin option due to market price movements.
This triggered a switch to “reg T” margin, which meant my now $95k-value pile of assets was not sufficient to cover the margin loan of about $1400.
So far, so normal—all following the rules, my own stupid fault even if the rules are very obscure.
Having triggered the margin call, their automated systems liquidated ~90% of the positions to cover
the $1400 margin deficit (too aggressive by a factor of 50+) while not informing me by any messaging system at all, before or after (wrong).
If they had told me, I could have bought almost all the stuff back the next day, but I didn’t know till end of month.
They denied that their system had done anything incorrect on either front.
So…better than any other broker, but don’t ever use a margin loan. Good advice with or without bugs : )

Jim

11 Likes

Wow, they liquidated $90,000 to cover $1,400? Crazy. I suppose could make sense if that port just had a singular Berkshire A share in the mid-late noughties?

Yeah it’s nice IB appears to give you the best price, often filling below your limit order. I’ve noticed other brokers sometimes filling at a price higher than the day range.

I have been using the TDAmeritrade API to pull options data and populate spreadsheets for a while now. It is fairly straightforward to use, assuming you are familiar with programming.

I have been doing it in python using the requests library. Let me know if you need help.

–Gabriel

1 Like

Wow, they liquidated $90,000 to cover $1,400? Crazy.

Yes. I was…displeased.
A bit of a correction:
My post was purely from memory. I looked it up to refresh that aging memory, to get the actual numbers.
The cash balance in the account was a settled cash deficit of -$684.48 on the day in question.
To cover that liability, their systems liquidated 48 contracts at a price of $16.64 for net proceeds of $79400.

I asked them to mail me a copy of the chat where I grilled them about it.
My plan was to post it so some blog.
But hey, other things to do. Life has other priorities.

Further info for those who might be interested:

The only asset held in the account was Berkshire calls.
With long call options, there is no possibility of an increased liability due to market movements.

My message to them included this bit:
"Basically, I am out $70k because your system wanted $680 from me, and liquidated enough positions
to raise 116 times as much money as was needed to wipe out the deficit, all without telling me".

Besides the foregone gain since then, the contracts were liquidated at a price causing a realized loss of about $48k.
By the time I found out about it, the market value of those contracts was up 84%.

As I noted in my letter to them:
“As is so often the case, almost all the liquidations were on the day of the absolute bottom price for the assets in question.”
For those interested, check out the price chart for Berkshire around 2016-01-25, the day they liquidated.
Do a chart from the year before to two years after.

Lesson: never, ever, use broker margin.
Once you break the rules, which are impenetrable and can change on an hour’s notice, they can do pretty much anything they like.
In their fine print, they mention that they themselves might be the counterparty for the liquidations.
Not specifically an IB issue, I should note.

Jim

6 Likes

It sort of is an IB problem. Most margin with brokerages isn’t liquidated in an automated fashion which as you noted is very very dangerous (not just for you, but for the market generally – what happens if there’s a misquote or an instant trade at $.01 in something?).