Multiple strategies

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
sectorbets
Posts: 92
Joined: Wed Apr 26, 2017 12:41 pm

Re: Multiple strategies

Post by sectorbets »

I'm thinking the easiest way to do this would be to get an additional TWSLInk license to run on one of our development machines, link it to one of the IB paper trade accounts, and then move the applications one at a time to the real IB account when they are ready. Is there anything that I am not thinking about.

IB is going to monitor the API tomorrow to see if they have any ideas, but now that I understand your code better, I doubt there is much they can do -- we'll see.

And I will talk to TS, but they aren't so happy to help interface to other platforms !! Even if I never mention TWSLink or IB, it will be pretty easy to see what I am doing.

sectorbets
Posts: 92
Joined: Wed Apr 26, 2017 12:41 pm

Re: Multiple strategies

Post by sectorbets »

Do you think that if I had two TS desktops open that I could access both paper and real accounts at IB -- one from each desktop ?? I was previously running from a single desktop with multiple windows. I don't want to play around too much since the real account is real money --
Last edited by sectorbets on Wed May 31, 2017 12:31 pm, edited 1 time in total.

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

Re: Multiple strategies

Post by board_admin »

2 dekstops are a solution. You need a 2nd TWSLink license and your TS costs are doubled, if i understood you correctly.

sectorbets
Posts: 92
Joined: Wed Apr 26, 2017 12:41 pm

Re: Multiple strategies

Post by sectorbets »

The TS costs would not be doubled since each desktop runs within a single TS license -- not sure about your code -- I would have to try it to see what happens since there is still just one TS license

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

Re: Multiple strategies

Post by board_admin »

"not sure about your code"

Each TS process can load one TWSLInk. One TWSLInk can connect to one IB account.
A TWSLink license is per machine.

Sorry, don't know how to explain it more clearly.

sectorbets
Posts: 92
Joined: Wed Apr 26, 2017 12:41 pm

Re: Multiple strategies

Post by sectorbets »

Here is what TS says about multiple desktops -- what do you think ??

You may want to have multiple open desktops depending on the way you want to organize windows on your screen or to support more than one monitor attached to your computer. Each desktop may be thought of as a separate instance of TradeStation and opens in its own window and has its own settings for items such as the order bar, toolbars, and desktop display preferences.

TradeStation enables you to have an unlimited number of desktops open simultaneously, depending on the amount of memory and resources available on your computer. For efficiency, it is always a good idea to have only the necessary number of desktops open.

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

Re: Multiple strategies

Post by board_admin »

I may misunderstood the word "desktop" in your last post. Ok, desktop means not machine or pc, instead the TS desktop.

For me it sounds, you can decide how many desktops you like to open on your machine or computer.
If you can do this, open one for development and one for production.

As each desktops is hosted in a separate process, each desktop can load a TWSLink instance
and each instance can connect to a TWS.
No TWSLink license needed. Shouldn't be no problem.

Note: If you run 2 TWS on this machine, one real, one paper, make sure the expose different API ports in the API settings.
Use those ports in your TWSLink::CONNECT call

sectorbets
Posts: 92
Joined: Wed Apr 26, 2017 12:41 pm

Re: Multiple strategies

Post by sectorbets »

I am setting it up right now -- will be back to you with the outcome after the open -- thank you

sectorbets
Posts: 92
Joined: Wed Apr 26, 2017 12:41 pm

Re: Multiple strategies

Post by sectorbets »

Didn't work -- same as running in a single desktop yesterday. Both the real and paper trades were executed in the paper trade account at IB. The signals were generated correctly on the TS end in the separate desktops just as they were yesterday in a single desktop with multiple windows.

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

Re: Multiple strategies

Post by board_admin »

Then you do something wrong.
Is it definite, that the 2 CONNECT calls happen in different processes ?
Perhaps i can connect per TeamViewer on your machine, so we can clarify this.

sectorbets
Posts: 92
Joined: Wed Apr 26, 2017 12:41 pm

Re: Multiple strategies

Post by sectorbets »

IB is using that machine at the moment -- I'll get back to you when they are done

sectorbets
Posts: 92
Joined: Wed Apr 26, 2017 12:41 pm

Re: Multiple strategies

Post by sectorbets »

Actually TeamViewer is not allowed on that machine since it has access to all our live IB accounts -- maybe you can tell me what to look for once IB is finished

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

Re: Multiple strategies

Post by board_admin »

Make sure each TWSLink instance is running in a separate process.
If not, then a subsequent call of CONNECT does a disconnect and reconnects to new site.
This generates exactly the symptoms you described.

Please have a look into the taskmanager. Can you see multiple TS processes?
As i ask previously, is it really definite, that a new TS desktop is running in an own process ?

---
I do not understand how IB is involved here. I am sure this is not an IB problem.
Thank you

sectorbets
Posts: 92
Joined: Wed Apr 26, 2017 12:41 pm

Re: Multiple strategies

Post by sectorbets »

I wanted to see exactly what was happening at IB -- I assumed it was the CONNECT issue, but wanted to see it for real.

We are using sockets 7498 for paper and 7499 for live accounts. When running both accounts, IB says that all the orders are coming in only trough 7498 -- the paper account -- including the live orders.

These are the TS processes -- looks liek two separate processes are running

TradeStation 9.1 (32 bit) (2) -- and then both copies are spelled out in detail
Live - Merion Live -----
and Paper -- SPX Paper -----

In addition, these are the TS background processes


TradeStationAgentForms
TradeStation Scanner
TradeStation Client Access Layer
TradeStation Charting
TradeStation
TradeSTation Client Proxy

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

Re: Multiple strategies

Post by board_admin »

The important point is: in which of those processes your scripts are running or in other words, TWSLink is loaded.

I see 2 processes which are candidates for loading TWSLink:

TradeStation Charting
TradeStation

But i would expect 2 of one of them. So i still guess you mention TWSLink running in 2 separate processes where it is actually running in a single process and so a subsequent call
of CONNECT makes a disconnect (from real account) and CONNECT to paper account.
From what you say, the CONNECT(,7499) is done first, then CONNECT(,7498).

Suggestion:
Call GET_CONNECTED before connect: For the first call of CONNECT, GET_CONNECTED should return 0.
If not, you know, you called CONNECTED already elswhere in this process.

What you need to achieve is to open 2 TS processes in which you can load an own instance of TWSLink.

sectorbets
Posts: 92
Joined: Wed Apr 26, 2017 12:41 pm

Re: Multiple strategies

Post by sectorbets »

Here are teh two separate processes

TradeStation 9.1 (32 bit) (2) -- and then both copies are spelled out in detail
Live - Merion Live -----
and Paper -- SPX Paper -----

But I would have expected two background processes as well.

I am going to experiment a little, but unless something looks promising, I am going to put this on the back burner, and come back to it once I have multiple symbols working well on the paper account.

Thank you for all your help

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

Re: Multiple strategies

Post by board_admin »

Sorry, Did not pay attention to the two processes.
You should see the process # of

Live - Merion Live -----
and Paper -- SPX Paper -----

in C:\trade-commander\twslink2\log
You should have twslink logs. Do you see something like p#,
so folders beginning with p and a number - the process number ?

Or, do you see 2 TWSLink tray icons when running Live and Paper desktop ?

sectorbets
Posts: 92
Joined: Wed Apr 26, 2017 12:41 pm

Re: Multiple strategies

Post by sectorbets »

there is just one log file -- twslink -- nothing starting with a p

there is only one tray icon which is connected to the paper account, but the live IB account is offline until after the close when I can check again

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

Re: Multiple strategies

Post by board_admin »

You don't need TWS running for this.
You need to check how to load 2 TWSLink instances.

So the TS desktop setup should spawn 2 TWSLink instances, if TS desktops
really run in separate processes and the desktop process loads TWSLink.

Presumed you run live and paper desktop, you should see 2 TWSLink tray icons.

- If you see only one, please right click on this icon. Then write down the processid
which can be seen in the centered edit field.

- Open Taskmanager, look for the process with matching id. This process is your script hosting process
and this is the kind of process we need twice.

What process is it please ?

sectorbets
Posts: 92
Joined: Wed Apr 26, 2017 12:41 pm

Re: Multiple strategies

Post by sectorbets »

The process id is 4004 -- it is for the paper account and there is nothing in the tray for the live account

PID 4004 is associated with orchart.exe which is the TS charting component

Post Reply