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"; } }

In reply to Cheap Stock watch with Tk by zentara

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.