line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::TW::EmergingQuote; |
2
|
|
|
|
|
|
|
our $VERSION = '0.26'; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
929
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
5
|
1
|
|
|
1
|
|
1078
|
use LWP::Simple (); |
|
1
|
|
|
|
|
280760
|
|
|
1
|
|
|
|
|
40
|
|
6
|
1
|
|
|
1
|
|
25
|
use Encode 'from_to'; |
|
1
|
|
|
|
|
47
|
|
|
1
|
|
|
|
|
938
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub resolve { |
9
|
0
|
|
|
0
|
1
|
|
die "not implemented"; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
0
|
|
|
0
|
1
|
|
my ($class, $target) = @_; |
14
|
0
|
|
|
|
|
|
my $self = bless {}, $class; |
15
|
|
|
|
|
|
|
|
16
|
0
|
0
|
|
|
|
|
$self->resolve($target) |
17
|
|
|
|
|
|
|
unless $target =~ /^\d+$/; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
0
|
|
|
|
$self->{id} ||= $target; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
return $self; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub get { |
25
|
0
|
0
|
|
0
|
1
|
|
my $self = shift if ref($_[0]) eq __PACKAGE__; |
26
|
0
|
0
|
|
|
|
|
shift if $_[0] eq __PACKAGE__; |
27
|
0
|
0
|
|
|
|
|
my $stockno = $self ? $self->{id} : shift; |
28
|
0
|
|
|
|
|
|
my $content = LWP::Simple::get("http://nweb.otc.org.tw/main.htm"); |
29
|
0
|
|
|
|
|
|
from_to($content, 'big5', 'utf-8'); |
30
|
0
|
|
|
|
|
|
my $result; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
my ($time) = $content =~ m/製表時間 :.*?,([\d:]+)/; |
33
|
|
|
|
|
|
|
|
34
|
0
|
0
|
|
|
|
|
undef $self->{quote} if $self; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# |
3480 | ®õ¦w¬ì | 70.56 | 68.0 | 1,000 | 72.0 | 1,000 | 71.0 | 69.0 | 70.47 | 71.0 | 25,039 | 95/04/03 | °e¥ó¥Ó½Ð¤W¥« |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
while ($content =~ s{ |
}{}) {
39
|
0
|
|
|
|
|
|
my $entrybuf = $1; |
40
|
0
|
|
|
|
|
|
my ($stock_no) = $entrybuf =~ m{"(\d+)"}; |
41
|
0
|
0
|
|
|
|
|
next unless $stock_no == $self->{id}; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
@{$result}{qw(id name PAvg BidBuy BidBuyVol BidSell BidSellVol HighPrice LowPrice Avg MatchPrice DQty)} = |
|
0
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
map {s/,//g; $_} grep { $_ ne ' ' } $entrybuf =~ m/>(?: \s*)?([^<>]+)
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
$result->{DQty} /= 1000; |
46
|
0
|
|
|
|
|
|
$result->{time} = $time; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
$self->{quote} = $result if $self; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
return $result; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Finance::TW::EmergingQuote - Check stock quotes from Taiwan Emerging Stock |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 SYNOPSIS |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
use Finance::TW::EmergingQuote; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
my $quote = Finance::TW::EmergingQuote->new('3481'); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
while (1) { print $quote->get->{MatchPrice}.$/; sleep 30 } |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 DESCRIPTION |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
This module provides interface to Emerging Stock price information |
72
|
|
|
|
|
|
|
available from Taiwan's OTC(over-the-counter market). You could get |
73
|
|
|
|
|
|
|
the real time quote. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 CLASS METHODS |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=over 4 |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item new |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Create a stock quote object. Resolve the name to symbol |
82
|
|
|
|
|
|
|
if the argument is not a symbol. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item resolve |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Resolve the company name to stock symbol. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item get |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Get the real time stock information. |
91
|
|
|
|
|
|
|
Return a hash containing stock information. The keys are: |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=over 4 |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item DQty |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
current volume |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=item MatchPrice |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
current price |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item HighPrice |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
daily high |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item LowPrice |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
daily low |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=back |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=back |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 AUTHORS |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Chia-liang Kao Eclkao@clkao.orgE |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 COPYRIGHT |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Copyright 2006 by Chia-liang Kao Eclkao@clkao.orgE. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
124
|
|
|
|
|
|
|
under the same terms as Perl itself. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
See L |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
129
|
|
|
|
|
|
|
|