Did you ever want to watch a stock price, but didn't want to stay logged in to a broker, or reload a full web page, or load a giant program that does everything? This will watch a stock's price, and keep it in view, so you can sell or buy when it hits your level. It is based on the yahooquote example that comes with Finance::YahooQuote.
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
use Finance::YahooQuote;
# mouse left click to quit
my @check = qw(BA BNI BASFY.PK); # stocks to check
# order of information sent by yahoo
my @h = ("Symbol","Name","Last","Trade Date","Trade Time","Change","%
+Change",
"Volume","Avg. Daily Volume","Bid","Ask","Prev. Close","Open",
"Day's Range","52-Week Range","EPS","P/E Ratio","Div. Pay Date",
"Div/Share","Div. Yield","Mkt. Cap","Exchange");
my %stocks;
my $mw = new MainWindow;
$mw->geometry('-0-0'); # lower right corner, my toolbar is at the top
+ :-)
$mw->overrideredirect(1); # show on all desktops
foreach my $stock (@check){
$stocks{$stock}{'info'}= ' ';
$stocks{$stock}{'lab'} = $mw->Label(-textvariable=>\$stocks{$stock}{
+'info'},
#-width => 45,
-justify => 'left',
-anchor => 'nw',
-height=>1,
-padx=>0,
-pady=>0,
-bg=>'black',
-fg=>'yellow')->pack(-expand=>1,-fill=>'x',-pady=>
+0,-padx=>0);
}
#set update time... don't overload server
my $id = Tk::After->new($mw,30000,'repeat',\&refresh); #30 seconds
refresh();
$mw->bind('<ButtonPress-1>', sub{ Tk::exit });
MainLoop;
sub refresh{
my @q = getquote(@check);
foreach $a (@q) {
$stocks{$$a[0]}{'info'} = $$a[2].' '.$$a[0].' '.$$a[5]."\n";
}
}