Getting started with the IB API

Posted By: Cstyle

Getting started with the IB API - 07/20/16 17:17

I have a demo account for IB, have installed the IB Gateway, and am trying to get Zorro to connect. I'm getting the following error message whenever I click on "Trade":

"!The TWS is out of date and must be upgraded."

This is odd, as I literally just downloaded it today from here:
https://www.interactivebrokers.com/en/index.php?f=16457

Is this not the right location to get the API, or am I doing something else wrong?

After the above error message, I'm also getting this error:

"Couldn't connect to TWS. Confirm that "Enable A..."

Where you see "..." the message is cut off. It is not clear to me how I can see the rest of the error message. Any ideas?

Thanks!
Posted By: jcl

Re: Getting started with the IB API - 07/21/16 09:00

I can't answer why your TWS is out of date - that's an issue for IB support - but you can see the rest of the error message in the log. Alternatively, double click into the message window - that will copy the message to the clipboard.
Posted By: Cstyle

Re: Getting started with the IB API - 07/22/16 22:22

Thanks for the double click advice. Very useful.

For some reason today, even though I've not changed anything, I'm no longer getting the error message for TWS being out of date. Instead, I'm getting this:

"Login IB (demo)..
!IB Socket connected at UTC 22.07. 22:18
!Account DU424687
Subscribe TSLA
!Requested market data is not subscribed.Error&BEST/STK/Top&BEST/STK/Top
Error 053: TSLA not available at this time
No bars generated
Logout.. ok
Copied to Clipboard!"

Is it because the markets are now closed? I realize I'm not going to be able to trade in the demo account with the markets closed, but I'm just trying to test connecting zorro to IB. Please advise.

Thanks!
Posted By: Cstyle

Re: Getting started with the IB API - 07/25/16 21:43

Any advice?
Posted By: jcl

Re: Getting started with the IB API - 07/26/16 08:53

IB already advised you: subscribe their market data.

Also look in the manual under "IB" about what you need to know for trading with IB.
Posted By: Cstyle

Re: Getting started with the IB API - 07/26/16 14:54

I am subscribed to their data, through my primary account. I do not (yet) want to connect zorro to my live account and trade with it until I've done some trading in my paper account. Do I have to subscribe to data in my paper account as well?
Posted By: jcl

Re: Getting started with the IB API - 07/26/16 15:38

I don't think so. I can trade with my paper and normal account, but have certainly not twice paid for market data. Maybe you have to activate your subscription for the paper account also. Contact IB support - they should know.
Posted By: Cstyle

Re: Getting started with the IB API - 07/26/16 16:25

Originally Posted By: jcl
I don't think so. I can trade with my paper and normal account, but have certainly not twice paid for market data. Maybe you have to activate your subscription for the paper account also. Contact IB support - they should know.


You're right. I had to activate it for the paper account. By default it is not active, which is kind of stupid in my opinion, but at least I was able to resolve it. Thanks!

Having said that, while z8 now runs and I can see in my IB portfolio that it did in fact execute some buy orders, I'm still getting errors from zorro:

Quote:
Trade Z8 portfolio (NFA) 26.07.2016
Error 062: Can't open Z8.par (rt:2)
Lookback period (252 bars).

What is error 062?

And I'm also getting a bunch of these warnings:

Quote:
XLU: Open: 0 New: 9
!Order Event Warning:Attribute 'Outside Regular Trading Hours' is ignored based on the order type and destination. PlaceOrder is now being processed.
[XLU::L0105] Long 9@52.24
XLV: Open: 0 New: 4
!Order Event Warning:Attribute 'Outside Regular Trading Hours' is ignored based on the order type and destination. PlaceOrder is now being processed.
[XLV::L0106] Long 4@74.76
Quit
Logout.. ok


Is it safe to ignore the Order Event Warnings?

Thanks!
Posted By: Cstyle

Re: Getting started with the IB API - 07/29/16 19:14

Quote:
Trade Z8 portfolio (NFA) 26.07.2016
Error 062: Can't open Z8.par (rt:2)
Lookback period (252 bars).


This anything to worry about? Just looking up that error in help I get:

Quote:
A file was not found or could not be opened. Check the file name and make sure that the file exists and is not opened in another application.


I did a search through the zorro install directory and z8.par was not found.

Please advise.
Posted By: jcl

Re: Getting started with the IB API - 07/30/16 07:12

You can ignore the message. - In case of such problems, look also in the recent bug list. Normally such a problem was already encountered by other people and is commented in the list.
Posted By: Cstyle

Re: Getting started with the IB API - 08/02/16 23:49

Originally Posted By: jcl
You can ignore the message. - In case of such problems, look also in the recent bug list. Normally such a problem was already encountered by other people and is commented in the list.


Good to know. Thanks a million!
Posted By: Cstyle

Re: Getting started with the IB API - 08/05/16 20:33

I'm not sure why I'm getting some of these messages in the log when I trade a strategy with the IB API:

Quote:
PennyPicker9
Login IB (demo)..
!IB Socket connected
!Real account not supported
!Account DUXXXXXX at UTC 03.08. 13:37
Loading AMLP prices.. 12000 min
Warning 034: No asset data for GDX
Loading GDX prices..
!Historical Market Data Service error message:Historical data request pacing violation
!No historical data query found for ticker id:17
!Historical Market Data Service error message:Historical data request pacing violation
!No historical data query found for ticker id:18
!Historical Market Data Service error message:Historical data request pacing violation
!No historical data query found for ticker id:19
!Historical Market Data Service error message:Historical data request pacing violation
!No historical data query found for ticker id:20
!Historical Market Data Service error message:Historical data request pacing violation
!No historical data query found for ticker id:21 . 12000 min
Warning 034: No asset data for REM
Loading REM prices.. 12000 min
Warning 034: No asset data for GYLD
Loading GYLD prices.. 12000 min
Warning 034: No asset data for UNG
Loading UNG prices.. 12000 min

Trade: PennyPicker9 portfolio 03.08.2016
Lookback period (500 bars)
[82: Tue 19.07.16 18:40] 999977 +0 +0 .
[83: Tue 19.07.16 19:00] 999977 +0 +0
[84: Tue 19.07.16 19:20] 999977 +0 +0
[85: Tue 19.07.16 19:40] 999977 +0 +0
[86: Tue 19.07.16 20:00] 999977 +0 +0
[87: Tue 19.07.16 20:20] 999977 +0 +0
...


Any advice?
Posted By: Cstyle

Re: Getting started with the IB API - 08/18/16 17:55

All of a sudden I'm no longer able to connect to the API:

Code:
PennyPicker9 compiling..............
IB.dll => IB (demo) plugin mounted
Login IB (demo)..
!Couldn't connect to TWS.  Confirm that "Enable ActiveX and Socket Clients" is enabled on the TWS "Configure->API" menu. 
!TWS Gateway running? Port =  4002
Can't connect!



When I look under IB's API settings I don't even see "Enable ActiveX and Socket Clients":

https://goo.gl/photos/87tchGU6At3ys6KFA

Any advice?

Thanks!
Posted By: jcl

Re: Getting started with the IB API - 08/19/16 09:49

How to set up the TWS is also described in the manual under "IB".
Posted By: mhdus

Re: Getting started with the IB API - 08/19/16 11:32

Check the socket port: As far as I remember, the full-blown TWS is using 4002 by default while the API Gateway is using 7496 (or vice versa). Both can be changed, of course. I believe you have a mismatch between Zorro and the API settings.
Posted By: Cstyle

Re: Getting started with the IB API - 08/19/16 15:19

Originally Posted By: jcl
How to set up the TWS is also described in the manual under "IB".


Right. I've compared what I have with what is in the manual. They match exactly, with the only exception being I don't have "Enable ActiveX and Socket Clients" as an option. Please take a look at what I'm seeing:

https://goo.gl/photos/87tchGU6At3ys6KFA

I'm not sure what else I can do to resolve this. Any help that can be provided would be great!
Posted By: Cstyle

Re: Getting started with the IB API - 08/19/16 15:21

Originally Posted By: mhdus
Check the socket port: As far as I remember, the full-blown TWS is using 4002 by default while the API Gateway is using 7496 (or vice versa). Both can be changed, of course. I believe you have a mismatch between Zorro and the API settings.


Per the zorro manual I have socket port set to 7496. You can see what I have here: https://goo.gl/photos/87tchGU6At3ys6KFA

What should I try next?

Thanks!
Posted By: jcl

Re: Getting started with the IB API - 08/19/16 15:28

There are only 2 opportunities to enter a wrong number. If it's not the socket port, then you maybe took your chance with the "User" field?
Posted By: mhdus

Re: Getting started with the IB API - 08/19/16 20:01

Well, your error log from Zorro says: "!TWS Gateway running? Port = 4002"
so it looks as if you have entered 1 as User in Zorro. For Socket port 7496 you need to enter 101 as the User in Zorro. Alternatively you can enter 4002 as the Socket port in the API Settings, of course, and keep User 1 in Zorro.
@jcl: maybe it would be easier to explain in the manual how to apply the SAME Socket port number in both, full TWS and Gateway - to avoid such confusion and surprises as users might switch between Gateway and TWS quite often. Just a thought.
Posted By: Cstyle

Re: Getting started with the IB API - 08/31/16 17:04

I had entered my IB username in the Zorro user field. I switched it to 101 and was able to connect. Thank you mhdus!!!
Posted By: Rockfish

Re: Getting started with the IB API - 10/04/16 15:53

Hi,
Can you activate it for the Paper account yourself or do the support at IB do this?

This might also answer why i get the following message:
"Z3 (oP group) ..
IB.dll => Interactive Brokers plugin mounted
Login Interactive Brokers..
!IB Socket connected at UTC 04.10. 17:46
Z3.45: PH M 100 H 5 W 2 V 2
Error 053: XAG/USD not available at this time
Error 053: XAU/USD not available at this time
Error 053: SPX500 not available at this time
Error 053: US30 not available at this time
Error 053: NAS100 not available at this time
No bars generated
Logout.. ok
"

Kind regards
Jp
Posted By: jcl

Re: Getting started with the IB API - 10/04/16 17:05

There is no activation. IB is not really suited for trading Z3, but if you still want to do it, read on the "IB" page in the manual how to subscribe market data, obtain trading permissions, and select the correct symbols. It is not as simple as with other brokers, but manageable.
Posted By: Rockfish

Re: Getting started with the IB API - 10/04/16 17:18

Thank you JCL, i have double checked that i have shared data on the IB account pages so... back to the manual. laugh

I have also spend the day opening an FXCM account, it just provides me with FX pairs. But my friend has access to Index and gold for the Z3. Are there any changes/settings i need to take into account?

Thanks!
Posted By: Rockfish

Re: Getting started with the IB API - 10/04/16 18:17

Originally Posted By: Rockfish
Thank you JCL, i have double checked that i have shared data on the IB account pages so... back to the manual. laugh

I have also spend the day opening an FXCM account, it just provides me with FX pairs. But my friend has access to Index and gold for the Z3. Are there any changes/settings i need to take into account?

Thanks!


The support desk at FXCM gave me the access.
Posted By: drzhous

Re: Getting started with the IB API - 01/27/17 20:31

Hi JCL,

Does Zorro 1.50 support IB live account? I installed the version but only see FXCM, IB(demo), MT4(demo) and Oanda V1 demo.
Posted By: jcl

Re: Getting started with the IB API - 01/30/17 14:53

For IB live you need to subscribe Zorro S. You can find a list of all differences of Zorro and Zorro S here: http://manual.zorro-project.com/restrictions.htm
© 2024 lite-C Forums