line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::Robinhood::Equity::Watchlist::Element; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf-8 |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=for stopwords watchlist watchlists untradable urls |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Finance::Robinhood::Equity::Watchlist - Represents a Single Robinhood Watchlist |
10
|
|
|
|
|
|
|
Element |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Finance::Robinhood; |
15
|
|
|
|
|
|
|
my $rh = Finance::Robinhood->new->login('user', 'pass'); |
16
|
|
|
|
|
|
|
my $watchlist = $rh->watchlists->current(); |
17
|
|
|
|
|
|
|
warn $watchlist->current->instrument->symbol; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# TODO |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '0.92_003'; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _test__init { |
26
|
1
|
|
|
1
|
|
12901
|
my $rh = t::Utility::rh_instance(1); |
27
|
0
|
|
|
|
|
0
|
my $element = $rh->equity_watchlist_by_name('Default')->current; |
28
|
0
|
|
|
|
|
0
|
isa_ok($element, __PACKAGE__); |
29
|
0
|
|
|
|
|
0
|
t::Utility::stash('ELEMENT', $element); # Store it for later |
30
|
|
|
|
|
|
|
} |
31
|
1
|
|
|
1
|
|
7
|
use Mojo::Base-base, -signatures; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
7
|
|
32
|
1
|
|
|
1
|
|
193
|
use Mojo::URL; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
33
|
1
|
|
|
1
|
|
28
|
use Time::Moment; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
62
|
|
34
|
1
|
|
|
1
|
|
8
|
use overload '""' => sub ($s, @) { $s->{url} }, fallback => 1; |
|
1
|
|
|
0
|
|
3
|
|
|
1
|
|
|
|
|
8
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
35
|
1
|
|
|
1
|
|
76
|
use Finance::Robinhood::Equity::Instrument; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
6
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _test_stringify { |
38
|
1
|
|
50
|
1
|
|
1909
|
t::Utility::stash('ELEMENT') // skip_all(); |
39
|
0
|
|
|
|
|
0
|
like(+t::Utility::stash('ELEMENT'), |
40
|
|
|
|
|
|
|
qr'^https://api.robinhood.com/watchlists/Default/.+$'); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
# |
43
|
|
|
|
|
|
|
has _rh => undef => weak => 1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 METHODS |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 C |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$element->created_at(); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Returns a Time::Moment object representing the time this element was added to |
52
|
|
|
|
|
|
|
the watchlist. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
0
|
1
|
0
|
sub created_at ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
57
|
0
|
|
|
|
|
0
|
Time::Moment->from_string($s->{created_at}); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _test_created_at { |
61
|
1
|
|
50
|
1
|
|
2019
|
t::Utility::stash('ELEMENT') // skip_all(); |
62
|
0
|
|
|
|
|
0
|
isa_ok(t::Utility::stash('ELEMENT')->created_at(), 'Time::Moment'); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 C |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
$element->delete(); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Removes a instrument from the parent watchlist. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
0
|
1
|
0
|
sub delete ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
74
|
0
|
|
|
|
|
0
|
my $res = $s->_rh->_delete($s->{url}); |
75
|
0
|
|
0
|
|
|
0
|
return $res->is_success || Finance::Robinhood::Error->new(%{$res->json}); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub _test_delete { |
79
|
1
|
|
50
|
1
|
|
1899
|
t::Utility::stash('ELEMENT') // skip_all(); |
80
|
|
|
|
|
|
|
todo("Add something and remove it and check watchlist" => |
81
|
0
|
|
|
0
|
|
0
|
sub { pass('ugh') }); |
|
0
|
|
|
|
|
0
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# isa_ok( t::Utility::stash('ELEMENT')->instrument, 'Finance::Robinhood::Equity::Instrument' ); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 C |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
$element->instrument(); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Returns a Finance::Robinhood::Equity::Instrument object. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
0
|
1
|
0
|
sub instrument ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
95
|
0
|
|
|
|
|
0
|
my $res = $s->_rh->_get($s->{instrument}); |
96
|
|
|
|
|
|
|
return $res->is_success |
97
|
|
|
|
|
|
|
? Finance::Robinhood::Equity::Instrument->new(_rh => $s->_rh, |
98
|
0
|
|
|
|
|
0
|
%{$res->json}) |
99
|
0
|
0
|
|
|
|
0
|
: Finance::Robinhood::Error->new(%{$res->json}); |
|
0
|
|
|
|
|
0
|
|
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub _test_instrument { |
103
|
1
|
|
50
|
1
|
|
1900
|
t::Utility::stash('ELEMENT') // skip_all(); |
104
|
0
|
|
|
|
|
0
|
isa_ok(t::Utility::stash('ELEMENT')->instrument, |
105
|
|
|
|
|
|
|
'Finance::Robinhood::Equity::Instrument'); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 C |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
$element->id(); |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Returns the UUID of the equity instrument. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
0
|
1
|
0
|
sub id ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
117
|
|
|
|
|
|
|
$s->{instrument} |
118
|
0
|
|
|
|
|
0
|
=~ qr[/([0-9a-f]{8}(?:\-[0-9a-f]{4}){3}\-[0-9a-f]{12})/$]i; |
119
|
0
|
|
|
|
|
0
|
$1; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub _test_id { |
123
|
1
|
|
50
|
1
|
|
1914
|
t::Utility::stash('ELEMENT') // skip_all(); |
124
|
0
|
|
|
|
|
0
|
like(t::Utility::stash('ELEMENT')->id, |
125
|
|
|
|
|
|
|
qr[^[0-9a-f]{8}(?:\-[0-9a-f]{4}){3}\-[0-9a-f]{12}$]i); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 C |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
$element->watchlist(); |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Returns a Finance::Robinhood::Equity::Instrument object. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=cut |
135
|
|
|
|
|
|
|
|
136
|
0
|
|
|
0
|
1
|
0
|
sub watchlist ($s) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
137
|
0
|
|
|
|
|
0
|
my $res = $s->_rh->_get($s->{watchlist}); |
138
|
|
|
|
|
|
|
return $res->is_success |
139
|
|
|
|
|
|
|
? Finance::Robinhood::Equity::Watchlist->new(_rh => $s->_rh, |
140
|
0
|
0
|
|
|
|
0
|
%{$res->json}) |
|
0
|
0
|
|
|
|
0
|
|
141
|
|
|
|
|
|
|
: Finance::Robinhood::Error->new( |
142
|
|
|
|
|
|
|
$res->is_server_error ? (details => $res->message) : $res->json); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub _test_watchlist { |
146
|
1
|
|
50
|
1
|
|
1875
|
t::Utility::stash('ELEMENT') // skip_all(); |
147
|
0
|
|
|
|
|
|
my $watchlist = t::Utility::stash('ELEMENT')->watchlist; |
148
|
0
|
|
|
|
|
|
isa_ok($watchlist, 'Finance::Robinhood::Equity::Watchlist'); |
149
|
0
|
|
|
|
|
|
is($watchlist->name, 'Default'); |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 LEGAL |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This is a simple wrapper around the API used in the official apps. The author |
155
|
|
|
|
|
|
|
provides no investment, legal, or tax advice and is not responsible for any |
156
|
|
|
|
|
|
|
damages incurred while using this software. This software is not affiliated |
157
|
|
|
|
|
|
|
with Robinhood Financial LLC in any way. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
For Robinhood's terms and disclosures, please see their website at |
160
|
|
|
|
|
|
|
https://robinhood.com/legal/ |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 LICENSE |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Copyright (C) Sanko Robinson. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it under |
167
|
|
|
|
|
|
|
the terms found in the Artistic License 2. Other copyrights, terms, and |
168
|
|
|
|
|
|
|
conditions may apply to data transmitted through this module. Please refer to |
169
|
|
|
|
|
|
|
the L section. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 AUTHOR |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Sanko Robinson Esanko@cpan.orgE |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=cut |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
1; |