#!/usr/bin/perl #NOTE: If you are using the example on Windows, you must install Perl #DOWNLOAD: http://www.activestate.com/activeperl/downloads use Net::SSLeay qw(get_https make_form); #FILL OUT YOUR ACCOUNT INFORMATION HERE $user_juno_email=''; $user_juno_password=''; &juno_login; for($i = 1; $i < 1000; $i++) { sleep 2; &juno_getBuyingPower; sleep 2; &juno_getOpenOrders; sleep 2; &juno_getPositions; &juno_get_price("INTC"); print "Bid: $current_bid{INTC} Ask: $current_ask{INTC}\n"; sleep 15; } &juno_logout; exit; sub juno_getPositions { ($page, $response, %reply_headers) = get_https('www.junotrade.com', 443,"/webapi/getPositions?PHPSESSID=$juno_sessid",'',''); print "GP result: $page\n"; } sub juno_getOpenOrders { ($page, $response, %reply_headers) = get_https('www.junotrade.com', 443,"/webapi/getOpenOrders?PHPSESSID=$juno_sessid",'',''); print "OO result: $page\n"; } sub juno_getBuyingPower { ($page, $response, %reply_headers) = get_https('www.junotrade.com', 443,"/webapi/getBuyingPower?PHPSESSID=$juno_sessid",'',''); print "BP result: $page\n"; } sub juno_login { $juno_sessid=''; $string= "UserName=$user_juno_email" . "&Password=$user_juno_password"; ($page, $response, %reply_headers) = get_https('www.junotrade.com', 443,"/webapi/login?$string",'',''); print "Login result: $page\n"; if (substr($page,0,4) eq 'S|1|') { ($junk,$tmp)=split(/\=/,$reply_headers{'SET-COOKIE'}); ($juno_sessid,$junk)=split(/\;/,$tmp); print "perl PHPSESSID: $juno_sessid\n"; } } sub juno_logout { ($page, $response, %reply_headers) = get_https('www.junotrade.com', 443,"/webapi/logout?PHPSESSID=$juno_sessid",'',''); print "Logout result: $page\n"; } sub juno_get_price { ($page, $response, %reply_headers) = get_https('www.junotrade.com', 443, "/webapi/getSymbol?PHPSESSID=$juno_sessid&sym=$_[0]", '', ''); @page=(split/\n/,$page); foreach $line (@page) { ($tmp_g, $tmp_symbol, $tmp_price, $tmp_time, $tmp_high, $tmp_low, $tmp_last, $tmp_open, $tmp_bid, $tmp_ask, $tmp_volume, $tmp_change, $tmp_tick, $junk)=split(/\|/,$line); $current_bid{$tmp_symbol}=sprintf('%.2f',$tmp_bid); $current_ask{$tmp_symbol}=sprintf('%.2f',$tmp_ask); } }