Issues related to using perl with TWslink

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
spy3d
Posts: 2
Joined: Wed Dec 27, 2017 7:22 pm

Issues related to using perl with TWslink

Post by spy3d » Mon Jan 08, 2018 5:24 am

I used perl with TWslink before and it worked great! But my machine crashed and I am having a lot of issues with the latest version and latest platform Win 10.

Following are the issues I found so far:

Prob 1: (win32) XP

I had an old laptop with with Windows XP Pro (SP3) - the latest TWslink won't install, getting the following error:

C:\WINDOWS\system32\twslink2.dll

Unable to register the DLL/OCX: RegSvr32 failed with exit code 0x3

So the latest download can't be used

Prob 2: (win32) XP

I had an old version of TWslink from 2013 - it installed and the perl wrapper worked with ActivePerl 5.14 but orders are not getting placed.

It goes through sample.pl, makes the connection but pending orders do not show up in IB

Prob 3: (win64) Win 10

Installed Visual Studio 2015 (Community edition) and tried to build example 'cpp'. It migrated the project and it is still trying to build the Win32 version. A proper project has to be created.

After Build , running the program as no affect. Stepping in shows that the dll is not getting loaded:

TWSLink2Wrap::Load returned false

The good thing is that C# example seems to work after Building. Connection is made through the GUI

Let me know what else I need to try

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

Re: Issues related to using perl with TWslink

Post by board_admin » Tue Jan 09, 2018 1:19 pm

Hello Sir,
i am very sorry but win xp is not longer supported.
Also in win7 and win 8.1 i do not longer any tests because Microsoft pushes
Windows 10.

Also 32 bit architecture is deprecated. Please move to a 64 bit Windows 10.
It will remove various problems.

If you have concerns about privacy, there are various tools which can help here.

spy3d
Posts: 2
Joined: Wed Dec 27, 2017 7:22 pm

Re: Issues related to using perl with TWslink

Post by spy3d » Wed Jan 10, 2018 11:45 pm

Now I am using Win 10 and the perl wrapper example "ap_perl_5.14._b1401_win32_twslink_2100" is working with ActivePerl-5.14.3.1404-MSWin32-x86-296513 - but no order is getting placed :cry:

PS D:\test> perl sample.pl
creating twslink wrapper:
start time=Wed Jan 10 23:17:25 2018
Connecting . . .
Connected=3
Register MSFT
uid MSFT=50005
Place buy market 100 MSFT
uid order MSFT=2

Here is the log:

20180110 23:17:28:186; 7992;note;toHandler;AddContract;contract added: mult=0 #set=STK#sbl=MSFT#lsl=#cur=USD#exc=SMART#pex=#exp=#mul=#mnt=0.0000000000#rgt=#srk=0.0000000000#sit=#sid=#als=#cid=0#vld=0# #id=50005 context=RegisterContract
20180110 23:17:28:198; 7992;action;TWSSocket;FinishRequest;command [reqContractDetails] transmitted. Bytes sent=44
20180110 23:17:28:228; 7992;action;toHandler;PerformDetailRequest;details requested for contract #set=STK#sbl=MSFT#lsl=#cur=USD#exc=SMART#pex=#exp=#mul=#mnt=0.0000000000#rgt=#srk=0.0000000000#sit=#sid=#als=#cid=0#vld=0# #id=50005 reqid=1000013
20180110 23:17:28:246; 7992;note;RequestStack;AddDetailRequest;detail requests stacked=0, detail requests pending=1, other requests stored=0, type of current request=0
20180110 23:17:28:257; 6756;note;tcExpFunc;REGISTER_CONTRACT;ret=50005
20180110 23:17:28:268; 6756;note;tcExpFunc;PLACE_ORDER;-50005 -0 -BUY -MKT -100 -0.0000000000 -0.0000000000 -GTC -1 -0
20180110 23:17:28:297; 7992;action;TWSSocket;FinishRequest;command [placeOrder] transmitted. Bytes sent=184
20180110 23:17:28:327; 7992;note;SmartOrder;openOrderCallExpected;flag=1 uid=2
20180110 23:17:28:337 [OUT] uid=2 BUY MSFT MKT 100 GTC SMART lmt=0 aux=0 Order in Transit acc_? clientid=1 transmit=IB ref= nref= oca= filled=0 lastfill=0 fa group= fa profile= fa method= fa percentage= gat= gtd= outside rth=1 hidden=0 algo= algo-param= oid=11 permid=0 uidp=0 oidp=0 cid=50005 comment=
20180110 23:17:28:383; 6756;note;tcExpFunc;PLACE_ORDER;ret=2
20180110 23:17:28:395; 6756;note;tcExpFunc;WAIT_FOR_FILLED;-2 -20000
20180110 23:17:29:267; 7992;note;TWSSocket;contractDetails;details received (2) for contract=#set=STK#sbl=MSFT#lsl=MSFT#cur=USD#exc=SMART#pex=NASDAQ#exp=#mul=#mnt=0.0100000000#rgt=#srk=0.0000000000#sit=#sid=#als=#cid=272093#vld=1# #id=50005
20180110 23:17:29:303; 7992;note;RequestStack;AddDetailRequest;detail requests stacked=0, detail requests pending=0, other requests stored=0, type of current request=0
20180110 23:17:29:540; 7992;error;API;;API-error: the contract description specified for msft is ambiguous. code=200 id=11
20180110 23:17:50:710; 7992;note;API;;API-message: market data farm connection is ok:cashfarm code=2104 id=-1
20180110 23:17:51:576; 7992;note;API;;API-message: market data farm connection is ok:usfarm.us code=2104 id=-1
20180110 23:18:03:024; 6756;note;tcExpFunc;WAIT_FOR_FILLED;ret=2

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

Re: Issues related to using perl with TWslink

Post by board_admin » Thu Jan 11, 2018 1:43 am

I think the important message in the log is:
"20180110 23:17:29:540; 7992;error;API;;API-error: the contract description specified for msft is ambiguous. code=200 id=11"

Please checkout using NASDAQ as exchange in REGISTER_CONTRACT instead of "SMART".

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest