line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Grizzly::Command::quote; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Gets a stock quote for the given symbol |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
1510
|
use Grizzly -command; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
22
|
|
6
|
2
|
|
|
2
|
|
666
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
42
|
|
7
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
58
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
10
|
use Finance::Quote; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
91
|
|
10
|
2
|
|
|
2
|
|
10
|
use Grizzly::Progress::Bar; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
71
|
|
11
|
2
|
|
|
2
|
|
10
|
use Term::ANSIColor; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1065
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $q = Finance::Quote->new("YahooJSON"); |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
0
|
1
|
0
|
sub abstract { "display stock quote" } |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
0
|
1
|
0
|
sub description { "Display the stock quote information." } |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub validate_args { |
20
|
3
|
|
|
3
|
1
|
5711261
|
my ( $self, $opt, $args ) = @_; |
21
|
3
|
100
|
|
|
|
26
|
$self->usage_error("Need a symbol args") unless @$args; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub execute { |
25
|
2
|
|
|
2
|
1
|
14
|
my ( $self, $opt, $args ) = @_; |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
|
|
8
|
quote_info(@$args); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub quote_info { |
31
|
2
|
|
|
2
|
0
|
5
|
my ($symbol) = @_; |
32
|
|
|
|
|
|
|
|
33
|
2
|
|
|
|
|
24
|
my %quote = $q->yahoo_json($symbol); |
34
|
|
|
|
|
|
|
|
35
|
2
|
|
|
|
|
386835
|
Grizzly::Progress::Bar->progressbar(); |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $name = $quote{ $symbol, "name" }; |
38
|
0
|
|
|
|
|
|
my $date = $quote{ $symbol, "date" }; |
39
|
0
|
|
|
|
|
|
my $last_price = $quote{ $symbol, "last" }; |
40
|
0
|
|
|
|
|
|
my $open = $quote{ $symbol, "open" }; |
41
|
0
|
|
|
|
|
|
my $high = $quote{ $symbol, "high" }; |
42
|
0
|
|
|
|
|
|
my $low = $quote{ $symbol, "low" }; |
43
|
0
|
|
|
|
|
|
my $close = $quote{ $symbol, "close" }; |
44
|
0
|
|
|
|
|
|
my $div_yield = $quote{ $symbol, "div_yield" }; |
45
|
0
|
|
|
|
|
|
my $pe = $quote{ $symbol, "pe" }; |
46
|
0
|
|
|
|
|
|
my $eps = $quote{ $symbol, "eps" }; |
47
|
|
|
|
|
|
|
|
48
|
0
|
0
|
|
|
|
|
unless ($name) { |
49
|
0
|
|
|
|
|
|
$name = $symbol; |
50
|
|
|
|
|
|
|
} |
51
|
0
|
0
|
|
|
|
|
unless ($date) { |
52
|
0
|
|
|
|
|
|
$date = 'n/a'; |
53
|
|
|
|
|
|
|
} |
54
|
0
|
0
|
|
|
|
|
unless ($last_price) { |
55
|
0
|
|
|
|
|
|
$last_price = 'n/a'; |
56
|
|
|
|
|
|
|
} |
57
|
0
|
0
|
|
|
|
|
unless ($open) { |
58
|
0
|
|
|
|
|
|
$open = 'n/a'; |
59
|
|
|
|
|
|
|
} |
60
|
0
|
0
|
|
|
|
|
unless ($high) { |
61
|
0
|
|
|
|
|
|
$high = 'n/a'; |
62
|
|
|
|
|
|
|
} |
63
|
0
|
0
|
|
|
|
|
unless ($low) { |
64
|
0
|
|
|
|
|
|
$low = 'n/a'; |
65
|
|
|
|
|
|
|
} |
66
|
0
|
0
|
|
|
|
|
unless ($close) { |
67
|
0
|
|
|
|
|
|
$close = 'n/a'; |
68
|
|
|
|
|
|
|
} |
69
|
0
|
0
|
|
|
|
|
unless ($div_yield) { |
70
|
0
|
|
|
|
|
|
$div_yield = 'n/a'; |
71
|
|
|
|
|
|
|
} |
72
|
0
|
0
|
|
|
|
|
unless ($pe) { |
73
|
0
|
|
|
|
|
|
$pe = 'n/a'; |
74
|
|
|
|
|
|
|
} |
75
|
0
|
0
|
|
|
|
|
unless ($eps) { |
76
|
0
|
|
|
|
|
|
$eps = 'n/a'; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my $title = colored( "Grizzly - Stock Quote Analysis", "blue" ); |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
print <<EOF,; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
$title |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Company: ========== $name |
86
|
|
|
|
|
|
|
Date: ============= $date |
87
|
|
|
|
|
|
|
Latest Price: ===== $last_price |
88
|
|
|
|
|
|
|
Open: ============= $open |
89
|
|
|
|
|
|
|
High: ============= $high |
90
|
|
|
|
|
|
|
Low: ============== $low |
91
|
|
|
|
|
|
|
Previous Close: === $close |
92
|
|
|
|
|
|
|
Dividend Yield: === $div_yield |
93
|
|
|
|
|
|
|
P/E Ratio: ======== $pe |
94
|
|
|
|
|
|
|
EPS: ============== $eps |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
EOF |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__END__ |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=pod |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=encoding UTF-8 |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 NAME |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Grizzly::Command::quote - Gets a stock quote for the given symbol |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 VERSION |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
version 0.103 |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 SYNOPSIS |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
grizzly quote [stock symbol] |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 DESCRIPTION |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Grizzly will output the stock quote of the inputted tickers symbol. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 NAME |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Grizzly::Command::quote |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 AUTHOR |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Nobunaga <nobunaga@cpan.org> |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Nobunaga. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
MIT License |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 AUTHOR |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Nobunaga <nobunaga@cpan.org> |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
This software is Copyright (c) 2021 by Nobunaga. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This is free software, licensed under: |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
The MIT (X11) License |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |