Error Msg ' Not Connected' in IB Trading Toolbox with Interactive Brokers TWS
Mostrar comentarios más antiguos
I am having issues using the Trading Toolbox with Interactive brokers. I have tried this on two separate TWS/Matlab installations on two different machines, connected to two different IB accounts. Both connect to Excel via the TWS api/DDE without difficulty.
I have the latest TWS and api software installed. ActiveX socket clients and DDE are enabled in the TWS api settings. Trusted ip is set to 127.0.0.1. ibtws object seems to be created fine:
ib =
ibtws with properties:
ClientId: 0
Handle: [1x1 COM.TWS_TwsCtrl_1]
Host: ''
Port: 7599
However, any attempt to retried data produces a 'not connected' error message in Matlab. For example: ib.Handle.createContract; ibContract.symbol = 'GS'; ibContract.secType = 'STK'; ibContract.exchange = 'NYSE'; ibContract.currency = 'USD'
ibContract =
Interface.AE6A66F3_8FA9_4076_9C1F_3728B10A4CC7
>> getdata(ib, ibContract)
ans =
Not connected
1 comentario
Karim
el 17 de Feb. de 2015
Hello again, I have the same problem rgds KJ
Respuestas (5)
Ray Ducharme
el 4 de Mayo de 2016
For me, it turned out I was using the wrong port. By going into...
TWS -> File -> Global Configuration -> API -> Settings -> Socket port...
I noticed the port number was not '7496' as seen in most Matlab examples (very close but not the same!). Making the switch fixed the "Not connected" error I was getting.
ib = ibtws('',7496) # <-- Switch the 7496 to your configuration port.
Good luck!
1 comentario
Mil Shastri
el 11 de Jul. de 2019
This was the issue. Thanks!
Alexey Yeremenko
el 28 de Oct. de 2015
0 votos
Hello
Have you been able to connect? I got the same problem. No idea how to fix it.
Yair Altman
el 7 de Nov. de 2015
0 votos
This problem is due to using the ActiveX connector to IB.
You might wish to try the cross-platform Java-based approach (not ActiveX) of the IB-Matlab product: http://undocumentedmatlab.com/ib-matlab
Lars Helfenstein
el 29 de Abr. de 2016
0 votos
Hi, did one of you ever find a solution? I got the same and checked and installed everything several times.
Jack Kenney
el 22 de En. de 2020
0 votos
Some customers have reported that it helps to specify the client id requirement during connection like this:
ib = ibtws('127.0.0.1', 7496, 0);
(Replacing 7496 with your configuration port)
Documentation for the Client ID argument in the "ibtws" function is available here:
4 comentarios
Annie Leonhart
el 23 de En. de 2020
You answer a question from 5 years ago. I'm sure they've figured it out by now.
Guillaume
el 23 de En. de 2020
Answers are not just for the benefit of the original poster. Others are encouraged to search answer and see if their question has already been answered.
Annie Leonhart
el 8 de Feb. de 2020
It’s already in the toolbox instructions. It clearly states how to set up the api.
Maxime Bergeron
el 19 de Feb. de 2021
Come on Annie...
Guillaume is right. It helped me.
No offense, but Jack comment is far more useful than yours.
Thanks Jack and Guillaume.
Categorías
Más información sobre Data Import from MATLAB en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!