Trading Toolbox Connecting to Interactive Broker
28 views (last 30 days)
Show older comments
I have a question on using the trading Toolbox for connecting to Interactive broker TWS. I executed this line of code, and it gives me an error that says the following:
===========================================================
">> ib = ibtws('',7496);
Error using actxserver (line 90)
Server creation failed. Invalid ProgID 'TWS.TwsCtrl.1'.
Error in ibtws (line 38)"
============================================================
Some details to my configuration.
- Windows 7 64-bit
- Matlab 2013b 32-bit version
- TWS was on during code excution. Build version: 927.7d, Jun 27, 2012 12:49:10 PM.
Does anybody know what I missed out or any configuration that needs to be set before I can connect to TWS using matlab. Any help appreciated. Thanks.
1 Comment
Diego Ochoa
on 24 Jan 2018
Does this mean that the only version of TWS compatible with Trading toolbox is 927.7 or older? Qhat happens if I Have other version or OS?
Answers (15)
Shiang Qiu
on 20 Aug 2017
Hi all,
I had the same issue.
>> ib = ibtws('',7496); Error using actxserver (line 90) Server creation failed. Invalid ProgID 'TWS.TwsCtrl.1'. Error in ibtws (line 38)
After I installed all the required software the issue persisted, then I realized that after setting up TWS, it is necessary to perform a TWS register procedure to activate the communication between MATALB and TWS. After TWS is installed, go to C:\TWS API\bin\ActiveX folder to find file Tws.ocx, right click and select open with other software, point it to MATLAB, then it will be working.
You can find more specific details in https://www.interactivebrokers.com/en/index.php?f=5041, search for Getting Started with the TWS ActiveX API, download it. At the end of the guide, you can find more details about establishing communication between TWS and other software.
8 Comments
Gilles Desvilles
on 22 Jul 2019
Thanks Jonathan for helping
First of all, do you succeed to connect your Matlab 64 bits with TWS ?
If yes, what is the version of Matlab that you are using ?
On my side I am only able to connect a 32 bit 2015a version with TWS using API 9 71 06
Somebody in Mathworks tells me he succeeds to connect 64 bit 2019a with TWS using API 9 73, but I am currently checking that with him because he is not a user of TWS, he may believe it works whereas it doesn't. If this is true then the Mathworks developers fixed the issue recently, good !
Jonathan, I have tried too often to connect my 2015a 64 bits with TWS using different API and it did not work, so I am skeptical about your steekoo solution, furthermore as there are comments on steekoo itself saying it doesn't work with 64 bits.
Ashishkumar Gupta
on 1 Mar 2023
I am using Ansys EDT. I am also facing similar issue.
actxserver('Ansoft.ElectronicsDesktop');
Error using actxserver (line 93)
Server creation failed. Invalid ProgID 'Ansoft.ElectronicsDesktop'.
What can be done here? TIA!!
Siu Kei Lam
on 8 Mar 2017
IB Technical Support team told me uninstall the TWS-API
Please delete the following files after uninstall old TWS-API software.
"C:\Windows\SysWOW64\TwsSocketClient.dll"
Then download another TWS-API version with ActiveX and install the new TWS-API again.
http://interactivebrokers.github.io/downloads/TWS%20API%20Install%20971.06.msi
It then all set and works for me now.
8 Comments
philip curran
on 23 Nov 2021
i have the same issue, i'm using MATLAB 2020b, is there a solution for this?
>>ib = ibtws('',7497);
Error using actxserver (line 93)
Server creation failed. Invalid ProgID 'TWS.TwsCtrl.1'.
Error in ibtws (line 37)
x.Handle = actxserver('TWS.TwsCtrl.1');
MrGrey
on 22 Nov 2015
I had both problems
- "Error using actxserver (line 90)" and
- "Error using feval Server Creation Failed"
depending on the IB API version I used. I tried the hints given in the forum and it seems to me that the final solution was the installation of the 32 bit Version of "Microsoft Visual C++ 2005 Redistributable".
Now I'm running the current versions:
- Windows 7 Ultimate 64 bit
- MatLab R2015b 64 bit (win64)
- TWS API Version 9.71.06
- TWS Build 954.2j, Nov 20, 2015 5:17:47 PM
Even without TWS started, the command:
ib = ibtws('',7496)
gives me the correct results now:
ib =
ibtws with properties:
ClientId: 0
Handle: [1x1 COM.TWS_TwsCtrl_1]
Host: ''
Port: 7496
But to retrieve data, TWS must be up and running, otherwise you will get a "Not connected" message later. I hope this helps.
1 Comment
Diego Ochoa
on 27 Apr 2016
Had Both Problems. No other solution worked for me excep installing the 9.70 version of IB API AND "Microsoft Visual C++ 2005 Redistributable". Try doing this before all other solutions. Specially if you have the latest IB API.
0 Comments
Hamid Ramezani
on 5 May 2016
Dear All,
Thanks for your comments and suggestions. I had the same problem (Win7, 64bit, updated, and all the requirements are installed), and none of them worked for me. It turns out that when you install API, a dll file will be placed in windows\system32\TwsSocketClient.dll, and when you install a newer version this dll file will be updated. However, when you install an older version of the API (going back to older version), this dll is not updated, and it has to be removed manually before installing an older version.
For more information about this see "https://www.interactivebrokers.com/en/software/api/apiguide/api/uninstalling_and_re-installing_the_tws_api_software_on_windows.htm"
To check the installed activex controller on your system and their status please check this: http://www.nirsoft.net/utils/axhelper.html
- Interactive Brokers Trader Workstation
- Microsoft Redistributable Packages for Visual C++ 2005 (x86) http://www.microsoft.com/en-us/download/details.aspx?id=3387
- Microsoft .NET Framework 3.5 (which includes support for .NET 2.0 and 3.0) http://www.microsoft.com/en-us/download/details.aspx?id=21
- Microsoft Visual J# Redistributable Package version 2.0 http://www.microsoft.com/en-us/download/details.aspx?id=4712
- Interactive Brokers TWS AP
0 Comments
Milad Jalali
on 2 Dec 2017
None of the above solutions worked for me.
In my case, the issue was the MATLAB bitness. Apparently, ActiveX connection does not work on 64-bit version of MATLAB. As soon as I switched to 32-bit version of MATLAB, it started working like a charm!
0 Comments
tj
on 21 Jan 2014
I've got the solution to this.
1. Please go to IB website and download the latest TWS and IB Gateway i.e. Trade Workstation 4.0 for Windows then download and install a "TWS API Install 970.07.msi" file from the link below:
2. Then configure the TWS using the following link:
After all this close all your programmes Matlab, TWS, IB Gateway. Restart your computer. Then restart TWS and IB Gateway and then Matlab and it should work.
Hope this helps.
0 Comments
Yair Altman
on 2 Feb 2014
Edited: Yair Altman
on 22 Mar 2015
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
3 Comments
Walter Roberson
on 1 Aug 2016
Diego,
You emailed me asking for assistance with this matter, and indicated that you have been blocked with this and need to get it working quickly. You might recall that my email answer was that I do not have the resources or experience for this. (If I already had a solution I would have posted it for you or for Simon.) If I had happened to have the resources then it is doubtful that I could have provided a quick solution.
But you know who has the resources and the experience and has already extensively tested and documented a solution for multiple platforms? Yair Altman. And he offers a free trial so you can determine for yourself whether his software will work for you.
When someone approaches me for something that is going to take extensive effort, I almost always reply back that it is more effort than I am willing to put in as a volunteer. "Good will" and "thanks" do not pay the bills, and the time I spend volunteering is time I do not spend doing my cleaning, cooking, maintenance, and so on. Volunteering is for short efforts. Yair put much much more than a short effort into getting the broker interface going, and Yair asks to be paid something in return. I have absolutely no problem with that.
If you have looked at Yair's web site you will see that he has done rather a lot of investigation of obscure aspects of MATLAB and has made the great majority of the resulting information available for free.
Perhaps you are one of the Free Software Foundation proponent who demands that "Information must be free", and that all software written must be made openly available, and that programmers should instead make their living by providing services, paid for their time, with the results always to be made public. Perhaps -- but I notice that you did not offer to pay for services in resolving this matter like a true FSF proponent would...
Edmond
on 11 Jun 2014
Edited: Walter Roberson
on 1 Aug 2016
I am a also get the same error:
>> ib = ibtws('',7496);
Error using feval
Server Creation Failed: The application has failed to start because its side-by-side configuration is incorrect. Please see the
application event log or use the command-line sxstrace.exe tool for more details.
Error in actxserver (line 86)
h=feval(['COM.' convertedProgID], 'server', machinename, interface);
Error in ibtws (line 38)
IB is setup right, running 2014A
0 Comments
sam
on 10 Dec 2014
Has anyone managed to solve this problem yet as I still get the same error message:
====== Error using actxserver (line 90) Server creation failed. Invalid ProgID 'TWS.TwsCtrl.1'.
Error in ibtws (line 38) ======
I have tried installing different IB API versions but non seems to be working: IB API version = API 9.70.06, API 9.71.06, API beta 9.72.03 TWS version = TWS 9394
Everything is configured as per tj post above so I am not sure why I still have problem.
Hope someone can help.
2 Comments
Eric W
on 12 Dec 2014
I am having the same problem as well.
I had a two machine setup running this afternoon---worked fine. Now I am getting ====== Error using actxserver (line 90) Server creation failed same as others in this thread.
I have:
- 1) Checked the MATLAB path to make sure it points to IBMATLAB files.
- 2) Checked the classpath.txt to make sure it points to IBMATLAB files.
- 3) Made sure that TWS is allowing ActiveX and Socket Clients
- 4) Made sure that the trust IP address in TWS is still valid.
- 5) Rebooted my MATLAB/IBMATLAB machine
- 6) Restarted TWS on my TWS machine.
- 7) Trial>> ib = ibtws('',7496);Error using actxserver (line 90)Server creation failed. Invalid ProgID 'TWS.TwsCtrl.1'.Error in ibtws (line 38)Trial>>
It worked a few hours ago...
Not sure what I'm doing wrong now.
Any thoughts?
sam
on 21 Dec 2014
Can you confirm what version if IB API are you using. I think our problem is related to using latest version of IB API. I have tested it with below API version and still not working: API 9.71.06, API beta 9.72.03 TWS version = TWS 9394
I can not find any older version of API from IB website.
Antonin Obdrzalek
on 18 Apr 2015
Hello,
did anyone manage to solve this issue?
Thanks a lot for response
0 Comments
Fabrizio Maccallini
on 22 Jul 2015
The PROGID of the axtiveX control I get is Tws.TwsCtrl (NOT Tws.TwsCtrl.1). If the PROGID was hardcoded in the function then there is not much to do, as the function ibtws is encrypted (.p not .m).
0 Comments
Vinod Rex
on 2 Aug 2015
Downgrading to IB API version 9.70 fixed the "Error using actxserver (line 90)" error for me
0 Comments
Daniel Matteson
on 23 Mar 2017
Edited: Daniel Matteson
on 23 Mar 2017
Error trying to connect Matlab to IB TWS. Tried installing 32 bit Microsoft Dist 2005 to no success. Also I made sure that TWS was configured correctly. This was verified by a successful connection to TWS through IB API using their provided VB sample program.
Configuration:
Win 7 64 bit
Matlab r2015b 64 bit - Trading toolbox installed
Java 1.8.0_121
This is the error I get in Matlab:
>> ib = ibtws('',7496); Error using actxserver (line 90) Server creation failed. Invalid ProgID 'TWS.TwsCtrl.1'. Error in ibtws (line 38)
Thank you in advance for any assistance any brave soul can offer me. I have been struggling with this problem for a week and my wife and puppy and dying for some attention.
0 Comments
Girish Nair
on 22 Oct 2017
I had the same problem few mentioned above: Below is what helped me - hope it might help you guys too.
- Windows 10 (pity this doesnt work on Mac)
- Matlab 2017b
- Latest TWS Windows app
- Use the below version of TWS API
- http://interactivebrokers.github.io/downloads/TWS%20API%20Install%20971.06.msi
- Install Microsoft Visual C++ 2005 Redistributable using the below link.
- http://www.microsoft.com/en-us/download/details.aspx?id=3387
This helped me establish a successful connection. Good luck.
1 Comment
Nicolas Poncelet
on 5 Nov 2017
And what about this new error message coming after realised all the steps describes here above :
>> ib = ibtws('',7496) Error using feval Server Creation Failed: The specific file is missing.
Error in actxserver (line 86) h=feval(['COM.' convertedProgID], 'server', machinename, interface);
Error in ibtws (line 38)
See Also
Categories
Find more on ActiveX in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!