开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Re: Compiling TestSocketClient


bbbvvgtm
 

--- In TWSAPI@..., bbbvvgtm <no_reply@...> wrote:

I just downloaded the latest versions from IB. I wanted to compile/run/modify TestSocketClient, but ran into a couple of minor gotchas. So, I decided to document it in case someone else finds it useful.

I started with IB's Getting Started document:
I had some troubles in a couple of areas, so this is my getting started HowTo.

Download and install the standalone desktop version of IB's Trader Workstation
Start Trader Workstation
Click on Edit-Global Configuration
Make sure "Enable ActiveX and Socket Clients" checkbox is checked
Note the number in "Socket port." (Here I will assume it's 7499.)
Click "OK" to save the settings

Download and install the IB API
Create a new folder for your program. (Here I will assume it's C:&#92;MyTestProgram.)
Copy the following folders (and sub-folders) from IB's API location:
Shared
SocketClient
TestSocketClient
Launch Microsoft Visual Studio 2010 Professional Edition
Hopefully 2008 and 2012 also work.
I don't believe the Express Edition includes MFC and therefore will not work.
Click on File - New - Project From Existing Code...
What type of project would you like to create? &#8594; Visual C++
Click on "Next"
Project file location: Browse to your folder (here C:&#92;MyTestProgram).
Project Name: MyTestProgram
Click on "Next"
Check the checkbox "Add support for MFC"
Click on "Finish"
Wait until your program is setup
Click on Project – Properties (or you can right click on MyTestProgram in the Solution Explorer and choose Properties)
Under Configuration Properties – C/C++ - General
For "Additional Include Directories", enter "./Shared;./SocketClient/src"
Do this for both "Debug" and "Release" (Configuration: at top)
Under Configuration Properties – C/C++ - Code Generation
For "Runtime Libraries", choose "Multi-Threaded DLL (/MD)"
Do this for both "Debug" and "Release" (Configuration: at top)
You should now be able to Build both the Debug and Release versions
Run the program, (in the debugger or C:&#92;MyTestProgram&#92;Release&#92;MyTestProgram.exe)
Click on "Connect..."
Change "Port" to the Socket Port noted above (7499).
Click on "Req Mkt Data..."
Change "Symbol" to "IBM" (or whatever)
Click on "OK"
You should now see IBM data being displayed
You can a lot of what is happening in the file "client2Dlg.cpp"
Whoops. Forgot one thing you need to do if you want to disable the "Accept incoming connection attempt" message TWS gives you when you try to connect. (This makes full automation easier.) In Trader Workstation, click on Edit-Global Configuration, then click on "General". Under "Trusted IP Addresses", click "Create" and add "127.0.0.1" then click on "OK" to save it.

Join twsapi@groups.io to automatically receive all group messages.