Debian Codegraph @

Examples/chkshares.pl

raw
1 #!/usr/bin/perl -w
2 use strict;
3 use lib '../lib';
4 use Finance::Quote qw/asx/;
5
6 =head1 NAME
7
8 chkshares.pl - Check share information.
9
10 =head1 USAGE
11
12 chkshares.pl australia TLS CML ITE
13
14 =head1 NOTES
15
16 Example program. Demonstrates how to use one of the interface to
17 Finance::Quote. The first argument must be the market.
18
19 =cut
20
21 my ($name, $date, $last, $p_change, $high, $low, $volume, $close);
22
23 format STDOUT_TOP =
24
25 STOCK REPORT
26
27 TICKER DATE LAST %CHANGE HIGH LOW VOLUME CLOSE
28 ----------------------------------------------------------------------------------
29 .
30
31 format STDOUT =
32 @<<<<<< @>>>>>>>>>> @####.### @###.### @####.### @####.### @>>>>>>>> @####.###
33 $name, $date, $last, $p_change, $high, $low, $volume, $close
34 .
35
36 my $quoter = Finance::Quote->new();
37 my $market = shift || die "Usage: $0 market stocks\n";
38
39 my %quote = $quoter->fetch($market,@ARGV);
40
41 foreach my $code (@ARGV) {
42 unless ($quote{$code,"success"}) {
43 warn "Lookup of $code failed - ".$quote{$code,"errormsg"}."\n";
44 next;
45 }
46 $name = $code;
47 $date = $quote{$code,'date'};
48 $last = $quote{$code,'last'};
49 $p_change = $quote{$code,'p_change'};
50 $high = $quote{$code,'high'};
51 $low = $quote{$code,'low'};
52 $volume = $quote{$code,'volume'};
53 $close = $quote{$code,'close'};
54 write;
55 }