TWS-Link / TradeStation Users / PC mutiple-cores / 4 orchart.exe processes / Order handling problems?

Discuss, post your questions about TWSLink here.

Users who just registered, please write an email to
forum@trade-commander.de
with your username mentioned.
So we can distinguish you from bots.
Thank you
Post Reply
Rocket130713
Posts: 21
Joined: Sat Mar 03, 2018 9:23 am

TWS-Link / TradeStation Users / PC mutiple-cores / 4 orchart.exe processes / Order handling problems?

Post by Rocket130713 »

Hello, you mentioned that its ideal for Tradestation users to run Tradestation 9.1 using a single core on a quad-core PC to allow the trader to do proper order handling. We have a different script attached to 23 futures market charts (script 1 is attached to chart 1 and is using CPU 1 // and script 2 is attached to chart 2 which is using CPU 1, and so on) in Tradestation. We have some questions which are as follows:

--> In each of the 23 different scripts should we connect to the IB API using the same "client id" number i.e. number 1? So in script 1 we would have retcode1 = CONNECT("",7496,1,500); and in script 2 we would have the same line at the top of the code i.e. retcode2 = CONNECT("",7496,1,500); Is this correct?

--> Also, if we place some orders and then TS crashes and has to be restarted as well as restarting the entire PC (to be safe), if the TS program is restarted and runs on a single core, but this time it runs on CPU 2, does this cause a problem for order handling? i.e. sometimes the TS "charting" process called ORCHART.exe will run on CPU 1 and other times it will run on CPU 2 when TS is re-started or re-launched? We can't control which CPU (my quad-core PC has 8 CPUs) the Tradestation program (app) uses each time TS is restarted. Could this be a problem? If so, why is this a problem? If so how do we solve this problem?

Thanks in advance. Regards, Rod

board_admin
Site Admin
Posts: 244
Joined: Mon Apr 24, 2017 3:24 pm

Re: TWS-Link / TradeStation Users / PC mutiple-cores / 4 orchart.exe processes / Order handling problems?

Post by board_admin »

Allow me to explain some basics about TWSLink, so you can decide on your own whats the best way
to go with TS9 and TWSLink.

Each windows process can load any DLL only once into his address space.
So each TS9 chart process can load only one TWSLink.
Each TWSLink can connect to only one IB account.

It uses a so called clientid for this. This clientid identifies the API client (TWSLink).

TWS/Gateway, or more general IBs API, can accept up to 8 API clients.

So, if you have more than 8 TS9 script/or chart processes, the 9th can't connect
to TWS.

As each API client has its unique clientid, he has only control about orders which are placed from
a client with same clientid.

For instance, when your script for ES is connecting with clientid=123 to TWS/API, you should make
sure that next the script for ES is connecting again with the same clientid.


---
If you run TS in multiple processes and you placed orders from different clientids
and you then run only one TS instance which can connect with only 1 clientid,
you lose control about orders which have not the clientid of your current connection.
--
The TWSLink is not perfectly designed for TS. TS spreads into multiple processes which
is today not really necessary, because any process has no memory limits on 64 bit machines
which should be the normal case.
It can have advantages in terms of security, so having a fail safe process running when one crashed,
but i am not convienced that this was the reason for TS to split into multiple processes.

I guess they did this, because they feared to migrate their 32 bit code to 64 bit code, because,
the processes TS is starting are all 32 bit processes and not 64 bit.
--

So you have the problems with process - clientid - orders
and the limit of max. 8 TWSLink can connect to IBs API, which is imposed by IBs API.

Rocket130713
Posts: 21
Joined: Sat Mar 03, 2018 9:23 am

Re: TWS-Link / TradeStation Users / PC mutiple-cores / 4 orchart.exe processes / Order handling problems?

Post by Rocket130713 »

Thanks for your reply. If script 1 is attached to ES chart, and script 2 is attached to Gold chart, do i need to use CONNECT("",7496,1,500) line of code in both script 1 and script 2, or, do I use CONNECT("",7496,1,500) in Script 1, and, CONNECT("",7496,2,500) in Script 2? Please note that I have used a client ID of 1 in script 1 and a client ID of 2 in script 2. Is this correct, or should I be using the same client ID in script 1 and script 2? Thanks in advance. Regards, Rod.

board_admin
Site Admin
Posts: 244
Joined: Mon Apr 24, 2017 3:24 pm

Re: TWS-Link / TradeStation Users / PC mutiple-cores / 4 orchart.exe processes / Order handling problems?

Post by board_admin »

It depends on if you are in another process or not. Per process 1 connect.
So the challenge is how to group always the same set of symbols (clientid) in one process.
Or, just make sure not to call connect multiple times within same process and different clientids.
process1=clientid1=symbol set 1 (ES,EURUSD,whatever)
process2=clientid2=symbol set 2 (NQ,EURJPY,whatever2)
...

Post Reply