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_003'; |
25
|
1
|
|
|
1
|
|
6
|
use Mojo::Base-base, -signatures; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
26
|
1
|
|
|
1
|
|
156
|
use Mojo::URL; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _test__init { |
29
|
1
|
|
|
1
|
|
11558
|
my $rh = t::Utility::rh_instance(1); |
30
|
0
|
|
|
|
|
0
|
my $msft = $rh->equity_instrument_by_id( |
31
|
|
|
|
|
|
|
'50810c35-d215-4866-9758-0ada4ac79ffa'); # MSFT |
32
|
0
|
|
|
|
|
0
|
my $ratings = $msft->ratings; |
33
|
0
|
|
|
|
|
0
|
isa_ok($ratings, __PACKAGE__); |
34
|
0
|
|
|
|
|
0
|
t::Utility::stash('RATINGS', $ratings); # Store it for later |
35
|
|
|
|
|
|
|
} |
36
|
1
|
|
|
1
|
|
133
|
use overload '""' => sub ($s, @) { $s->{instrument_id} }, fallback => 1; |
|
1
|
|
|
0
|
|
2
|
|
|
1
|
|
|
|
|
14
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _test_stringify { |
39
|
1
|
|
50
|
1
|
|
1929
|
t::Utility::stash('RATINGS') // skip_all(); |
40
|
0
|
|
|
|
|
0
|
like(+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
|
|
1894
|
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
|
|
1864
|
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
|
1
|
|
|
1
|
|
1862
|
sub _test_hold { skip_all() } |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 C |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Returns a hash reference with the following keys: C, C, C. The |
85
|
|
|
|
|
|
|
values are ratings. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
0
|
1
|
0
|
sub all ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
90
|
0
|
|
|
|
|
0
|
{buy => [$s->buy], hold => [$s->hold], sell => [$s->sell]} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub _test_all { |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
#t::Utility::stash('RATINGS') // |
96
|
1
|
|
|
1
|
|
1966
|
skip_all(); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 C |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Returns a hash reference with the following keys: C, C, C. The |
102
|
|
|
|
|
|
|
values are numbers. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
0
|
1
|
0
|
sub totals ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
107
|
|
|
|
|
|
|
{buy => $s->{summary}{num_buy_ratings}, |
108
|
|
|
|
|
|
|
hold => $s->{summary}{num_hold_ratings}, |
109
|
|
|
|
|
|
|
sell => $s->{summary}{num_sell_ratings} |
110
|
|
|
|
|
|
|
} |
111
|
0
|
|
|
|
|
0
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub _test_totals { |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
#t::Utility::stash('RATINGS') // |
116
|
1
|
|
|
1
|
|
1862
|
skip_all(); |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
#my $instrument = t::Utility::stash('RATINGS')->instrument; |
119
|
|
|
|
|
|
|
#isa_ok( $instrument, 'Finance::Robinhood::Instrument' ); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 C |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
my $instrument = $ratings->instrument; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Returns an iterator containing Finance::Robinhood::News elements. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
129
|
|
|
|
|
|
|
|
130
|
0
|
|
|
0
|
1
|
0
|
sub instrument ($s) { $s->_rh->equity_instrument_by_id($s->{instrument_id}) } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub _test_instrument { |
133
|
1
|
|
50
|
1
|
|
1878
|
t::Utility::stash('RATINGS') // skip_all(); |
134
|
0
|
|
|
|
|
|
my $instrument = t::Utility::stash('RATINGS')->instrument; |
135
|
0
|
|
|
|
|
|
isa_ok($instrument, 'Finance::Robinhood::Equity::Instrument'); |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 LEGAL |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
This is a simple wrapper around the API used in the official apps. The author |
141
|
|
|
|
|
|
|
provides no investment, legal, or tax advice and is not responsible for any |
142
|
|
|
|
|
|
|
damages incurred while using this software. This software is not affiliated |
143
|
|
|
|
|
|
|
with Robinhood Financial LLC in any way. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
For Robinhood's terms and disclosures, please see their website at |
146
|
|
|
|
|
|
|
https://robinhood.com/legal/ |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 LICENSE |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Copyright (C) Sanko Robinson. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
153
|
|
|
|
|
|
|
the terms found in the Artistic License 2. Other copyrights, terms, and |
154
|
|
|
|
|
|
|
conditions may apply to data transmitted through this module. Please refer to |
155
|
|
|
|
|
|
|
the L section. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 AUTHOR |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Sanko Robinson Esanko@cpan.orgE |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=cut |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
1; |