line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::Robinhood::News; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf-8 |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=for stopwords watchlist watchlists untradable urls |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Finance::Robinhood::News - Represents a Single News Article |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use Text::Wrap qw[wrap]; |
14
|
|
|
|
|
|
|
use Finance::Robinhood; |
15
|
|
|
|
|
|
|
my $rh = Finance::Robinhood->new; |
16
|
|
|
|
|
|
|
CORE::say wrap( '', ' ', $_->title . "\n" . $_->summary ) for $rh->news('TSLA')->take(10); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 METHODS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.92_002'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _test__init { |
25
|
1
|
|
|
1
|
|
11802
|
my $rh = t::Utility::rh_instance(1); |
26
|
0
|
|
|
|
|
0
|
my $msft = $rh->news('MSFT')->current; |
27
|
0
|
|
|
|
|
0
|
my $btc = $rh->news('d674efea-e623-4396-9026-39574b92b093')->current; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
0
|
isa_ok( $msft, __PACKAGE__ ); |
30
|
0
|
|
|
|
|
0
|
t::Utility::stash( 'MSFT', $msft ); # Store it for later |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
0
|
isa_ok( $btc, __PACKAGE__ ); |
33
|
0
|
|
|
|
|
0
|
t::Utility::stash( 'BTC', $btc ); # Store it for later |
34
|
|
|
|
|
|
|
} |
35
|
1
|
|
|
1
|
|
9
|
use Mojo::Base-base, -signatures; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
10
|
|
36
|
1
|
|
|
1
|
|
338
|
use Mojo::URL; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
37
|
1
|
|
|
1
|
|
46
|
use Time::Moment; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
733
|
|
38
|
|
|
|
|
|
|
# |
39
|
|
|
|
|
|
|
has _rh => undef => weak => 1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 C |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Returns the article's source. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 C |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
If available, this will return the author who wrote the article. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 C |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
The current total number of times this article has been clicked by Robinhod's |
52
|
|
|
|
|
|
|
users. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 C |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Returns the article's source in a format suited for display. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 C |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Returns a brief (often truncated) summary of the article. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 C |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Returns the article's title. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 C |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Returns the article's unique ID. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
has [ |
73
|
|
|
|
|
|
|
'api_source', 'author', |
74
|
|
|
|
|
|
|
'num_clicks', |
75
|
|
|
|
|
|
|
'source', 'summary', |
76
|
|
|
|
|
|
|
'title', 'uuid' |
77
|
|
|
|
|
|
|
]; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 C |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
If this article has a thumbnail, this will return the URL as a Mojo::Url |
82
|
|
|
|
|
|
|
object. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
0
|
1
|
0
|
sub preview_image_url($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
87
|
0
|
0
|
|
|
|
0
|
$s->{preview_image_url} ? Mojo::URL->new( $s->{preview_image_url} ) : (); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub _test_preview_image_url { |
91
|
1
|
|
50
|
1
|
|
1852
|
t::Utility::stash('MSFT') // skip_all(); |
92
|
0
|
|
|
|
|
0
|
isa_ok( t::Utility::stash('MSFT')->preview_image_url, 'Mojo::URL' ); |
93
|
0
|
|
0
|
|
|
0
|
t::Utility::stash('BTC') // skip_all(); |
94
|
0
|
|
|
|
|
0
|
isa_ok( t::Utility::stash('BTC')->preview_image_url, 'Mojo::URL' ); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 C |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Returns a Mojo::URL object containing the URL Robinhood would like you to use. |
100
|
|
|
|
|
|
|
This will register as a click and will then redirect to the article itself. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
0
|
1
|
0
|
sub relay_url($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
105
|
0
|
0
|
|
|
|
0
|
$s->{relay_url} ? Mojo::URL->new( $s->{relay_url} ) : (); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub _test_relay_url { |
109
|
1
|
|
50
|
1
|
|
1838
|
t::Utility::stash('MSFT') // skip_all(); |
110
|
0
|
|
|
|
|
0
|
isa_ok( t::Utility::stash('MSFT')->relay_url, 'Mojo::URL' ); |
111
|
0
|
|
0
|
|
|
0
|
t::Utility::stash('BTC') // skip_all(); |
112
|
0
|
|
|
|
|
0
|
isa_ok( t::Utility::stash('BTC')->relay_url, 'Mojo::URL' ); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 C |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Mojo::URL object containing a direct link to the article. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
0
|
1
|
0
|
sub url($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
122
|
0
|
0
|
|
|
|
0
|
$s->{url} ? Mojo::URL->new( $s->{url} ) : (); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub _test_url { |
126
|
1
|
|
50
|
1
|
|
1840
|
t::Utility::stash('MSFT') // skip_all(); |
127
|
0
|
|
|
|
|
0
|
isa_ok( t::Utility::stash('MSFT')->url, 'Mojo::URL' ); |
128
|
0
|
|
0
|
|
|
0
|
t::Utility::stash('BTC') // skip_all(); |
129
|
0
|
|
|
|
|
0
|
isa_ok( t::Utility::stash('BTC')->url, 'Mojo::URL' ); |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 C |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
If the news is related to a particular forex currency, this will return the |
135
|
|
|
|
|
|
|
Finance::Robinhood::Forex::Currency object. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
0
|
0
|
0
|
sub currency($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
140
|
0
|
0
|
|
|
|
0
|
$s->{currency_id} ? $s->_rh->forex_currency_by_id( $s->{currency_id} ) : (); |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub _test_currency { |
144
|
1
|
|
50
|
1
|
|
1940
|
t::Utility::stash('BTC') // skip_all(); |
145
|
0
|
|
|
|
|
0
|
isa_ok( t::Utility::stash('BTC')->currency, 'Finance::Robinhood::Forex::Currency' ); |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 C |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
If the new is related to a particular equity instrument, this will return the |
151
|
|
|
|
|
|
|
Finance::Robihood::Equity::Instrument object. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=cut |
154
|
|
|
|
|
|
|
|
155
|
0
|
|
|
0
|
1
|
0
|
sub instrument($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
156
|
|
|
|
|
|
|
$s->{instrument} |
157
|
|
|
|
|
|
|
? $s->_rh->equity_instruments_by_id( $s->{instrument} |
158
|
0
|
0
|
|
|
|
0
|
=~ m'^.+/([0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})/$'i ) |
159
|
|
|
|
|
|
|
: (); |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub _test_instrument { |
163
|
1
|
|
50
|
1
|
|
1882
|
t::Utility::stash('MSFT') // skip_all(); |
164
|
0
|
|
|
|
|
0
|
isa_ok( t::Utility::stash('MSFT')->instrument, 'Finance::Robinhood::Equity::Instrument' ); |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head2 C |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
$article->published_at->to_string; |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Returns the time the article was published as a Time::Moment object. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=cut |
174
|
|
|
|
|
|
|
|
175
|
0
|
|
|
0
|
1
|
0
|
sub published_at($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
176
|
0
|
|
|
|
|
0
|
Time::Moment->from_string( $s->{published_at} ); |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub _test_published_at { |
180
|
1
|
|
50
|
1
|
|
1873
|
t::Utility::stash('MSFT') // skip_all(); |
181
|
0
|
|
|
|
|
0
|
isa_ok( t::Utility::stash('MSFT')->published_at, 'Time::Moment' ); |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=head2 C |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
$article->updated_at->to_string; |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Returns the time the article was published or last updated as a Time::Moment |
189
|
|
|
|
|
|
|
object. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=cut |
192
|
|
|
|
|
|
|
|
193
|
0
|
|
|
0
|
1
|
0
|
sub updated_at($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
194
|
0
|
|
|
|
|
0
|
Time::Moment->from_string( $s->{updated_at} ); |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub _test_updated_at { |
198
|
1
|
|
50
|
1
|
|
1859
|
t::Utility::stash('MSFT') // skip_all(); |
199
|
0
|
|
|
|
|
|
isa_ok( t::Utility::stash('MSFT')->updated_at, 'Time::Moment' ); |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 LEGAL |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
This is a simple wrapper around the API used in the official apps. The author |
205
|
|
|
|
|
|
|
provides no investment, legal, or tax advice and is not responsible for any |
206
|
|
|
|
|
|
|
damages incurred while using this software. This software is not affiliated |
207
|
|
|
|
|
|
|
with Robinhood Financial LLC in any way. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
For Robinhood's terms and disclosures, please see their website at |
210
|
|
|
|
|
|
|
https://robinhood.com/legal/ |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 LICENSE |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Copyright (C) Sanko Robinson. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
217
|
|
|
|
|
|
|
the terms found in the Artistic License 2. Other copyrights, terms, and |
218
|
|
|
|
|
|
|
conditions may apply to data transmitted through this module. Please refer to |
219
|
|
|
|
|
|
|
the L section. |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head1 AUTHOR |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
Sanko Robinson Esanko@cpan.orgE |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=cut |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
1; |