line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
# ABSTRACT: Gets the stock news for the given symbol |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use Grizzly -command; |
5
|
2
|
|
|
2
|
|
7902
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
28
|
|
6
|
2
|
|
|
2
|
|
595
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
32
|
|
7
|
2
|
|
|
2
|
|
8
|
use Carp; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
38
|
|
8
|
2
|
|
|
2
|
|
7
|
use open ':std', ':encoding(UTF-8)'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
117
|
|
9
|
2
|
|
|
2
|
|
756
|
|
|
2
|
|
|
|
|
2216
|
|
|
2
|
|
|
|
|
12
|
|
10
|
|
|
|
|
|
|
use Finance::Quote; |
11
|
2
|
|
|
2
|
|
28785
|
use Web::NewsAPI; |
|
2
|
|
|
|
|
110862
|
|
|
2
|
|
|
|
|
97
|
|
12
|
2
|
|
|
2
|
|
870
|
use Grizzly::Progress::Bar; |
|
2
|
|
|
|
|
2700363
|
|
|
2
|
|
|
|
|
71
|
|
13
|
2
|
|
|
2
|
|
887
|
use Term::ANSIColor; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
62
|
|
14
|
2
|
|
|
2
|
|
1106
|
|
|
2
|
|
|
|
|
14405
|
|
|
2
|
|
|
|
|
912
|
|
15
|
|
|
|
|
|
|
my $q = Finance::Quote->new("YahooJSON"); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
0
|
1
|
0
|
|
19
|
|
|
|
|
|
|
my ( $self, $opt, $args ) = @_; |
20
|
0
|
|
|
0
|
1
|
0
|
$self->usage_error("Need a symbol args") unless @$args; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
3
|
|
|
3
|
1
|
4526060
|
my ( $self, $opt, $args ) = @_; |
24
|
3
|
100
|
|
|
|
22
|
|
25
|
|
|
|
|
|
|
quote_info(@$args); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
2
|
1
|
11
|
my ($symbol) = @_; |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
|
|
8
|
my $article_number = 1; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my %quote = $q->yahoo_json($symbol); |
33
|
|
|
|
|
|
|
|
34
|
2
|
|
|
2
|
0
|
5
|
Grizzly::Progress::Bar->progressbar(); |
35
|
|
|
|
|
|
|
|
36
|
2
|
|
|
|
|
5
|
my $name = $quote{ $symbol, "name" }; |
37
|
|
|
|
|
|
|
|
38
|
2
|
|
|
|
|
23
|
my $api_key = $ENV{'NEWS_API_KEY'} |
39
|
|
|
|
|
|
|
or croak |
40
|
2
|
|
|
|
|
305504
|
"You need to set an API key to NEWS_API_KEY environment variable"; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my $newsapi = Web::NewsAPI->new( api_key => $api_key, ); |
43
|
|
|
|
|
|
|
|
44
|
0
|
0
|
|
|
|
|
unless ($name) { |
45
|
|
|
|
|
|
|
$name = $symbol; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
print colored( "Here are the top ten headlines worldwide for ", "blue" ) |
49
|
|
|
|
|
|
|
. colored( "$name...\n", "white" ); |
50
|
0
|
0
|
|
|
|
|
print "\n"; |
51
|
0
|
|
|
|
|
|
my $stock_news = $newsapi->everything( q => $name, pageSize => 10 ); |
52
|
|
|
|
|
|
|
for my $article ( $stock_news->articles ) { |
53
|
|
|
|
|
|
|
print colored( "$article_number: \n", "magenta" ) |
54
|
0
|
|
|
|
|
|
. $article->title . "\n"; |
55
|
|
|
|
|
|
|
print colored( "Link: ", "cyan" ) . $article->url . "\n"; |
56
|
0
|
|
|
|
|
|
print colored( "Description: ", "cyan" ) . $article->description . "\n"; |
57
|
0
|
|
|
|
|
|
print "\n"; |
58
|
0
|
|
|
|
|
|
$article_number += 1; |
59
|
0
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
print colored( "The total number of $name articles returned: ", "blue" ) |
61
|
0
|
|
|
|
|
|
. colored( $stock_news->total_results . "\n", "white" ); |
62
|
0
|
|
|
|
|
|
} |
63
|
0
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=pod |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=encoding UTF-8 |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 NAME |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Grizzly::Command::news - Gets the stock news for the given symbol |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 VERSION |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
version 0.104 |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 SYNOPSIS |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
grizzly news [stock symbol] |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 DESCRIPTION |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
The news feture will output stock in formation on the inputted ticker symbol. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 NAME |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Grizzly::Command::news |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 API Key |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
You will need to get a free API key from L<NewsAPI|https://newsapi.org/>. Afterwards you will need to set the NEWS_API_KEY environment variable to the API key. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 AUTHOR |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Nobunaga <nobunaga@cpan.org> |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Nobunaga. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
MIT License |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 AUTHOR |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Nobunaga <nobunaga@cpan.org> |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This software is Copyright (c) 2022 by Nobunaga. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
This is free software, licensed under: |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
The MIT (X11) License |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |