Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
using TWS ActiveX API in QM
#1
Hello,

I am using Trader Workstation (TWS) from Interactive Brokers. TWS is probably the most commonly used online trading application. It comes with an ActiveX/COM proprietary Application Programming Interface (API), which can be used in different programming languages. The TWS API package actually provides working sample programs in Visual Basic, C++ and Java.

Here is the link to the TWS API downloads:
http://www.interactivebrokers.com/en/p.p..._entity=uk
Click the tab Proprietary API.

I have downloaded and installed the API package and tried the VB sample program. It all works fine.

The actual COM type library sits in a file called Tws.ocx. I registered the library in QM and I can see all the available classes and methods. It contains control and non-control components. So far so good....

Now, I'm trying to use QM to automate some tasks in TWS. Compiling goes fine, but whatever I do I keep getting runtime error messages: "Error (RT) in Function: 0x8000FFFF, Catastrophic failure"

Here is the code I'm using to try to connect to the TWS application running on my PC:

Code:
Copy      Help
typelib TWSLib {0A77CCF5-052C-11D6-B0EC-00B0D074179C} 1.0

str HostIP="" ;;leave blank if TWS runs on the same computer
int Port=7496
int ClientID=0

TWSLib.Tws Tws1._create

Tws1.connect(HostIP, 7496, 0)

Nothing wrong with the code, I think, but it gives a runtime error. As said, when I use the same method 'connect()' in Visual Basic with the same arguments, it all works fine. Does anyone have experience with TWS ActiveX API in QM? Why should a COM library that works in VB not work in QM? What am I doing wrong? Is it because the COM module contains control and non-control components that I should not use the _create statement? Any tips or ideas?

Thanks,

Ruud


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)