Perl 5 x64 wrapper for TWSLink

Python 5 x64 wrapper for TWSLink along with Visual Studio wrapper solution and sample

  • 64 bit twslink2pl.dll and twslink2pl.pm included.
  • Visual Studion 2017 solution file included: This is to create your own twslink2 wrapper for other perl versions.
  • Includes also a small sample in the test folder of download.

 

When the TWSLink2 interfaces should change, which is unlikely, or a new Perl version is out which you want to use, you may want to have a new TWSLink2 wrapper,
so you can call TWSLink from within Perl. In order to build your own wrapper, you need some tools:

The Visual Studio project for this perl wrapper, assumes that swig is in c:\swig. Details about building the wrapper are in the readme.txt of download.

Note: With swig, Visual Studio and TWSLink2 wrapper cpp files (contained in download), you can build wrapper for ANY LANGUAGE contained in the swig world. Just watch the samples in the swig project, to get an idea and use the Perl wrapper Visual Studio project as draft.

View sample code

# --- including libs ---
# twslink module
use twslink2pl;
# module to modify console
#use Win32::Console;


# ----- Object creation -----
print "creating twslink wrapper:\n";
$tws = new twslink2pl::TWSLink2Wrap("",1);
#print "creating console:\n";
#$console = new Win32::Console;

#$tws->Load(true,"");
my $stime=gmtime();
print "start time=$stime\n";

print "Connecting . . . \n" ;
$status = $tws->CONNECT("127.0.0.1",7496,1,6000) ;
print "Connected=$status\n";
# register a stock; wait at the most 5 seconds until contract has been accpeted by tws


print "Register MSFT\n";
my $uidMSFT = $tws->REGISTER_CONTRACT("MSFT","STK","USD","NASDAQ","","","",0.0,"",0,0.0) ;
print "uid MSFT=$uidMSFT\n";

print "Place buy market 100 MSFT\n";
my $uidOrderMSFT = $tws->PLACE_ORDER($uidMSFT,0,"BUY","MKT",100,0.0,0.0,"GTC",1,0) ;
print "uid order MSFT=$uidOrderMSFT\n";
$tws->WAIT_FOR_FILLED($uidOrderMSFT,20000);

[ddownload id=”1869″ style=”link” text=”Download TWSLink Perl 5 x64 wrapper”]

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.