TWSLink2 Perl 5 sample

# --- 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);