Error Msg ' Not Connected' in IB Trading Toolbox with Interactive Brokers TWS
조회 수: 1 (최근 30일)
이전 댓글 표시
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
답변 (5개)
Ray Ducharme
2016년 5월 4일
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!
Alexey Yeremenko
2015년 10월 28일
Hello
Have you been able to connect? I got the same problem. No idea how to fix it.
댓글 수: 0
Yair Altman
2015년 11월 7일
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
댓글 수: 0
Lars Helfenstein
2016년 4월 29일
Hi, did one of you ever find a solution? I got the same and checked and installed everything several times.
댓글 수: 0
Jack Kenney
2020년 1월 22일
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
Annie Leonhart
2020년 2월 8일
It’s already in the toolbox instructions. It clearly states how to set up the api.
Maxime Bergeron
2021년 2월 19일
Come on Annie...
Guillaume is right. It helped me.
No offense, but Jack comment is far more useful than yours.
Thanks Jack and Guillaume.
참고 항목
카테고리
Help Center 및 File Exchange에서 Transaction Cost Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!