Interactive Brokers

Posted By: stevegee58

Interactive Brokers - 02/10/12 17:44

I do most of my trading using Interactive Brokers. I've also written many programs using their API. Is ZT's broker API published somewhere? I might be able to write a dll for it.
Posted By: stevegee58

Re: Interactive Brokers - 02/10/12 18:05

Sorry I didn't search the other postings. InteractiveBrokers does not support MT4. Their API is proprietary.

But like I said I'm very familiar with this API so maybe I can help out.
Posted By: jcl

Re: Interactive Brokers - 02/10/12 18:53

Zorro does not have a DLL broker interface yet, but it's on our to do list. However you can already implement the IB API through the "broker" script function.

http://zorro-trader.com/manual/en/brokers.htm

This is a limited interface, but it should be sufficient to send buy and sell commands to your broker. The price data must be received the usual way from a FXCM demo account.

For accessing your DLL through the "broker" function, use the lite-C DLL interface:

http://zorro-trader.com/manual/en/litec_api.htm
Posted By: stevegee58

Re: Interactive Brokers - 02/10/12 19:04

Maybe a call-out function like broker() could be specified that is called when one of the "price" functions is called. e.g. if a lite-c script calls PriceOpen, the call-out function brokerPriceOpen() could be called. The user could then refer to his own data source and return a value.

I have tons of M1 data I can use for testing.
Posted By: jcl

Re: Interactive Brokers - 02/10/12 19:15

Yes, exactly this is planned for the broker interface.

If you want to use your M1 data for testing, you can just write a simple function to convert it in Zorro's price data file format. It is just a file with a one-year list of TICK structs. You'll find the TICK struct definition in include\trading.h.
Posted By: JanBa

Re: Interactive Brokers - 02/11/12 19:58

Interesting that ypu have written many program using the TWS-API. You did this in C(++) or Java or something else ?
Posted By: JanBa

Re: Interactive Brokers - 02/11/12 20:04

Imo the connection with IB should maybe be made via socket functions of C++ ??
MT4 approach maybe via Trade-Commander, unfortenately is it commercial software.
Posted By: JanBa

Re: Interactive Brokers - 02/11/12 20:06

tons of M1 data ? that's : M1 plays a leading role in the Singapore telecom market ??
Posted By: Petra

Re: Interactive Brokers - 02/12/12 08:28

I think he means one-minute data?
Posted By: JanBa

Re: Interactive Brokers - 02/12/12 13:17

You are probably right, make sense, thanks
Posted By: stevegee58

Re: Interactive Brokers - 02/13/12 01:35

Sorry I was out of town at a wedding all weekend.

All of my programs for the IB TWS API were in C++. I used socket programming exclusively, not ActiveX or COM.
Posted By: JanBa

Re: Interactive Brokers - 02/13/12 14:01

Interesting, it seems more than suitable to make an interface for Zorro. I was looking at a socket-interface for Visual Foxpro, but i think c++ works the same and probably free to use. I take a look at the C(++) interface of IB-TWS-API.
I am not a C-specialist but learn more every day.
Today i started Zorro-Z1 with 3 lots and margin 500 and let it run for a week.
Let's look on friday what the results are ?
Posted By: jcl

Re: Interactive Brokers - 02/13/12 16:00

Originally Posted By: JanBa
Today i started Zorro-Z1 with 3 lots and margin 500 and let it run for a week.
Let's look on friday what the results are ?

Check out the risk before you try something, especially with money. Your 50,000 demo account is far too small for 3 lots and margin 500. These settings will likely wipe out your account before you can make any profit.

Ok, it's only a demo account, but I suppose you want to simulate how it feels to trade with money? If you really want to risk all your 50,000, leave the margin at 50 and set the lots to 4 or 5. Then you can win a lot, but also lose a lot. With the original settings of 1 lot, you only risk about 10,000.
Posted By: JanBa

Re: Interactive Brokers - 02/13/12 21:50

Ok, i put margin at 50 and lots to 5, curious what will happen.
Posted By: JanBa

Re: Interactive Brokers - 02/14/12 16:06

Steve, i looked at the C++ interface to IB Brokers and i saw that the "requirments" are .NET and Visual Studio C++.

Do you think this is necessary to develop C++ interfacing TWS-API. ?

Or do you work more direct, straightforward ?
Posted By: stevegee58

Re: Interactive Brokers - 02/14/12 16:27

I use Visual C++ 2010 (also called VC9).

The IB API is kind of a pain in the neck to program. However I have working example code I've written that I use for a starting point on new projects.
Posted By: stevegee58

Re: Interactive Brokers - 09/03/12 16:12

Haha it took a while but I started writing a broker plugin for Interactive Brokers. I'm using Visual C++ 2008 (VC9).

I created a skeleton dll based on the FXCM. I just copy/pasted the cpp file and deleted the contents of the 9 functions. I then made each function return a value that should look like everything is OK.

Here is my BrokerOpen:

DLLFUNC int BrokerOpen(char* Name,FARPROC fpError,FARPROC fpProgress)
{
strcpy_s(Name,32,"IB");
(FARPROC&)BrokerError = fpError;
(FARPROC&)BrokerProgress = fpProgress;

return 1;
}

When I put my dll in the plugin directory however, the IB entry does not appear in the Account scrollbox and it stays grayed out. In the text window it says "IB.dll opened"

Here's a screen cap:

Posted By: jcl

Re: Interactive Brokers - 09/04/12 08:10

Thanks - this was a bug, the scrollbox was wrongly greyed out. Please download the fix here: http://server.conitec.net/down/Zorro.zip.

It's version 0.99.2 now - unzip it into the Zorro folder.
Posted By: stevegee58

Re: Interactive Brokers - 09/08/12 20:58

I'm having a problem with BrokerTime. The time from IB is in UNIX time and that's what I'm returning in the pTimeGMT parameter of BrokerTime. However ZT says:

"Login.. at GMTInvalid DateTime"

The IB API provides this time in a long which I'm casting to the double parameter like this:

*pTimeGMT = EW.m_CurrentTime;
Posted By: stevegee58

Re: Interactive Brokers - 09/09/12 14:09

Never mind, I found the real format of DateTime and figured out the conversion.
Posted By: stevegee58

Re: Interactive Brokers - 09/16/12 11:40

I'm currently working on implementing BrokerHistory. IB doesn't allow for getting historical data from an arbitrary period. IB's history is really a backfill so it starts from the current date/time and goes back to a specified end date. Also there are limits on how many bars of history you can request in each time frame.

It looks like FXCM allows requests for any number of bars from any period in any time frame. Is that true?
Posted By: jcl

Re: Interactive Brokers - 09/17/12 07:31

Yes, that's theoretically true, but the FXCM price server has only data back to 2002 for Forex and 2008 for CFDs. However for trading, you only need a limited bar number that starts with the current time and is equivalent to the lookback period. So trading would work with IB, only for simulation you then need to get the historic price data from another source.
Posted By: 35trader

Re: Interactive Brokers - 10/10/13 13:07

Is there an update on the IB connection?

I'm not sure of the exact reason but anyone using the backfill with IB has issues populating any amount of historic data and times out, eg) Amibroker and Quantshare have this issue if memory serves me correct. Ninja and Multicharts have no issue extracting historic data. Now why one can and the other can't I'm not sure of, but that backfill process is a pain in the ass.
Posted By: jcl

Re: Interactive Brokers - 10/11/13 09:25

Backfill is usual in broker APIs and not a problem. But problems arise when the price server has a limited history and/or a long response time.
Posted By: Tompsi

Re: Interactive Brokers - 11/08/13 14:16

OK, here is another guy interested in hearing whether there is any news on an IB API integration? is anybody currently working on that or has at least some limited success in getting somewhere? Much obliged!
© 2024 lite-C Forums