line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::Robinhood::Equity::Ratings; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf-8 |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=for stopwords watchlist watchlists untradable urls |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Finance::Robinhood::Equity::Ratings - Morningstar ratings for equity |
10
|
|
|
|
|
|
|
instruments Watchlist |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Finance::Robinhood; |
15
|
|
|
|
|
|
|
my $rh = Finance::Robinhood->new; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $msft = $rh->equity_instrument_by_id('50810c35-d215-4866-9758-0ada4ac79ffa'); |
18
|
|
|
|
|
|
|
my $ratings = $msft->ratings; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# TODO |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=cut |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our $VERSION = '0.92_001'; |
25
|
1
|
|
|
1
|
|
7
|
use Mojo::Base-base, -signatures; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
26
|
1
|
|
|
1
|
|
182
|
use Mojo::URL; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _test__init { |
29
|
1
|
|
|
1
|
|
12047
|
my $rh = t::Utility::rh_instance(1); |
30
|
0
|
|
|
|
|
0
|
my $msft = $rh->equity_instrument_by_id('50810c35-d215-4866-9758-0ada4ac79ffa'); # MSFT |
31
|
0
|
|
|
|
|
0
|
my $ratings = $msft->ratings; |
32
|
0
|
|
|
|
|
0
|
isa_ok( $ratings, __PACKAGE__ ); |
33
|
0
|
|
|
|
|
0
|
t::Utility::stash( 'RATINGS', $ratings ); # Store it for later |
34
|
|
|
|
|
|
|
} |
35
|
1
|
|
|
1
|
|
153
|
use overload '""' => sub ( $s, @ ) { $s->{instrument_id} }, fallback => 1; |
|
1
|
|
|
0
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _test_stringify { |
38
|
1
|
|
50
|
1
|
|
1872
|
t::Utility::stash('RATINGS') // skip_all(); |
39
|
0
|
|
|
|
|
0
|
like( |
40
|
|
|
|
|
|
|
+t::Utility::stash('RATINGS'), |
41
|
|
|
|
|
|
|
qr'^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$'i |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
# |
45
|
|
|
|
|
|
|
has _rh => undef => weak => 1; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 METHODS |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 C |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Returns a list of buy ratings. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
0
|
1
|
0
|
sub buy ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
56
|
0
|
|
|
|
|
0
|
map { $_->{text} } grep { $_->{type} eq 'buy' } @{ $s->{ratings} }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
57
|
|
|
|
|
|
|
} |
58
|
1
|
|
|
1
|
|
1826
|
sub _test_buy { skip_all() } |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 C |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Returns a list of sell ratings. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
0
|
1
|
0
|
sub sell ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
67
|
0
|
|
|
|
|
0
|
map { $_->{text} } grep { $_->{type} eq 'sell' } @{ $s->{ratings} }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
68
|
|
|
|
|
|
|
} |
69
|
1
|
|
|
1
|
|
1854
|
sub _test_sell { skip_all() } |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 C |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Returns a list of hold ratings. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
0
|
1
|
0
|
sub hold ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
78
|
0
|
|
|
|
|
0
|
map { $_->{text} } grep { $_->{type} eq 'hold' } @{ $s->{ratings} }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
1
|
|
|
1
|
|
1838
|
sub _test_hold { skip_all() } |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 C |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Returns a hash reference with the following keys: C, C, C. The |
86
|
|
|
|
|
|
|
values are ratings. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
0
|
1
|
0
|
sub all ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
91
|
|
|
|
|
|
|
{ |
92
|
0
|
|
|
|
|
0
|
buy => [ $s->buy ], |
93
|
|
|
|
|
|
|
hold => [ $s->hold ], |
94
|
|
|
|
|
|
|
sell => [ $s->sell ] |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub _test_all { |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
#t::Utility::stash('RATINGS') // |
101
|
1
|
|
|
1
|
|
2012
|
skip_all(); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 C |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Returns a hash reference with the following keys: C, C, C. The |
107
|
|
|
|
|
|
|
values are numbers. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
0
|
1
|
0
|
sub totals ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
112
|
|
|
|
|
|
|
{ |
113
|
|
|
|
|
|
|
buy => $s->{summary}{num_buy_ratings}, |
114
|
|
|
|
|
|
|
hold => $s->{summary}{num_hold_ratings}, |
115
|
|
|
|
|
|
|
sell => $s->{summary}{num_sell_ratings} |
116
|
|
|
|
|
|
|
} |
117
|
0
|
|
|
|
|
0
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub _test_totals { |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
#t::Utility::stash('RATINGS') // |
122
|
1
|
|
|
1
|
|
1854
|
skip_all(); |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
#my $instrument = t::Utility::stash('RATINGS')->instrument; |
125
|
|
|
|
|
|
|
#isa_ok( $instrument, 'Finance::Robinhood::Instrument' ); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 C |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
my $instrument = $ratings->instrument; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Returns an iterator containing Finance::Robinhood::News elements. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |
135
|
|
|
|
|
|
|
|
136
|
0
|
|
|
0
|
1
|
0
|
sub instrument ($s) { $s->_rh->equity_instrument_by_id( $s->{instrument_id} ) } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub _test_instrument { |
139
|
1
|
|
50
|
1
|
|
2057
|
t::Utility::stash('RATINGS') // skip_all(); |
140
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
my $instrument = t::Utility::stash('RATINGS')->instrument; |
142
|
0
|
|
|
|
|
|
isa_ok( $instrument, 'Finance::Robinhood::Equity::Instrument' ); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 LEGAL |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
This is a simple wrapper around the API used in the official apps. The author |
148
|
|
|
|
|
|
|
provides no investment, legal, or tax advice and is not responsible for any |
149
|
|
|
|
|
|
|
damages incurred while using this software. This software is not affiliated |
150
|
|
|
|
|
|
|
with Robinhood Financial LLC in any way. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
For Robinhood's terms and disclosures, please see their website at |
153
|
|
|
|
|
|
|
https://robinhood.com/legal/ |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 LICENSE |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Copyright (C) Sanko Robinson. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
160
|
|
|
|
|
|
|
the terms found in the Artistic License 2. Other copyrights, terms, and |
161
|
|
|
|
|
|
|
conditions may apply to data transmitted through this module. Please refer to |
162
|
|
|
|
|
|
|
the L section. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 AUTHOR |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Sanko Robinson Esanko@cpan.orgE |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=cut |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
1; |