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
#2
I also could not make it work in QM. Also does not work in Windows Script Host.

Macro
Code:
Copy      Help
str vbs=
;set t=CreateObject("TWS.TwsCtrl.1")
;t.connect "", 7496, 0
;msgbox 1

vbs.setfile("$temp$\tws.vbs")

run "$temp$\tws.vbs"
#3
Thanks Gintaras,

Yes, I considered running the COM module in a VB script, but then how do I capture the data that is fed back from TWS through COM events in QM?

Ruud
#4
In VBScript it also does not work.

Now I am working with QM code that creates the control. It probably will work in QM 2.3.0.10. Probably will release it this week.
#5
OK Gintaras,

Thanks for trying. I will wait eagerly for the new release.... Big Grin

Ruud
#6
It will not work with _create but will work as control in dialog.
#7
Quote:Now I am working with QM code that creates the control. It probably will work in QM 2.3.0.10. Probably will release it this week.

Gintaras,

Any idea when you will release QM 2.3.0.10?

Ruud
#8
Sorry for the delay. Should be this week. Still finding and fixing bugs.
#9
QM 2.3.0.10 released.
#10
Thanks Gintaras, will quickly try.

Ruud


Forum Jump:


Users browsing this thread: 1 Guest(s)